diff --git a/moulin/builders/custom_script.py b/moulin/builders/custom_script.py index d187d14..0764ae7 100644 --- a/moulin/builders/custom_script.py +++ b/moulin/builders/custom_script.py @@ -10,6 +10,7 @@ import os.path from typing import List from moulin.yaml_wrapper import YamlValue +from moulin.utils import construct_fetcher_dep_cmd from moulin import ninja_syntax @@ -26,9 +27,12 @@ def gen_build_rules(generator: ninja_syntax.Writer): Generate custom_script build rules for ninja """ cmd = " && ".join([ + # Generate fetcher dependency file + construct_fetcher_dep_cmd(), + "cd $build_dir", "( [ -d $work_dir ] || mkdir $work_dir )", - "echo '# Code generated by moulin. All manual changes will be lost' > $work_dir/$config_file", - "echo $b64config | base64 -d - >> $work_dir/$config_file", + "echo '# Code generated by moulin. All manual changes will be lost' > $config_file", + "echo $b64config | base64 -d - >> $config_file", ]) generator.rule("cs_update_conf", command=cmd, @@ -36,7 +40,8 @@ def gen_build_rules(generator: ninja_syntax.Writer): generator.newline() cmd = " && ".join([ - "$script $args $work_dir/$config_file" + "cd $build_dir", + "$script $args $config_file" ]) generator.rule("cs_build", command=cmd, @@ -65,9 +70,11 @@ def gen_build(self): common_variables = { "script": self.conf["script"].as_str, "work_dir": work_dir, + "build_dir": self.build_dir, + "name": self.name, } - local_conf_file = f"conf-{self.name}.yaml" - local_conf_target = os.path.join(work_dir, local_conf_file) + local_conf_file = os.path.join(work_dir, f"conf-{self.name}.yaml") + local_conf_target = os.path.join(self.build_dir, local_conf_file) serialized_conf = yaml.serialize(self.conf._node) conf_bytes = serialized_conf.encode("utf-8") b64bytes = base64.b64encode(conf_bytes)