Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Clang wrapper script to pass "-x assembler-with-cpp" to clang in preprocessor mode
import System.Environment
import System.Process
flags =
[ "-Wno-invalid-pp-token"
, "-Wno-unicode"
, "-Wno-trigraphs"
-- See if we're in preprocessor mode
check args@("-E":"-undef":"-traditional":_) = replace args
check other = other
-- make sure we use assembler-with-cpp
replace ("-x":"c":xs) = "-x":"assembler-with-cpp":replace xs
replace (x:xs) = x:replace xs
replace [] = []
main = do
args <- getArgs
rawSystem clang $ flags ++ (check args)
clang = "/usr/bin/clang" -- system clang
--clang = "/usr/local/bin/clang" -- clang 3.4/HEAD
--clang = "/usr/local/clang-3.0/bin/clang"
--clang = "/Users/lukexi/bin/clang-3.2/bin/clang"
--clang = "/Users/lukexi/bin/clang-3.3/bin/clang"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment