tools: Implement and inject enumproc CLI tool for script-preprocessing

This commit is contained in:
Rachel
2026-04-25 09:47:32 -07:00
parent 54e7939d73
commit c20af39290
9 changed files with 315 additions and 15 deletions

View File

@@ -8,6 +8,7 @@ help() {
echo " -h | --help print this help message and exit"
echo " -i | --include append an include directory for the assembler"
echo " -a | --assembler path to the assembler executable"
echo " -E | --enumproc path to the enumproc executable for translating enums to preproc #defines"
echo " -o | --objcopy path to the objcopy executable for data extraction"
echo " -d | --out-dir directory for output files (default: current directory)"
echo " -M | --depfile output a compiler-generated depfile for the source"
@@ -39,6 +40,11 @@ while [[ $# -gt 0 ]] ; do
shift
shift
;;
-E|--enumproc)
ENUMPROC="$2"
shift
shift
;;
-o|--objcopy)
OBJCOPY="$2"
shift
@@ -64,6 +70,8 @@ while [[ $# -gt 0 ]] ; do
esac
done
if [[ -z ${ENUMPROC:-} ]]; then echo "error: enumproc not specified!"; exit 1; fi
for script_file in "${SCRIPT_FILES[@]}" ; do
script_fname=${script_file##*/}
script_noext=${script_fname%.*}
@@ -78,7 +86,9 @@ for script_file in "${SCRIPT_FILES[@]}" ; do
script_bin="$OUTDIR/$script_noext"
# Convert + clean-up
$AS $MD -c -x assembler-with-cpp "${INCLUDE_ARGS[@]}" -o "$script_obj" "$script_file"
$AS $MD -E -x assembler-with-cpp "${INCLUDE_ARGS[@]}" "$script_file" \
| $ENUMPROC \
| $AS -x assembler-with-cpp -o "$script_obj" -c -
$OBJCOPY -O binary --file-alignment 4 "$script_obj" "$script_bin"
$LD "$script_obj" -o "$script_obj.dummy"
rm "$script_obj" "$script_obj.dummy"