ninja include/ld_addrs.h

This commit is contained in:
Alex Bates 2021-01-14 12:05:55 +00:00
parent c2c49b191e
commit 38d825dc12
2 changed files with 34 additions and 10 deletions

View File

@ -289,8 +289,8 @@ $(BUILD_DIR)/$(TARGET).elf: $(BUILD_DIR)/$(LD_SCRIPT) $(OBJECTS)
$(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf
$(OBJCOPY) $< $@ -O binary $(OBJCOPY) $< $@ -O binary
include/ld_addrs.h: $(BUILD_DIR)/$(LD_SCRIPT) # include/ld_addrs.h: $(BUILD_DIR)/$(LD_SCRIPT)
grep -E "[^\. ]+ =" $< -o | sed 's/^/extern void* /; s/ =/;/' > $@ # grep -E "[^\. ]+ =" $< -o | sed 's/^/extern void* /; s/ =/;/' > $@
### Star Rod (optional) ### ### Star Rod (optional) ###

View File

@ -136,6 +136,7 @@ async def main():
n = ninja_syntax.Writer(open("build.ninja", "w"), width=120) n = ninja_syntax.Writer(open("build.ninja", "w"), width=120)
n.variable("builddir", "build") n.variable("builddir", "build")
n.variable("target", "papermario")
n.variable("cross", "mips-linux-gnu-") n.variable("cross", "mips-linux-gnu-")
n.variable("python", sys.executable) n.variable("python", sys.executable)
n.variable("os", "mac" if sys.platform == "darwin" else "linux") n.variable("os", "mac" if sys.platform == "darwin" else "linux")
@ -156,6 +157,13 @@ async def main():
deps="gcc") deps="gcc")
n.newline() n.newline()
n.rule("cpp",
command=f"{cpp} -P -DBUILD_DIR=$builddir $in -o $out",
description="cc (with dsl) $in",
depfile="$out.d",
deps="gcc")
n.newline()
n.rule("yay0compress", n.rule("yay0compress",
command=f"tools/Yay0compress $in $out", command=f"tools/Yay0compress $in $out",
description="compress $in") description="compress $in")
@ -180,13 +188,21 @@ async def main():
# $sprite_id # $sprite_id
n.rule("sprite_animations_h", n.rule("sprite_animations_h",
command="$python tools/gen_sprite_animations_h.py $out $sprite_dir $sprite_id", command="$python tools/gen_sprite_animations_h.py $out $sprite_dir $sprite_id",
description="sprite_animations_h $in") description="sprite_animations_h $sprite_dir")
n.newline()
n.rule("ld_addrs_h",
command="grep -E \"[^\. ]+ =\" $in -o | sed 's/^/extern void* /; s/ =/;/' > $out",
description="ld_addrs_h $in")
n.newline() n.newline()
objects, segments = read_splat("tools/splat.yaml") # no .o extension! objects, segments = read_splat("tools/splat.yaml") # no .o extension!
c_files = (f for f in objects if f.endswith(".c")) # glob("src/**/*.c", recursive=True) c_files = (f for f in objects if f.endswith(".c")) # glob("src/**/*.c", recursive=True)
# TODO: build elf n.comment("target")
n.build("$builddir/$target.ld", "cpp", "$target.ld")
# TODO ...
n.newline()
# generated headers # generated headers
n.comment("generated headers") n.comment("generated headers")
@ -203,13 +219,21 @@ async def main():
# mark it as really old so ninja builds it # mark it as really old so ninja builds it
os.utime(h, (0, 0)) os.utime(h, (0, 0))
return h
n.build(add_generated_header("include/ld_addrs.h"), "ld_addrs_h", "$builddir/$target.ld")
for sprite_id, sprite_name in enumerate(NPC_SPRITES, 1): for sprite_id, sprite_name in enumerate(NPC_SPRITES, 1):
h = f"include/sprite/npc/{sprite_name}.h" n.build(
n.build(h, "sprite_animations_h", glob(f"sprite/npc/{sprite_name}/**/*.*", recursive=True), variables={ add_generated_header(f"include/sprite/npc/{sprite_name}.h"),
"sprite_dir": f"sprite/npc/{sprite_name}", "sprite_animations_h",
"sprite_id": sprite_id, glob(f"sprite/npc/{sprite_name}/**/*.*", recursive=True),
}) variables={
add_generated_header(h) "sprite_dir": f"sprite/npc/{sprite_name}",
"sprite_id": sprite_id,
},
)
n.newline() n.newline()