mirror of
https://gitlab.com/ryandwyer/perfect-dark
synced 2026-07-11 14:08:37 -04:00
Update asm_processor and make it only used where necessary
This commit is contained in:
Executable → Regular
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
asm_processor = ['python3', os.path.join(dir_path, "asm-processor.py")]
|
||||
prelude = os.path.join(dir_path, "prelude.inc")
|
||||
|
||||
all_args = sys.argv[1:]
|
||||
sep1 = all_args.index('--')
|
||||
sep2 = all_args.index('--', sep1+1)
|
||||
|
||||
compiler = all_args[:sep1]
|
||||
|
||||
assembler = all_args[sep1+1:sep2]
|
||||
assembler_sh = ' '.join(shlex.quote(x) for x in assembler)
|
||||
|
||||
compile_args = all_args[sep2+1:]
|
||||
in_file = compile_args[-1]
|
||||
out_ind = compile_args.index('-o')
|
||||
out_file = compile_args[out_ind + 1]
|
||||
del compile_args[-1]
|
||||
del compile_args[out_ind + 1]
|
||||
del compile_args[out_ind]
|
||||
|
||||
in_dir = os.path.split(os.path.realpath(in_file))[0]
|
||||
opt_flags = [x for x in compile_args if x in ['-g', '-O2', '-O1', '-framepointer']]
|
||||
|
||||
preprocessed_file = tempfile.NamedTemporaryFile(prefix='preprocessed', suffix='.c')
|
||||
|
||||
subprocess.check_call(asm_processor + opt_flags + [in_file], stdout=preprocessed_file)
|
||||
subprocess.check_call(compiler + compile_args + ['-I', in_dir, '-o', out_file, preprocessed_file.name])
|
||||
subprocess.check_call(asm_processor + opt_flags + [in_file, '--post-process', out_file, '--assembler', assembler_sh, '--asm-prelude', prelude])
|
||||
@@ -1,5 +1,5 @@
|
||||
.set noat
|
||||
.set noreorder
|
||||
.set gp=64
|
||||
.include "src/include/macros.inc"
|
||||
.include "macros.inc"
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
INPUT="$1"
|
||||
OUTPUT="${INPUT%.c}.o"
|
||||
INCLUDE="-I include -I include/libultra"
|
||||
|
||||
CC="$QEMU_IRIX -silent -L $IRIX_ROOT $IRIX_ROOT/usr/bin/cc"
|
||||
CFLAGS="-Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -fullwarn -wlint -woff 819,820,852,821 -signed $INCLUDE -mips2"
|
||||
AS="mips-linux-gnu-as"
|
||||
ASFLAGS="-march=vr4300 -mabi=32 $INCLUDE"
|
||||
|
||||
python3 tools/asmpreproc/asm-processor.py -O2 "$INPUT" | $CC -c $CFLAGS tools/asmpreproc/include-stdin.c -o "$OUTPUT" -O2
|
||||
python3 tools/asmpreproc/asm-processor.py -O2 "$INPUT" --post-process "$OUTPUT" --assembler "$AS $ASFLAGS" --asm-prelude tools/asmpreproc/prelude.s
|
||||
|
||||
mv $OUTPUT ${OUTPUT/src/build}
|
||||
@@ -1,2 +0,0 @@
|
||||
// (this is used for piping input to the IRIX compiler without needing to make a temporary .c file)
|
||||
#include "/dev/stdin"
|
||||
Reference in New Issue
Block a user