components2defs.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Generates the contents of "components_defs.mk".
  2. from components import (
  3. EmulationCore, iterBuildableComponents, iterComponents,
  4. requiredLibrariesFor
  5. )
  6. from makeutils import extractMakeVariables
  7. from outpututils import rewriteIfChanged
  8. import sys
  9. def iterComponentDefs(probeMakePath):
  10. probeVars = extractMakeVariables(probeMakePath)
  11. yield '# Automatically generated by build process.'
  12. yield ''
  13. yield 'LIBRARY_COMPILE_FLAGS:='
  14. yield 'LIBRARY_LINK_FLAGS:='
  15. for libName in requiredLibrariesFor(iterBuildableComponents(probeVars)):
  16. yield '# %s' % libName
  17. yield 'LIBRARY_COMPILE_FLAGS+=' + probeVars.get(libName + '_CFLAGS', '')
  18. yield 'LIBRARY_LINK_FLAGS+=' + probeVars.get(libName + '_LDFLAGS', '')
  19. yield ''
  20. for component in iterComponents():
  21. yield 'COMPONENT_%s:=%s' % (
  22. component.makeName,
  23. str(component.canBuild(probeVars)).lower()
  24. )
  25. if len(sys.argv) == 3:
  26. rewriteIfChanged(sys.argv[1], iterComponentDefs(sys.argv[2]))
  27. else:
  28. print(
  29. 'Usage: python3 components2defs.py COMPONENTS_DEFS PROBE_MAKE',
  30. file=sys.stderr
  31. )
  32. sys.exit(2)