def genConfig(platform, configuration, outputPath): buildPath = 'build' msvcPath = os.path.join(buildPath, 'msvc') probeMakePath = os.path.join(msvcPath, 'probed_defs.mk') # # build-info.hh # buildInfoHeader = os.path.join(outputPath, 'build-info.hh') targetPlatform = 'mingw32' if platform == 'Win32': targetCPU = 'x86' elif platform == 'x64': targetCPU = 'x86_64' else: raise ValueError('Invalid platform: ' + platform) flavour = configuration installShareDir = '/opt/openMSX/share' #not used on Windows, so whatever generator = buildinfo2code.iterBuildInfoHeader(targetPlatform, targetCPU, flavour, installShareDir) outpututils.rewriteIfChanged(buildInfoHeader, generator) # # components.hh # componentsHeader = os.path.join(outputPath, 'components.hh') generator = components2code.iterComponentsHeader(probeMakePath) outpututils.rewriteIfChanged(componentsHeader, generator) # # systemfuncs.hh # systemFuncsHeader = os.path.join(outputPath, 'systemfuncs.hh') generator = systemfuncs2code.iterSystemFuncsHeader(systemfuncs2code.getSystemFuncsInfo()) outpututils.rewriteIfChanged(systemFuncsHeader, generator) # # resource-info.hh # resourceInfoHeader = os.path.join(outputPath, 'resource-info.h') generator = win_resource.iterResourceHeader() outpututils.rewriteIfChanged(resourceInfoHeader, generator) # # version.ii # versionHeader = os.path.join(outputPath, 'version.ii') generator = version2code.iterVersionInclude() outpututils.rewriteIfChanged(versionHeader, generator)
def genConfig(platform, configuration, outputPath): # # resource-info.hh # resourceInfoHeader = os.path.join(outputPath, 'resource-info.h') generator = win_resource.iterResourceHeader() outpututils.rewriteIfChanged(resourceInfoHeader, generator) # # version.ii # versionHeader = os.path.join(outputPath, 'version.ii') generator = version2code.iterVersionInclude() outpututils.rewriteIfChanged(versionHeader, generator)
def writeAll(self): def iterVars(): yield '# Automatically generated by build system.' yield '# Non-empty value means found, empty means not found.' for library in self.libraries: for name in ( 'HAVE_%s_H' % library, 'HAVE_%s_LIB' % library, '%s_CFLAGS' % library, '%s_LDFLAGS' % library, ): yield '%s:=%s' % (name, self.outVars[name]) rewriteIfChanged(self.outMakePath, iterVars()) rewriteIfChanged( self.outHeaderPath, iterSystemFuncsHeader(self.functionResults), )
# Generates Windows resource header. from outpututils import rewriteIfChanged from version import (extractRevisionNumber, getDetailedVersion, packageVersionNumber) import sys def iterResourceHeader(): versionComponents = packageVersionNumber.split('.') versionComponents += ['0'] * (3 - len(versionComponents)) versionComponents.append(str(extractRevisionNumber())) assert len(versionComponents) == 4, versionComponents yield '#define OPENMSX_VERSION_INT %s' % ', '.join(versionComponents) yield '#define OPENMSX_VERSION_STR "%s\\0"' % getDetailedVersion() if __name__ == '__main__': if len(sys.argv) == 2: rewriteIfChanged(sys.argv[1], iterResourceHeader()) else: print('Usage: python3 win-resource.py RESOURCE_HEADER', file=sys.stderr) sys.exit(2)
yield '#define MIN_SCALE_FACTOR %d' % minScaleFactor yield '#define MAX_SCALE_FACTOR %d' % maxScaleFactor yield '' yield 'namespace openmsx {' yield '' # Note: Don't call it "BIG_ENDIAN", because some system header may #define # that. yield 'static const bool OPENMSX_BIGENDIAN = %s;' \ % str(targetCPU.bigEndian).lower() yield 'static const bool OPENMSX_UNALIGNED_MEMORY_ACCESS = %s;' \ % str(targetCPU.unalignedMemoryAccess).lower() yield 'static const bool OPENMSX_SET_WINDOW_ICON = %s;' \ % str(setWindowIcon).lower() yield 'static const char* const DATADIR = "%s";' % installShareDir yield 'static const char* const BUILD_FLAVOUR = "%s";' % flavour yield 'static const char* const TARGET_PLATFORM = "%s";' % targetPlatform yield '' yield '} // namespace openmsx' yield '' yield '#endif // BUILD_INFO_HH' if __name__ == '__main__': if len(sys.argv) == 6: rewriteIfChanged(sys.argv[1], iterBuildInfoHeader(*sys.argv[2:])) else: print >> sys.stderr, \ 'Usage: python buildinfo2code.py CONFIG_HEADER ' \ 'platform cpu flavour share-install-dir' sys.exit(2)
yield '#define HAVE_32BPP %d' % have32BPP yield '#define MIN_SCALE_FACTOR %d' % minScaleFactor yield '#define MAX_SCALE_FACTOR %d' % maxScaleFactor yield '' yield 'namespace openmsx {' yield '' # Note: Don't call it "BIG_ENDIAN", because some system header may #define # that. yield 'static const bool OPENMSX_BIGENDIAN = %s;' \ % str(targetCPU.bigEndian).lower() yield 'static const bool OPENMSX_UNALIGNED_MEMORY_ACCESS = %s;' \ % str(targetCPU.unalignedMemoryAccess).lower() yield 'static const bool OPENMSX_SET_WINDOW_ICON = %s;' \ % str(setWindowIcon).lower() yield 'static const char* const DATADIR = "%s";' % installShareDir yield 'static const char* const BUILD_FLAVOUR = "%s";' % flavour yield 'static const char* const TARGET_PLATFORM = "%s";' % targetPlatform yield '' yield '} // namespace openmsx' yield '' yield '#endif // BUILD_INFO_HH' if __name__ == '__main__': if len(sys.argv) == 6: rewriteIfChanged(sys.argv[1], iterBuildInfoHeader(*sys.argv[2 : ])) else: print >> sys.stderr, \ 'Usage: python buildinfo2code.py CONFIG_HEADER ' \ 'platform cpu flavour share-install-dir' sys.exit(2)
from systemfuncs import systemFunctions from outpututils import rewriteIfChanged import sys def iterSystemFuncsHeader(functionResults): yield '// Automatically generated by build system.' for makeName in sorted(func.getMakeName() for func in systemFunctions): yield '#define HAVE_%s %d' % (makeName, functionResults[makeName]) def getSystemFuncsInfo(): return dict.fromkeys((func.getMakeName() for func in systemFunctions), False) if __name__ == '__main__': if len(sys.argv) == 2: rewriteIfChanged(sys.argv[1], iterSystemFuncsHeader(getSystemFuncsInfo())) else: print >> sys.stderr, \ 'Usage: python systemfuncs2code.py CONFIG_HEADER ' print >> sys.stderr, \ 'Note: Should only be called directly on systems where the probe ' \ 'does not work.' sys.exit(2)
import sys def iterComponentDefs(probeMakePath): probeVars = extractMakeVariables(probeMakePath) yield '# Automatically generated by build process.' yield '' yield 'LIBRARY_COMPILE_FLAGS:=' yield 'LIBRARY_LINK_FLAGS:=' for libName in requiredLibrariesFor(iterBuildableComponents(probeVars)): yield '# %s' % libName yield 'LIBRARY_COMPILE_FLAGS+=' + probeVars.get( libName + '_CFLAGS', '') yield 'LIBRARY_LINK_FLAGS+=' + probeVars.get(libName + '_LDFLAGS', '') yield '' for component in iterComponents(): yield 'COMPONENT_%s:=%s' % (component.makeName, str(component.canBuild(probeVars)).lower()) if len(sys.argv) == 3: rewriteIfChanged(sys.argv[1], iterComponentDefs(sys.argv[2])) else: print('Usage: python3 components2defs.py COMPONENTS_DEFS PROBE_MAKE', file=sys.stderr) sys.exit(2)
# Generates version include file. from outpututils import rewriteIfChanged from version import extractRevisionString, packageVersion, releaseFlag import sys def iterVersionInclude(): revision = extractRevisionString() yield '// Automatically generated by build process.' yield 'const bool Version::RELEASE = %s;' % str(releaseFlag).lower() yield 'const char* const Version::VERSION = "%s";' % packageVersion yield 'const char* const Version::REVISION = "%s";' % revision if __name__ == '__main__': if len(sys.argv) == 2: rewriteIfChanged(sys.argv[1], iterVersionInclude()) else: print('Usage: python version2code.py VERSION_HEADER', file=sys.stderr) sys.exit(2)
# Generates Windows resource header. from outpututils import rewriteIfChanged from version import extractRevisionNumber, packageVersion, extractRevision import sys def iterResourceHeader(): if '-' in packageVersion: versionNumber = packageVersion[ : packageVersion.index('-')] else: versionNumber = packageVersion versionComponents = versionNumber.split('.') + [ str(extractRevisionNumber()) ] assert len(versionComponents) == 4, versionComponents versionStr = packageVersion extractedRevision = extractRevision() if extractedRevision is not None: versionStr += "-" + extractedRevision yield '#define CATAPULT_VERSION_INT %s' % ', '.join(versionComponents) yield '#define CATAPULT_VERSION_STR "%s\\0"' % versionStr if __name__ == '__main__': if len(sys.argv) == 2: rewriteIfChanged(sys.argv[1], iterResourceHeader()) else: print >> sys.stderr, \ 'Usage: python win-resource.py RESOURCE_HEADER' sys.exit(2)
def mesonSources(): files, dirs = scanSources('src/') testSources = [] yield "sources = files(" for name in sorted(files): if name.startswith('unittest/'): testSources.append(name) elif not (name == 'main.cc' or name.endswith('Test.cc') or name.endswith('_test.cc')): yield " '%s'," % name yield " )" yield "" yield "main_sources = files(" yield " 'main.cc'," yield " )" yield "" yield "test_sources = files(" for name in testSources: yield " '%s'," % name yield " )" yield "" yield "incdirs = include_directories(" for name in dirs: yield " '%s'," % name yield " )" if __name__ == '__main__': rewriteIfChanged('src/meson.build', mesonSources())
) yield '// Automatically generated by build process.' yield '' yield '#ifndef COMPONENTS_HH' yield '#define COMPONENTS_HH' yield '' yield '#include <string>' yield '' for component in iterComponents(): varName = component.makeName yield '#define COMPONENT_%s %d' % (varName, varName in buildComponents) yield '' yield 'namespace openmsx {' yield '' yield 'static const std::string BUILD_COMPONENTS = "%s";' \ % ' '.join(sorted(buildComponents)) yield '' yield '} // namespace openmsx' yield '' yield '#endif // COMPONENTS_HH' if __name__ == '__main__': if len(sys.argv) == 3: rewriteIfChanged(sys.argv[1], iterComponentsHeader(sys.argv[2])) else: print >> sys.stderr, ( 'Usage: python components2code.py COMPONENTS_HEADER PROBE_MAKE' ) sys.exit(2)
# Generates the contents of "components_defs.mk". from components import EmulationCore, iterComponents from makeutils import extractMakeVariables from outpututils import rewriteIfChanged import sys def iterComponentDefs(probeMakePath): probeVars = extractMakeVariables(probeMakePath) yield '# Automatically generated by build process.' yield 'CORE_LIBS:=%s' % ' '.join(EmulationCore.dependsOn) for component in iterComponents(): yield 'COMPONENT_%s:=%s' % ( component.makeName, str(component.canBuild(probeVars)).lower() ) if len(sys.argv) == 3: rewriteIfChanged(sys.argv[1], iterComponentDefs(sys.argv[2])) else: print >> sys.stderr, ( 'Usage: python components2defs.py COMPONENTS_DEFS PROBE_MAKE' ) sys.exit(2)
# Generates version include file. from outpututils import rewriteIfChanged from version import extractRevisionString, packageVersion, releaseFlag import sys def iterVersionInclude(): revision = extractRevisionString() yield '// Automatically generated by build process.' yield 'const bool Version::RELEASE = %s;' % str(releaseFlag).lower() yield 'const char* const Version::VERSION = "%s";' % packageVersion yield 'const char* const Version::REVISION = "%s";' % revision if __name__ == '__main__': if len(sys.argv) == 2: rewriteIfChanged(sys.argv[1], iterVersionInclude()) else: print >> sys.stderr, \ 'Usage: python version2code.py VERSION_HEADER' sys.exit(2)
for component in iterComponents() if component.canBuild(probeVars) ) yield '// Automatically generated by build process.' yield '' yield '#ifndef COMPONENTS_HH' yield '#define COMPONENTS_HH' yield '' for component in iterComponents(): varName = component.makeName yield '#define COMPONENT_%s %d' % (varName, varName in buildComponents) yield '' yield 'namespace openmsx {' yield '' yield 'static const char* const BUILD_COMPONENTS = "%s";' \ % ' '.join(sorted(buildComponents)) yield '' yield '} // namespace openmsx' yield '' yield '#endif // COMPONENTS_HH' if __name__ == '__main__': if len(sys.argv) == 3: rewriteIfChanged(sys.argv[1], iterComponentsHeader(sys.argv[2])) else: print >> sys.stderr, ( 'Usage: python components2code.py COMPONENTS_HEADER PROBE_MAKE' ) sys.exit(2)