| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import json | 5 import json |
| 6 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 | 8 |
| 9 import buildbot_common | 9 import buildbot_common |
| 10 import build_version | 10 import build_version |
| 11 import getos | 11 import getos |
| 12 from buildbot_common import ErrorExit | 12 from buildbot_common import ErrorExit |
| 13 from easy_template import RunTemplateFileIfChanged | 13 from easy_template import RunTemplateFileIfChanged |
| 14 from build_paths import SCRIPT_DIR, SDK_EXAMPLE_DIR | 14 from build_paths import SDK_RESOURCE_DIR |
| 15 | 15 |
| 16 def Trace(msg): | 16 def Trace(msg): |
| 17 if Trace.verbose: | 17 if Trace.verbose: |
| 18 sys.stderr.write(str(msg) + '\n') | 18 sys.stderr.write(str(msg) + '\n') |
| 19 Trace.verbose = False | 19 Trace.verbose = False |
| 20 | 20 |
| 21 | 21 |
| 22 def IsExample(desc): | 22 def IsExample(desc): |
| 23 dest = desc['DEST'] | 23 dest = desc['DEST'] |
| 24 return dest.startswith('examples') or dest.startswith('tests') | 24 return dest.startswith('examples') or dest.startswith('tests') |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 'title': desc['TITLE'], | 130 'title': desc['TITLE'], |
| 131 'attrs': | 131 'attrs': |
| 132 'data-name="%s" data-tools="%s" data-configs="%s" data-path="%s"' % ( | 132 'data-name="%s" data-tools="%s" data-configs="%s" data-path="%s"' % ( |
| 133 nmf, ' '.join(tools), ' '.join(configs), path), | 133 nmf, ' '.join(tools), ' '.join(configs), path), |
| 134 } | 134 } |
| 135 RunTemplateFileIfChanged(srcpath, dstpath, replace) | 135 RunTemplateFileIfChanged(srcpath, dstpath, replace) |
| 136 | 136 |
| 137 | 137 |
| 138 def GenerateManifest(srcroot, dstroot, desc): | 138 def GenerateManifest(srcroot, dstroot, desc): |
| 139 outdir = os.path.join(dstroot, desc['DEST'], desc['NAME']) | 139 outdir = os.path.join(dstroot, desc['DEST'], desc['NAME']) |
| 140 srcpath = os.path.join(SDK_EXAMPLE_DIR, 'resources', 'manifest.json.template') | 140 srcpath = os.path.join(SDK_RESOURCE_DIR, 'manifest.json.template') |
| 141 dstpath = os.path.join(outdir, 'manifest.json') | 141 dstpath = os.path.join(outdir, 'manifest.json') |
| 142 permissions = desc.get('PERMISSIONS', []) | 142 permissions = desc.get('PERMISSIONS', []) |
| 143 socket_permissions = desc.get('SOCKET_PERMISSIONS', []) | 143 socket_permissions = desc.get('SOCKET_PERMISSIONS', []) |
| 144 combined_permissions = list(permissions) | 144 combined_permissions = list(permissions) |
| 145 if socket_permissions: | 145 if socket_permissions: |
| 146 combined_permissions.append({'socket': socket_permissions}) | 146 combined_permissions.append({'socket': socket_permissions}) |
| 147 pretty_permissions = json.dumps(combined_permissions, | 147 pretty_permissions = json.dumps(combined_permissions, |
| 148 sort_keys=True, indent=4) | 148 sort_keys=True, indent=4) |
| 149 replace = { | 149 replace = { |
| 150 'name': desc['TITLE'], | 150 'name': desc['TITLE'], |
| (...skipping 24 matching lines...) Expand all Loading... |
| 175 | 175 |
| 176 | 176 |
| 177 def ProcessProject(pepperdir, srcroot, dstroot, desc, toolchains, configs=None, | 177 def ProcessProject(pepperdir, srcroot, dstroot, desc, toolchains, configs=None, |
| 178 first_toolchain=False): | 178 first_toolchain=False): |
| 179 if not configs: | 179 if not configs: |
| 180 configs = ['Debug', 'Release'] | 180 configs = ['Debug', 'Release'] |
| 181 | 181 |
| 182 name = desc['NAME'] | 182 name = desc['NAME'] |
| 183 out_dir = os.path.join(dstroot, desc['DEST'], name) | 183 out_dir = os.path.join(dstroot, desc['DEST'], name) |
| 184 buildbot_common.MakeDir(out_dir) | 184 buildbot_common.MakeDir(out_dir) |
| 185 srcdirs = desc.get('SEARCH', ['.', '..', '../..']) | 185 srcdirs = desc.get('SEARCH', ['.', SDK_RESOURCE_DIR]) |
| 186 srcdirs.append(os.path.join(SDK_EXAMPLE_DIR, 'resources')) | |
| 187 | 186 |
| 188 # Copy sources to example directory | 187 # Copy sources to example directory |
| 189 sources = GenerateSourceCopyList(desc) | 188 sources = GenerateSourceCopyList(desc) |
| 190 FindAndCopyFiles(sources, srcroot, srcdirs, out_dir) | 189 FindAndCopyFiles(sources, srcroot, srcdirs, out_dir) |
| 191 | 190 |
| 192 # Copy public headers to the include directory. | 191 # Copy public headers to the include directory. |
| 193 for headers_set in desc.get('HEADERS', []): | 192 for headers_set in desc.get('HEADERS', []): |
| 194 headers = headers_set['FILES'] | 193 headers = headers_set['FILES'] |
| 195 header_out_dir = os.path.join(dstroot, headers_set['DEST']) | 194 header_out_dir = os.path.join(dstroot, headers_set['DEST']) |
| 196 FindAndCopyFiles(headers, srcroot, srcdirs, header_out_dir) | 195 FindAndCopyFiles(headers, srcroot, srcdirs, header_out_dir) |
| 197 | 196 |
| 198 make_path = os.path.join(out_dir, 'Makefile') | 197 make_path = os.path.join(out_dir, 'Makefile') |
| 199 | 198 |
| 200 if IsNexe(desc): | 199 if IsNexe(desc): |
| 201 template = os.path.join(SCRIPT_DIR, 'template.mk') | 200 template = os.path.join(SDK_RESOURCE_DIR, 'Makefile.example.template') |
| 202 else: | 201 else: |
| 203 template = os.path.join(SCRIPT_DIR, 'library.mk') | 202 template = os.path.join(SDK_RESOURCE_DIR, 'Makefile.library.template') |
| 204 | 203 |
| 205 # Ensure the order of |tools| is the same as toolchains; that way if | 204 # Ensure the order of |tools| is the same as toolchains; that way if |
| 206 # first_toolchain is set, it will choose based on the order of |toolchains|. | 205 # first_toolchain is set, it will choose based on the order of |toolchains|. |
| 207 tools = [tool for tool in toolchains if tool in desc['TOOLS']] | 206 tools = [tool for tool in toolchains if tool in desc['TOOLS']] |
| 208 if first_toolchain: | 207 if first_toolchain: |
| 209 tools = [tools[0]] | 208 tools = [tools[0]] |
| 210 for target in desc['TARGETS']: | 209 for target in desc['TARGETS']: |
| 211 target.setdefault('CXXFLAGS', []) | 210 target.setdefault('CXXFLAGS', []) |
| 212 target['CXXFLAGS'].insert(0, '-Wall') | 211 target['CXXFLAGS'].insert(0, '-Wall') |
| 213 | 212 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 233 | 232 |
| 234 | 233 |
| 235 def GenerateMasterMakefile(pepperdir, out_path, targets): | 234 def GenerateMasterMakefile(pepperdir, out_path, targets): |
| 236 """Generate a Master Makefile that builds all examples. | 235 """Generate a Master Makefile that builds all examples. |
| 237 | 236 |
| 238 Args: | 237 Args: |
| 239 pepperdir: NACL_SDK_ROOT | 238 pepperdir: NACL_SDK_ROOT |
| 240 out_path: Root for output such that out_path+NAME = full path | 239 out_path: Root for output such that out_path+NAME = full path |
| 241 targets: List of targets names | 240 targets: List of targets names |
| 242 """ | 241 """ |
| 243 in_path = os.path.join(SDK_EXAMPLE_DIR, 'Makefile') | 242 in_path = os.path.join(SDK_RESOURCE_DIR, 'Makefile.index.template') |
| 244 out_path = os.path.join(out_path, 'Makefile') | 243 out_path = os.path.join(out_path, 'Makefile') |
| 245 rel_path = os.path.relpath(pepperdir, os.path.dirname(out_path)) | 244 rel_path = os.path.relpath(pepperdir, os.path.dirname(out_path)) |
| 246 template_dict = { | 245 template_dict = { |
| 247 'projects': targets, | 246 'projects': targets, |
| 248 'rel_sdk' : rel_path, | 247 'rel_sdk' : rel_path, |
| 249 } | 248 } |
| 250 RunTemplateFileIfChanged(in_path, out_path, template_dict) | 249 RunTemplateFileIfChanged(in_path, out_path, template_dict) |
| 251 outdir = os.path.dirname(os.path.abspath(out_path)) | 250 outdir = os.path.dirname(os.path.abspath(out_path)) |
| 252 if getos.GetPlatform() == 'win': | 251 if getos.GetPlatform() == 'win': |
| 253 AddMakeBat(pepperdir, outdir) | 252 AddMakeBat(pepperdir, outdir) |
| OLD | NEW |