buildable
This commit is contained in:
parent
d5d3fa9d11
commit
569a44307e
41
dodo.py
41
dodo.py
@ -16,21 +16,9 @@ class Patchwork(dict):
|
|||||||
self.patchwork_path = Path(kwargs.pop("patchwork_path"))
|
self.patchwork_path = Path(kwargs.pop("patchwork_path"))
|
||||||
super().__init__(*arkg, **kwargs)
|
super().__init__(*arkg, **kwargs)
|
||||||
patchwork_mkdir = 'mkdir -p {}/{}'
|
patchwork_mkdir = 'mkdir -p {}/{}'
|
||||||
def prerequisites(self, vanilla_path):
|
|
||||||
for i in self.values():
|
|
||||||
yield self.patches_path/i
|
|
||||||
for i in self.keys():
|
|
||||||
yield vanilla_path/i
|
|
||||||
def targets(self):
|
def targets(self):
|
||||||
for i in self.keys():
|
for i in self.keys():
|
||||||
yield self.patchwork_path/i
|
yield self.patchwork_path/i
|
||||||
def action_generator(self, key, value, vanilla_path):
|
|
||||||
yield f"mkdir -p {self.patchwork_path}/{Path(key).parent}"
|
|
||||||
yield f"patch -u --binary -N -o '{self.patchwork_path}/{key}' "\
|
|
||||||
f"'{vanilla_path}/{key}' '{self.patches_path}/{value}'"
|
|
||||||
def actions(self, vanilla_path):
|
|
||||||
for k, v in self.items():
|
|
||||||
yield from self.action_generator(k, v, vanilla_path)
|
|
||||||
def tasks(self, vanilla_path):
|
def tasks(self, vanilla_path):
|
||||||
for k, v in self.items():
|
for k, v in self.items():
|
||||||
yield (
|
yield (
|
||||||
@ -44,6 +32,12 @@ class Patchwork(dict):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ScriptedPatchwork(dict):
|
||||||
|
def __init__(self, source_file):
|
||||||
|
with open(source_file) as s:
|
||||||
|
super().__init__(safe_load(s))
|
||||||
|
|
||||||
|
|
||||||
mod_name = 'randchgs'
|
mod_name = 'randchgs'
|
||||||
mod_install_path = 'C:/Users/User/Documents/Paradox Interactive/Hearts of Iron IV/mod/randchgs'
|
mod_install_path = 'C:/Users/User/Documents/Paradox Interactive/Hearts of Iron IV/mod/randchgs'
|
||||||
dir_vanilla = Path("../vanilla/v1.13.4")
|
dir_vanilla = Path("../vanilla/v1.13.4")
|
||||||
@ -53,14 +47,16 @@ dir_src_raw = Path('src/raw')
|
|||||||
dir_src_raw_files = list(files(Path(dir_src_raw).rglob("*")))
|
dir_src_raw_files = list(files(Path(dir_src_raw).rglob("*")))
|
||||||
dir_patches_path = Path('src/patches')
|
dir_patches_path = Path('src/patches')
|
||||||
dir_patchwork_path = Path('build/patched')
|
dir_patchwork_path = Path('build/patched')
|
||||||
|
|
||||||
patchwork = Patchwork({
|
patchwork = Patchwork({
|
||||||
'map/definition.csv': 'map_definition.patch',
|
'map/definition.csv': 'map_definition.patch',
|
||||||
'history/countries/ISR - Israel.txt': 'history_countries_ISR.patch',
|
'history/countries/ISR - Israel.txt': 'history_countries_ISR.patch',
|
||||||
# 'history/states/728-Guangzhouwan.txt' : 'history_states_728.patch',
|
},
|
||||||
}, patches_path = dir_patches_path, patchwork_path = dir_patchwork_path )
|
patches_path = dir_patches_path,
|
||||||
patchwork_scripted_template_input_file = dir_patches_path/'extrapoint.yaml'
|
patchwork_path = dir_patchwork_path
|
||||||
with open(patchwork_scripted_template_input_file) as s:
|
)
|
||||||
patchwork_scripted_template_input_data = safe_load(s)
|
|
||||||
|
patchwork_scripted = ScriptedPatchwork(dir_patches_path/'extrapoint.yaml')
|
||||||
|
|
||||||
dir_image_files = [ f"{dir_modimage}/{f.relative_to(dir_src_raw)}" for f in dir_src_raw_files ] + \
|
dir_image_files = [ f"{dir_modimage}/{f.relative_to(dir_src_raw)}" for f in dir_src_raw_files ] + \
|
||||||
[ f"{dir_modimage}/{f.relative_to(patchwork.patchwork_path)}" for f in patchwork.targets() ]
|
[ f"{dir_modimage}/{f.relative_to(patchwork.patchwork_path)}" for f in patchwork.targets() ]
|
||||||
@ -92,13 +88,12 @@ def task_patch_history_states_scripted():
|
|||||||
if not wrote_history and seen_history and '{' in line_in:
|
if not wrote_history and seen_history and '{' in line_in:
|
||||||
for province_id, province_info in provinces.items():
|
for province_id, province_info in provinces.items():
|
||||||
outfile.write(
|
outfile.write(
|
||||||
"\t\tvictory_points = {\n"\
|
"\t\tvictory_points = {\r\n"\
|
||||||
f"\t\t\t{province_id} {province_info['points']}\n"\
|
f"\t\t\t{province_id} {province_info['points']}\r\n"\
|
||||||
"\t\t}\n"\
|
"\t\t}\r\n"\
|
||||||
)
|
)
|
||||||
wrote_history = True
|
wrote_history = True
|
||||||
target.touch()
|
for state_id, state_data in patchwork_scripted.items():
|
||||||
for state_id, state_data in patchwork_scripted_template_input_data.items():
|
|
||||||
files = history_states_path(state_id)
|
files = history_states_path(state_id)
|
||||||
yield {
|
yield {
|
||||||
'name' : f"{state_id}",
|
'name' : f"{state_id}",
|
||||||
@ -124,7 +119,7 @@ def task_image():
|
|||||||
return {
|
return {
|
||||||
'file_dep' : filelist +
|
'file_dep' : filelist +
|
||||||
[ history_states_path(state_id)['dest']
|
[ history_states_path(state_id)['dest']
|
||||||
for state_id in patchwork_scripted_template_input_data.keys() ],
|
for state_id in patchwork_scripted.keys() ],
|
||||||
'targets' : dir_image_files,
|
'targets' : dir_image_files,
|
||||||
'actions' : [f"mkdir -p {dir_modimage}",
|
'actions' : [f"mkdir -p {dir_modimage}",
|
||||||
f"rsync -rv {dir_src_raw}/ {patchwork.patchwork_path}/"\
|
f"rsync -rv {dir_src_raw}/ {patchwork.patchwork_path}/"\
|
||||||
|
Loading…
Reference in New Issue
Block a user