systemfuncs2code.py 816 B

123456789101112131415161718192021222324252627282930313233
  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('Usage: python3 systemfuncs2code.py CONFIG_HEADER ', file=sys.stderr)
  23. print(
  24. 'Note: Should only be called directly on systems '
  25. 'where the probe does not work.',
  26. file=sys.stderr
  27. )
  28. sys.exit(2)