How to use the haros.cmake_parser.CMakeGrammar.split_args function in haros

To help you get started, we’ve selected a few haros examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github git-afsantos / haros / haros / cmake_parser.py View on Github external
def _analyse_control_flow(self, command, args, children):
        if command == "else":
            condition = True
        else:
            condition = self._control_arguments(args)
        if condition:
            for stmt in children:
                child_command = stmt[0].lower()
                child_args = CMakeGrammar.split_args(stmt[1]) if stmt[1] else []
                child_children = stmt[3]
                if child_command in self._CONTROL_FLOW and child_children:
                    self._analyse_control_flow(child_command, child_args, child_children)
                else:
                    self._analyse_command(child_command, child_args)
github git-afsantos / haros / haros / cmake_parser.py View on Github external
def split_paren_args(self, text):
        i = text.find("(")
        if i < 0:
            return CMakeGrammar.split_args(text)
        args = CMakeGrammar.split_args(text[:i])
        expr, k = self.read_until_match(text, start = i)
        expr = self.split_paren_args(expr)
        rest = self.split_paren_args(text[k+1:])
        args.append(expr)
        args.extend(rest)
        while len(args) == 1 and isinstance(args[0], list):
            args = args[0]
        return args
github git-afsantos / haros / haros / cmake_parser.py View on Github external
def parse(self, cmakelists, toplevel = True):
        self.directory = os.path.dirname(cmakelists)
        if toplevel:
            self.directory = os.path.abspath(self.directory)
            self.variables["CMAKE_SOURCE_DIR"] = self.directory
        self.variables["CMAKE_CURRENT_SOURCE_DIR"] = self.directory
        self.variables["CMAKE_CURRENT_LIST_FILE"] = cmakelists
        self.variables["CMAKE_CURRENT_LIST_DIR"] = self.directory
        self.variables["CMAKE_CURRENT_BINARY_DIR"] = (
            self.binary_dir + self.directory[len(self.source_dir):]
        )
        self.parser.parse(cmakelists)
        for stmt in self.parser.parsetree:
            command = stmt[0].lower()
            args = CMakeGrammar.split_args(stmt[1]) if stmt[1] else []
            children = stmt[3]
            if command in self._CONTROL_FLOW and children:
                self._analyse_control_flow(command, args, children)
            else:
                self._analyse_command(command, args)
        for subdir in self.subdirectories:
            path = os.path.join(self.directory, subdir, "CMakeLists.txt")
            if os.path.isfile(path):
                parser = RosCMakeParser(self.source_dir, self.binary_dir,
                                          pkgs = self.packages,
                                          env = self.environment,
                                          vars = dict(self.variables))
                parser.parse(path, toplevel = False)
                self._merge(parser)
        if toplevel:
            self._link_targets()
github git-afsantos / haros / haros / cmake_parser.py View on Github external
def split_paren_args(self, text):
        i = text.find("(")
        if i < 0:
            return CMakeGrammar.split_args(text)
        args = CMakeGrammar.split_args(text[:i])
        expr, k = self.read_until_match(text, start = i)
        expr = self.split_paren_args(expr)
        rest = self.split_paren_args(text[k+1:])
        args.append(expr)
        args.extend(rest)
        while len(args) == 1 and isinstance(args[0], list):
            args = args[0]
        return args