aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlastimil Babka <caster@gentoo.org>2007-05-28 12:00:44 +0000
committerVlastimil Babka <caster@gentoo.org>2007-05-28 12:00:44 +0000
commit56974b3c3b7251daee54d1c2e593eb0b3a03f7d5 (patch)
tree58f405df321840bf6832dd80284bf2d1d76f7b93
parentFix "Unable to determine VM for building from dependencies." exception when n... (diff)
downloadjava-config-56974b3c3b7251daee54d1c2e593eb0b3a03f7d5.tar.gz
java-config-56974b3c3b7251daee54d1c2e593eb0b3a03f7d5.tar.bz2
java-config-56974b3c3b7251daee54d1c2e593eb0b3a03f7d5.zip
Support for OPTIONAL_DEPEND in package.env, bug #176182.
svn path=/projects/java-config-2/trunk/; revision=4863
-rwxr-xr-xsrc/gjl2
-rw-r--r--src/java_config/EnvironmentManager.py17
-rw-r--r--src/java_config/Package.py25
3 files changed, 36 insertions, 8 deletions
diff --git a/src/gjl b/src/gjl
index 9263be9..6e2d711 100755
--- a/src/gjl
+++ b/src/gjl
@@ -34,7 +34,7 @@ def get_needed_packages(package):
pkg = unresolved.pop()
resolved.add(pkg)
# dep is in the form of (jar, pkg)
- for dep in pkg.deps():
+ for dep in manager.get_pkg_deps(pkg):
dep_pkg = dep[-1]
p = manager.get_package(dep_pkg)
if p is None:
diff --git a/src/java_config/EnvironmentManager.py b/src/java_config/EnvironmentManager.py
index 4fc64fa..4ea55bc 100644
--- a/src/java_config/EnvironmentManager.py
+++ b/src/java_config/EnvironmentManager.py
@@ -263,6 +263,19 @@ class EnvironmentManager:
def build_classpath(self, pkgs):
return self.build_path(pkgs, "CLASSPATH")
+ def get_pkg_deps(self, pkg):
+ """
+ Returns list of package's deps and optional deps.
+ Filters out optional deps that are not present.
+ """
+ deps = pkg.deps();
+ for opt_dep in pkg.opt_deps():
+ p = self.get_package(opt_dep[-1])
+ if p:
+ deps.append(opt_dep)
+
+ return deps
+
def add_dep_classpath(self, pkg, dep, classpath):
pkg_cp = pkg.classpath()
if pkg_cp:
@@ -295,7 +308,7 @@ class EnvironmentManager:
lpath = pkg.query(query)
self.add_path_elements(lpath, path)
- for dep in pkg.deps():
+ for dep in self.get_pkg_deps(pkg):
p = self.get_package(dep[-1])
if p:
@@ -344,7 +357,7 @@ class EnvironmentManager:
self.add_pkg_env_vars(pkg, env)
- for dep in pkg.deps():
+ for dep in self.get_pkg_deps(pkg):
p = self.get_package(dep[-1])
if p:
diff --git a/src/java_config/Package.py b/src/java_config/Package.py
index f30aa3c..5135b1d 100644
--- a/src/java_config/Package.py
+++ b/src/java_config/Package.py
@@ -55,11 +55,13 @@ class Package:
"""
Return all packages this package depends on
"""
- depstr = self.query("DEPEND")
- if depstr:
- return [dep.split("@") for dep in depstr.split(":")]
- else:
- return []
+ return self.__get_deps("DEPEND")
+
+ def opt_deps(self):
+ """
+ Return all packages this package optionally depends on
+ """
+ return self.__get_deps("OPTIONAL_DEPEND")
def provides(self):
"""
@@ -69,5 +71,18 @@ class Package:
if pv:
return pv.split(" ")
return []
+
+ def __get_deps(self, query):
+ """
+ Internal function to get package's (optional) dependencies;
+ @param query: variable to read from package.env
+ """
+ depstr = self.query(query)
+ if depstr:
+ return [dep.split("@") for dep in depstr.split(":")]
+ else:
+ return []
+
+
# vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap: