Skip to content

Commit

Permalink
fixup! fixup! layers: SCM support
Browse files Browse the repository at this point in the history
  • Loading branch information
rhubert committed Aug 15, 2024
1 parent f66ac05 commit 707019f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
19 changes: 7 additions & 12 deletions pym/bob/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
from yaml import load as yamlLoad, SafeLoader as YamlSafeLoader


class LayerNotFoundError(ParseError):
pass

def isPrefixPath(p1, p2):
"""Check if the initial elements of ``p2`` equal ``p1``.
Expand Down Expand Up @@ -3476,8 +3473,11 @@ def __parse(self, envOverrides, platform, recipesRoot="", dryRun=False):
env["BOB_HOST_PLATFORM"] = platform
self.__rootEnv = env

if dryRun:
self.__parseUserConfig(os.path.join(recipesRoot or ".", "default.yaml"))
return
# Begin with root layer
self.__parseLayer(LayerSpec(""), "9999", recipesRoot, dryRun)
self.__parseLayer(LayerSpec(""), "9999", recipesRoot)

# Out-of-tree builds may have a dedicated default.yaml
if recipesRoot:
Expand All @@ -3499,9 +3499,6 @@ def __parse(self, envOverrides, platform, recipesRoot="", dryRun=False):
env["BOB_HOST_PLATFORM"] = platform
self.__rootEnv = env

if dryRun:
return

# resolve recipes and their classes
rootRecipes = []
for recipe in self.__recipes.values():
Expand All @@ -3522,7 +3519,7 @@ def __parse(self, envOverrides, platform, recipesRoot="", dryRun=False):
self.__rootRecipe = Recipe.createVirtualRoot(self, sorted(filteredRoots), self.__properties)
self.__addRecipe(self.__rootRecipe)

def __parseLayer(self, layerSpec, maxVer, recipesRoot, dryRun):
def __parseLayer(self, layerSpec, maxVer, recipesRoot):
layer = layerSpec.getName()

if layer in self.__layers:
Expand All @@ -3531,7 +3528,7 @@ def __parseLayer(self, layerSpec, maxVer, recipesRoot, dryRun):

rootDir = os.path.join(recipesRoot, os.path.join("layers", layer) if layer != "" else "")
if not os.path.isdir(rootDir or "."):
raise LayerNotFoundError(f"Layer '{layer}' does not exist!",
raise ParseError(f"Layer '{layer}' does not exist!",
help="You probably want to run 'bob layers update' to fetch missing layers.")

configYaml = os.path.join(rootDir, "config.yaml")
Expand All @@ -3556,8 +3553,6 @@ def preValidate(data):
raise ParseError("Projects before bobMinimumVersion 0.16 are not supported!")
maxVer = minVer # sub-layers must not have a higher bobMinimumVersion

if dryRun:
return

# Determine policies. The root layer determines the default settings
# implicitly by bobMinimumVersion or explicitly via 'policies'. All
Expand All @@ -3576,7 +3571,7 @@ def preValidate(data):
# First parse any sub-layers. Their settings have a lower precedence
# and may be overwritten by higher layers.
for l in config.get("layers", []):
self.__parseLayer(l, maxVer, recipesRoot, dryRun)
self.__parseLayer(l, maxVer, recipesRoot)

# Load plugins and re-create schemas as new keys may have been added
self.__loadPlugins(rootDir, layer, config.get("plugins", []))
Expand Down
7 changes: 2 additions & 5 deletions pym/bob/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .errors import BuildError
from .invoker import CmdFailedError, InvocationError, Invoker
from .state import BobState
from .input import LayerNotFoundError, RecipeSet, Scm, YamlCache
from .input import RecipeSet, Scm, YamlCache
from .utils import INVALID_CHAR_TRANS
from .tty import DEBUG, EXECUTED, INFO, NORMAL, IMPORTANT, SKIPPED, WARNING, log

Expand Down Expand Up @@ -187,10 +187,7 @@ def status(self, printer):
layer.status(printer)

def updateLayers(recipes, loop, defines, verbose):
try:
recipes.parse(defines, dryRun=True)
except LayerNotFoundError:
pass
recipes.parse(defines, dryRun=True)

layers = Layers(recipes, loop)
layers.collect(True, verbose)
2 changes: 1 addition & 1 deletion test/black-box/layers-checkout/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ layers:
url: "file://${FOO_DIR}"
- name: bar
scm: git
url: "file://${BAR_DIR}"
url: "replaced_by_override"
commit: "${BAR_1_COMMIT}"
5 changes: 5 additions & 0 deletions test/black-box/layers-checkout/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scmOverrides:
- match:
url: "replaced_by_override"
set:
url: "file://${BAR_DIR}"

0 comments on commit 707019f

Please sign in to comment.