Skip to content

Commit 02605c9

Browse files
authored
Merge pull request #647 from jkloetzke/package-dependencies
Package step dependencies
2 parents 93b7177 + e222b25 commit 02605c9

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

doc/manual/configuration.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,15 +548,16 @@ a script for the same step are joined in front of this script in the order the
548548
inheritance is specified. The inheritance graph is traversed depth first and
549549
every class is included exactly once.
550550

551-
Dependencies of the recipe are by default only available to the
551+
Dependencies of the recipe are generally only available to the
552552
``buildScript``. The path to the previous step (checkout workspace for
553553
``buildScript``, build workspace for ``packageScript``) is always passed in
554554
``$1``. Other dependencies are available in the order in which they were
555555
declared at the :ref:`configuration-recipes-depends` section of the recipe. If
556556
a dependencies ``checkoutDep`` flag is set to ``True`` it will also be
557557
available to the ``checkoutScript``. This should be used carefully as it makes
558558
the checkout of the recipe sources dependent on the result of another
559-
dependency.
559+
dependency. Enabling the :ref:`configuration-recipes-packagedepends` property
560+
will make the dependencies available to the package step too.
560561

561562
During execution of the script only the environment variables SHELL, USER,
562563
TERM, HOME and anything that was declared via {checkout,build,package}Vars
@@ -1694,6 +1695,20 @@ packages that are built from a library: a ``-target`` packet that has the
16941695
shared libraries needed during runtime and a ``-dev`` packet that has the
16951696
header files and other needed files to link with this library.
16961697

1698+
.. _configuration-recipes-packagedepends:
1699+
1700+
packageDepends
1701+
~~~~~~~~~~~~~~
1702+
1703+
Type: Boolean
1704+
1705+
Defaults to ``False``. If enabled, all dependencies that are named in the
1706+
:ref:`configuration-recipes-depends` section are available during the package
1707+
step execution too. By default, just the build step has access to them.
1708+
1709+
Enabling this property is useful for recipes that only need a package script.
1710+
Typical examples are recipes that create images or that just gather packages.
1711+
16971712
.. _configuration-recipes-privateenv:
16981713

16991714
privateEnvironment

pym/bob/input.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2160,6 +2160,7 @@ def __init__(self, recipeSet, recipe, layer, sourceFile, baseDir, packageName, b
21602160
self.__buildVars |= self.__checkoutVars
21612161
self.__buildVarsWeak = set(recipe.get("buildVarsWeak", []))
21622162
self.__buildVarsWeak |= self.__checkoutVarsWeak
2163+
self.__packageDepends = recipe.get("packageDepends")
21632164
self.__packageVars = set(recipe.get("packageVars", []))
21642165
self.__packageVars |= self.__buildVars
21652166
self.__packageVarsWeak = set(recipe.get("packageVarsWeak", []))
@@ -2312,6 +2313,7 @@ def coDet(r):
23122313
if self.__shared is None: self.__shared = cls.__shared
23132314
if self.__relocatable is None: self.__relocatable = cls.__relocatable
23142315
if self.__jobServer is None: self.__jobServer = cls.__jobServer
2316+
if self.__packageDepends is None: self.__packageDepends = cls.__packageDepends
23152317
tmp = cls.__provideTools.copy()
23162318
tmp.update(self.__provideTools)
23172319
self.__provideTools = tmp
@@ -2352,6 +2354,9 @@ def coDet(r):
23522354
if self.__jobServer is None:
23532355
self.__jobServer = False
23542356

2357+
if self.__packageDepends is None:
2358+
self.__packageDepends = False
2359+
23552360
# Optimize provideDeps
23562361
self.__provideDeps = [ getProvideDepsResolver(d) for d in self.__provideDeps ]
23572362

@@ -2788,8 +2793,11 @@ def prepare(self, inputEnv, sandboxEnabled, inputStates, inputSandbox=None,
27882793
packageDigestEnv = env.prune(self.__packageVars)
27892794
packageEnv = ( env.prune(self.__packageVars | self.__packageVarsWeak)
27902795
if self.__packageVarsWeak else packageDigestEnv )
2796+
packageDeps = [CoreRef(buildCoreStep)]
2797+
if self.__packageDepends:
2798+
packageDeps.extend(results)
27912799
packageCoreStep = p.createCorePackageStep(self.__package, packageDigestEnv, packageEnv,
2792-
[CoreRef(buildCoreStep)], doFingerprint, toolDepPackage, toolDepPackageWeak)
2800+
packageDeps, doFingerprint, toolDepPackage, toolDepPackageWeak)
27932801

27942802
# provide environment
27952803
packageCoreStep.providedEnv = env.substituteCondDict(self.__provideVars, "provideVars")
@@ -4083,6 +4091,7 @@ def __createSchemas(self):
40834091
schema.Optional('scriptLanguage') : schema.And(schema.Or("bash", "PowerShell"),
40844092
schema.Use(ScriptLanguage)),
40854093
schema.Optional('jobServer') : bool,
4094+
schema.Optional('packageDepends') : bool,
40864095
}
40874096
for (name, prop) in self.__properties.items():
40884097
classSchemaSpec[schema.Optional(name)] = schema.Schema(prop.validate,

test/unit/test_input_recipeset.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,32 @@ def testDepInherit(self):
850850
self.assertNotEqual(pb_e.getPackageStep().getSandbox(), None)
851851
self.assertNotEqual(pd.getPackageStep().getSandbox(), None)
852852

853+
def testPackageDepends(self):
854+
"""Test that checkoutDepends enables dependencies in package step"""
855+
856+
self.writeRecipe("root", """\
857+
root: True
858+
depends:
859+
- lib1
860+
- lib2
861+
packageDepends: True
862+
packageScript: "true"
863+
""")
864+
self.writeRecipe("lib1", "")
865+
self.writeRecipe("lib2", "")
866+
867+
recipes = RecipeSet()
868+
recipes.parse()
869+
packages = recipes.generatePackages(lambda x,y: "unused")
870+
p = packages.walkPackagePath("root")
871+
self.assertEqual(len(p.getPackageStep().getArguments()), 3)
872+
self.assertEqual(p.getPackageStep().getArguments()[0].getPackage().getName(),
873+
"root")
874+
self.assertEqual(p.getPackageStep().getArguments()[1].getPackage().getName(),
875+
"lib1")
876+
self.assertEqual(p.getPackageStep().getArguments()[2].getPackage().getName(),
877+
"lib2")
878+
853879
class TestDependencyEnv(RecipesTmp, TestCase):
854880
"""Tests related to "environment" block in dependencies"""
855881

0 commit comments

Comments
 (0)