Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(896)

Side by Side Diff: native_client_sdk/src/build_tools/make_rules.py

Issue 10868089: add PRESUBMIT for native_client_sdk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
9 # This file contains lines longer than 80
8 10
9 # 11 #
10 # Default macros for various platforms. 12 # Default macros for various platforms.
11 # 13 #
12 NEWLIB_DEFAULTS = """ 14 NEWLIB_DEFAULTS = """
13 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
14 NEWLIB_CXX?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -c -std=gnu++98 16 NEWLIB_CXX?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -c -std=gnu++98
15 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
16 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
17 NEWLIB_DUMP?=$(TC_PATH)/$(OSNAME)_x86_newlib/x86_64-nacl/bin/objdump 19 NEWLIB_DUMP?=$(TC_PATH)/$(OSNAME)_x86_newlib/x86_64-nacl/bin/objdump
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 """MakeRules generates Tool, Config, and Arch dependend makefile settings. 289 """MakeRules generates Tool, Config, and Arch dependend makefile settings.
288 290
289 The MakeRules object generates strings used in the makefile based on the 291 The MakeRules object generates strings used in the makefile based on the
290 current object settings such as toolchain, configuration, architecture... 292 current object settings such as toolchain, configuration, architecture...
291 It stores settings such as includes, defines, and lists, and converts them 293 It stores settings such as includes, defines, and lists, and converts them
292 to the appropriate format whenever the toolchain changes. 294 to the appropriate format whenever the toolchain changes.
293 """ 295 """
294 296
295 def __init__(self, tc, cfg=None, arch=None): 297 def __init__(self, tc, cfg=None, arch=None):
296 self.tc = tc 298 self.tc = tc
299 self.project = ''
300 self.cfg = ''
301 self.arch = ''
302 self.ptype = ''
297 self.defines = [] 303 self.defines = []
298 self.includes = [] 304 self.includes = []
299 self.libraries = [] 305 self.libraries = []
300 self.vars = { 306 self.vars = {
301 '<TAB>': '\t', 307 '<TAB>': '\t',
302 } 308 }
303 self.SetToolchain(tc) 309 self.SetToolchain(tc)
304 if cfg: 310 if cfg:
305 self.SetConfig(cfg) 311 self.SetConfig(cfg)
306 if arch: 312 if arch:
(...skipping 18 matching lines...) Expand all
325 331
326 rules += '\n# Include header dependency files.\n' 332 rules += '\n# Include header dependency files.\n'
327 for cfg in configs: 333 for cfg in configs:
328 rules += '-include %s/%s/*.d\n' % (tc, cfg) 334 rules += '-include %s/%s/*.d\n' % (tc, cfg)
329 return rules + '\n' 335 return rules + '\n'
330 336
331 def BuildCompileRule(self, EXT, src): 337 def BuildCompileRule(self, EXT, src):
332 self.vars['<EXT>'] = EXT 338 self.vars['<EXT>'] = EXT
333 out = '<tc>/<config>/%s_<ARCH>.o : %s $(THIS_MAKE) | <tc>/<config>\n' % ( 339 out = '<tc>/<config>/%s_<ARCH>.o : %s $(THIS_MAKE) | <tc>/<config>\n' % (
334 os.path.splitext(src)[0], src) 340 os.path.splitext(src)[0], src)
335 out+= BUILD_RULES[self.tc][EXT][self.cfg] + '\n\n' 341 out += BUILD_RULES[self.tc][EXT][self.cfg] + '\n\n'
336 return self.Replace(out) 342 return self.Replace(out)
337 343
338 def BuildLinkRule(self): 344 def BuildLinkRule(self):
339 target = BUILD_RULES[self.tc]['TOOL'][self.ptype.upper()] 345 target = BUILD_RULES[self.tc]['TOOL'][self.ptype.upper()]
340 out = '' 346 out = ''
341 if self.ptype == 'lib': 347 if self.ptype == 'lib':
342 out = 'ALL_TARGETS+=%s\n' % target 348 out = 'ALL_TARGETS+=%s\n' % target
343 out += target + ' : $(<PROJ>_<TC>_<CONFIG>_<ARCH>_O)\n' 349 out += target + ' : $(<PROJ>_<TC>_<CONFIG>_<ARCH>_O)\n'
344 out += BUILD_RULES[self.tc][self.ptype.upper()][self.cfg] + '\n\n' 350 out += BUILD_RULES[self.tc][self.ptype.upper()][self.cfg] + '\n\n'
345 return self.Replace(out) 351 return self.Replace(out)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 def SetProject(self, proj, ptype, defs=None, incs=None, libs=None): 395 def SetProject(self, proj, ptype, defs=None, incs=None, libs=None):
390 self.project = proj 396 self.project = proj
391 self.ptype = ptype 397 self.ptype = ptype
392 self.vars['<proj>'] = proj 398 self.vars['<proj>'] = proj
393 self.vars['<PROJ>'] = proj.upper() 399 self.vars['<PROJ>'] = proj.upper()
394 self.SetDefines(defs) 400 self.SetDefines(defs)
395 self.SetIncludes(incs) 401 self.SetIncludes(incs)
396 self.SetLibraries(libs) 402 self.SetLibraries(libs)
397 403
398 def SetSource(self, src): 404 def SetSource(self, src):
399 self.source = source
400 self.vars['<src>'] = src 405 self.vars['<src>'] = src
401 406
402 def SetToolchain(self, tc): 407 def SetToolchain(self, tc):
403 TC = tc.upper() 408 TC = tc.upper()
404 if tc in ('linux', 'win'): 409 if tc in ('linux', 'win'):
405 tcname = 'host' 410 tcname = 'host'
406 else: 411 else:
407 tcname = tc 412 tcname = tc
408 self.vars['<CC>'] = '%s_CC' % TC 413 self.vars['<CC>'] = '%s_CC' % TC
409 self.vars['<CXX>'] = '%s_CXX' % TC 414 self.vars['<CXX>'] = '%s_CXX' % TC
410 self.vars['<DUMP>'] = '%s_DUMP' % TC 415 self.vars['<DUMP>'] = '%s_DUMP' % TC
411 self.vars['<LIB>'] = '%s_LIB' % TC 416 self.vars['<LIB>'] = '%s_LIB' % TC
412 self.vars['<LINK>'] = '%s_LINK' % TC 417 self.vars['<LINK>'] = '%s_LINK' % TC
413 self.vars['<tc>'] = tc 418 self.vars['<tc>'] = tc
414 self.vars['<tcname>'] = tcname 419 self.vars['<tcname>'] = tcname
415 self.vars['<TC>'] = TC 420 self.vars['<TC>'] = TC
416 self.SetDefines(self.defines) 421 self.SetDefines(self.defines)
417 self.SetIncludes(self.includes) 422 self.SetIncludes(self.includes)
418 self.SetLibraries(self.libraries) 423 self.SetLibraries(self.libraries)
419 424
420 def SetVars(self, **kwargs): 425 def SetVars(self, **kwargs):
421 # Add other passed in replacements 426 # Add other passed in replacements
422 for key in kwargs: 427 for key in kwargs:
423 self.vars['<%s>' % key] = kwargs[key] 428 self.vars['<%s>' % key] = kwargs[key]
424 self.var_set = kwargs
425 429
426 def Replace(self, text): 430 def Replace(self, text):
427 return Replace(text, self.vars) 431 return Replace(text, self.vars)
428 432
429 433
430 def Replace(text, replacements): 434 def Replace(text, replacements):
431 for key in replacements: 435 for key in replacements:
432 val = replacements[key] 436 val = replacements[key]
433 if val is not None: 437 if val is not None:
434 text = text.replace(key, val) 438 text = text.replace(key, val)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 } 480 }
477 for dll in dlls: 481 for dll in dlls:
478 replace['<proj>'] = dll 482 replace['<proj>'] = dll
479 nmf_targets.append(Replace(dll_target, replace)) 483 nmf_targets.append(Replace(dll_target, replace))
480 replace['<proj>'] = main 484 replace['<proj>'] = main
481 nmf_targets.append(Replace(target, replace)) 485 nmf_targets.append(Replace(target, replace))
482 486
483 replace['<NMF_TARGETS>'] = ' '.join(nmf_targets) 487 replace['<NMF_TARGETS>'] = ' '.join(nmf_targets)
484 rules = Replace(BUILD_RULES[tc]['NMF'], replace) 488 rules = Replace(BUILD_RULES[tc]['NMF'], replace)
485 return '\nALL_TARGETS+=%s/%s/%s.nmf' % (tc, cfg, main) + rules + '\n' 489 return '\nALL_TARGETS+=%s/%s/%s.nmf' % (tc, cfg, main) + rules + '\n'
OLDNEW
« no previous file with comments | « native_client_sdk/src/build_tools/build_utils.py ('k') | native_client_sdk/src/build_tools/manifest_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698