JD2022-TU1/main/extern/gear4/buildfolder/generation/generate_all.py

161 lines
8.2 KiB
Python

import os
import sys
import platform
import subprocess
premake_bin = { 'Darwin' : '../../private/tools/Premake/premake4_mac',
'Linux' : '../../private/tools/Premake/premake4_linux',
'Windows' : '../../private/tools/Premake/premake4.exe'
}
premake_platform_name = { 'cafe' : 'wiiu',
'durango' : 'durango',
'linux' : 'linux',
'ios' : 'ios',
'mac' : 'universal64',
'orbis' : 'orbis',
'ps3' : 'ps3',
'vita' : 'vita',
'win32' : 'x32',
'win64' : 'x64',
'xenon' : 'xbox360',
'android' : 'android'
}
premake_solution = { 'cafe' : ['vs2010', 'vs2012'],
'durango' : ['vs2012'],
'ios' : ['xcode5'],
'mac' : ['xcode5'],
'orbis' : ['vs2010', 'vs2012'],
'ps3' : ['vs2010', 'vs2012'],
'vita' : ['vs2010', 'vs2012'],
'win32' : ['vs2010', 'vs2012'],
'win64' : ['vs2010', 'vs2012'],
'xenon' : ['vs2010'],
'linux' : ['gmake', 'codeblocks'],
'android' : ['vs2010', 'vs2012']
}
premake_platform_extra_args = { 'cafe' : [],
'durango' : [],
'ios' : ['--os=ios7.0'],
'mac' : ['--os=mac10.8'],
'orbis' : [],
'ps3' : ['--cc=snc'],
'vita' : [],
'win32' : ['--os=windows'],
'win64' : ['--os=windows'],
'xenon' : [],
'linux' : ['--cc=gcc'],
'android' : ['--os=windows']
}
class BlobModuleList:
all_modules = {# Gear core
'gear_core/base',
'gear_core/eal_utils',
'gear_core/generics',
'gear_core/math',
'gear_core/os',
'gear_core/services/compression',
'gear_core/services/dbghelp',
'gear_core/services/encryption',
'gear_core/services/random',
'gear_core/services/runtimetype',
'gear_core/services/spursmanager',
# Gear detection
'gear_detection',
# Gear testing
'gear_testing'}
@staticmethod
def All():
return BlobModuleList.all_modules
@staticmethod
def AllBut(modules_to_remove):
return BlobModuleList.all_modules.difference(modules_to_remove)
platform_blob_generation_info = { 'cafe' : { 'cafe' : BlobModuleList.AllBut({'gear_detection'})},
'durango' : { 'durango' : BlobModuleList.AllBut({'gear_detection'})},
'ios' : { 'ios' : BlobModuleList.AllBut({'gear_detection'})},
'mac' : { 'mac' : BlobModuleList.AllBut({'gear_detection'})},
'orbis' : { 'orbis' : BlobModuleList.AllBut({'gear_detection'})},
'ps3' : { 'ps3_ppu' : BlobModuleList.AllBut({'gear_detection'}),
'ps3_spu' : BlobModuleList.AllBut({'gear_detection'})},
'vita' : { 'vita' : BlobModuleList.AllBut({'gear_detection'})},
'win32' : { 'win32' : BlobModuleList.All()},
'win64' : { 'win64' : BlobModuleList.All()},
'xenon' : { 'xenon' : BlobModuleList.AllBut({'gear_detection'})},
'linux' : { 'linux' : BlobModuleList.AllBut({'gear_detection'})},
'android' : { 'android' : BlobModuleList.AllBut({'gear_detection'})}
}
def generate_math():
print 'Generating maths files'
working_dir = os.getcwd()
os.chdir('../../gear_core/math/generation/')
subprocess.call([sys.executable, 'generate_all.py'])
os.chdir(working_dir)
def generate(platform_name, skip_blob_generation, extra_argument):
if skip_blob_generation == False:
# Generate blob files
import blobTheBuilder
# Generate blobs for all suffixes, for all modules
for blob_name_suffix, blob_module_list in platform_blob_generation_info[platform_name].items():
for blob_module in blob_module_list:
blobTheBuilder.buildBlobFor(blob_module, blob_name_suffix, 'cpp')
# Run HG to test files
subprocess.call([sys.executable, 'run_hg.py', blob_name_suffix])
# Generate projects
cmdargs = [premake_bin[platform.system()], '--file=gear4.lua', '--platform=' + premake_platform_name[platform_name]] + premake_platform_extra_args[platform_name] + extra_argument
# Set correct execution right on binary
if platform.system() == 'Linux' or platform.system() == 'Darwin':
subprocess.call(['chmod', '+x', '../../private/tools/Premake/premake4_linux'])
print('* Generating projects for ' + platform_name)
for solution in premake_solution[platform_name]:
print(' - ' + solution + '...')
subprocess.call( cmdargs + [solution] )
def generate_all(skip_blob_generation, extra_argument):
if platform.system() == 'Darwin':
generate('ios', skip_blob_generation, extra_argument)
generate('mac', skip_blob_generation, extra_argument)
elif platform.system() == 'Linux':
generate('linux', skip_blob_generation, extra_argument)
elif platform.system() == 'Windows': # We are on Windows. We want to generate everything so that we can also create the full installer
print 'Generating project files files'
generate('cafe', skip_blob_generation, extra_argument)
generate('durango', skip_blob_generation, extra_argument)
generate('orbis', skip_blob_generation, extra_argument)
generate('ps3', skip_blob_generation, extra_argument)
generate('vita', skip_blob_generation, extra_argument)
generate('win32', skip_blob_generation, extra_argument)
generate('win64', skip_blob_generation, extra_argument)
generate('xenon', skip_blob_generation, extra_argument)
generate('ios', skip_blob_generation, extra_argument)
generate('mac', skip_blob_generation, extra_argument)
generate('linux', skip_blob_generation, extra_argument)
generate('android', skip_blob_generation, extra_argument)
else:
print('Error: ' + platform.system() + ' not handled as host platform.')
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description='Generate Files and projects')
parser.add_argument('--platform', type=str, default='all', help="Set the platform to generate.", choices = ['all', 'android', 'cafe', 'durango', 'ios', 'linux', 'mac', 'orbis', 'ps3', 'vita', 'win32', 'win64', 'xenon'])
parser.add_argument('--skipMathGeneration', action='store_true', default=False, help='Do not generate math files. This flag won\'t affect blob files, config files, project and solution generation.')
parser.add_argument('--skipBlobGeneration', action='store_true', default=False, help='Do not generate blob files and config files. This flag won\'t affect math files, project and solution generation.')
args, extra = parser.parse_known_args()
# Math generation
if args.skipMathGeneration == False:
generate_math()
# Blob and Project generation
if args.platform == 'all':
generate_all(args.skipBlobGeneration, extra)
else:
generate(args.platform, args.skipBlobGeneration, extra)