| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 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 multiprocessing | 6 import multiprocessing |
| 7 import optparse | 7 import optparse |
| 8 import os | 8 import os |
| 9 import posixpath | 9 import posixpath |
| 10 import sys | 10 import sys |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 with open(make_exe, 'wb') as f: | 87 with open(make_exe, 'wb') as f: |
| 88 f.write(urllib2.urlopen(make_url).read()) | 88 f.write(urllib2.urlopen(make_url).read()) |
| 89 | 89 |
| 90 | 90 |
| 91 def ValidateToolchains(toolchains): | 91 def ValidateToolchains(toolchains): |
| 92 invalid_toolchains = set(toolchains) - set(VALID_TOOLCHAINS) | 92 invalid_toolchains = set(toolchains) - set(VALID_TOOLCHAINS) |
| 93 if invalid_toolchains: | 93 if invalid_toolchains: |
| 94 buildbot_common.ErrorExit('Invalid toolchain(s): %s' % ( | 94 buildbot_common.ErrorExit('Invalid toolchain(s): %s' % ( |
| 95 ', '.join(invalid_toolchains))) | 95 ', '.join(invalid_toolchains))) |
| 96 | 96 |
| 97 def GetDeps(projects): |
| 98 out = {} |
| 99 |
| 100 # Build list of all project names |
| 101 localtargets = [proj['NAME'] for proj in projects] |
| 102 |
| 103 # For each project |
| 104 for proj in projects: |
| 105 deplist = [] |
| 106 # generate a list of dependencies |
| 107 for targ in proj.get('TARGETS', []): |
| 108 deplist.extend(targ.get('DEPS', []) + targ.get('LIBS', [])) |
| 109 |
| 110 # and add dependencies to targets built in this subtree |
| 111 localdeps = [dep for dep in deplist if dep in localtargets] |
| 112 if localdeps: |
| 113 out[proj['NAME']] = localdeps |
| 114 |
| 115 return out |
| 116 |
| 97 | 117 |
| 98 def UpdateProjects(pepperdir, project_tree, toolchains, | 118 def UpdateProjects(pepperdir, project_tree, toolchains, |
| 99 clobber=False, configs=None, first_toolchain=False): | 119 clobber=False, configs=None, first_toolchain=False): |
| 100 if configs is None: | 120 if configs is None: |
| 101 configs = ['Debug', 'Release'] | 121 configs = ['Debug', 'Release'] |
| 102 if not os.path.exists(os.path.join(pepperdir, 'tools')): | 122 if not os.path.exists(os.path.join(pepperdir, 'tools')): |
| 103 buildbot_common.ErrorExit('Examples depend on missing tools.') | 123 buildbot_common.ErrorExit('Examples depend on missing tools.') |
| 104 if not os.path.exists(os.path.join(pepperdir, 'toolchain')): | 124 if not os.path.exists(os.path.join(pepperdir, 'toolchain')): |
| 105 buildbot_common.ErrorExit('Examples depend on missing toolchains.') | 125 buildbot_common.ErrorExit('Examples depend on missing toolchains.') |
| 106 | 126 |
| 107 ValidateToolchains(toolchains) | 127 ValidateToolchains(toolchains) |
| 108 | 128 |
| 109 # Create the library output directories | 129 # Create the library output directories |
| 110 libdir = os.path.join(pepperdir, 'lib') | 130 libdir = os.path.join(pepperdir, 'lib') |
| 111 platform = getos.GetPlatform() | 131 platform = getos.GetPlatform() |
| 112 for config in configs: | 132 for config in configs: |
| 113 for arch in LIB_DICT[platform]: | 133 for arch in LIB_DICT[platform]: |
| 114 dirpath = os.path.join(libdir, '%s_%s_host' % (platform, arch), config) | 134 dirpath = os.path.join(libdir, '%s_%s_host' % (platform, arch), config) |
| 115 if clobber: | 135 if clobber: |
| 116 buildbot_common.RemoveDir(dirpath) | 136 buildbot_common.RemoveDir(dirpath) |
| 117 buildbot_common.MakeDir(dirpath) | 137 buildbot_common.MakeDir(dirpath) |
| 118 | 138 |
| 119 landing_page = None | 139 landing_page = None |
| 120 for branch, projects in project_tree.iteritems(): | 140 for branch, projects in project_tree.iteritems(): |
| 121 dirpath = os.path.join(pepperdir, branch) | 141 dirpath = os.path.join(pepperdir, branch) |
| 122 if clobber: | 142 if clobber: |
| 123 buildbot_common.RemoveDir(dirpath) | 143 buildbot_common.RemoveDir(dirpath) |
| 124 buildbot_common.MakeDir(dirpath) | 144 buildbot_common.MakeDir(dirpath) |
| 125 targets = [desc['NAME'] for desc in projects] | 145 targets = [desc['NAME'] for desc in projects] |
| 146 deps = GetDeps(projects) |
| 126 | 147 |
| 127 # Generate master make for this branch of projects | 148 # Generate master make for this branch of projects |
| 128 generate_make.GenerateMasterMakefile(pepperdir, | 149 generate_make.GenerateMasterMakefile(pepperdir, |
| 129 os.path.join(pepperdir, branch), | 150 os.path.join(pepperdir, branch), |
| 130 targets) | 151 targets, deps) |
| 131 | 152 |
| 132 if branch.startswith('examples') and not landing_page: | 153 if branch.startswith('examples') and not landing_page: |
| 133 landing_page = LandingPage() | 154 landing_page = LandingPage() |
| 134 | 155 |
| 135 # Generate individual projects | 156 # Generate individual projects |
| 136 for desc in projects: | 157 for desc in projects: |
| 137 srcroot = os.path.dirname(desc['FILEPATH']) | 158 srcroot = os.path.dirname(desc['FILEPATH']) |
| 138 generate_make.ProcessProject(pepperdir, srcroot, pepperdir, desc, | 159 generate_make.ProcessProject(pepperdir, srcroot, pepperdir, desc, |
| 139 toolchains, configs=configs, | 160 toolchains, configs=configs, |
| 140 first_toolchain=first_toolchain) | 161 first_toolchain=first_toolchain) |
| 141 | 162 |
| 142 if branch.startswith('examples'): | 163 if branch.startswith('examples'): |
| 143 landing_page.AddDesc(desc) | 164 landing_page.AddDesc(desc) |
| 144 | 165 |
| 145 if landing_page: | 166 if landing_page: |
| 146 # Generate the landing page text file. | 167 # Generate the landing page text file. |
| 147 index_html = os.path.join(pepperdir, 'examples', 'index.html') | 168 index_html = os.path.join(pepperdir, 'examples', 'index.html') |
| 148 index_template = os.path.join(SDK_RESOURCE_DIR, 'index.html.template') | 169 index_template = os.path.join(SDK_RESOURCE_DIR, 'index.html.template') |
| 149 with open(index_html, 'w') as fh: | 170 with open(index_html, 'w') as fh: |
| 150 out = landing_page.GeneratePage(index_template) | 171 out = landing_page.GeneratePage(index_template) |
| 151 fh.write(out) | 172 fh.write(out) |
| 152 | 173 |
| 153 # Generate top Make for examples | 174 # Generate top Make for examples |
| 154 targets = ['api', 'demo', 'getting_started', 'tutorial'] | 175 targets = ['api', 'demo', 'getting_started', 'tutorial'] |
| 155 targets = [x for x in targets if 'examples/'+x in project_tree] | 176 targets = [x for x in targets if 'examples/'+x in project_tree] |
| 156 branch_name = 'examples' | 177 branch_name = 'examples' |
| 157 generate_make.GenerateMasterMakefile(pepperdir, | 178 generate_make.GenerateMasterMakefile(pepperdir, |
| 158 os.path.join(pepperdir, branch_name), | 179 os.path.join(pepperdir, branch_name), |
| 159 targets) | 180 targets, {}) |
| 160 | 181 |
| 161 | 182 |
| 162 def BuildProjectsBranch(pepperdir, branch, deps, clean, config, args=None): | 183 def BuildProjectsBranch(pepperdir, branch, deps, clean, config, args=None): |
| 163 make_dir = os.path.join(pepperdir, branch) | 184 make_dir = os.path.join(pepperdir, branch) |
| 164 print "\nMake: " + make_dir | 185 print "\nMake: " + make_dir |
| 165 | 186 |
| 166 if getos.GetPlatform() == 'win': | 187 if getos.GetPlatform() == 'win': |
| 167 # We need to modify the environment to build host on Windows. | 188 # We need to modify the environment to build host on Windows. |
| 168 make = os.path.join(make_dir, 'make.bat') | 189 make = os.path.join(make_dir, 'make.bat') |
| 169 else: | 190 else: |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 335 |
| 315 | 336 |
| 316 if __name__ == '__main__': | 337 if __name__ == '__main__': |
| 317 script_name = os.path.basename(sys.argv[0]) | 338 script_name = os.path.basename(sys.argv[0]) |
| 318 try: | 339 try: |
| 319 sys.exit(main(sys.argv)) | 340 sys.exit(main(sys.argv)) |
| 320 except parse_dsc.ValidationError as e: | 341 except parse_dsc.ValidationError as e: |
| 321 buildbot_common.ErrorExit('%s: %s' % (script_name, e)) | 342 buildbot_common.ErrorExit('%s: %s' % (script_name, e)) |
| 322 except KeyboardInterrupt: | 343 except KeyboardInterrupt: |
| 323 buildbot_common.ErrorExit('%s: interrupted' % script_name) | 344 buildbot_common.ErrorExit('%s: interrupted' % script_name) |
| OLD | NEW |