From fbc0e5353bf3ceaf92c281a8ce0901626b198bbc Mon Sep 17 00:00:00 2001 From: yenatch Date: Thu, 5 Dec 2013 01:42:50 -0500 Subject: rename textpre.py -> preprocessor.py --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3fd12308..155df163 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ redrle: extras/redtools/redrle.c ${CC} -o $@ $> .asm.tx: - python textpre.py < $< > $@ + python preprocessor.py < $< > $@ pokered.gbc: pokered.o rgblink -o $@ $*.o -- cgit v1.3.1-sl0p From 07a7739f3ecc7bd3670fe17b717fad49783db3f4 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 6 Dec 2013 01:12:02 -0500 Subject: rewrite the makefile to be consistent with pokecrystal still needs globals.asm and a preprocessor queue to compile multiple objects also, spit out a mapfile and symfile --- Makefile | 56 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 17 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 155df163..0163ebf9 100644 --- a/Makefile +++ b/Makefile @@ -1,32 +1,54 @@ +PYTHON := python .SUFFIXES: .asm .tx .o .gbc +.PHONY: all clean red blue +.SECONDEXPANSION: -TEXTFILES := $(shell find ./ -type f -name '*.asm') -all: pokered.gbc +RED_OBJS := pokered.o +BLUE_OBJS := pokeblue.o -pokered.o: pokered.tx main.tx constants.tx wram.tx ${TEXTFILES:.asm=.tx} - rgbasm -o pokered.o pokered.tx - -pokeblue.o: pokeblue.tx main.tx constants.tx music.tx wram.tx ${TEXTFILES:.asm=.tx} - rgbasm -o pokeblue.o pokeblue.tx +OBJS := $(RED_OBJS) $(BLUE_OBJS) + +ROMS := pokered.gbc pokeblue.gbc + +# generate dependencies for each object +$(shell $(foreach obj, $(OBJS), \ + $(eval $(obj:.o=)_DEPENDENCIES := $(shell $(PYTHON) extras/pokemontools/scan_includes.py $(obj:.o=.asm))) \ +)) + + +all: $(ROMS) +red: pokered.gbc +blue: pokeblue.gbc redrle: extras/redtools/redrle.c ${CC} -o $@ $> +clean: + rm -f $(ROMS) + rm -f $(OBJS) + find -iname '*.tx' -delete + rm -f redrle + + +baserom.gbc: ; + @echo "Wait! Need baserom.gbc first. Check README and INSTALL for details." && false + +%.asm: ; + .asm.tx: - python preprocessor.py < $< > $@ + $(PYTHON) preprocessor.py < $< > $@ + +$(OBJS): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_DEPENDENCIES)) + rgbasm -o $@ $(@:.o=.tx) -pokered.gbc: pokered.o - rgblink -o $@ $*.o +pokered.gbc: $(RED_OBJS) + rgblink -n $*.sym -m $*.map -o $@ $^ rgbfix -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON RED" $@ cmp baserom.gbc $@ - -pokeblue.gbc: pokeblue.o - rgblink -o $@ $*.o + +pokeblue.gbc: $(BLUE_OBJS) + rgblink -n $*.sym -m $*.map -o $@ $^ rgbfix -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON BLUE" $@ cmp blue.gbc $@ -clean: - rm -f pokered.o pokered.gbc pokeblue.o pokeblue.gbc redrle $(TEXTFILES:.asm=.tx) - -more: pokered.gbc pokeblue.gbc -- cgit v1.3.1-sl0p From 120ba9664992cada4781e4d524304e4499e9083f Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 6 Dec 2013 22:40:46 -0500 Subject: handle preprocessing in one python procress; export asm labels instead of running a process for each file, one process handles all files rgbasm requires label EXPORT definitions for cross-object compiling. this is handled by globals.asm --- .gitignore | 3 +++ Makefile | 31 +++++++++++++++++++++---------- preprocessor.py | 30 +++++++++++++++++++++--------- prequeue.py | 29 +++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 prequeue.py (limited to 'Makefile') diff --git a/.gitignore b/.gitignore index 4c5eaeb9..527dfdd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# global label defs are generated +globals.asm + # precompiled python *.pyc diff --git a/Makefile b/Makefile index 0163ebf9..41a620a0 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,8 @@ PYTHON := python .SECONDEXPANSION: +TEXTQUEUE := + RED_OBJS := pokered.o BLUE_OBJS := pokeblue.o @@ -13,9 +15,11 @@ ROMS := pokered.gbc pokeblue.gbc # generate dependencies for each object $(shell $(foreach obj, $(OBJS), \ - $(eval $(obj:.o=)_DEPENDENCIES := $(shell $(PYTHON) extras/pokemontools/scan_includes.py $(obj:.o=.asm))) \ + $(eval $(obj:.o=)_DEPENDENCIES := $(shell $(PYTHON) extras/pokemontools/scan_includes.py $(obj:.o=.asm) | sed s/globals.asm//g)) \ +)) +$(shell $(foreach obj, $(OBJS), \ + $(eval ALL_DEPENDENCIES := $(ALL_DEPENDENCIES) $($(obj:.o=)_DEPENDENCIES)) \ )) - all: $(ROMS) red: pokered.gbc @@ -27,6 +31,7 @@ redrle: extras/redtools/redrle.c clean: rm -f $(ROMS) rm -f $(OBJS) + rm -f globals.asm find -iname '*.tx' -delete rm -f redrle @@ -35,20 +40,26 @@ baserom.gbc: ; @echo "Wait! Need baserom.gbc first. Check README and INSTALL for details." && false %.asm: ; - .asm.tx: - $(PYTHON) preprocessor.py < $< > $@ + $(eval TEXTQUEUE := $(TEXTQUEUE) $<) + @rm -f $@ + +globals.asm: $(ALL_DEPENDENCIES:.asm=.tx) $(OBJS:.o=.tx) + @touch $@ + @$(PYTHON) prequeue.py $(TEXTQUEUE) +globals.tx: globals.asm + @cp $< $@ -$(OBJS): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_DEPENDENCIES)) - rgbasm -o $@ $(@:.o=.tx) +$(OBJS): $$*.tx $$($$*_DEPENDENCIES$:.asm=.tx) + rgbasm -o $@ $*.tx -pokered.gbc: $(RED_OBJS) - rgblink -n $*.sym -m $*.map -o $@ $^ +pokered.gbc: globals.tx $(RED_OBJS) + rgblink -n $*.sym -m $*.map -o $@ $(RED_OBJS) rgbfix -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON RED" $@ cmp baserom.gbc $@ -pokeblue.gbc: $(BLUE_OBJS) - rgblink -n $*.sym -m $*.map -o $@ $^ +pokeblue.gbc: globals.tx $(BLUE_OBJS) + rgblink -n $*.sym -m $*.map -o $@ $(BLUE_OBJS) rgbfix -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON BLUE" $@ cmp blue.gbc $@ diff --git a/preprocessor.py b/preprocessor.py index 294e9ccb..317a2fe6 100644 --- a/preprocessor.py +++ b/preprocessor.py @@ -1,10 +1,17 @@ # -*- coding: utf-8 -*- import extras.pokemontools.preprocessor as preprocessor + import extras.pokemontools.configuration as configuration +config = configuration.Config() import sys +from extras.pokemontools.crystal import ( + callchannel, + loopchannel, +) + chars = { "ガ": 0x05, "ギ": 0x06, @@ -260,14 +267,19 @@ chars = { "9": 0xFF, } -preprocessor.chars = chars +def load_pokered_macros(): + macros = [callchannel, loopchannel] + return macros -from extras.pokemontools.crystal import ( - callchannel, - loopchannel, -) +def setup_processor(): + preprocessor.chars = chars + macros = load_pokered_macros() + processor = preprocessor.Preprocessor(config, macros) + return processor -config = configuration.Config() -macros = [callchannel, loopchannel] -processor = preprocessor.Preprocessor(config, macros) -processor.preprocess() +def main(): + processor = setup_processor() + processor.preprocess() + +if __name__ == '__main__': + main() diff --git a/prequeue.py b/prequeue.py new file mode 100644 index 00000000..6ad16d2c --- /dev/null +++ b/prequeue.py @@ -0,0 +1,29 @@ +# coding: utf-8 +""" +Starting a new python process to preprocess each source file creates too much +overhead. Instead, a list of files to preprocess is fed into a script run from +a single process. +""" + +import os +import sys + +import preprocessor + +def main(): + processor = preprocessor.setup_processor() + + for source in sys.argv[1:]: + dest = os.path.splitext(source)[0] + '.tx' + + stdout = sys.stdout + + sys.stdin = open(source, 'r') + sys.stdout = open(dest, 'w') + + processor.preprocess() + + sys.stdout = stdout + +if __name__ == '__main__': + main() -- cgit v1.3.1-sl0p From 516dbd1aaec669d27db253c3e74bf7d5f90eaf8d Mon Sep 17 00:00:00 2001 From: yenatch Date: Sun, 8 Dec 2013 01:34:53 -0500 Subject: Makefile: $: is not an escaped : --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 41a620a0..e68fa7ac 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ globals.asm: $(ALL_DEPENDENCIES:.asm=.tx) $(OBJS:.o=.tx) globals.tx: globals.asm @cp $< $@ -$(OBJS): $$*.tx $$($$*_DEPENDENCIES$:.asm=.tx) +$(OBJS): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_DEPENDENCIES)) rgbasm -o $@ $*.tx pokered.gbc: globals.tx $(RED_OBJS) -- cgit v1.3.1-sl0p From b9218d843b1dc1b5ab52bb375c910118865ad112 Mon Sep 17 00:00:00 2001 From: yenatch Date: Sun, 8 Dec 2013 18:02:29 -0500 Subject: Makefile: use += to append to variables --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index e68fa7ac..6caf470f 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ $(shell $(foreach obj, $(OBJS), \ $(eval $(obj:.o=)_DEPENDENCIES := $(shell $(PYTHON) extras/pokemontools/scan_includes.py $(obj:.o=.asm) | sed s/globals.asm//g)) \ )) $(shell $(foreach obj, $(OBJS), \ - $(eval ALL_DEPENDENCIES := $(ALL_DEPENDENCIES) $($(obj:.o=)_DEPENDENCIES)) \ + $(eval ALL_DEPENDENCIES += $($(obj:.o=)_DEPENDENCIES)) \ )) all: $(ROMS) -- cgit v1.3.1-sl0p From 1953e89b86572fec2e0628ddee029833c253eca9 Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 9 Dec 2013 23:47:39 -0500 Subject: makefile: find -delete isnt portable --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 6caf470f..8315e2b7 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ clean: rm -f $(ROMS) rm -f $(OBJS) rm -f globals.asm - find -iname '*.tx' -delete + @echo "removing *.tx" && rm -f $(shell find . -iname '*.tx' -printf '"%p" ') rm -f redrle -- cgit v1.3.1-sl0p From 515357a4504aa8c0816f088054c26f1902e71e72 Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Mon, 9 Dec 2013 23:00:38 -0700 Subject: Use safer and more standard POSIX find options. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 8315e2b7..3a31e258 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ clean: rm -f $(ROMS) rm -f $(OBJS) rm -f globals.asm - @echo "removing *.tx" && rm -f $(shell find . -iname '*.tx' -printf '"%p" ') + @echo "removing *.tx" && find . -iname '*.tx' -exec rm {} + rm -f redrle -- cgit v1.3.1-sl0p