예제 #1
0
    def _patch_cargo_abi(self):
        cargo_path = path.join(self.directory, "abi", TemplateRust.CARGO_TOML)
        if not path.isfile(cargo_path):
            return

        cargo_file = CargoFile(cargo_path)
        cargo_file.package_name = f"{self.project_name}-abi"
        cargo_file.version = "0.0.0"
        cargo_file.authors = ["you"]
        cargo_file.edition = "2018"
        cargo_file.publish = False

        for dependency in cargo_file.get_dependencies().values():
            del dependency["path"]
        for dependency in cargo_file.get_dev_dependencies().values():
            del dependency["path"]

        # Patch the path towards the project crate (one folder above):
        cargo_file.get_dependency(self.template_name)["path"] = ".."

        cargo_file.save()

        self._replace_in_files([cargo_path],
                               [(f"[dependencies.{self.template_name}]",
                                 f"[dependencies.{self.project_name}]")])
예제 #2
0
    def _patch_cargo_wasm(self):
        cargo_path = path.join(self.directory, "wasm", TemplateRust.CARGO_TOML)

        cargo_file = CargoFile(cargo_path)
        cargo_file.package_name = f"{self.project_name}-wasm"
        cargo_file.version = "0.0.1"
        cargo_file.authors = ["you"]
        cargo_file.edition = "2018"

        for dependency in cargo_file.get_dependencies().values():
            del dependency["path"]
        cargo_file.get_dependency(self.template_name)["path"] = ".."

        cargo_file.save()

        self._replace_in_files([cargo_path],
                               [(f"[dependencies.{self.template_name}]",
                                 f"[dependencies.{self.project_name}]")])
예제 #3
0
    def _patch_cargo_debug(self):
        cargo_debug_path = path.join(self.directory, "debug",
                                     TemplateRust.CARGO_TOML)
        if not path.exists(cargo_debug_path):
            return

        cargo_file_debug = CargoFile(cargo_debug_path)
        cargo_file_debug.package_name = f"{self.project_name}-debug"
        cargo_file_debug.version = "0.0.1"
        cargo_file_debug.authors = ["you"]
        cargo_file_debug.edition = "2018"

        for dependency in cargo_file_debug.get_dependencies().values():
            del dependency["path"]
        cargo_file_debug.get_dependency(self.template_name)["path"] = ".."

        cargo_file_debug.save()

        self._replace_in_files([cargo_debug_path],
                               [(f"[dependencies.{self.template_name}]",
                                 f"[dependencies.{self.project_name}]")])
예제 #4
0
    def _patch_cargo_wasm(self):
        cargo_path = path.join(self.directory, "wasm", TemplateRust.CARGO_TOML)

        cargo_file = CargoFile(cargo_path)
        cargo_file.package_name = f"{self.project_name}-wasm"
        cargo_file.version = "0.0.1"
        cargo_file.authors = ["you"]
        cargo_file.edition = "2018"

        for dependency in cargo_file.get_dependencies().values():
            del dependency["path"]
        # Currently, the following logic is not really needed (we don't have dev-dependencies in wasm/Cargo.toml):
        for dependency in cargo_file.get_dev_dependencies().values():
            del dependency["path"]

        # Patch the path towards the project crate (one folder above):
        cargo_file.get_dependency(self.template_name)["path"] = ".."

        cargo_file.save()

        self._replace_in_files([cargo_path],
                               [(f"[dependencies.{self.template_name}]",
                                 f"[dependencies.{self.project_name}]")])