trace-gen.py 595 B

12345678910111213141516
  1. # This Source Code Form is subject to the terms of the Mozilla Public
  2. # License, v. 2.0. If a copy of the MPL was not distributed with this
  3. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. import os
  5. import subprocess
  6. def main(fp, input):
  7. temporary_file = 'mozilla-trace.h.tmp'
  8. subprocess.check_call(['dtrace', '-x', 'nolibs', '-h', '-s', input, '-o', temporary_file])
  9. with open(temporary_file, 'r') as temporary_fp:
  10. output = temporary_fp.read()
  11. fp.write(output.replace('if _DTRACE_VERSION', 'ifdef INCLUDE_MOZILLA_DTRACE'))
  12. os.remove(temporary_file)