Beispiel #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}]")])
Beispiel #2
0
    def _patch_cargo(self):
        cargo_path = path.join(self.directory, TemplateRust.CARGO_TOML)

        cargo_file = CargoFile(cargo_path)
        cargo_file.package_name = self.project_name
        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"]
        for dependency in cargo_file.get_dev_dependencies().values():
            del dependency["path"]

        cargo_file.save()
Beispiel #3
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}]")])