Example #1
0
    def importScriptImpl(self, parent, path, vars):
        assert isinstance(path, util.StringType())

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

        # Get the absolute script path.
        scriptPath = os.path.join(self.sourcePath, scriptFile)
        self.addConfigureFile(parent, scriptPath)

        # Make the new context.
        cx = EmptyContext(self, parent, vars, scriptPath)
        scriptGlobals = self.execContext(cx)

        # Only return variables that changed.
        obj = util.Expando()
        for key in scriptGlobals:
            if (not key in cx.vars_) or (scriptGlobals[key]
                                         is not cx.vars_[key]):
                setattr(obj, key, scriptGlobals[key])
        return obj
Example #2
0
    def runBuildScriptImpl(self, parent, path, vars):
        assert isinstance(path, util.StringType())

        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)

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

        # Make the new context. We allow top-level contexts in the root build
        # and otherwise for absolute paths.
        if isinstance(parent, RootBuildContext) or \
           (isinstance(parent, TopLevelBuildContext) and path.startswith('/')):
            constructor = TopLevelBuildContext
        else:
            if not paths.IsSubPath(sourceFolder, parent.sourceFolder):
                raise Exception(
                    "Nested build contexts must be within the same folder structure"
                )
            constructor = BuildContext

        cx = constructor(cm=self,
                         parent=parent,
                         vars=vars,
                         script=scriptPath,
                         sourceFolder=sourceFolder,
                         buildFolder=buildFolder)

        scriptGlobals = self.execContext(cx)
        return scriptGlobals.get('rvalue', None)
Example #3
0
 def runBuildScript(self, context, path, vars=None):
     if not isinstance(path, util.StringType()):
         for item in path:
             self.runBuildScriptImpl(context, item, vars or {})
         return None
     return self.runBuildScriptImpl(context, path, vars or {})
Example #4
0
 def importScript(self, context, path, vars={}):
     if not isinstance(path, util.StringType()):
         for item in path:
             self.importScriptImpl(context, item, vars)
         return None
     return self.importScriptImpl(context, path, vars)