moved from gnu make to pydoit
This commit is contained in:
parent
b9e19385af
commit
fd5d575a96
.gitignoreMakefiledodo.py
src
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,3 +3,5 @@
|
||||
/patchwork
|
||||
/image
|
||||
/install
|
||||
__pycache__
|
||||
.doit.db
|
||||
|
51
Makefile
51
Makefile
@ -1,51 +0,0 @@
|
||||
all: patch/tree/map/definition.csv
|
||||
DESTDIR ?= install
|
||||
MODNAME ?= randchgs
|
||||
MODPATH ?= C:/Users/User/Documents/Paradox Interactive/Hearts of Iron IV/mod/randchgs
|
||||
nullstring :=
|
||||
space :=
|
||||
space +=
|
||||
replaceQuestionBySpace = $(subst ?,$(space),$1)
|
||||
replaceSpaceByQuestion = $(subst $(space),?,$1)
|
||||
|
||||
# patch
|
||||
VANILLA_SRC ?= ../vanilla
|
||||
patchwork/map/definition.csv: $(VANILLA_SRC)/map/definition.csv patches/map_definition.patch
|
||||
mkdir -p $(@D)
|
||||
patch -u --binary -N -o $@ $^
|
||||
|
||||
#build
|
||||
patched_requisites := patchwork/map/definition.csv "patchwork/history/countries/ISR - Israel.txt"
|
||||
build:
|
||||
mkdir $@
|
||||
release: build/release.zip
|
||||
|
||||
image/$(MODNAME): $(wildcard scr/%) patchwork/map/definition.csv
|
||||
mkdir -p $@
|
||||
rsync -rv src/ $@/
|
||||
rsync -rv patchwork/ $@/
|
||||
image/$(MODNAME).zip: image/$(MODNAME) image/$(MODNAME).mod
|
||||
cd image && zip -r $(MODNAME).zip $(MODNAME)
|
||||
cd image && zip $(MODNAME).zip $(MODNAME).mod
|
||||
image/$(MODNAME).mod: src/descriptor.mod
|
||||
cp $< $@
|
||||
printf '\n%s\n' 'path="$(MODPATH)/$(MODNAME)"' >> $@
|
||||
|
||||
build/release.zip: src/* $(patched_requisites) | build
|
||||
cd src && zip -r ../build/$(@F) ./
|
||||
cd patchwork && zip -r ../build/$(@F) ./
|
||||
|
||||
# install
|
||||
install: $(DESTDIR)/$(MODNAME).mod | $(DESTDIR)/$(MODNAME)
|
||||
$(DESTDIR)/$(MODNAME) $(DESTDIR):
|
||||
mkdir -p $@
|
||||
$(DESTDIR)/$(MODNAME)/descriptor.mod: build/release.zip | $(DESTDIR)/$(MODNAME)
|
||||
cd $| && unzip -o $(abspath build/release.zip)
|
||||
$(DESTDIR)/$(MODNAME).mod: $(DESTDIR)/$(MODNAME)/descriptor.mod
|
||||
cp $< $@
|
||||
printf '\n%s\n' 'path="$(MODPATH)/$(MODNAME)"' >> $@
|
||||
|
||||
#clean
|
||||
clean:
|
||||
rm -rf patchwork build
|
||||
.PHONY: all release clean patch install
|
79
dodo.py
Normal file
79
dodo.py
Normal file
@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python3
|
||||
from pathlib import Path
|
||||
mod_name = 'randchgs'
|
||||
mod_install_path = 'C:/Users/User/Documents/Paradox Interactive/Hearts of Iron IV/mod/randchgs'
|
||||
vnla = "../vanilla"
|
||||
dir_image = 'image'
|
||||
dir_src_raw = 'src/raw'
|
||||
|
||||
class Patchwork(dict):
|
||||
patches_path = "src/patches"
|
||||
patchwork_path = "build/patched"
|
||||
def prerequisites(self, vanilla_path):
|
||||
for i in self.values():
|
||||
yield f"{self.patches_path}/{i}"
|
||||
for i in self.keys():
|
||||
yield f"{vanilla_path}/{i}"
|
||||
def targets(self):
|
||||
for i in self.keys():
|
||||
yield f"{self.patchwork_path}/{i}"
|
||||
|
||||
patchwork = Patchwork({
|
||||
'map/definition.csv': 'map_definition.patch',
|
||||
'history/countries/ISR - Israel.txt': 'history_countries_ISR.patch'
|
||||
})
|
||||
|
||||
# def task_wipe():
|
||||
# return {
|
||||
# 'actions' :[f"rm -rf {dir_image} {patchwork.patchwork_path}"],
|
||||
# 'uptodate': [True]
|
||||
# }
|
||||
|
||||
def task_patch():
|
||||
def acts():
|
||||
for k, v in patchwork.items():
|
||||
yield f"mkdir -p {patchwork.patchwork_path}/{Path(k).parent}"
|
||||
yield f"patch -u --binary -N -o '{patchwork.patchwork_path}/{k}' "\
|
||||
f"'{vnla}/{k}' '{patchwork.patches_path}/{v}'"
|
||||
return {
|
||||
'file_dep' : list(patchwork.prerequisites(vnla)),
|
||||
'targets': list(patchwork.targets()),
|
||||
'actions': list(acts())
|
||||
}
|
||||
|
||||
def task_image():
|
||||
def files(p):
|
||||
for i in p:
|
||||
if i.is_file():
|
||||
yield i
|
||||
filelist = list(files(Path(dir_src_raw).rglob("*"))) + \
|
||||
list(files(Path(patchwork.patchwork_path).rglob("*")))
|
||||
return {
|
||||
'file_dep': filelist,
|
||||
'targets': [f"{dir_image}/{mod_name}"],
|
||||
'actions': [f"mkdir -p %(targets)s",
|
||||
f"rsync -rv {dir_src_raw}/ {patchwork.patchwork_path}/"\
|
||||
" %(targets)s/"]
|
||||
}
|
||||
|
||||
def task_image_mod():
|
||||
dep = 'src/raw/descriptor.mod'
|
||||
def prepare_modname_mod(targets):
|
||||
with open(dep) as s:
|
||||
with open(targets[0], 'w') as o:
|
||||
o.write(s.read())
|
||||
o.write(f"path=\"{mod_install_path}\"")
|
||||
return {
|
||||
'file_dep': [dep],
|
||||
'targets': [f"{dir_image}/{mod_name}.mod"],
|
||||
'actions': [ prepare_modname_mod ]
|
||||
}
|
||||
|
||||
def task_build():
|
||||
return {
|
||||
'task_dep' : ['image'],
|
||||
'file_dep' : [f"image/{mod_name}.mod"],
|
||||
'targets': [f"{dir_image}/{mod_name}.zip"],
|
||||
'actions' : [f"cd {dir_image} && zip -r {mod_name}.zip {mod_name}",
|
||||
f"cd {dir_image} && zip -r {mod_name}.zip {mod_name}.mod"]
|
||||
}
|
Before ![]() (image error) Size: 11 MiB After ![]() (image error) Size: 11 MiB ![]() ![]() |
Loading…
Reference in New Issue
Block a user