Exemplo n.º 1
0
    def __init__(self, options):
        self._options = {}

        # Set "root_path" use "root_path": "" in JSON to use CWD.
        self._options["root_path"] = os.path.abspath(options["root_path"])

        # Paths
        for path in ["output_path", "lib_path", "inc_path"]:
            self._options[path] = prepend_path(self._options["root_path"],
                                               options[path])

        # Includes
        self._options["includes"] = ""
        for include_path in options["includes"]:
            self._options["includes"] += '-I %s%s' % (prepend_path(
                self._options["root_path"], include_path), os.sep)

        # Compiler and linker flags
        self._options["cflags"] = " ".join(options["cflags"])
        self._options["lflags"] = " ".join(options["lflags"])

        # Use replements on these
        self._options["ctargets"] = " ".join(
            options["ctargets"]) % (self._options)

        self._options["ltargets"] = " ".join(
            options["ltargets"]) % (self._options)

        self._options["commands"] = [
            cmd % self._options for cmd in options["commands"]
        ]
        self._options["save_autogen"] = bool(options["save_autogen"])
Exemplo n.º 2
0
    def __init__(self, config_fn=None):
        """

        :config_fn str: Path to configuration file.
        """

        if not config_fn:  # Load configuration
            config_path = []
            path = inspect.getmodule(self).__file__.split(os.sep)
            for directory in path:
                if directory == "lib":
                    break
                config_path.append(directory)
            config_path += ["share", "pych", "config", "pych.json"]
            config_fn = os.sep.join(config_path)

        config_raw = json.load(open(config_fn))
        config = config_raw

        # TODO: Configuration here should do whatever path-magic is needed...

        #
        # The paths in configuration file should just be made absolute... this
        # is too much complexity for simple thing.
        #

        #
        # Object store paths
        #
        root_path = config_raw["object_store"]["root_path"]
        if not root_path:  # Root-path defaults to cwd
            root_path = os.getcwd()
            # Search paths
        search_paths = dict(
            (source, [])
            for source in config_raw["object_store"]["search_paths"])
        for source in config_raw["object_store"]["search_paths"]:
            for search_path in config_raw["object_store"]["search_paths"][
                    source]:
                search_paths[source].append(
                    prepend_path(root_path, search_path))
                # Output paths
        output_paths = dict(
            (source, [])
            for source in config_raw["object_store"]["output_paths"])
        for source in config_raw["object_store"]["output_paths"]:
            output_path = config_raw["object_store"]["output_paths"][source]
            output_paths[source] = prepend_path(root_path, output_path)
        config["object_store"]["search_paths"] = search_paths
        config["object_store"]["output_paths"] = output_paths

        #
        # TODO: Specializer paths

        #
        # TODO:
        self._config = config
Exemplo n.º 3
0
    def __init__(self, options):
        self._options = {}

        # Set "root_path" use "root_path": "" in JSON to use CWD.
        self._options["root_path"] = os.path.abspath(options["root_path"])

        # Paths
        for path in ["output_path", "lib_path", "inc_path"]:
            self._options[path] = prepend_path(
                self._options["root_path"],
                options[path]
            )

        # Includes
        self._options["includes"] = ""
        for include_path in options["includes"]:
            self._options["includes"] += '-I %s%s' % (
                prepend_path(self._options["root_path"], include_path),
                os.sep
            )

        # Compiler and linker flags
        self._options["cflags"] = " ".join(options["cflags"])
        self._options["lflags"] = " ".join(options["lflags"])

        # Use replements on these
        self._options["ctargets"] = " ".join(options["ctargets"]) % (
            self._options
        )

        self._options["ltargets"] = " ".join(options["ltargets"]) % (
            self._options
        )

        self._options["commands"] = [
            cmd % self._options for cmd in options["commands"]
        ]
        self._options["save_autogen"] = bool(options["save_autogen"])
Exemplo n.º 4
0
    def __init__(self, config_fn=None):
        """

        :config_fn str: Path to configuration file.
        """

        if not config_fn:               # Load configuration
            config_path = []
            path = inspect.getmodule(self).__file__.split(os.sep)
            for directory in path:
                if directory == "lib" or directory == "local":
                    break
                config_path.append(directory)
            config_path += [
                "share",
                "pych",
                "config",
                "pych.json"
            ]
            config_fn = os.sep.join(config_path)

        config_raw = json.load(open(config_fn))
        config = config_raw

        # TODO: Configuration here should do whatever path-magic is needed...

        #
        # The paths in configuration file should just be made absolute... this
        # is too much complexity for simple thing.
        #

        #
        # Object store paths
        #
        root_path = config_raw["object_store"]["root_path"]
        if not root_path:             # Root-path defaults to cwd
            root_path = os.getcwd()
                                            # Search paths
        search_paths = dict((source, []) for source in config_raw["object_store"]["search_paths"])
        for source in config_raw["object_store"]["search_paths"]:
            for search_path in config_raw["object_store"]["search_paths"][source]:
                search_paths[source].append(prepend_path(
                    root_path, search_path
                ))
                                            # Output paths
        output_paths = dict((source, []) for source in config_raw["object_store"]["output_paths"])
        for source in config_raw["object_store"]["output_paths"]:
            output_path = config_raw["object_store"]["output_paths"][source]
            output_paths[source] = prepend_path(
                root_path,
                output_path
            )
        config["object_store"]["search_paths"] = search_paths
        config["object_store"]["output_paths"] = output_paths

        #
        # TODO: Specializer paths

        #
        # TODO: 
        self._config = config