Skip to content

Commit

Permalink
fix: Eval scripts no longer mangle absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
psychonic committed Jul 6, 2024
1 parent 88895ab commit 71b4912
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions ambuild2/frontend/v2_2/context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ def runBuildScript(self, context, path, vars = None):
def importScriptImpl(self, parent, path, vars):
assert isinstance(path, util.StringType())

sourceFolder, _, scriptFile = self.computeScriptPaths(parent, path)
sourceFolder, _ = self.computeScriptPaths(parent, path)

# Get the absolute script path.
scriptPath = os.path.join(self.sourcePath, scriptFile)
if os.path.isabs(path):
scriptPath = path
else:
scriptPath = os.path.join(self.sourcePath, path)
self.generator.addConfigureFile(parent, scriptPath)

# Make the new context.
Expand All @@ -93,10 +96,13 @@ def runBuildScriptImpl(self, parent, path, vars):
if parent is not self.contextStack_[-1]:
raise Exception('Can only create child build contexts of the currently active context')

sourceFolder, buildFolder, scriptFile = self.computeScriptPaths(parent, path)
sourceFolder, buildFolder = self.computeScriptPaths(parent, path)

# Get the absolute script path.
scriptPath = os.path.join(self.sourcePath, scriptFile)
if os.path.isabs(path):
scriptPath = path
else:
scriptPath = os.path.join(self.sourcePath, path)
self.generator.addConfigureFile(parent, scriptPath)

# Make the new context. We allow top-level contexts in the root build
Expand Down Expand Up @@ -176,7 +182,7 @@ def computeScriptPaths(self, parent, target):
sourceFolder = ''
buildFolder = ''

return sourceFolder, buildFolder, os.path.join(sourceFolder, name)
return sourceFolder, buildFolder

def getLocalFolder(self, context):
return context.buildFolder
Expand Down

0 comments on commit 71b4912

Please sign in to comment.