systemfuncs2code.py 810 B

1234567891011121314151617181920212223242526272829303132
  1. from systemfuncs import systemFunctions
  2. from outpututils import rewriteIfChanged
  3. import sys
  4. def iterSystemFuncsHeader(functionResults):
  5. yield '// Automatically generated by build system.'
  6. for makeName in sorted(
  7. func.getMakeName() for func in systemFunctions
  8. ):
  9. yield '#define HAVE_%s %d' % (makeName, functionResults[makeName])
  10. def getSystemFuncsInfo():
  11. return dict.fromkeys(
  12. (func.getMakeName() for func in systemFunctions),
  13. False
  14. )
  15. if __name__ == '__main__':
  16. if len(sys.argv) == 2:
  17. rewriteIfChanged(
  18. sys.argv[1],
  19. iterSystemFuncsHeader(getSystemFuncsInfo())
  20. )
  21. else:
  22. print >> sys.stderr, \
  23. 'Usage: python systemfuncs2code.py CONFIG_HEADER '
  24. print >> sys.stderr, \
  25. 'Note: Should only be called directly on systems where the probe ' \
  26. 'does not work.'
  27. sys.exit(2)