You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

894 lines
27 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. # -*- Python -*-
  2. #
  3. #
  4. # All the helper functions are defined in:
  5. # - site_scons/talk.py
  6. # Use 'import talk' in any .scons file to get access to it.
  7. # Add any new helper functions to it; unittest are available
  8. # in talk_unittest.py.
  9. #
  10. # Each 'component' that is built is defined in a .scons file.
  11. # See talk.Components(...) for further info on file naming convention.
  12. #
  13. # To add a new platform clone and modify the root_env object. Remember to add
  14. # the new environment object to the envs list otherwise it will not be included
  15. # in the build.
  16. #
  17. #
  18. #
  19. import talk
  20. import os
  21. import platform
  22. #-------------------------------------------------------------------------------
  23. # The build files/directories to 'build'.
  24. # If the name is the name of a directory then that directory shall contain a
  25. # .scons file with the same name as the directory itself:
  26. # Ex: The directory session/phone contains a file called phone.scons
  27. # This list must be in order of library dependencies. e.g., if
  28. # session/phone/phone.scons defines a target that links to a library target
  29. # defined in sound/sound.scons, then 'sound' must come first.
  30. # When no particular order is imposed by library dependencies, try to keep in
  31. # mostly alphabetical order.
  32. #
  33. components = talk.Components("libjingle.scons")
  34. #-------------------------------------------------------------------------------
  35. # Build environments
  36. #
  37. # The list of build environments.
  38. envs = []
  39. # The root of all builds.
  40. root_env = Environment(
  41. tools = [
  42. 'component_bits',
  43. 'component_setup',
  44. 'replace_strings',
  45. 'talk_noops',
  46. #'talk_utils',
  47. ],
  48. BUILD_SCONSCRIPTS = components,
  49. DESTINATION_ROOT = '$MAIN_DIR/build',
  50. CPPPATH = [
  51. '$OBJ_ROOT', # generated headers are relative to here
  52. '$MAIN_DIR/..', # TODO(dape): how can we use GOOGLECLIENT instead?
  53. ],
  54. CPPDEFINES = [
  55. 'LOGGING=1',
  56. # Feature selection
  57. 'FEATURE_ENABLE_SSL',
  58. 'FEATURE_ENABLE_VOICEMAIL',
  59. 'FEATURE_ENABLE_PSTN',
  60. 'HAVE_SRTP',
  61. ],
  62. # Ensure the os environment is captured for any scripts we call out to
  63. ENV = os.environ,
  64. )
  65. # This is where we set common environments
  66. #
  67. # Detect if building on 64-bit or 32-bit platform.
  68. DeclareBit('build_platform_64bit', 'Platform of the build machine is 64-bit')
  69. if platform.architecture()[0] == "64bit":
  70. root_env.SetBits('build_platform_64bit')
  71. # This bit denotes that an env is for 64-bit builds. When set, all build
  72. # artifacts will be 64-bit. When unset, all build artifacts will be 32-bit.
  73. DeclareBit('host_platform_64bit',
  74. 'Platform of the host machine (where artifacts will execute) is '
  75. '64-bit')
  76. # This bit denotes that we are cross-compiling using a sysroot.
  77. DeclareBit('cross_compile',
  78. 'Cross compiling using the SYSROOT environment variable')
  79. def CrossArch(env):
  80. """Return whether or not the host platform architecture differs from the build
  81. environment architecture."""
  82. if env.Bit('cross_compile'):
  83. # The architecture of the Python process may not match the architecture of
  84. # the sysroot, so we just assume it's not a cross-arch build or that it
  85. # doesn't matter. Currently it only matters if you try to build a cross-arch
  86. # Debian package, so just don't do that.
  87. return False
  88. else:
  89. return env.Bit('host_platform_64bit') != env.Bit('build_platform_64bit')
  90. root_env.AddMethod(CrossArch)
  91. DeclareBit('use_static_openssl', 'Build OpenSSL as a static library')
  92. DeclareBit('have_dbus_glib',
  93. 'Whether the build system has the dbus-glib-1 package')
  94. DeclareBit('have_libpulse',
  95. 'Whether the build system has the libpulse package')
  96. # List all the locales we localize to.
  97. root_env.AppendUnique(locales = [
  98. 'af', 'am', 'ar', 'bg', 'bn', 'ca', 'cs', 'da', 'de', 'el', 'en', 'en-GB',
  99. 'es', 'es-419', 'et', 'eu', 'fa', 'fi', 'fil', 'fr', 'fr-CA', 'gl', 'gu',
  100. 'hi', 'hr', 'hu', 'id', 'is', 'it', 'iw', 'ja', 'kn', 'ko', 'lt', 'lv',
  101. 'ml', 'mr', 'ms', 'nl', 'no', 'or', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru',
  102. 'sk', 'sl', 'sr', 'sv', 'sw', 'ta', 'te', 'th', 'tl', 'tr', 'uk', 'ur',
  103. 'vi', 'zh-CN', 'zh-HK', 'zh-TW', 'zu'])
  104. AddTargetGroup('all_breakpads', 'breakpad files can be built')
  105. AddTargetGroup('all_dsym', 'dsym debug packages can be built')
  106. #-------------------------------------------------------------------------------
  107. # W I N D O W S
  108. #
  109. win_env = root_env.Clone(
  110. tools = [
  111. 'atlmfc_vc80',
  112. #'code_signing',
  113. 'component_targets_msvs',
  114. 'directx_9_0_c',
  115. #'grid_builder',
  116. 'mc',
  117. 'midl',
  118. 'target_platform_windows'
  119. ],
  120. # Don't use default vc80 midl.exe. It doesn't understand vista_sdk idl files.
  121. MIDL = '$PLATFORM_SDK_VISTA_6_0_DIR/Bin/midl.exe ',
  122. WIX_DIR = '$GOOGLECLIENT/third_party/wix/v3_0_2925/files',
  123. # Flags for debug and optimization are added to CCFLAGS instead
  124. CCPDBFLAGS = '',
  125. CCFLAGS_DEBUG = '',
  126. CCFLAGS_OPTIMIZED = '',
  127. # We force a x86 target even when building on x64 Windows platforms.
  128. TARGET_ARCH = 'x86',
  129. )
  130. win_env.Decider('MD5-timestamp')
  131. win_env.Append(
  132. COMPONENT_LIBRARY_PUBLISH = True, # Put dlls in output dir too
  133. CCFLAGS = [
  134. '/Fd${TARGET}.pdb', # pdb per object allows --jobs=
  135. '/WX', # warnings are errors
  136. '/Zc:forScope', # handle 'for (int i = 0 ...)' right
  137. '/EHs-c-', # disable C++ EH
  138. '/GR-', # disable RTTI
  139. '/Gy', # enable function level linking
  140. '/wd4996', # ignore POSIX deprecated warnings
  141. # promote certain level 4 warnings
  142. '/w14701', # potentially uninitialized var
  143. '/w14702', # unreachable code
  144. '/w14706', # assignment within a conditional
  145. '/w14709', # comma operator within array index
  146. '/w14063', # case 'identifier' is not a valid value for switch of enum
  147. '/w14064', # switch of incomplete enum 'enumeration'
  148. '/w14057', # 'identifier1' indirection to slightly different base
  149. # types from 'identifier2'
  150. '/w14263', # member function does not override any base class virtual
  151. # member function
  152. '/w14266', # no override available for virtual memberfunction from base
  153. # 'type'; function is hidden
  154. '/w14296', # expression is always false
  155. '/w14355', # 'this' : used in base member initializer list
  156. ],
  157. CPPDEFINES = [
  158. '_ATL_CSTRING_EXPLICIT_CONSTRUCTORS',
  159. # TODO(dape): encapsulate all string operations that are not based
  160. # on std::string/std::wstring and make sure we use the safest versions
  161. # available on all platforms.
  162. '_CRT_SECURE_NO_WARNINGS',
  163. '_USE_32BIT_TIME_T',
  164. '_UNICODE',
  165. 'UNICODE',
  166. '_HAS_EXCEPTIONS=0',
  167. 'WIN32',
  168. # TODO(dape): remove this from logging.cc and enable here instead.
  169. #'WIN32_LEAN_AND_MEAN',
  170. 'WINVER=0x0500',
  171. '_WIN32_WINNT=0x0501',
  172. '_WIN32_IE=0x0501',
  173. # The Vista platform SDK 6.0 needs at least
  174. # this NTDDI version or else the headers
  175. # that LMI includes from it won't compile.
  176. 'NTDDI_VERSION=NTDDI_WINXP',
  177. # npapi.h requires the following:
  178. '_WINDOWS',
  179. ],
  180. CPPPATH = [
  181. '$THIRD_PARTY/wtl_71/include',
  182. '$PLATFORM_SDK_VISTA_6_0_DIR/Include',
  183. ],
  184. LIBPATH = [
  185. '$PLATFORM_SDK_VISTA_6_0_DIR/Lib'
  186. ],
  187. LINKFLAGS = [
  188. '-manifest', # TODO(thaloun): Why do we need this?
  189. # Some of the third-party libraries we link in don't have public symbols, so
  190. # ignore that linker warning.
  191. '/ignore:4221',
  192. '/nxcompat', # Binary was tested to be be compatible with Windows DEP.
  193. '/dynamicbase', # Use ASLR to dynamically rebase at load-time.
  194. '/fixed:no', # Binary can be loaded at any base-address.
  195. ],
  196. MIDLFLAGS = [
  197. '/win32',
  198. '/I$PLATFORM_SDK_VISTA_6_0_DIR/include'
  199. ]
  200. )
  201. # TODO(dape): Figure out what this does; found it in
  202. # omaha/main.scons. This fixes the problem with redefinition
  203. # of OS_WINDOWS symbol.
  204. win_env.FilterOut(CPPDEFINES = ['OS_WINDOWS=OS_WINDOWS'])
  205. # Set up digital signing
  206. DeclareBit('test_signing', 'Sign binaries with the test certificate')
  207. win_env.SetBitFromOption('test_signing', False)
  208. if win_env.Bit('test_signing'):
  209. win_env.Replace(
  210. CERTIFICATE_PATH = win_env.File(
  211. '$GOOGLECLIENT/tools/test_key/testkey.pfx').abspath,
  212. CERTIFICATE_PASSWORD = 'test',
  213. )
  214. AddTargetGroup('signed_binaries', 'digitally signed binaries can be built')
  215. win_dbg_env = win_env.Clone(
  216. BUILD_TYPE = 'dbg',
  217. BUILD_TYPE_DESCRIPTION = 'Windows debug build',
  218. BUILD_GROUPS = ['default', 'all'],
  219. tools = ['target_debug'],
  220. )
  221. win_dbg_env.Prepend(
  222. CCFLAGS = [
  223. '/ZI', # enable debugging
  224. '/Od', # disable optimizations
  225. '/MTd', # link with LIBCMTD.LIB debug lib
  226. '/RTC1', # enable runtime checks
  227. ],
  228. )
  229. envs.append(win_dbg_env)
  230. win_dbg64_env = win_dbg_env.Clone(
  231. BUILD_TYPE = 'dbg64',
  232. BUILD_TYPE_DESCRIPTION = 'Windows debug 64bit build',
  233. BUILD_GROUPS = ['all'],
  234. )
  235. win_dbg64_env.FilterOut(CCFLAGS = ['/ZI'])
  236. win_dbg64_env.Append(
  237. CCFLAGS = [
  238. '/Zi', # enable debugging that is 64 bit compatible.
  239. # TODO(fbarchard): fix warnings and remove these disables.
  240. '/wd4244', # disable cast warning
  241. '/wd4267', # disable cast warning
  242. ],
  243. ARFLAGS = [
  244. '/MACHINE:x64',
  245. ],
  246. CPPDEFINES = [
  247. 'WIN64',
  248. 'ARCH_CPU_64_BITS',
  249. ],
  250. LIBFLAGS = [
  251. '/MACHINE:x64',
  252. ],
  253. LINKFLAGS = [
  254. '/MACHINE:x64',
  255. ],
  256. )
  257. win_dbg64_env.FilterOut(CPPDEFINES = ['_USE_32BIT_TIME_T'])
  258. win_dbg64_env.Prepend(
  259. LIBPATH = [
  260. '$VC80_DIR/vc/lib/amd64',
  261. '$ATLMFC_VC80_DIR/lib/amd64',
  262. '$PLATFORM_SDK_VISTA_6_0_DIR/Lib/x64',
  263. ],
  264. )
  265. win_dbg64_env.PrependENVPath(
  266. 'PATH',
  267. win_dbg64_env.Dir('$VC80_DIR/vc/bin/x86_amd64'))
  268. win_dbg64_env.SetBits('host_platform_64bit')
  269. envs.append(win_dbg64_env)
  270. win_coverage_env = win_dbg_env.Clone(
  271. tools = ['code_coverage'],
  272. BUILD_TYPE = 'coverage',
  273. BUILD_TYPE_DESCRIPTION = 'Windows code coverage build',
  274. BUILD_GROUPS = ['all'],
  275. )
  276. win_coverage_env.Append(
  277. CPPDEFINES = [
  278. 'COVERAGE_ENABLED',
  279. ],
  280. )
  281. envs.append(win_coverage_env)
  282. win_opt_env = win_env.Clone(
  283. BUILD_TYPE = 'opt',
  284. BUILD_TYPE_DESCRIPTION = 'Windows opt build',
  285. BUILD_GROUPS = ['all'],
  286. tools = ['target_optimized'],
  287. )
  288. win_opt_env.Prepend(
  289. CCFLAGS=[
  290. '/Zi', # enable debugging
  291. '/O1', # optimize for size
  292. '/fp:fast', # float faster but less precise
  293. '/MT', # link with LIBCMT.LIB (multi-threaded, static linked crt)
  294. '/GS', # enable security checks
  295. ],
  296. LINKFLAGS = [
  297. '/safeseh', # protect against attacks against exception handlers
  298. '/opt:ref', # Remove unused references (functions/data).
  299. ],
  300. )
  301. envs.append(win_opt_env)
  302. #-------------------------------------------------------------------------------
  303. # P O S I X
  304. #
  305. posix_env = root_env.Clone()
  306. posix_env.Append(
  307. CPPDEFINES = [
  308. 'HASHNAMESPACE=__gnu_cxx',
  309. 'HASH_NAMESPACE=__gnu_cxx',
  310. 'POSIX',
  311. 'DISABLE_DYNAMIC_CAST',
  312. # The POSIX standard says we have to define this.
  313. '_REENTRANT',
  314. ],
  315. CCFLAGS = [
  316. '-Wall',
  317. '-Werror',
  318. '-Wno-switch',
  319. '-fno-exceptions',
  320. # Needed for a clean ABI and for link-time dead-code removal to work
  321. # properly.
  322. '-fvisibility=hidden',
  323. # Generate debugging info in the DWARF2 format.
  324. '-gdwarf-2',
  325. # Generate maximal debugging information. (It is stripped from what we ship
  326. # to users, so we want it for both dbg and opt.)
  327. # Note that hammer automatically supplies "-g" for mac/linux dbg, so that
  328. # flag must be filtered out of linux_dbg and mac_dbg envs below.
  329. '-g3',
  330. ],
  331. CXXFLAGS = [
  332. '-Wno-non-virtual-dtor',
  333. '-Wno-ctor-dtor-privacy',
  334. # '-fno-rtti',
  335. ],
  336. )
  337. # Switch-hit between NSS and OpenSSL
  338. if 'NSS_BUILD_PLATFORM' in root_env['ENV']:
  339. posix_env.AppendUnique(CPPDEFINES=['HAVE_NSS_SSL_H=1',
  340. 'NSS_SSL_RELATIVE_PATH'])
  341. else:
  342. posix_env.AppendUnique(CPPDEFINES=['HAVE_OPENSSL_SSL_H=1'])
  343. #-------------------------------------------------------------------------------
  344. # M A C OSX
  345. #
  346. mac_env = posix_env.Clone(
  347. tools = [
  348. 'target_platform_mac',
  349. #'talk_mac',
  350. #'fill_plist',
  351. ],
  352. )
  353. # Use static OpenSSL on mac so that we can use the latest APIs on all
  354. # supported mac platforms (10.5+).
  355. mac_env.SetBits('use_static_openssl')
  356. # For libjingle we don't specify a sysroot or minimum OS version.
  357. mac_osx_version_min_32 = ""
  358. mac_osx_version_min_64 = ""
  359. # Generic mac environment common to all targets
  360. mac_env.Append(
  361. CPPDEFINES = [
  362. 'OSX',
  363. ],
  364. CCFLAGS = [
  365. '-arch', 'i386',
  366. '-isysroot', '/Developer/SDKs/MacOSX10.7.sdk',
  367. '-fasm-blocks',
  368. ],
  369. LINKFLAGS = [
  370. '-Wl,-search_paths_first',
  371. # This flag makes all members of a static library be included in the
  372. # final exe - that increases the size of the exe, but without it
  373. # Obj-C categories aren't properly included in the exe.
  374. # TODO(thaloun): consider only defining for libs that actually have objc.
  375. '-ObjC',
  376. '-arch', 'i386',
  377. '-mmacosx-version-min=10.5',
  378. '-isysroot', '/Developer/SDKs/MacOSX10.7.sdk',
  379. '-m32',
  380. '-dead_strip',
  381. ],
  382. FRAMEWORKS = [
  383. 'CoreServices',
  384. 'Security',
  385. 'SystemConfiguration',
  386. 'OpenGL',
  387. 'CoreAudio',
  388. 'Quartz',
  389. 'Cocoa',
  390. 'QTKit',
  391. ]
  392. )
  393. if 'NSS_BUILD_PLATFORM' in root_env['ENV']:
  394. mac_env.AppendUnique(LINKFLAGS = ['-Lthird_party/mozilla/dist/' + root_env['ENV']['NSS_BUILD_PLATFORM'] + '/lib'])
  395. else:
  396. mac_env.AppendUnique(LINKFLAGS = ['-Lthird_party/openssl'])
  397. # add debug flags to environment
  398. def mac_debug_include(env):
  399. env.Append(
  400. CCFLAGS = [
  401. '-O0',
  402. ],
  403. CPPDEFINES = [
  404. 'DEBUG=1',
  405. ],
  406. )
  407. # Remove -g set by hammer, which is not what we want (we have set -g3 above).
  408. env.FilterOut(CCFLAGS = ['-g'])
  409. # add 32/64 bit specific options to specified environment
  410. def mac_common_include_x86_32(env):
  411. env.Append(
  412. CCFLAGS = [
  413. '-m32',
  414. ],
  415. LINKFLAGS = [
  416. '-m32',
  417. ],
  418. FRAMEWORKS = [
  419. 'Carbon',
  420. 'QuickTime',
  421. ],
  422. )
  423. envs.append(env)
  424. def mac_common_include_x86_64(env):
  425. env.Append(
  426. CCFLAGS = [
  427. '-m64',
  428. '-fPIC',
  429. ],
  430. CPPDEFINES = [
  431. 'ARCH_CPU_64_BITS',
  432. 'CARBON_DEPRECATED',
  433. ],
  434. LINKFLAGS = [
  435. '-m64',
  436. ],
  437. FRAMEWORKS = [
  438. 'AppKit',
  439. ],
  440. )
  441. env.SetBits('host_platform_64bit')
  442. envs.append(env)
  443. def mac_osx_version_min(env, ver):
  444. if ver != "":
  445. sdk_path = '/Developer/SDKs/MacOSX%s.sdk' % ver
  446. env.Append(
  447. CCFLAGS = [
  448. '-mmacosx-version-min=' + ver,
  449. '-isysroot', sdk_path,
  450. ],
  451. LINKFLAGS = [
  452. '-mmacosx-version-min=' + ver,
  453. '-isysroot', sdk_path,
  454. ],
  455. osx_sdk_path = sdk_path,
  456. osx_version_min = ver,
  457. )
  458. # Create all environments
  459. mac_dbg_env = mac_env.Clone(
  460. BUILD_TYPE = 'dbg',
  461. BUILD_TYPE_DESCRIPTION = 'Mac debug build',
  462. BUILD_GROUPS = ['default', 'all'],
  463. tools = ['target_debug'],
  464. )
  465. mac_opt_env = mac_env.Clone(
  466. BUILD_TYPE = 'opt',
  467. BUILD_TYPE_DESCRIPTION = 'Mac opt build',
  468. BUILD_GROUPS = ['all'],
  469. tools = ['target_optimized'],
  470. )
  471. mac_dbg64_env = mac_dbg_env.Clone(
  472. BUILD_TYPE = 'dbg64',
  473. BUILD_TYPE_DESCRIPTION = 'Mac debug 64bit build',
  474. BUILD_GROUPS = ['all'],
  475. )
  476. mac_opt64_env = mac_opt_env.Clone(
  477. BUILD_TYPE = 'opt64',
  478. BUILD_TYPE_DESCRIPTION = 'Mac opt 64bit build',
  479. BUILD_GROUPS = ['all'],
  480. )
  481. mac_debug_include(mac_dbg_env)
  482. mac_debug_include(mac_dbg64_env)
  483. mac_common_include_x86_32(mac_dbg_env)
  484. mac_common_include_x86_32(mac_opt_env)
  485. mac_common_include_x86_64(mac_dbg64_env)
  486. mac_common_include_x86_64(mac_opt64_env)
  487. mac_osx_version_min(mac_dbg_env, mac_osx_version_min_32)
  488. mac_osx_version_min(mac_opt_env, mac_osx_version_min_32)
  489. mac_osx_version_min(mac_dbg64_env, mac_osx_version_min_64)
  490. mac_osx_version_min(mac_opt64_env, mac_osx_version_min_64)
  491. #-------------------------------------------------------------------------------
  492. # L I N U X
  493. #
  494. linux_common_env = posix_env.Clone(
  495. tools = [
  496. 'target_platform_linux',
  497. 'talk_linux',
  498. ],
  499. )
  500. linux_common_env.Append(
  501. CPPDEFINES = [
  502. 'LINUX',
  503. ],
  504. CCFLAGS = [
  505. # Needed for link-time dead-code removal to work properly.
  506. '-ffunction-sections',
  507. '-fdata-sections',
  508. ],
  509. LINKFLAGS = [
  510. # Enable dead-code removal.
  511. '-Wl,--gc-sections',
  512. # Elide dependencies on shared libraries that we're not actually using.
  513. '-Wl,--as-needed',
  514. '-Wl,--start-group',
  515. ],
  516. _LIBFLAGS = ['-Wl,--end-group'],
  517. )
  518. # Remove default rpath set by Hammer. Hammer sets it to LIB_DIR, which is wrong.
  519. # The rpath is the _run-time_ library search path for the resulting binary, i.e.
  520. # the one used by ld.so at load time. Setting it equal to the path to build
  521. # output on the build machine is nonsense.
  522. linux_common_env.Replace(
  523. RPATH = [],
  524. )
  525. # Enable the optional DBus-GLib code if the build machine has the required
  526. # dependency.
  527. linux_common_env.EnableFeatureWherePackagePresent('have_dbus_glib',
  528. 'HAVE_DBUS_GLIB',
  529. 'dbus-glib-1')
  530. def linux_common_include_x86_32(env):
  531. """Include x86-32 settings into an env based on linux_common."""
  532. env.Append(
  533. CCFLAGS = [
  534. '-m32',
  535. ],
  536. LINKFLAGS = [
  537. '-m32',
  538. ],
  539. )
  540. def linux_common_include_x86_64(env):
  541. """Include x86-64 settings into an env based on linux_common."""
  542. env.Append(
  543. CCFLAGS = [
  544. '-m64',
  545. '-fPIC',
  546. ],
  547. LINKFLAGS = [
  548. '-m64',
  549. ],
  550. )
  551. env.SetBits('host_platform_64bit')
  552. #-------------------------------------------------------------------------------
  553. # L I N U X -- C R O S S -- B U I L D
  554. # Cross build requires the following tool names be provided by the environment:
  555. linux_cross_common_env = linux_common_env.Clone(
  556. AR = os.environ.get("AR"),
  557. AS = os.environ.get("AS"),
  558. LD = os.environ.get("LD"),
  559. NM = os.environ.get("NM"),
  560. RANLIB = os.environ.get("RANLIB"),
  561. CC = str(os.environ.get("CC")) +
  562. ' --sysroot=' + str(os.environ.get("SYSROOT")),
  563. CXX = str(os.environ.get("CXX")) +
  564. ' --sysroot=' + str(os.environ.get("SYSROOT")),
  565. )
  566. linux_cross_common_env.SetBits('cross_compile')
  567. # The rest of these paths and flags are optional:
  568. if os.environ.get("CPPPATH"):
  569. linux_cross_common_env.Append(
  570. CPPPATH = os.environ.get("CPPPATH").split(':'),
  571. )
  572. if os.environ.get("LIBPATH"):
  573. linux_cross_common_env.Append(
  574. LIBPATH = os.environ.get("LIBPATH").split(':'),
  575. )
  576. if os.environ.get("CFLAGS"):
  577. linux_cross_common_env.Append(
  578. CFLAGS = os.environ.get("CFLAGS").split(' '),
  579. )
  580. if os.environ.get("CCFLAGS"):
  581. linux_cross_common_env.Append(
  582. CCFLAGS = os.environ.get("CCFLAGS").split(' '),
  583. )
  584. if os.environ.get("CXXFLAGS"):
  585. linux_cross_common_env.Append(
  586. CXXFLAGS = os.environ.get("CXXFLAGS").split(' '),
  587. )
  588. if os.environ.get("LIBFLAGS"):
  589. linux_cross_common_env.Append(
  590. _LIBFLAGS = os.environ.get("LIBFLAGS").split(' '),
  591. )
  592. if os.environ.get("LINKFLAGS"):
  593. linux_cross_common_env.Prepend(
  594. LINKFLAGS = os.environ.get("LINKFLAGS").split(' '),
  595. )
  596. #-------------------------------------------------------------------------------
  597. # L I N U X -- T R A D I T I O N A L -- X 8 6
  598. #
  599. # Settings that are specific to our desktop Linux x86 targets.
  600. def linux_common_include_traditional(env):
  601. """Include traditional Linux settings into an env based on linux_common."""
  602. # OpenSSL has infamously poor ABI stability, so that building against one
  603. # version and running against a different one often will not work. Since our
  604. # non-ChromeOS Linux builds are used on many different distros and distro
  605. # versions, this means we can't safely dynamically link to OpenSSL because the
  606. # product would end up being broken on any computer with a different version
  607. # installed. So instead we build it ourself and statically link to it.
  608. env.SetBits('use_static_openssl')
  609. # Enable the optional PulseAudio code if the build machine has the required
  610. # dependency.
  611. # TODO(?): This belongs in linux_common_env, but we can't safely move it there
  612. # yet because pkg-config is not being used properly with ChromeOS builds (see
  613. # TODO below).
  614. env.EnableFeatureWherePackagePresent('have_libpulse',
  615. 'HAVE_LIBPULSE',
  616. 'libpulse')
  617. def linux_traditional_include_dbg(env):
  618. """Include traditional Linux dbg settings into an env based on the above."""
  619. # Remove -g set by hammer, which is not what we want (we have set -g3 above).
  620. env.FilterOut(CCFLAGS = ['-g'])
  621. def linux_traditional_include_opt(env):
  622. """Include traditional Linux opt settings into an env based on the above."""
  623. # Remove -O2 set by hammer, which is not what we want.
  624. env.FilterOut(CCFLAGS = ['-O2'])
  625. env.Append(CCFLAGS = ['-Os'])
  626. def gen_linux_nonhermetic(linux_env, type_suffix, desc_suffix):
  627. groups = ['nonhermetic']
  628. if not linux_env.CrossArch():
  629. groups = groups + ['nonhermetic-native']
  630. # The non-hermetic, native-arch dbg build is the default.
  631. dbg_groups = groups + ['default']
  632. native_desc = ', native '
  633. # No suffix for native modes.
  634. type_suffix = ''
  635. else:
  636. groups = groups + ['nonhermetic-cross']
  637. dbg_groups = groups
  638. native_desc = ', cross-built for '
  639. linux_dbg_env = linux_env.Clone(
  640. BUILD_TYPE = 'dbg' + type_suffix,
  641. BUILD_TYPE_DESCRIPTION = 'Linux debug build%s%s' % (native_desc,
  642. desc_suffix),
  643. BUILD_GROUPS = dbg_groups,
  644. tools = ['target_debug'],
  645. )
  646. linux_traditional_include_dbg(linux_dbg_env)
  647. envs.append(linux_dbg_env)
  648. linux_opt_env = linux_env.Clone(
  649. BUILD_TYPE = 'opt' + type_suffix,
  650. BUILD_TYPE_DESCRIPTION = 'Linux optimized build%s%s' % (native_desc,
  651. desc_suffix),
  652. BUILD_GROUPS = groups,
  653. tools = ['target_optimized'],
  654. )
  655. linux_traditional_include_opt(linux_opt_env)
  656. envs.append(linux_opt_env)
  657. linux_nonhermetic_common_env = linux_common_env.Clone()
  658. linux_common_include_traditional(linux_nonhermetic_common_env)
  659. linux_nonhermetic_x86_32_env = linux_nonhermetic_common_env.Clone()
  660. linux_common_include_x86_32(linux_nonhermetic_x86_32_env)
  661. gen_linux_nonhermetic(linux_nonhermetic_x86_32_env, '32', '32-bit')
  662. linux_nonhermetic_x86_64_env = linux_nonhermetic_common_env.Clone()
  663. linux_common_include_x86_64(linux_nonhermetic_x86_64_env)
  664. gen_linux_nonhermetic(linux_nonhermetic_x86_64_env, '64', '64-bit')
  665. def gen_linux_hermetic(linux_env, type_suffix, desc):
  666. groups = ['hermetic']
  667. linux_dbg_env = linux_env.Clone(
  668. BUILD_TYPE = 'hermetic-dbg' + type_suffix,
  669. BUILD_TYPE_DESCRIPTION = 'Hermetic %s Linux debug build' % desc,
  670. BUILD_GROUPS = groups,
  671. tools = ['target_debug'],
  672. )
  673. linux_traditional_include_dbg(linux_dbg_env)
  674. envs.append(linux_dbg_env)
  675. linux_opt_env = linux_env.Clone(
  676. BUILD_TYPE = 'hermetic-opt' + type_suffix,
  677. BUILD_TYPE_DESCRIPTION = 'Hermetic %s Linux optimized build' % desc,
  678. BUILD_GROUPS = groups,
  679. tools = ['target_optimized'],
  680. )
  681. linux_traditional_include_opt(linux_opt_env)
  682. envs.append(linux_opt_env)
  683. linux_hermetic_common_env = linux_cross_common_env.Clone()
  684. linux_common_include_traditional(linux_hermetic_common_env)
  685. linux_hermetic_x86_32_env = linux_hermetic_common_env.Clone()
  686. linux_common_include_x86_32(linux_hermetic_x86_32_env)
  687. gen_linux_hermetic(linux_hermetic_x86_32_env, '32', '32-bit')
  688. linux_hermetic_x86_64_env = linux_hermetic_common_env.Clone()
  689. linux_common_include_x86_64(linux_hermetic_x86_64_env)
  690. gen_linux_hermetic(linux_hermetic_x86_64_env, '64', '64-bit')
  691. #-------------------------------------------------------------------------------
  692. # L I N U X -- C R O S S -- B U I L D -- A R M
  693. # TODO(noahric): All the following Linux builds are running against a sysroot
  694. # but improperly using the host machine's pkg-config environment. The ChromeOS
  695. # ones should probably be using
  696. # https://cs.corp.google.com/#chrome/src/build/linux/pkg-config-wrapper.
  697. linux_cross_arm_env = linux_cross_common_env.Clone()
  698. linux_cross_arm_env.Append(
  699. CPPDEFINES = [
  700. 'NACL_BUILD_ARCH=arm',
  701. 'DISABLE_EFFECTS=1',
  702. ],
  703. CCFLAGS = [
  704. '-fPIC',
  705. ],
  706. )
  707. DeclareBit('arm', 'ARM build')
  708. linux_cross_arm_env.SetBits('arm')
  709. # Detect NEON support from the -mfpu build flag.
  710. DeclareBit('arm_neon', 'ARM supporting neon')
  711. if '-mfpu=neon' in linux_cross_arm_env['CFLAGS'] or \
  712. '-mfpu=neon' in linux_cross_arm_env['CCFLAGS'] or \
  713. '-mfpu=neon' in linux_cross_arm_env['CXXFLAGS']:
  714. print "Building with ARM NEON support."
  715. linux_cross_arm_env.SetBits('arm_neon')
  716. # Detect hardfp from the -mfloat-abi build flag
  717. DeclareBit('arm_hardfp', 'ARM supporting hardfp')
  718. if '-mfloat-abi=hard' in linux_cross_arm_env['CFLAGS'] or \
  719. '-mfloat-abi=hard' in linux_cross_arm_env['CCFLAGS'] or \
  720. '-mfloat-abi=hard' in linux_cross_arm_env['CXXFLAGS']:
  721. print "Building with hard floating point support."
  722. linux_cross_arm_env.SetBits('arm_hardfp')
  723. linux_cross_arm_dbg_env = linux_cross_arm_env.Clone(
  724. BUILD_TYPE = 'arm-dbg',
  725. BUILD_TYPE_DESCRIPTION = 'Cross-compiled ARM debug build',
  726. BUILD_GROUPS = ['arm'],
  727. tools = ['target_debug'],
  728. )
  729. envs.append(linux_cross_arm_dbg_env)
  730. linux_cross_arm_opt_env = linux_cross_arm_env.Clone(
  731. BUILD_TYPE = 'arm-opt',
  732. BUILD_TYPE_DESCRIPTION = 'Cross-compiled ARM optimized build',
  733. BUILD_GROUPS = ['arm'],
  734. tools = ['target_optimized'],
  735. )
  736. envs.append(linux_cross_arm_opt_env)
  737. # Create a group for installers
  738. AddTargetGroup('all_installers', 'installers that can be built')
  739. # Parse child .scons files
  740. BuildEnvironments(envs)
  741. # Explicitly set which targets to build when not stated on commandline
  742. Default(None)
  743. # Build the following, which excludes unit test output (ie running them)
  744. # To run unittests, specify the test to run, or run_all_tests. See -h option.
  745. Default(['all_libraries', 'all_programs', 'all_test_programs'])
  746. # .sln creation code lifted from googleclient/bar/main.scons. Must be after
  747. # the call to BuildEnvironments for all_foo aliases to be defined.
  748. # Run 'hammer --mode=all --vsproj' to generate
  749. DeclareBit('vsproj', 'Generate Visual Studio projects and solution files.')
  750. win_env.SetBitFromOption('vsproj', False)
  751. if win_env.Bit('vsproj'):
  752. vs_env = win_env.Clone()
  753. vs_env.Append(
  754. COMPONENT_VS_SOURCE_SUFFIXES = [
  755. '.def',
  756. '.grd',
  757. '.html',
  758. '.idl',
  759. '.mk',
  760. '.txt',
  761. '.py',
  762. '.scons',
  763. '.wxs.template',
  764. ]
  765. )
  766. # Source project
  767. p = vs_env.ComponentVSDirProject(
  768. 'flute_source',
  769. ['$MAIN_DIR',
  770. ],
  771. COMPONENT_VS_SOURCE_FOLDERS = [
  772. # Files are assigned to first matching folder. Folder names of None
  773. # are filters.
  774. (None, '$DESTINATION_ROOT'),
  775. ('flute', '$MAIN_DIR'),
  776. ('google3', '$GOOGLE3'),
  777. ('third_party', '$THIRD_PARTY'),
  778. ],
  779. # Force source project to main dir, so that Visual Studio can find the
  780. # source files corresponding to build errors.
  781. COMPONENT_VS_PROJECT_DIR = '$MAIN_DIR',
  782. )
  783. vs_env.AlwaysBuild(p)
  784. # Solution and target projects
  785. s = vs_env.ComponentVSSolution(
  786. # 'libjingle', # Please uncomment this line if you build VS proj files.
  787. ['all_libraries', 'all_programs', 'all_test_programs'],
  788. projects = [p],
  789. )
  790. print '***Unfortunately the vsproj creator isn\'t smart enough to '
  791. print '***automatically get the correct output locations. It is very easy'
  792. print '***though to change it in the properties pane to the following'
  793. print '***$(SolutionDir)/build/<foo>/staging/<bar>.exe'
  794. Default(None)
  795. Default([s])