Remove duplication in defining rules

Former-commit-id: 9f6f0b596c
This commit is contained in:
Henrique Gemignani Passos Lima 2023-01-05 17:30:21 +02:00
parent c5e1c9faf7
commit 883583f75c
1 changed files with 64 additions and 78 deletions

View File

@ -1174,105 +1174,91 @@ if __name__ == "__main__":
# Rules # Rules
### ###
if os.name == "nt": if os.name == "nt":
n.comment("MWCC build") mwcc_command = "tools\\mwcc_compiler\\$mwcc_version\\mwcceppc.exe $cflags -c $in -o $basedir"
n.rule( mwcc_frank_command = (
name="mwcc", ALLOW_CHAIN
command="tools\\mwcc_compiler\\$mwcc_version\\mwcceppc.exe $cflags -c $in -o $basedir",
description="MWCC $out",
depfile="$basefile.d",
deps="gcc",
)
n.newline()
n.comment("MWCC build with franklite")
n.rule(
name="mwcc_frank",
command=ALLOW_CHAIN
+ "tools\\mwcc_compiler\\$mwcc_version\\mwcceppc.exe $cflags -c $in -o $basedir && " + "tools\\mwcc_compiler\\$mwcc_version\\mwcceppc.exe $cflags -c $in -o $basedir && "
+ "$python tools/franklite.py $out $out", + "$python tools/franklite.py $out $out"
description="FRANK $out",
depfile="$basefile.d",
deps="gcc",
) )
n.newline() link_elf_command = "tools\\mwcc_compiler\\$mwcc_version\\mwldeppc.exe $ldflags -o $out @$out.rsp"
assemble_asm_command = (
ALLOW_CHAIN
+ "$devkitppc\\bin\\powerpc-eabi-as.exe $asflags -o $out $in -MD $out.d"
+ " && $dtk elf fixup $out $out"
)
n.comment("Link ELF file") n.comment("Link ELF file")
n.rule( n.rule(
name="link", name="link",
command="tools\\mwcc_compiler\\$mwcc_version\\mwldeppc.exe $ldflags -o $out @$out.rsp", command=link_elf_command,
description="LINK $out", description="LINK $out",
rspfile="$out.rsp", rspfile="$out.rsp",
rspfile_content="$in", rspfile_content="$in",
) )
n.newline() n.newline()
n.comment("Assemble asm")
n.rule(
name="as",
command=ALLOW_CHAIN
+ "$devkitppc\\bin\\powerpc-eabi-as.exe $asflags -o $out $in -MD $out.d"
+ " && $dtk elf fixup $out $out",
description="AS $out",
depfile="$out.d",
deps="gcc",
)
n.newline()
n.comment("Create static library")
n.rule(
name="ar",
command="$dtk ar create $out @$out.rsp",
description="AR $out",
rspfile="$out.rsp",
rspfile_content="$in_newline",
)
n.newline()
else: else:
n.comment("MWCC build") mwcc_command = "${wine}tools/mwcc_compiler/$mwcc_version/mwcceppc.exe $cflags -c $in -o $basedir && $python tools/transform-dep.py $basefile.d $basefile.d"
n.rule( mwcc_frank_command = (
name="mwcc", "${wine}tools/mwcc_compiler/$mwcc_version/mwcceppc.exe $cflags -c $in -o $basedir && "
command="${wine}tools/mwcc_compiler/$mwcc_version/mwcceppc.exe $cflags -c $in -o $basedir && "
+ "$python tools/transform-dep.py $basefile.d $basefile.d",
description="MWCC $out",
depfile="$basefile.d",
deps="gcc",
)
n.newline()
n.comment("MWCC build with franklite")
n.rule(
name="mwcc_frank",
command="${wine}tools/mwcc_compiler/$mwcc_version/mwcceppc.exe $cflags -c $in -o $basedir && "
+ "$python tools/franklite.py $out $out && " + "$python tools/franklite.py $out $out && "
+ "$python tools/transform-dep.py $basefile.d $basefile.d", + "$python tools/transform-dep.py $basefile.d $basefile.d"
description="FRANK $out",
depfile="$basefile.d",
deps="gcc",
) )
n.newline() link_elf_command = "${wine}tools/mwcc_compiler/$mwcc_version/mwldeppc.exe $ldflags -o $out @$out.rsp"
assemble_asm_command = (
"$devkitppc/bin/powerpc-eabi-as $asflags -o $out $in -MD $out.d"
+ " && $dtk elf fixup $out $out"
)
n.comment("Link ELF file") n.comment("Link ELF file")
n.rule( n.rule(
name="link", name="link",
command="${wine}tools/mwcc_compiler/$mwcc_version/mwldeppc.exe $ldflags -o $out @$out.rsp", command=link_elf_command,
description="LINK $out", description="LINK $out",
rspfile="$out.rsp", rspfile="$out.rsp",
rspfile_content="$in_newline", rspfile_content="$in_newline",
) )
n.newline() n.newline()
n.comment("Assemble asm")
n.rule( n.comment("MWCC build")
name="as", n.rule(
command="$devkitppc/bin/powerpc-eabi-as $asflags -o $out $in -MD $out.d" name="mwcc",
+ " && $dtk elf fixup $out $out", command=mwcc_command,
description="AS $out", description="MWCC $out",
depfile="$out.d", depfile="$basefile.d",
deps="gcc", deps="gcc",
) )
n.newline() n.newline()
n.comment("Create static library")
n.rule( n.comment("MWCC build with franklite")
name="ar", n.rule(
command="$dtk ar create $out @$out.rsp", name="mwcc_frank",
description="AR $out", command=mwcc_frank_command,
rspfile="$out.rsp", description="FRANK $out",
rspfile_content="$in_newline", depfile="$basefile.d",
) deps="gcc",
n.newline() )
n.newline()
n.comment("Assemble asm")
n.rule(
name="as",
command=assemble_asm_command,
description="AS $out",
depfile="$out.d",
deps="gcc",
)
n.newline()
n.comment("Create static library")
n.rule(
name="ar",
command="$dtk ar create $out @$out.rsp",
description="AR $out",
rspfile="$out.rsp",
rspfile_content="$in_newline",
)
n.newline()
n.comment("Host build") n.comment("Host build")
n.variable("host_cflags", "-I include/ -Wno-trigraphs") n.variable("host_cflags", "-I include/ -Wno-trigraphs")
n.variable( n.variable(