genconfig.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Generates configuration headers for VC++ builds
  2. import sys
  3. import os.path
  4. import outpututils
  5. import buildinfo2code
  6. import components2code
  7. import systemfuncs2code
  8. import win_resource
  9. import version2code
  10. #
  11. # platform: one of { Win32, x64 }
  12. # configuration: one of { Debug, Developer, Release }
  13. # outputPath: the location in which to generate config files
  14. #
  15. def genConfig(platform, configuration, outputPath):
  16. buildPath = 'build'
  17. msvcPath = os.path.join(buildPath, 'msvc')
  18. probeMakePath = os.path.join(msvcPath, 'probed_defs.mk')
  19. #
  20. # build-info.hh
  21. #
  22. buildInfoHeader = os.path.join(outputPath, 'build-info.hh')
  23. targetPlatform = 'mingw32'
  24. if platform == 'Win32':
  25. targetCPU = 'x86'
  26. elif platform == 'x64':
  27. targetCPU = 'x86_64'
  28. else:
  29. raise ValueError('Invalid platform: ' + platform)
  30. flavour = configuration
  31. installShareDir = '/opt/openMSX/share' #not used on Windows, so whatever
  32. generator = buildinfo2code.iterBuildInfoHeader(targetPlatform, targetCPU, flavour, installShareDir)
  33. outpututils.rewriteIfChanged(buildInfoHeader, generator)
  34. #
  35. # components.hh
  36. #
  37. componentsHeader = os.path.join(outputPath, 'components.hh')
  38. generator = components2code.iterComponentsHeader(probeMakePath)
  39. outpututils.rewriteIfChanged(componentsHeader, generator)
  40. #
  41. # systemfuncs.hh
  42. #
  43. systemFuncsHeader = os.path.join(outputPath, 'systemfuncs.hh')
  44. generator = systemfuncs2code.iterSystemFuncsHeader(systemfuncs2code.getSystemFuncsInfo())
  45. outpututils.rewriteIfChanged(systemFuncsHeader, generator)
  46. #
  47. # resource-info.hh
  48. #
  49. resourceInfoHeader = os.path.join(outputPath, 'resource-info.h')
  50. generator = win_resource.iterResourceHeader()
  51. outpututils.rewriteIfChanged(resourceInfoHeader, generator)
  52. #
  53. # version.ii
  54. #
  55. versionHeader = os.path.join(outputPath, 'version.ii')
  56. generator = version2code.iterVersionInclude()
  57. outpututils.rewriteIfChanged(versionHeader, generator)
  58. if len(sys.argv) == 4:
  59. genConfig(sys.argv[1], sys.argv[2], sys.argv[3])
  60. else:
  61. print >> sys.stderr, 'Usage: python genconfig.py platform configuration outputPath'
  62. sys.exit(2)