OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 | 7 |
8 # pylint: disable=C0301 | 8 # pylint: disable=C0301 |
9 # This file contains lines longer than 80 | 9 # This file contains lines longer than 80 |
10 | 10 |
11 # | 11 # |
12 # Default macros for various platforms. | 12 # Default macros for various platforms. |
13 # | 13 # |
14 NEWLIB_DEFAULTS = """ | 14 NEWLIB_DEFAULTS = """ |
15 NEWLIB_CC?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-gcc -c | 15 NEWLIB_CC?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-gcc -c |
16 NEWLIB_CXX?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -c | 16 NEWLIB_CXX?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -c |
17 NEWLIB_LINK?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -Wl,-as-needed | 17 NEWLIB_LINK?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -Wl,-as-needed |
18 NEWLIB_LIB?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-ar r | 18 NEWLIB_LIB?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-ar r |
19 NEWLIB_CCFLAGS?=-MMD -pthread $(NACL_WARNINGS) -idirafter $(NACL_SDK_ROOT)/inclu
de | 19 NEWLIB_CCFLAGS?=-MMD -pthread $(NACL_WARNINGS) -idirafter $(NACL_SDK_ROOT)/inclu
de |
20 NEWLIB_LDFLAGS?=-pthread | 20 NEWLIB_LDFLAGS?=-pthread |
21 """ | 21 """ |
22 | 22 |
| 23 ARM_DEFAULTS = """ |
| 24 ARM_CC?=$(TC_PATH)/$(OSNAME)_arm_newlib/bin/arm-nacl-gcc -c |
| 25 ARM_CXX?=$(TC_PATH)/$(OSNAME)_arm_newlib/bin/arm-nacl-g++ -c |
| 26 ARM_LINK?=$(TC_PATH)/$(OSNAME)_arm_newlib/bin/arm-nacl-g++ -Wl,-as-needed |
| 27 ARM_LIB?=$(TC_PATH)/$(OSNAME)_arm_newlib/bin/arm-nacl-ar r |
| 28 """ |
| 29 |
23 GLIBC_DEFAULTS = """ | 30 GLIBC_DEFAULTS = """ |
24 GLIBC_CC?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-gcc -c | 31 GLIBC_CC?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-gcc -c |
25 GLIBC_CXX?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-g++ -c | 32 GLIBC_CXX?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-g++ -c |
26 GLIBC_LINK?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-g++ -Wl,-as-needed | 33 GLIBC_LINK?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-g++ -Wl,-as-needed |
27 GLIBC_LIB?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-ar r | 34 GLIBC_LIB?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-ar r |
28 GLIBC_DUMP?=$(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/bin/objdump | 35 GLIBC_DUMP?=$(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/bin/objdump |
29 GLIBC_PATHS:=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib32 | 36 GLIBC_PATHS:=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib32 |
30 GLIBC_PATHS+=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib | 37 GLIBC_PATHS+=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib |
31 GLIBC_CCFLAGS?=-MMD -pthread $(NACL_WARNINGS) -idirafter $(NACL_SDK_ROOT)/includ
e | 38 GLIBC_CCFLAGS?=-MMD -pthread $(NACL_WARNINGS) -idirafter $(NACL_SDK_ROOT)/includ
e |
32 GLIBC_LDFLAGS?=-pthread | 39 GLIBC_LDFLAGS?=-pthread |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 '<tc>/<config>/<proj>_arm.nexe', | 205 '<tc>/<config>/<proj>_arm.nexe', |
199 'SO': None, | 206 'SO': None, |
200 'LIB': '$(NACL_SDK_ROOT)/lib/<libdir>/<config>/lib<proj>.a', | 207 'LIB': '$(NACL_SDK_ROOT)/lib/<libdir>/<config>/lib<proj>.a', |
201 } | 208 } |
202 | 209 |
203 | 210 |
204 # | 211 # |
205 # Various Architectures | 212 # Various Architectures |
206 # | 213 # |
207 LINUX = { | 214 LINUX = { |
208 '<arch>': '', | 215 '<arch>': 'linux', |
209 '<ARCH>': '', | 216 '<ARCH>': '', |
210 '<MACH>': '', | 217 '<MACH>': '', |
211 } | 218 } |
212 NACL_X86_32 = { | 219 NACL_X86_32 = { |
213 '<arch>': '32', | 220 '<arch>': 'x86', |
214 '<ARCH>': 'x86_32', | 221 '<ARCH>': 'x86_32', |
215 '<MACH>': '-m32', | 222 '<MACH>': '-m32', |
216 } | 223 } |
217 NACL_X86_64 = { | 224 NACL_X86_64 = { |
218 '<arch>': '64', | 225 '<arch>': 'x64', |
219 '<ARCH>': 'x86_64', | 226 '<ARCH>': 'x86_64', |
220 '<MACH>': '-m64', | 227 '<MACH>': '-m64', |
221 } | 228 } |
222 NACL_PNACL = { | 229 NACL_PNACL = { |
223 '<arch>': 'pnacl', | 230 '<arch>': 'pnacl', |
224 '<MACH>': '', | 231 '<MACH>': '', |
225 } | 232 } |
| 233 NACL_ARM = { |
| 234 '<arch>': 'arm', |
| 235 '<ARCH>': 'arm', |
| 236 '<MACH>': '', |
| 237 # override the default NACL toolchain |
| 238 '<TOOLSET>': 'ARM', |
| 239 } |
226 WIN_32 = { | 240 WIN_32 = { |
227 '<arch>': '', | 241 '<arch>': '', |
228 '<ARCH>': 'x86_32', | 242 '<ARCH>': 'x86_32', |
229 '<MACH>': '', | 243 '<MACH>': '', |
230 } | 244 } |
231 | 245 |
232 | 246 |
233 BUILD_RULES = { | 247 BUILD_RULES = { |
234 'newlib' : { | 248 'newlib' : { |
235 'ARCHES': [NACL_X86_32, NACL_X86_64], | 249 'ARCHES': [NACL_X86_32, NACL_X86_64, NACL_ARM], |
236 'DEFS': NEWLIB_DEFAULTS, | 250 'DEFS': NEWLIB_DEFAULTS + ARM_DEFAULTS, |
237 'CC' : NACL_CC_RULES, | 251 'CC' : NACL_CC_RULES, |
238 'CXX' : NACL_CC_RULES, | 252 'CXX' : NACL_CC_RULES, |
239 'NMF' : NMF_RULE, | 253 'NMF' : NMF_RULE, |
240 'MAIN': NEXE_LINK_RULES, | 254 'MAIN': NEXE_LINK_RULES, |
241 'LIB': POSIX_LIB_RULES, | 255 'LIB': POSIX_LIB_RULES, |
242 'SO' : None, | 256 'SO' : None, |
243 'TOOL': NACL_TOOL, | 257 'TOOL': NACL_TOOL, |
244 }, | 258 }, |
245 'glibc' : { | 259 'glibc' : { |
246 'ARCHES': [NACL_X86_32, NACL_X86_64], | 260 'ARCHES': [NACL_X86_32, NACL_X86_64], |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 304 |
291 class MakeRules(object): | 305 class MakeRules(object): |
292 """MakeRules generates Tool, Config, and Arch dependend makefile settings. | 306 """MakeRules generates Tool, Config, and Arch dependend makefile settings. |
293 | 307 |
294 The MakeRules object generates strings used in the makefile based on the | 308 The MakeRules object generates strings used in the makefile based on the |
295 current object settings such as toolchain, configuration, architecture... | 309 current object settings such as toolchain, configuration, architecture... |
296 It stores settings such as includes, defines, and lists, and converts them | 310 It stores settings such as includes, defines, and lists, and converts them |
297 to the appropriate format whenever the toolchain changes. | 311 to the appropriate format whenever the toolchain changes. |
298 """ | 312 """ |
299 | 313 |
300 def __init__(self, tc, cfg=None, arch=None): | 314 def __init__(self, tc): |
301 self.tc = tc | 315 self.tc = tc |
302 self.project = '' | 316 self.project = '' |
303 self.cfg = '' | 317 self.cfg = '' |
304 self.arch = '' | |
305 self.ptype = '' | 318 self.ptype = '' |
306 self.arch_ext = '' | 319 self.arch_ext = '' |
307 self.defines = [] | 320 self.defines = [] |
308 self.includes = [] | 321 self.includes = [] |
309 self.libraries = [] | 322 self.libraries = [] |
310 self.vars = { | 323 self.vars = { |
311 '<TAB>': '\t', | 324 '<TAB>': '\t', |
312 } | 325 } |
313 self.SetToolchain(tc) | 326 self.SetToolchain(tc) |
314 if cfg: | |
315 self.SetConfig(cfg) | |
316 if arch: | |
317 self.SetArch(arch) | |
318 | 327 |
319 def _BuildList(self, key, items): | 328 def _BuildList(self, key, items): |
320 pattern = BUILD_RULES[self.tc]['TOOL'][key] | 329 pattern = BUILD_RULES[self.tc]['TOOL'][key] |
321 if pattern and items: | 330 if pattern and items: |
322 items = [pattern % item for item in items] | 331 items = [pattern % item for item in items] |
323 return ' '.join(items) | 332 return ' '.join(items) |
324 return '' | 333 return '' |
325 | 334 |
326 def BuildDefaults(self): | 335 def BuildDefaults(self): |
327 return BUILD_RULES[self.tc]['DEFS'] | 336 return BUILD_RULES[self.tc]['DEFS'] |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 sub_str = '$(patsubst %%,%s/%s/%%%s.o,$(%s_OBJS))' % ( | 373 sub_str = '$(patsubst %%,%s/%s/%%%s.o,$(%s_OBJS))' % ( |
365 self.tc, self.cfg, self.arch_ext, self.project.upper()) | 374 self.tc, self.cfg, self.arch_ext, self.project.upper()) |
366 return '%s:=%s\n' % (obj_list, sub_str) | 375 return '%s:=%s\n' % (obj_list, sub_str) |
367 | 376 |
368 def GetArches(self): | 377 def GetArches(self): |
369 return BUILD_RULES[self.tc]['ARCHES'] | 378 return BUILD_RULES[self.tc]['ARCHES'] |
370 | 379 |
371 def GetObjectList(self): | 380 def GetObjectList(self): |
372 return '%s_%s_%s%s_O' % (self.project.upper(), self.tc.upper(), | 381 return '%s_%s_%s%s_O' % (self.project.upper(), self.tc.upper(), |
373 self.cfg.upper(), self.arch_ext) | 382 self.cfg.upper(), self.arch_ext) |
374 | |
375 def GetPepperPlugin(self): | 383 def GetPepperPlugin(self): |
376 plugin = self.Replace(BUILD_RULES[self.tc]['TOOL']['MAIN']) | 384 plugin = self.Replace(BUILD_RULES[self.tc]['TOOL']['MAIN']) |
377 text = 'PPAPI_<CONFIG>:=$(abspath %s)' % plugin | 385 text = 'PPAPI_<CONFIG>:=$(abspath %s)' % plugin |
378 text += ';application/x-ppapi-%s\n' % self.vars['<config>'].lower() | 386 text += ';application/x-ppapi-%s\n' % self.vars['<config>'].lower() |
379 return self.Replace(text) | 387 return self.Replace(text) |
380 | 388 |
381 | |
382 def SetArch(self, arch): | 389 def SetArch(self, arch): |
383 self.arch = arch | |
384 for key in arch: | 390 for key in arch: |
385 self.vars[key] = arch[key] | 391 self.vars[key] = arch[key] |
386 if '<ARCH>' in self.vars: | 392 if '<ARCH>' in self.vars: |
387 self.arch_ext = "_" + self.arch['<ARCH>'] | 393 self.arch_ext = "_" + arch['<ARCH>'] |
388 self.vars['<libdir>'] = "%s_%s" % (self.tc, self.vars['<ARCH>']) | 394 self.vars['<libdir>'] = "%s_%s" % (self.tc, self.vars['<ARCH>']) |
389 else: | 395 else: |
390 self.vars['<libdir>'] = self.tc | 396 self.vars['<libdir>'] = self.tc |
391 | 397 |
| 398 toolset = arch.get('<TOOLSET>', self.tc.upper()) |
| 399 self.SetTools(toolset) |
| 400 |
392 def SetConfig(self, config): | 401 def SetConfig(self, config): |
393 self.cfg = config | 402 self.cfg = config |
394 self.vars['<config>'] = config | 403 self.vars['<config>'] = config |
395 self.vars['<CONFIG>'] = config.upper() | 404 self.vars['<CONFIG>'] = config.upper() |
396 | 405 |
397 def SetDefines(self, defs): | 406 def SetDefines(self, defs): |
398 self.defines = defs | 407 self.defines = defs |
399 self.vars['<DEFLIST>'] = self._BuildList('DEFINE', defs) | 408 self.vars['<DEFLIST>'] = self._BuildList('DEFINE', defs) |
400 | 409 |
401 def SetIncludes(self, incs): | 410 def SetIncludes(self, incs): |
(...skipping 15 matching lines...) Expand all Loading... |
417 | 426 |
418 def SetSource(self, src): | 427 def SetSource(self, src): |
419 self.vars['<src>'] = src | 428 self.vars['<src>'] = src |
420 | 429 |
421 def SetToolchain(self, tc): | 430 def SetToolchain(self, tc): |
422 TC = tc.upper() | 431 TC = tc.upper() |
423 if tc in ('linux', 'win'): | 432 if tc in ('linux', 'win'): |
424 tcname = 'host' | 433 tcname = 'host' |
425 else: | 434 else: |
426 tcname = tc | 435 tcname = tc |
427 self.vars['<CC>'] = '%s_CC' % TC | |
428 self.vars['<CXX>'] = '%s_CXX' % TC | |
429 self.vars['<LIB>'] = '%s_LIB' % TC | |
430 self.vars['<LINK>'] = '%s_LINK' % TC | |
431 self.vars['<tc>'] = tc | 436 self.vars['<tc>'] = tc |
432 self.vars['<tcname>'] = tcname | 437 self.vars['<tcname>'] = tcname |
433 self.vars['<TC>'] = TC | 438 self.vars['<TC>'] = TC |
434 self.SetDefines(self.defines) | 439 self.SetDefines(self.defines) |
435 self.SetIncludes(self.includes) | 440 self.SetIncludes(self.includes) |
436 self.SetLibraries(self.libraries) | 441 self.SetLibraries(self.libraries) |
437 | 442 |
| 443 def SetTools(self, toolname): |
| 444 self.vars['<CC>'] = '%s_CC' % toolname |
| 445 self.vars['<CXX>'] = '%s_CXX' % toolname |
| 446 self.vars['<LIB>'] = '%s_LIB' % toolname |
| 447 self.vars['<LINK>'] = '%s_LINK' % toolname |
| 448 |
438 def SetVars(self, **kwargs): | 449 def SetVars(self, **kwargs): |
439 # Add other passed in replacements | 450 # Add other passed in replacements |
440 for key in kwargs: | 451 for key in kwargs: |
441 self.vars['<%s>' % key] = kwargs[key] | 452 self.vars['<%s>' % key] = kwargs[key] |
442 | 453 |
443 def Replace(self, text): | 454 def Replace(self, text): |
444 return Replace(text, self.vars) | 455 return Replace(text, self.vars) |
445 | 456 |
446 | 457 |
447 def Replace(text, replacements): | 458 def Replace(text, replacements): |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 replace['<ARCH>'] = arch['<ARCH>'] | 506 replace['<ARCH>'] = arch['<ARCH>'] |
496 for dll in dlls: | 507 for dll in dlls: |
497 replace['<proj>'] = dll | 508 replace['<proj>'] = dll |
498 nmf_targets.append(Replace(dll_target, replace)) | 509 nmf_targets.append(Replace(dll_target, replace)) |
499 replace['<proj>'] = main | 510 replace['<proj>'] = main |
500 nmf_targets.append(Replace(target, replace)) | 511 nmf_targets.append(Replace(target, replace)) |
501 | 512 |
502 replace['<NMF_TARGETS>'] = ' '.join(nmf_targets) | 513 replace['<NMF_TARGETS>'] = ' '.join(nmf_targets) |
503 rules = Replace(BUILD_RULES[tc]['NMF'], replace) | 514 rules = Replace(BUILD_RULES[tc]['NMF'], replace) |
504 return '\nALL_TARGETS+=%s/%s/%s.nmf' % (tc, cfg, main) + rules + '\n' | 515 return '\nALL_TARGETS+=%s/%s/%s.nmf' % (tc, cfg, main) + rules + '\n' |
OLD | NEW |