| 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 buildbot_common | 6 import buildbot_common |
| 7 import make_rules | 7 import make_rules |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| 11 | 11 |
| 12 from make_rules import BuildDefineList, BuildLibList, BuildToolDict | 12 from make_rules import BuildDefineList, BuildLibList, BuildToolDict |
| 13 from make_rules import GetBuildRule, BUILD_RULES | 13 from make_rules import BuildIncludeList, GetBuildRule, BUILD_RULES |
| 14 | 14 |
| 15 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 15 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 16 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR) | 16 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR) |
| 17 SDK_EXAMPLE_DIR = os.path.join(SDK_SRC_DIR, 'examples') | 17 SDK_EXAMPLE_DIR = os.path.join(SDK_SRC_DIR, 'examples') |
| 18 SDK_DIR = os.path.dirname(SDK_SRC_DIR) | 18 SDK_DIR = os.path.dirname(SDK_SRC_DIR) |
| 19 SRC_DIR = os.path.dirname(SDK_DIR) | 19 SRC_DIR = os.path.dirname(SDK_DIR) |
| 20 OUT_DIR = os.path.join(SRC_DIR, 'out') | 20 OUT_DIR = os.path.join(SRC_DIR, 'out') |
| 21 PPAPI_DIR = os.path.join(SRC_DIR, 'ppapi') | 21 PPAPI_DIR = os.path.join(SRC_DIR, 'ppapi') |
| 22 | 22 |
| 23 # Add SDK make tools scripts to the python path. | 23 # Add SDK make tools scripts to the python path. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 For the given target, toolset and architecture, returns a rule to generate | 138 For the given target, toolset and architecture, returns a rule to generate |
| 139 the object files for the set of sources. | 139 the object files for the set of sources. |
| 140 | 140 |
| 141 Returns: | 141 Returns: |
| 142 Returns a tuple containin the objects and the rule. | 142 Returns a tuple containin the objects and the rule. |
| 143 """ | 143 """ |
| 144 rules = '' | 144 rules = '' |
| 145 name = target['NAME'] | 145 name = target['NAME'] |
| 146 object_sets = [] | 146 object_sets = [] |
| 147 | 147 |
| 148 defines = target.get('DEFINES', []) | 148 defs = BuildDefineList(tool, target.get('DEFINES', [])) |
| 149 defs = BuildDefineList(tool, defines) | 149 includes = BuildIncludeList(tool, target.get('INCLUDES', [])) |
| 150 | 150 |
| 151 if srcs['.c']: | 151 if srcs['.c']: |
| 152 replace = BuildToolDict(tool, name, arch, 'c', DEFLIST=defs) | 152 replace = BuildToolDict(tool, name, arch, 'c', |
| 153 DEFLIST=defs, INCLUDELIST=includes) |
| 153 compile_rule = GetBuildRule(tool, 'CC') | 154 compile_rule = GetBuildRule(tool, 'CC') |
| 154 rules += Replace(compile_rule, replace) | 155 rules += Replace(compile_rule, replace) |
| 155 object_sets.append('$(%s)' % replace['<OBJS>']) | 156 object_sets.append('$(%s)' % replace['<OBJS>']) |
| 156 | 157 |
| 157 if srcs['.cc']: | 158 if srcs['.cc']: |
| 158 replace = BuildToolDict(tool, name, arch, 'cc', DEFLIST=defs) | 159 replace = BuildToolDict(tool, name, arch, 'cc', |
| 160 DEFLIST=defs, INCLUDELIST=includes) |
| 159 compile_rule = GetBuildRule(tool, 'CXX') | 161 compile_rule = GetBuildRule(tool, 'CXX') |
| 160 rules += Replace(compile_rule, replace) | 162 rules += Replace(compile_rule, replace) |
| 161 object_sets.append('$(%s)' % replace['<OBJS>']) | 163 object_sets.append('$(%s)' % replace['<OBJS>']) |
| 162 | 164 |
| 163 return (' '.join(object_sets), rules) | 165 return (' '.join(object_sets), rules) |
| 164 | 166 |
| 165 | 167 |
| 166 def GenerateLink(target, tool, arch, objs): | 168 def GenerateLink(target, tool, arch, objs): |
| 167 """Generate a Link target. | 169 """Generate a Link target. |
| 168 | 170 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 DSC_FORMAT = { | 264 DSC_FORMAT = { |
| 263 'TOOLS' : (list, ['newlib', 'glibc', 'pnacl', 'win'], True), | 265 'TOOLS' : (list, ['newlib', 'glibc', 'pnacl', 'win'], True), |
| 264 'PREREQ' : (list, '', False), | 266 'PREREQ' : (list, '', False), |
| 265 'TARGETS' : (list, { | 267 'TARGETS' : (list, { |
| 266 'NAME': (str, '', True), | 268 'NAME': (str, '', True), |
| 267 'TYPE': (str, ['main', 'nexe', 'lib', 'so'], True), | 269 'TYPE': (str, ['main', 'nexe', 'lib', 'so'], True), |
| 268 'SOURCES': (list, '', True), | 270 'SOURCES': (list, '', True), |
| 269 'CCFLAGS': (list, '', False), | 271 'CCFLAGS': (list, '', False), |
| 270 'CXXFLAGS': (list, '', False), | 272 'CXXFLAGS': (list, '', False), |
| 271 'LDFLAGS': (list, '', False), | 273 'LDFLAGS': (list, '', False), |
| 274 'INCLUDES': (list, '', False), |
| 272 'LIBS' : (list, '', False) | 275 'LIBS' : (list, '', False) |
| 273 }, True), | 276 }, True), |
| 274 'HEADERS': (list, { | 277 'HEADERS': (list, { |
| 275 'FILES': (list, '', True), | 278 'FILES': (list, '', True), |
| 276 'DEST': (str, '', True), | 279 'DEST': (str, '', True), |
| 277 }, False), | 280 }, False), |
| 278 'SEARCH': (list, '', False), | 281 'SEARCH': (list, '', False), |
| 279 'POST': (str, '', False), | 282 'POST': (str, '', False), |
| 280 'PRE': (str, '', False), | 283 'PRE': (str, '', False), |
| 281 'DEST': (str, ['examples', 'src'], True), | 284 'DEST': (str, ['examples', 'src', 'testing'], True), |
| 282 'NAME': (str, '', False), | 285 'NAME': (str, '', False), |
| 283 'DATA': (list, '', False), | 286 'DATA': (list, '', False), |
| 284 'TITLE': (str, '', False), | 287 'TITLE': (str, '', False), |
| 285 'DESC': (str, '', False), | 288 'DESC': (str, '', False), |
| 286 'INFO': (str, '', False), | 289 'INFO': (str, '', False), |
| 287 'EXPERIMENTAL': (bool, [True, False], False) | 290 'EXPERIMENTAL': (bool, [True, False], False) |
| 288 } | 291 } |
| 289 | 292 |
| 290 | 293 |
| 291 def ErrorMsgFunc(text): | 294 def ErrorMsgFunc(text): |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 toolchains.append(platform) | 548 toolchains.append(platform) |
| 546 | 549 |
| 547 if not args: | 550 if not args: |
| 548 ErrorExit('Please specify one or more projects to generate Makefiles for.') | 551 ErrorExit('Please specify one or more projects to generate Makefiles for.') |
| 549 | 552 |
| 550 # By default support newlib and glibc | 553 # By default support newlib and glibc |
| 551 if not toolchains: | 554 if not toolchains: |
| 552 toolchains = ['newlib', 'glibc'] | 555 toolchains = ['newlib', 'glibc'] |
| 553 print 'Using default toolchains: ' + ' '.join(toolchains) | 556 print 'Using default toolchains: ' + ' '.join(toolchains) |
| 554 | 557 |
| 555 examples = [] | 558 master_projects = {} |
| 556 libs = [] | |
| 557 for filename in args: | 559 for filename in args: |
| 558 desc = LoadProject(filename, toolchains) | 560 desc = LoadProject(filename, toolchains) |
| 559 if not desc: | 561 if not desc: |
| 560 print 'Skipping %s, not in [%s].' % (filename, ', '.join(toolchains)) | 562 print 'Skipping %s, not in [%s].' % (filename, ', '.join(toolchains)) |
| 561 continue | 563 continue |
| 562 | 564 |
| 563 if desc.get('EXPERIMENTAL', False) and not options.experimental: | 565 if desc.get('EXPERIMENTAL', False) and not options.experimental: |
| 564 print 'Skipping %s, experimental only.' % (filename,) | 566 print 'Skipping %s, experimental only.' % (filename,) |
| 565 continue | 567 continue |
| 566 | 568 |
| 567 srcroot = os.path.dirname(os.path.abspath(filename)) | 569 srcroot = os.path.dirname(os.path.abspath(filename)) |
| 568 if not ProcessProject(srcroot, options.dstroot, desc, toolchains): | 570 if not ProcessProject(srcroot, options.dstroot, desc, toolchains): |
| 569 ErrorExit('\n*** Failed to process project: %s ***' % filename) | 571 ErrorExit('\n*** Failed to process project: %s ***' % filename) |
| 570 | 572 |
| 571 # if this is an example add it to the master make and update the html | 573 # if this is an example update the html |
| 572 if desc['DEST'] == 'examples': | 574 if desc['DEST'] == 'examples': |
| 573 examples.append(desc['NAME']) | |
| 574 ProcessHTML(srcroot, options.dstroot, desc, toolchains) | 575 ProcessHTML(srcroot, options.dstroot, desc, toolchains) |
| 575 | 576 |
| 576 # if this is a library add it to the master make | 577 # Create a list of projects for each DEST. This will be used to generate a |
| 577 if desc['DEST'] == 'src': | 578 # master makefile. |
| 578 libs.append(desc['NAME']) | 579 master_projects.setdefault(desc['DEST'], []).append(desc['NAME']) |
| 579 | 580 |
| 580 if options.master: | 581 if options.master: |
| 581 master_in = os.path.join(SDK_EXAMPLE_DIR, 'Makefile') | 582 master_in = os.path.join(SDK_EXAMPLE_DIR, 'Makefile') |
| 582 master_out = os.path.join(options.dstroot, 'examples', 'Makefile') | 583 for dest, projects in master_projects.iteritems(): |
| 583 GenerateMasterMakefile(master_in, master_out, examples) | 584 master_out = os.path.join(options.dstroot, dest, 'Makefile') |
| 584 master_out = os.path.join(options.dstroot, 'src', 'Makefile') | 585 GenerateMasterMakefile(master_in, master_out, projects) |
| 585 GenerateMasterMakefile(master_in, master_out, libs) | |
| 586 return 0 | 586 return 0 |
| 587 | 587 |
| 588 | 588 |
| 589 if __name__ == '__main__': | 589 if __name__ == '__main__': |
| 590 sys.exit(main(sys.argv[1:])) | 590 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |