core/AMBuilder
author Nicholas Hastings <skamonkey@gmail.com>
Wed Oct 09 08:43:08 2013 -0400 (2013-10-09)
changeset 4137 11a7aa48621c
parent 4027 d2c15108b468
child 4138 da768ad428cf
permissions -rw-r--r--
Move ADTFactory from core to logic (bug 5953, r=fyren).
     1 # vim: set ts=2 sw=2 tw=99 noet ft=python: 
     2 import os
     3 from ambuild.command import SymlinkCommand
     4 
     5 for i in SM.sdkInfo:
     6 	sdk = SM.sdkInfo[i]
     7 	if AMBuild.target['platform'] not in sdk['platform']:
     8 		continue
     9 
    10 	name = 'sourcemod.' + sdk['ext']
    11 
    12 	compiler = SM.DefaultHL2Compiler('core', i)
    13 
    14 	if i == 'csgo':
    15 		# Protobuf 2.3 headers have some signed/unsigned compares. I believe that it's fixed in later versions, but Valve.
    16 		if isinstance(compiler.cxx, Cpp.CompatGCC):
    17 			compiler.AddToListVar('CFLAGS', '-Wno-sign-compare')
    18 		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache[sdk['sdk']], 'common', 'protobuf-2.3.0', 'src'))
    19 		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache[sdk['sdk']], 'public', 'engine', 'protobuf'))
    20 		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache[sdk['sdk']], 'public', 'game', 'shared', 'csgo', 'protobuf'))
    21 	elif i == 'dota':
    22 		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache[sdk['sdk']], 'common', 'protobuf-2.4.1', 'src'))
    23 		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache[sdk['sdk']], 'public', 'engine', 'protobuf'))
    24 		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache[sdk['sdk']], 'public', 'game', 'shared', 'protobuf'))
    25 		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache[sdk['sdk']], 'public', 'game', 'shared', 'dota', 'protobuf'))
    26 
    27 	extension = AMBuild.AddJob(name)
    28 	binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler)
    29 	SM.PreSetupHL2Job(extension, binary, i)
    30 
    31 	if AMBuild.target['platform'] == 'linux':
    32 		compiler['POSTLINKFLAGS'].append('-lpthread')
    33 		compiler['POSTLINKFLAGS'].append('-lrt')
    34 
    35 	if i in ['csgo', 'dota']:
    36 		if AMBuild.target['platform'] == 'linux':
    37 			link = os.path.join(os.path.join(AMBuild.outputFolder, extension.workFolder), 'libprotobuf.a')
    38 			target = os.path.join(os.path.join(AMBuild.cache[sdk['sdk']], 'lib', 'linux32', 'release'), 'libprotobuf.a')
    39 			try:
    40 				os.lstat(link)
    41 			except:
    42 				extension.AddCommand(SymlinkCommand(link, target))
    43 		elif AMBuild.target['platform'] == 'darwin':
    44 			link = os.path.join(os.path.join(AMBuild.outputFolder, extension.workFolder), 'libprotobuf.a')
    45 			target = os.path.join(os.path.join(AMBuild.cache[sdk['sdk']], 'lib', 'osx32', 'release'), 'libprotobuf.a')
    46 			try:
    47 				os.lstat(link)
    48 			except:
    49 				extension.AddCommand(SymlinkCommand(link, target))
    50 		elif AMBuild.target['platform'] == 'windows':
    51 			if 'DEBUG' in compiler['CDEFINES']:
    52 				libPath = os.path.join(AMBuild.cache[sdk['sdk']], 'lib', 'win32', 'debug', 'vs2010', 'libprotobuf.lib')
    53 			else:
    54 				libPath = os.path.join(AMBuild.cache[sdk['sdk']], 'lib', 'win32', 'release', 'vs2010', 'libprotobuf.lib')
    55 			binary.RebuildIfNewer(libPath)
    56 			binary['POSTLINKFLAGS'].append(libPath)
    57 
    58 	files = [
    59 		'AdminCache.cpp',
    60 		'MenuStyle_Valve.cpp',
    61 		'logic_bridge.cpp',
    62 		'smn_entities.cpp',
    63 		'sm_stringutil.cpp',
    64 		'ForwardSys.cpp',
    65 		'MenuVoting.cpp',
    66 		'smn_events.cpp',
    67 		'smn_menus.cpp',
    68 		'sm_trie.cpp',
    69 		'CDataPack.cpp',
    70 		'frame_hooks.cpp',
    71 		'smn_nextmap.cpp',
    72 		'sourcemm_api.cpp',
    73 		'ChatTriggers.cpp',
    74 		'smn_player.cpp',
    75 		'sourcemod.cpp',
    76 		'concmd_cleaner.cpp',
    77 		'HalfLife2.cpp',
    78 		'NextMap.cpp',
    79 		'ConCmdManager.cpp',
    80 		'ConVarManager.cpp',
    81 		'LibrarySys.cpp',
    82 		'PlayerManager.cpp',
    83 		'TimerSys.cpp',
    84 		'CoreConfig.cpp',
    85 		'Logger.cpp',
    86 		'smn_halflife.cpp',
    87 		'smn_console.cpp',
    88 		'UserMessages.cpp',
    89 		'Database.cpp',
    90 		'MenuManager.cpp',
    91 		'smn_core.cpp',
    92 		'smn_hudtext.cpp',
    93 		'smn_usermsgs.cpp',
    94 		'MenuStyle_Base.cpp',
    95 		'smn_database.cpp',
    96 		'smn_keyvalues.cpp',
    97 		'smn_vector.cpp',
    98 		'EventManager.cpp',
    99 		'MenuStyle_Radio.cpp',
   100 		'sm_autonatives.cpp',
   101 		'sm_srvcmds.cpp',
   102 		'ConsoleDetours.cpp'
   103 		]
   104 	
   105 	if i in ['csgo', 'dota']:
   106 		files.append('smn_protobuf.cpp')
   107 	else:
   108 		files.append('smn_bitbuffer.cpp')
   109 
   110 	binary.AddSourceFiles('core', files)
   111 
   112 	if i == 'csgo':
   113 		files = [
   114 			os.path.join('public', 'engine', 'protobuf', 'netmessages.pb.cc'),
   115 			os.path.join('public', 'game', 'shared', 'csgo', 'protobuf', 'cstrike15_usermessages.pb.cc'),
   116 			os.path.join('public', 'game', 'shared', 'csgo', 'protobuf', 'cstrike15_usermessage_helpers.cpp'),
   117 			]
   118 		binary.AddSourceFiles(AMBuild.cache[sdk['sdk']], files)
   119 	elif i == 'dota':
   120 		files = [
   121 			os.path.join('public', 'engine', 'protobuf', 'networkbasetypes.pb.cc'),
   122 			os.path.join('public', 'engine', 'protobuf', 'netmessages.pb.cc'),
   123 			os.path.join('public', 'game', 'shared', 'protobuf', 'ai_activity.pb.cc'),
   124 			os.path.join('public', 'game', 'shared', 'protobuf', 'usermessages.pb.cc'),
   125 			os.path.join('public', 'game', 'shared', 'dota', 'protobuf', 'dota_commonmessages.pb.cc'),
   126 			os.path.join('public', 'game', 'shared', 'dota', 'protobuf', 'dota_usermessages.pb.cc'),
   127 			os.path.join('public', 'game', 'shared', 'dota', 'protobuf', 'dota_usermessage_helpers.cpp'),
   128 			]
   129 		binary.AddSourceFiles(AMBuild.cache[sdk['sdk']], files)
   130 
   131 	SM.PostSetupHL2Job(extension, binary, i)
   132 	
   133 	if i in ['csgo', 'dota']:
   134 		if AMBuild.target['platform'] in ['linux', 'darwin']:
   135 			binary.AddObjectFiles(['libprotobuf.a'])
   136 	
   137 	SM.AutoVersion('core', binary)
   138 	SM.ExtractDebugInfo(extension, binary)
   139 	binary.SendToJob()
   140