Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Eval scripts no longer mangle absolute paths #170

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading