components2defs.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 >> sys.stderr, (
  29. 'Usage: python components2defs.py COMPONENTS_DEFS PROBE_MAKE'
  30. )
  31. sys.exit(2)