Skip to content

Instantly share code, notes, and snippets.

@nmnobre
Forked from xianyi/as
Last active January 11, 2018 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmnobre/0fe85d47a63cd9cd34d521171b03277d to your computer and use it in GitHub Desktop.
Save nmnobre/0fe85d47a63cd9cd34d521171b03277d to your computer and use it in GitHub Desktop.
Replace the native and ancient macOS assembler (/usr/bin/as) or the MacPorts assembler (/opt/local/bin/as) by a script which calls the clang assembler. Now removing "-I dir" options from the arguments passed to the assembler and taking into account possible spaces in ARG in the condition for the first if statement.
#!/bin/sh
HAS_INPUT_FILE=0
ARGS=$@
ARGS=$(echo $ARGS | perl -pe 's/-I.*?(\s-[^I])/\1/')
while [ $# -ne 0 ]; do
ARG=$1
# Skip options
if [ "$ARG" == "-arch" ] || [ "$ARG" == "-o" ]; then
# Skip next token
shift
shift
continue
fi
if [ `echo $ARG | head -c1` == "-" ]; then
shift
continue
fi
HAS_INPUT_FILE=1
break
done
if [ $HAS_INPUT_FILE -eq 1 ]; then
clang -c -x assembler $ARGS
else
clang -c -x assembler $ARGS -
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment