preprocess_libffi_asm.py (919B)
1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- 2 # vim: set filetype=python: 3 # This Source Code Form is subject to the terms of the Mozilla Public 4 # License, v. 2.0. If a copy of the MPL was not distibuted with this 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 7 import os 8 import shlex 9 import subprocess 10 11 import buildconfig 12 import mozpack.path as mozpath 13 14 15 def main(output, input_asm, ffi_h, ffi_config_h, defines, includes): 16 defines = shlex.split(defines) 17 includes = shlex.split(includes) 18 # CPP uses -E which generates #line directives. -EP suppresses them. 19 # -TC forces the compiler to treat the input as C. 20 cpp = buildconfig.substs["CPP"] + ["-EP"] + ["-TC"] 21 input_asm = mozpath.relpath(input_asm, os.getcwd()) 22 args = cpp + defines + includes + [input_asm] 23 print(" ".join(args)) 24 preprocessed = subprocess.check_output(args) 25 output.write(preprocessed)