Skip to content

Commit

Permalink
custom_script: Add posibility to fetch script from repository
Browse files Browse the repository at this point in the history
Add posibility to fetch script from repository

Signed-off-by: Dmytro Semenets <[email protected]>
  • Loading branch information
dsemenets committed Feb 26, 2024
1 parent 670e0a2 commit 7a3cfa1
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions moulin/builders/custom_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -26,17 +27,21 @@ 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,
description="Updating config")
generator.newline()

cmd = " && ".join([
"$script $args $work_dir/$config_file"
"cd $build_dir",
"$script $args $config_file"
])
generator.rule("cs_build",
command=cmd,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7a3cfa1

Please sign in to comment.