secret
Last active

Clang wrapper script to pass "-x assembler-with-cpp" to clang in preprocessor mode

  • Download Gist
gistfile1.hs
Haskell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
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"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.