def InstallHeaders(tc_dst_inc, pepper_ver, tc_name): """Copies NaCl headers to expected locations in the toolchain.""" if tc_name == 'arm': # arm toolchain header should be the same as the x86 newlib # ones tc_name = 'newlib' tc_map = HEADER_MAP[tc_name] for filename in tc_map: src = os.path.join(NACL_DIR, tc_map[filename]) dst = os.path.join(tc_dst_inc, filename) buildbot_common.MakeDir(os.path.dirname(dst)) buildbot_common.CopyFile(src, dst) # Clean out per toolchain ppapi directory ppapi = os.path.join(tc_dst_inc, 'ppapi') buildbot_common.RemoveDir(ppapi) # Copy in c and c/dev headers buildbot_common.MakeDir(os.path.join(ppapi, 'c', 'dev')) buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'c', '*.h'), os.path.join(ppapi, 'c')) buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'c', 'dev', '*.h'), os.path.join(ppapi, 'c', 'dev')) # Run the generator to overwrite IDL files generator_args = [ sys.executable, 'generator.py', '--wnone', '--cgen', '--verbose', '--dstroot=%s/c' % ppapi ] if pepper_ver: generator_args.append('--release=M' + pepper_ver) buildbot_common.Run(generator_args, cwd=os.path.join(PPAPI_DIR, 'generators')) # Remove private and trusted interfaces buildbot_common.RemoveDir(os.path.join(ppapi, 'c', 'private')) buildbot_common.RemoveDir(os.path.join(ppapi, 'c', 'trusted')) # Copy in the C++ headers buildbot_common.MakeDir(os.path.join(ppapi, 'cpp', 'dev')) buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'cpp', '*.h'), os.path.join(ppapi, 'cpp')) buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'cpp', 'dev', '*.h'), os.path.join(ppapi, 'cpp', 'dev')) buildbot_common.MakeDir(os.path.join(ppapi, 'utility', 'graphics')) buildbot_common.MakeDir(os.path.join(ppapi, 'utility', 'threading')) buildbot_common.MakeDir(os.path.join(ppapi, 'utility', 'websocket')) buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'utility', '*.h'), os.path.join(ppapi, 'utility')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'utility', 'graphics', '*.h'), os.path.join(ppapi, 'utility', 'graphics')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'utility', 'threading', '*.h'), os.path.join(ppapi, 'utility', 'threading')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'utility', 'websocket', '*.h'), os.path.join(ppapi, 'utility', 'websocket')) # Copy in the gles2 headers buildbot_common.MakeDir(os.path.join(ppapi, 'gles2')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'lib', 'gl', 'gles2', '*.h'), os.path.join(ppapi, 'gles2')) # Copy the EGL headers buildbot_common.MakeDir(os.path.join(tc_dst_inc, 'EGL')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'lib', 'gl', 'include', 'EGL', '*.h'), os.path.join(tc_dst_inc, 'EGL')) # Copy the GLES2 headers buildbot_common.MakeDir(os.path.join(tc_dst_inc, 'GLES2')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'lib', 'gl', 'include', 'GLES2', '*.h'), os.path.join(tc_dst_inc, 'GLES2')) # Copy the KHR headers buildbot_common.MakeDir(os.path.join(tc_dst_inc, 'KHR')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'lib', 'gl', 'include', 'KHR', '*.h'), os.path.join(tc_dst_inc, 'KHR')) # Copy the lib files buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'lib'), os.path.join(tc_dst_inc, 'ppapi'))
def GypNinjaInstall(pepperdir, platform, toolchains): build_dir = 'gypbuild' ninja_out_dir = os.path.join(OUT_DIR, build_dir, 'Release') # src_file, dst_file, is_host_exe? tools_files = [ ('sel_ldr', 'sel_ldr_x86_32', True), ('ncval_x86_32', 'ncval_x86_32', True), ('ncval_arm', 'ncval_arm', True), ('irt_core_newlib_x32.nexe', 'irt_core_newlib_x32.nexe', False), ('irt_core_newlib_x64.nexe', 'irt_core_newlib_x64.nexe', False), ] if platform != 'mac': # Mac doesn't build 64-bit binaries. tools_files.append(('sel_ldr64', 'sel_ldr_x86_64', True)) tools_files.append(('ncval_x86_64', 'ncval_x86_64', True)) if platform == 'linux': tools_files.append( ('nacl_helper_bootstrap', 'nacl_helper_bootstrap_x86_32', True)) tools_files.append( ('nacl_helper_bootstrap64', 'nacl_helper_bootstrap_x86_64', True)) buildbot_common.MakeDir(os.path.join(pepperdir, 'tools')) for src, dst, host_exe in tools_files: if platform == 'win' and host_exe: src += '.exe' dst += '.exe' buildbot_common.CopyFile(os.path.join(ninja_out_dir, src), os.path.join(pepperdir, 'tools', dst)) for tc in set(toolchains) & set(['newlib', 'glibc']): for archname in ('arm', '32', '64'): if tc == 'glibc' and archname == 'arm': continue tc_dir = 'tc_' + tc lib_dir = 'lib' + archname if archname == 'arm': build_dir = 'gypbuild-arm' tcdir = '%s_arm_%s' % (platform, tc) else: build_dir = 'gypbuild' tcdir = '%s_x86_%s' % (platform, tc) ninja_out_dir = os.path.join(OUT_DIR, build_dir, 'Release') src_dir = os.path.join(ninja_out_dir, 'gen', tc_dir, lib_dir) tcpath = os.path.join(pepperdir, 'toolchain', tcdir) dst_dir = GetToolchainNaClLib(tc, tcpath, 'x86', archname) buildbot_common.MakeDir(dst_dir) buildbot_common.CopyDir(os.path.join(src_dir, '*.a'), dst_dir) if tc == 'newlib': buildbot_common.CopyDir(os.path.join(src_dir, '*.o'), dst_dir) if tc == 'glibc': buildbot_common.CopyDir(os.path.join(src_dir, '*.so'), dst_dir) ninja_tcpath = os.path.join(ninja_out_dir, 'gen', 'sdk', 'toolchain', tcdir) lib_dir = GetToolchainNaClLib(tc, ninja_tcpath, 'x86', archname) buildbot_common.CopyFile(os.path.join(lib_dir, 'crt1.o'), dst_dir)
def main(args): parser = optparse.OptionParser() parser.add_option('-c', '--channel', help='Channel to display in the name of the package.') # To setup bash completion for this command first install optcomplete # and then add this line to your .bashrc: # complete -F _optcomplete build_app.py try: import optcomplete optcomplete.autocomplete(parser) except ImportError: pass options, args = parser.parse_args(args[1:]) if options.channel: if options.channel not in ('Dev', 'Beta'): parser.error('Unknown channel: %s' % options.channel) toolchains = ['newlib', 'glibc'] pepper_ver = str(int(build_version.ChromeMajorVersion())) pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) app_dir = os.path.join(OUT_DIR, 'naclsdk_app') app_examples_dir = os.path.join(app_dir, 'examples') sdk_resources_dir = SDK_RESOURCE_DIR platform = getos.GetPlatform() buildbot_common.RemoveDir(app_dir) buildbot_common.MakeDir(app_dir) # Add some dummy directories so build_projects doesn't complain... buildbot_common.MakeDir(os.path.join(app_dir, 'tools')) buildbot_common.MakeDir(os.path.join(app_dir, 'toolchain')) config = 'Release' filters = {} filters['DISABLE_PACKAGE'] = False filters['EXPERIMENTAL'] = False filters['TOOLS'] = toolchains filters['DEST'] = [ 'examples/api', 'examples/getting_started', 'examples/demo', 'examples/tutorial' ] tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters) build_projects.UpdateHelpers(app_dir, clobber=True) build_projects.UpdateProjects(app_dir, tree, clobber=False, toolchains=toolchains, configs=[config], first_toolchain=True) # Collect permissions from each example, and aggregate them. def MergeLists(list1, list2): return list1 + [x for x in list2 if x not in list1] all_permissions = [] all_socket_permissions = [] for _, project in parse_dsc.GenerateProjects(tree): permissions = project.get('PERMISSIONS', []) all_permissions = MergeLists(all_permissions, permissions) socket_permissions = project.get('SOCKET_PERMISSIONS', []) all_socket_permissions = MergeLists(all_socket_permissions, socket_permissions) if all_socket_permissions: all_permissions.append({'socket': all_socket_permissions}) pretty_permissions = json.dumps(all_permissions, sort_keys=True, indent=4) for filename in ['background.js', 'icon128.png']: buildbot_common.CopyFile(os.path.join(sdk_resources_dir, filename), os.path.join(app_examples_dir, filename)) os.environ['NACL_SDK_ROOT'] = pepperdir build_projects.BuildProjects(app_dir, tree, deps=False, clean=False, config=config) RemoveBuildCruft(app_dir) StripNexes(app_dir, platform, pepperdir) # Add manifest.json after RemoveBuildCruft... that function removes the # manifest.json files for the individual examples. name = 'Native Client SDK' if options.channel: name += ' (%s)' % options.channel template_dict = { 'name': name, 'channel': options.channel, 'description': 'Native Client SDK examples, showing API use and key concepts.', 'key': False, # manifests with "key" are rejected when uploading to CWS. 'permissions': pretty_permissions, 'version': build_version.ChromeVersionNoTrunk() } easy_template.RunTemplateFile( os.path.join(sdk_resources_dir, 'manifest.json.template'), os.path.join(app_examples_dir, 'manifest.json'), template_dict) app_zip = os.path.join(app_dir, 'examples.zip') os.chdir(app_examples_dir) oshelpers.Zip([app_zip, '-r', '*']) return 0
def BuildStepUntarToolchains(pepperdir, platform, arch, toolchains): buildbot_common.BuildStep('Untar Toolchains') tcname = platform + '_' + arch tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') buildbot_common.RemoveDir(tmpdir) buildbot_common.MakeDir(tmpdir) if 'newlib' in toolchains: # Untar the newlib toolchains tarfile = GetNewlibToolchain(platform, arch) buildbot_common.Run( [sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) # Then rename/move it to the pepper toolchain directory srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk') newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') buildbot_common.Move(srcdir, newlibdir) if 'arm' in toolchains: # Copy the existing arm toolchain from native_client tree arm_toolchain = os.path.join(NACL_DIR, 'toolchain', platform + '_arm_newlib') arm_toolchain_sdk = os.path.join(pepperdir, 'toolchain', os.path.basename(arm_toolchain)) buildbot_common.CopyDir(arm_toolchain, arm_toolchain_sdk) if 'glibc' in toolchains: # Untar the glibc toolchains tarfile = GetGlibcToolchain(platform, arch) buildbot_common.Run( [sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) # Then rename/move it to the pepper toolchain directory srcdir = os.path.join(tmpdir, 'toolchain', tcname) glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') buildbot_common.Move(srcdir, glibcdir) # Untar the pnacl toolchains if 'pnacl' in toolchains: tmpdir = os.path.join(tmpdir, 'pnacl') buildbot_common.RemoveDir(tmpdir) buildbot_common.MakeDir(tmpdir) tarfile = GetPNaClToolchain(platform, arch) buildbot_common.Run( [sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) # Then rename/move it to the pepper toolchain directory pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl') buildbot_common.Move(tmpdir, pnacldir) if options.gyp and sys.platform not in ['cygwin', 'win32']: # If the gyp options is specified we install a toolchain # wrapper so that gyp can switch toolchains via a commandline # option. bindir = os.path.join(pepperdir, 'toolchain', tcname, 'bin') wrapper = os.path.join(SDK_SRC_DIR, 'tools', 'compiler-wrapper.py') buildbot_common.MakeDir(bindir) buildbot_common.CopyFile(wrapper, bindir) # Module 'os' has no 'symlink' member (on Windows). # pylint: disable=E1101 os.symlink('compiler-wrapper.py', os.path.join(bindir, 'i686-nacl-g++')) os.symlink('compiler-wrapper.py', os.path.join(bindir, 'i686-nacl-gcc')) os.symlink('compiler-wrapper.py', os.path.join(bindir, 'i686-nacl-ar'))
def BuildStepCleanPepperDirs(pepperdir, pepperdir_old): buildbot_common.BuildStep('Clean Pepper Dirs') buildbot_common.RemoveDir(pepperdir_old) buildbot_common.RemoveDir(pepperdir) buildbot_common.MakeDir(pepperdir)
def main(args): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--nacl-tree-path', help='Path to native client tree for bionic build.', dest='nacl_tree_path') parser.add_argument('--qemu', help='Add qemu for ARM.', action='store_true') parser.add_argument('--bionic', help='Add bionic build.', action='store_true') parser.add_argument('--tar', help='Force the tar step.', action='store_true') parser.add_argument('--archive', help='Force the archive step.', action='store_true') parser.add_argument('--release', help='PPAPI release version.', dest='release', default=None) parser.add_argument('--build-ports', help='Build naclport bundle.', action='store_true') parser.add_argument('--build-app-engine', help='Build AppEngine demos.', action='store_true') parser.add_argument('--experimental', help='build experimental examples and libraries', action='store_true', dest='build_experimental') parser.add_argument('--skip-toolchain', help='Skip toolchain untar', action='store_true') parser.add_argument('--no-clean', dest='clean', action='store_false', help="Don't clean gypbuild directories") parser.add_argument( '--mac-sdk', help='Set the mac-sdk (e.g. 10.6) to use when building with ninja.') parser.add_argument( '--no-arm-trusted', action='store_true', help='Disable building of ARM trusted components (sel_ldr, etc).') # To setup bash completion for this command first install optcomplete # and then add this line to your .bashrc: # complete -F _optcomplete build_sdk.py try: import optcomplete optcomplete.autocomplete(parser) except ImportError: pass global options options = parser.parse_args(args) buildbot_common.BuildStep('build_sdk') if options.nacl_tree_path: options.bionic = True toolchain_build = os.path.join(options.nacl_tree_path, 'toolchain_build') print 'WARNING: Building bionic toolchain from NaCl checkout.' print 'This option builds bionic from the sources currently in the' print 'provided NativeClient checkout, and the results instead of ' print 'downloading a toolchain from the builder. This may result in a' print 'NaCl SDK that can not run on ToT chrome.' print 'NOTE: To clobber you will need to run toolchain_build_bionic.py' print 'directly from the NativeClient checkout.' print '' response = raw_input("Type 'y' and hit enter to continue.\n") if response != 'y' and response != 'Y': print 'Aborting.' return 1 # Get head version of NativeClient tree buildbot_common.BuildStep('Build bionic toolchain.') buildbot_common.Run( [sys.executable, 'toolchain_build_bionic.py', '-f'], cwd=toolchain_build) else: toolchain_build = None if buildbot_common.IsSDKBuilder(): options.archive = True options.build_ports = True # TODO(binji): re-enable app_engine build when the linux builder stops # breaking when trying to git clone from github. # See http://crbug.com/412969. options.build_app_engine = False options.tar = True # NOTE: order matters here. This will be the order that is specified in the # Makefiles; the first toolchain will be the default. toolchains = ['pnacl', 'newlib', 'glibc', 'arm', 'clang-newlib', 'host'] # Changes for experimental bionic builder if options.bionic: toolchains.append('bionic') options.build_ports = False options.build_app_engine = False print 'Building: ' + ' '.join(toolchains) platform = getos.GetPlatform() if options.archive and not options.tar: parser.error('Incompatible arguments with archive.') chrome_version = int(build_version.ChromeMajorVersion()) chrome_revision = build_version.ChromeRevision() nacl_revision = build_version.NaClRevision() pepper_ver = str(chrome_version) pepper_old = str(chrome_version - 1) pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) pepperdir_old = os.path.join(OUT_DIR, 'pepper_' + pepper_old) if options.bionic: tarname = 'naclsdk_bionic.tar.bz2' else: tarname = 'naclsdk_%s.tar.bz2' % platform tarfile = os.path.join(OUT_DIR, tarname) if options.release: pepper_ver = options.release print 'Building PEPPER %s at %s' % (pepper_ver, chrome_revision) if 'NACL_SDK_ROOT' in os.environ: # We don't want the currently configured NACL_SDK_ROOT to have any effect # of the build. del os.environ['NACL_SDK_ROOT'] if platform == 'linux': # Linux-only: make sure the debian/stable sysroot image is installed install_script = os.path.join(SRC_DIR, 'chrome', 'installer', 'linux', 'sysroot_scripts', 'install-debian.wheezy.sysroot.py') buildbot_common.Run([sys.executable, install_script, '--arch=arm']) buildbot_common.Run([sys.executable, install_script, '--arch=i386']) buildbot_common.Run([sys.executable, install_script, '--arch=amd64']) if not options.skip_toolchain: BuildStepCleanPepperDirs(pepperdir, pepperdir_old) BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools']) BuildStepDownloadToolchains(toolchains) if options.nacl_tree_path: # Instead of untarring, copy the raw bionic toolchain not_bionic = [i for i in toolchains if i != 'bionic'] BuildStepUntarToolchains(pepperdir, not_bionic) tcname = GetToolchainDirName('bionic', 'arm') srcdir = os.path.join(toolchain_build, 'out', tcname) bionicdir = os.path.join(pepperdir, 'toolchain', tcname) oshelpers.Copy(['-r', srcdir, bionicdir]) else: BuildStepUntarToolchains(pepperdir, toolchains) if platform == 'linux': buildbot_common.Move( os.path.join(pepperdir, 'toolchain', 'arm_trusted'), os.path.join(OUT_DIR, 'arm_trusted')) if platform == 'linux': # Linux-only: Copy arm libraries from the arm_trusted package. These are # needed to be able to run sel_ldr_arm under qemu. arm_libs = [ 'lib/arm-linux-gnueabihf/librt.so.1', 'lib/arm-linux-gnueabihf/libpthread.so.0', 'lib/arm-linux-gnueabihf/libgcc_s.so.1', 'lib/arm-linux-gnueabihf/libc.so.6', 'lib/arm-linux-gnueabihf/ld-linux-armhf.so.3', 'lib/arm-linux-gnueabihf/libm.so.6', 'usr/lib/arm-linux-gnueabihf/libstdc++.so.6' ] arm_lib_dir = os.path.join(pepperdir, 'tools', 'lib', 'arm_trusted', 'lib') buildbot_common.MakeDir(arm_lib_dir) for arm_lib in arm_libs: arm_lib = os.path.join(OUT_DIR, 'arm_trusted', arm_lib) buildbot_common.CopyFile(arm_lib, arm_lib_dir) buildbot_common.CopyFile( os.path.join(OUT_DIR, 'arm_trusted', 'qemu-arm'), os.path.join(pepperdir, 'tools')) BuildStepBuildToolchains(pepperdir, toolchains, not options.skip_toolchain, options.clean) BuildStepUpdateHelpers(pepperdir, True) BuildStepUpdateUserProjects(pepperdir, toolchains, options.build_experimental, True) BuildStepCopyTextFiles(pepperdir, pepper_ver, chrome_revision, nacl_revision) # Ship with libraries prebuilt, so run that first. BuildStepBuildLibraries(pepperdir, 'src') GenerateNotice(pepperdir) # Verify the SDK contains what we expect. if not options.bionic: BuildStepVerifyFilelist(pepperdir) if options.tar: BuildStepTarBundle(pepper_ver, tarfile) if platform == 'linux': BuildStepBuildPNaClComponent(pepper_ver, chrome_revision) if options.build_ports: ports_tarfile = os.path.join(OUT_DIR, 'naclports.tar.bz2') BuildStepSyncNaClPorts() BuildStepBuildNaClPorts(pepper_ver, pepperdir) if options.tar: BuildStepTarNaClPorts(pepper_ver, ports_tarfile) if options.build_app_engine and platform == 'linux': BuildStepBuildAppEngine(pepperdir, chrome_revision) if options.qemu: qemudir = os.path.join(NACL_DIR, 'toolchain', 'linux_arm-trusted') oshelpers.Copy(['-r', qemudir, pepperdir]) # Archive the results on Google Cloud Storage. if options.archive: BuildStepArchiveBundle('build', pepper_ver, chrome_revision, nacl_revision, tarfile) # Only archive sdk_tools/naclport/pnacl_component on linux. if platform == 'linux': if options.build_ports: BuildStepArchiveBundle('naclports', pepper_ver, chrome_revision, nacl_revision, ports_tarfile) BuildStepArchiveSDKTools() BuildStepArchivePNaClComponent() return 0
def _MakeDirname(self): if os.path.exists(self.dirname): buildbot_common.RemoveDir(self.dirname) buildbot_common.MakeDir(self.dirname)
def BuildStepTarBundle(pepper_ver, tarfile): buildbot_common.BuildStep('Tar Pepper Bundle') buildbot_common.MakeDir(os.path.dirname(tarfile)) buildbot_common.Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile, 'pepper_' + pepper_ver], cwd=NACL_DIR)
def InstallCommonHeaders(inc_path): # Clean out per toolchain ppapi directory ppapi = os.path.join(inc_path, 'ppapi') buildbot_common.RemoveDir(ppapi) # Copy in c, c/dev and c/extensions/dev headers buildbot_common.MakeDir(os.path.join(ppapi, 'c', 'dev')) buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'c', '*.h'), os.path.join(ppapi, 'c')) buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'c', 'dev', '*.h'), os.path.join(ppapi, 'c', 'dev')) buildbot_common.MakeDir(os.path.join(ppapi, 'c', 'extensions', 'dev')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'c', 'extensions', 'dev', '*.h'), os.path.join(ppapi, 'c', 'extensions', 'dev')) # Remove private and trusted interfaces buildbot_common.RemoveDir(os.path.join(ppapi, 'c', 'private')) buildbot_common.RemoveDir(os.path.join(ppapi, 'c', 'trusted')) # Copy in the C++ headers buildbot_common.MakeDir(os.path.join(ppapi, 'cpp', 'dev')) buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'cpp', '*.h'), os.path.join(ppapi, 'cpp')) buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'cpp', 'dev', '*.h'), os.path.join(ppapi, 'cpp', 'dev')) buildbot_common.MakeDir(os.path.join(ppapi, 'cpp', 'extensions', 'dev')) buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'cpp', 'extensions', '*.h'), os.path.join(ppapi, 'cpp', 'extensions')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'cpp', 'extensions', 'dev', '*.h'), os.path.join(ppapi, 'cpp', 'extensions', 'dev')) buildbot_common.MakeDir(os.path.join(ppapi, 'utility', 'graphics')) buildbot_common.MakeDir(os.path.join(ppapi, 'utility', 'threading')) buildbot_common.MakeDir(os.path.join(ppapi, 'utility', 'websocket')) buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'utility', '*.h'), os.path.join(ppapi, 'utility')) buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'utility', 'graphics', '*.h'), os.path.join(ppapi, 'utility', 'graphics')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'utility', 'threading', '*.h'), os.path.join(ppapi, 'utility', 'threading')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'utility', 'websocket', '*.h'), os.path.join(ppapi, 'utility', 'websocket')) # Copy in the gles2 headers buildbot_common.MakeDir(os.path.join(ppapi, 'gles2')) buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'lib', 'gl', 'gles2', '*.h'), os.path.join(ppapi, 'gles2')) # Copy the EGL headers buildbot_common.MakeDir(os.path.join(inc_path, 'EGL')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'lib', 'gl', 'include', 'EGL', '*.h'), os.path.join(inc_path, 'EGL')) # Copy the GLES2 headers buildbot_common.MakeDir(os.path.join(inc_path, 'GLES2')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'lib', 'gl', 'include', 'GLES2', '*.h'), os.path.join(inc_path, 'GLES2')) # Copy the KHR headers buildbot_common.MakeDir(os.path.join(inc_path, 'KHR')) buildbot_common.CopyDir( os.path.join(PPAPI_DIR, 'lib', 'gl', 'include', 'KHR', '*.h'), os.path.join(inc_path, 'KHR')) # Copy the lib files buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'lib'), os.path.join(inc_path, 'ppapi'))
def ProcessProject(pepperdir, srcroot, dstroot, desc, toolchains, configs=None, first_toolchain=False): if not configs: configs = ['Debug', 'Release'] name = desc['NAME'] out_dir = os.path.join(dstroot, desc['DEST'], name) buildbot_common.MakeDir(out_dir) srcdirs = desc.get('SEARCH', ['.', SDK_RESOURCE_DIR]) # Copy sources to example directory sources = GenerateSourceCopyList(desc) FindAndCopyFiles(sources, srcroot, srcdirs, out_dir) # Copy public headers to the include directory. for headers_set in desc.get('HEADERS', []): headers = headers_set['FILES'] header_out_dir = os.path.join(dstroot, headers_set['DEST']) FindAndCopyFiles(headers, srcroot, srcdirs, header_out_dir) make_path = os.path.join(out_dir, 'Makefile') outdir = os.path.dirname(os.path.abspath(make_path)) if getos.GetPlatform() == 'win': AddMakeBat(pepperdir, outdir) # If this project has no TARGETS, then we don't need to generate anything. if 'TARGETS' not in desc: return (name, desc['DEST']) if IsNexe(desc): template = os.path.join(SDK_RESOURCE_DIR, 'Makefile.example.template') else: template = os.path.join(SDK_RESOURCE_DIR, 'Makefile.library.template') # Ensure the order of |tools| is the same as toolchains; that way if # first_toolchain is set, it will choose based on the order of |toolchains|. tools = [tool for tool in toolchains if tool in desc['TOOLS']] if first_toolchain: tools = [tools[0]] for target in desc['TARGETS']: target.setdefault('CXXFLAGS', []) target['CXXFLAGS'].insert(0, '-Wall') template_dict = { 'desc': desc, 'rel_sdk': '/'.join(['..'] * (len(desc['DEST'].split('/')) + 1)), 'pre': desc.get('PRE', ''), 'post': desc.get('POST', ''), 'tools': tools, 'targets': desc['TARGETS'], } RunTemplateFileIfChanged(template, make_path, template_dict) if IsExample(desc): ProcessHTML(srcroot, dstroot, desc, toolchains, configs, first_toolchain) if not desc.get('NO_PACKAGE_FILES'): GenerateManifest(srcroot, dstroot, desc) return (name, desc['DEST'])
def GypNinjaInstall(pepperdir, toolchains): build_dir = GYPBUILD_DIR ninja_out_dir = os.path.join(OUT_DIR, build_dir, 'Release') tools_files = [ ['sel_ldr', 'sel_ldr_x86_32'], ['ncval_new', 'ncval'], ['irt_core_newlib_x32.nexe', 'irt_core_x86_32.nexe'], ['irt_core_newlib_x64.nexe', 'irt_core_x86_64.nexe'], ] platform = getos.GetPlatform() # TODO(binji): dump_syms doesn't currently build on Windows. See # http://crbug.com/245456 if platform != 'win': tools_files += [['dump_syms', 'dump_syms'], ['minidump_dump', 'minidump_dump'], ['minidump_stackwalk', 'minidump_stackwalk']] tools_files.append(['sel_ldr64', 'sel_ldr_x86_64']) if platform == 'linux': tools_files.append( ['nacl_helper_bootstrap', 'nacl_helper_bootstrap_x86_32']) tools_files.append( ['nacl_helper_bootstrap64', 'nacl_helper_bootstrap_x86_64']) tools_files.append( ['nonsfi_loader_newlib_x32_nonsfi.nexe', 'nonsfi_loader_x86_32']) buildbot_common.MakeDir(os.path.join(pepperdir, 'tools')) # Add .exe extensions to all windows tools for pair in tools_files: if platform == 'win' and not pair[0].endswith('.nexe'): pair[0] += '.exe' pair[1] += '.exe' InstallFiles(ninja_out_dir, os.path.join(pepperdir, 'tools'), tools_files) # Add ARM binaries if platform == 'linux' and not options.no_arm_trusted: tools_files = [['irt_core_newlib_arm.nexe', 'irt_core_arm.nexe'], ['irt_core_newlib_arm.nexe', 'irt_core_arm.nexe'], ['nacl_helper_bootstrap', 'nacl_helper_bootstrap_arm'], [ 'nonsfi_loader_newlib_arm_nonsfi.nexe', 'nonsfi_loader_arm' ], ['sel_ldr', 'sel_ldr_arm']] ninja_out_dir = os.path.join(OUT_DIR, build_dir + '-arm', 'Release') InstallFiles(ninja_out_dir, os.path.join(pepperdir, 'tools'), tools_files) for tc in set(toolchains) & set(['newlib', 'glibc', 'pnacl']): if tc == 'pnacl': xarches = (None, ) else: xarches = ('arm', '32', '64') for xarch in xarches: if tc == 'glibc' and xarch == 'arm': continue src_dir = GetGypBuiltLib(tc, xarch) dst_dir = GetOutputToolchainLib(pepperdir, tc, xarch) InstallFiles(src_dir, dst_dir, TOOLCHAIN_LIBS[tc]) # Copy ARM newlib components to bionic if tc == 'newlib' and xarch == 'arm' and 'bionic' in toolchains: bionic_dir = GetOutputToolchainLib(pepperdir, 'bionic', xarch) InstallFiles(src_dir, bionic_dir, TOOLCHAIN_LIBS['bionic']) if tc != 'pnacl': src_dir = GetGypToolchainLib(tc, xarch) InstallFiles(src_dir, dst_dir, ['crt1.o'])
def ProcessProject(srcroot, dstroot, desc, toolchains): name = desc['NAME'] out_dir = os.path.join(dstroot, desc['DEST'], name) buildbot_common.MakeDir(out_dir) srcdirs = desc.get('SEARCH', ['.', '..']) # Copy sources to example directory sources = GenerateSourceCopyList(desc) FindAndCopyFiles(sources, srcroot, srcdirs, out_dir) # Copy public headers to the include directory. for headers_set in desc.get('HEADERS', []): headers = headers_set['FILES'] header_out_dir = os.path.join(dstroot, headers_set['DEST']) FindAndCopyFiles(headers, srcroot, srcdirs, header_out_dir) make_path = os.path.join(out_dir, 'Makefile') if use_gyp: # Process the dsc file to produce gyp input dsc = desc['FILENAME'] dsc2gyp = os.path.join(SDK_SRC_DIR, 'build_tools/dsc2gyp.py') gypfile = os.path.join(OUT_DIR, 'tmp', name, name + '.gyp') buildbot_common.Run([sys.executable, dsc2gyp, dsc, '-o', gypfile], cwd=out_dir) # Run gyp on the generated gyp file if sys.platform == 'win32': generator = 'msvs' else: generator = os.path.join(SCRIPT_DIR, "make_simple.py") gyp = os.path.join(SDK_SRC_DIR, '..', '..', 'tools', 'gyp', 'gyp') if sys.platform == 'win32': gyp += '.bat' buildbot_common.Run([gyp, '-Gstandalone', '--format', generator, '--toplevel-dir=.', gypfile], cwd=out_dir) if sys.platform == 'win32' or not use_gyp: if IsNexe(desc): template = os.path.join(SCRIPT_DIR, 'template.mk') else: template = os.path.join(SCRIPT_DIR, 'library.mk') tools = {} tool_list = [] for tool in desc['TOOLS']: if ':' in tool: tool, arch = tool.split(':') else: arch = None # Ignore tools that are not enabled in this SDK build if tool not in toolchains: continue tools.setdefault(tool, []) if tool not in tool_list: tool_list.append(tool) if arch: tools[tool].append(arch) desc['TOOLS'] = tool_list # Add Makefile and make.bat repdict = GenerateReplacements(desc, tools) if not 'Makefile' in desc.get('DATA', []): WriteReplaced(template, make_path, repdict) outdir = os.path.dirname(os.path.abspath(make_path)) pepperdir = os.path.dirname(os.path.dirname(outdir)) AddMakeBat(pepperdir, outdir) return (name, desc['DEST'])
def GypNinjaInstall(pepperdir, platform, toolchains): build_dir = GYPBUILD_DIR ninja_out_dir = os.path.join(OUT_DIR, build_dir, 'Release') tools_files = [ ['sel_ldr', 'sel_ldr_x86_32'], ['ncval_new', 'ncval'], ['irt_core_newlib_x32.nexe', 'irt_core_x86_32.nexe'], ['irt_core_newlib_x64.nexe', 'irt_core_x86_64.nexe'], ] if sys.platform not in ['cygwin', 'win32']: minidump_files = [['dump_syms', 'dump_syms'], ['minidump_dump', 'minidump_dump'], ['minidump_stackwalk', 'minidump_stackwalk']] tools_files.extend(minidump_files) # TODO(binji): dump_syms doesn't currently build on Windows. See # http://crbug.com/245456 if platform != 'win': tools_files.append(['dump_syms', 'dump_syms']) if platform != 'mac': # Mac doesn't build 64-bit binaries. tools_files.append(['sel_ldr64', 'sel_ldr_x86_64']) if platform == 'linux': tools_files.append( ['nacl_helper_bootstrap', 'nacl_helper_bootstrap_x86_32']) tools_files.append( ['nacl_helper_bootstrap64', 'nacl_helper_bootstrap_x86_64']) buildbot_common.MakeDir(os.path.join(pepperdir, 'tools')) # Add .exe extensions to all windows tools for pair in tools_files: if platform == 'win' and not pair[0].endswith('.nexe'): pair[0] += '.exe' pair[1] += '.exe' InstallFiles(ninja_out_dir, os.path.join(pepperdir, 'tools'), tools_files) for tc in set(toolchains) & set(['newlib', 'glibc']): for archname in ('arm', '32', '64'): if tc == 'glibc' and archname == 'arm': continue tc_dir = 'tc_' + tc lib_dir = 'lib' + archname if archname == 'arm': build_dir = GYPBUILD_DIR + '-arm' tcdir = '%s_arm_%s' % (platform, tc) else: build_dir = GYPBUILD_DIR tcdir = '%s_x86_%s' % (platform, tc) ninja_out_dir = os.path.join(OUT_DIR, build_dir, 'Release') src_dir = os.path.join(ninja_out_dir, 'gen', tc_dir, lib_dir) tcpath = os.path.join(pepperdir, 'toolchain', tcdir) dst_dir = GetToolchainNaClLib(tc, tcpath, 'x86', archname) InstallFiles(src_dir, dst_dir, TOOLCHAIN_LIBS[tc]) ninja_tcpath = os.path.join(ninja_out_dir, 'gen', 'sdk', 'toolchain', tcdir) lib_dir = GetToolchainNaClLib(tc, ninja_tcpath, 'x86', archname) buildbot_common.CopyFile(os.path.join(lib_dir, 'crt1.o'), dst_dir)
def main(args): parser = optparse.OptionParser() parser.add_option('--arch', help='Target architecture', dest='arch', default='x86-32') parser.add_option('--sdk-revision', help='SDK Revision' ' (default=buildbot revision)', dest='sdk_revision', default=None) parser.add_option('--sdk-url', help='SDK Download URL', dest='sdk_url', default=None) parser.add_option('--install-dir', help='Install Directory', dest='install_dir', default='naclmono') (options, args) = parser.parse_args(args[1:]) assert sys.platform.find('linux') != -1 buildbot_revision = os.environ.get('BUILDBOT_REVISION', '') build_prefix = options.arch + ' ' buildbot_common.BuildStep(build_prefix + 'Clean Old SDK') buildbot_common.MakeDir(MONO_BUILD_DIR) buildbot_common.RemoveDir(os.path.join(MONO_BUILD_DIR, 'pepper_*')) buildbot_common.BuildStep(build_prefix + 'Setup New SDK') sdk_dir = None sdk_revision = options.sdk_revision sdk_url = options.sdk_url if not sdk_url: if not sdk_revision: assert buildbot_revision sdk_revision = buildbot_revision.split(':')[0] sdk_url = 'gs://nativeclient-mirror/nacl/nacl_sdk/'\ 'trunk.%s/naclsdk_linux.tar.bz2' % sdk_revision sdk_url = sdk_url.replace('https://commondatastorage.googleapis.com/', 'gs://') sdk_file = sdk_url.split('/')[-1] buildbot_common.Run([buildbot_common.GetGsutil(), 'cp', sdk_url, sdk_file], cwd=MONO_BUILD_DIR) tar_file = None try: tar_file = tarfile.open(os.path.join(MONO_BUILD_DIR, sdk_file)) pepper_dir = os.path.commonprefix(tar_file.getnames()) tar_file.extractall(path=MONO_BUILD_DIR) sdk_dir = os.path.join(MONO_BUILD_DIR, pepper_dir) finally: if tar_file: tar_file.close() assert sdk_dir buildbot_common.BuildStep(build_prefix + 'Checkout Mono') # TODO(elijahtaylor): Get git URL from master/trigger to make this # more flexible for building from upstream and release branches. if options.arch == 'arm': git_url = 'git://github.com/igotti-google/mono.git' git_rev = 'arm_nacl' else: git_url = 'git://github.com/elijahtaylor/mono.git' git_rev = 'HEAD' if buildbot_revision: # Unfortunately, we use different git branches/revisions # for ARM and x86 now, so ignore buildbot_revision variable for ARM. # Need to rethink this approach, if we'll plan to support # more flexible repo selection mechanism. if options.arch != 'arm': git_rev = buildbot_revision.split(':')[1] # ARM and x86 is built out of different git trees, so distinguish # them by appending the arch. It also makes 32 and 64 bit x86 separated, # which is good. # TODO(olonho): maybe we need to avoid modifications of global. global MONO_DIR tag = options.arch MONO_DIR = "%s-%s" % (MONO_DIR, tag) if not os.path.exists(MONO_DIR): buildbot_common.MakeDir(MONO_DIR) buildbot_common.Run(['git', 'clone', git_url, MONO_DIR]) else: buildbot_common.Run(['git', 'fetch'], cwd=MONO_DIR) if git_rev: buildbot_common.Run(['git', 'checkout', git_rev], cwd=MONO_DIR) arch_to_bitsize = {'x86-32': '32', 'x86-64': '64', 'arm': 'arm'} arch_to_output_folder = { 'x86-32': 'runtime-x86-32-build', 'x86-64': 'runtime-x86-64-build', 'arm': 'runtime-arm-build' } buildbot_common.BuildStep(build_prefix + 'Configure Mono') os.environ['NACL_SDK_ROOT'] = sdk_dir os.environ['TARGET_ARCH'] = options.arch os.environ['TARGET_BITSIZE'] = arch_to_bitsize[options.arch] buildbot_common.Run(['./autogen.sh'], cwd=MONO_DIR) buildbot_common.Run(['make', 'distclean'], cwd=MONO_DIR) buildbot_common.BuildStep(build_prefix + 'Build and Install Mono') nacl_interp_script = os.path.join(SDK_BUILD_DIR, 'nacl_interp_loader_mono.sh') os.environ['NACL_INTERP_LOADER'] = nacl_interp_script buildbot_common.Run( [ './nacl-mono-runtime.sh', MONO_DIR, # Mono directory with 'configure' arch_to_output_folder[options.arch], # Build dir options.install_dir ], cwd=SDK_BUILD_DIR) # TODO(elijahtaylor,olonho): Re-enable tests on arm when they compile/run. if options.arch != 'arm': buildbot_common.BuildStep(build_prefix + 'Test Mono') buildbot_common.Run(['make', 'check', '-j8'], cwd=os.path.join( SDK_BUILD_DIR, arch_to_output_folder[options.arch])) return 0
def main(args): parser = optparse.OptionParser() parser.add_option('--arch', help='Target architecture', dest='arch', default='x86-32') parser.add_option('--sdk_version', help='SDK Version (pepper_[X], r[X])' ' (default=buildbot revision)', dest='sdk_version', default='') parser.add_option('--install-dir', help='Install Directory', dest='install_dir', default='naclmono') (options, args) = parser.parse_args(args[1:]) assert sys.platform.find('linux') != -1 buildbot_revision = os.environ.get('BUILDBOT_REVISION', '') build_prefix = options.arch + ' ' buildbot_common.BuildStep(build_prefix + 'Clean Old SDK') buildbot_common.MakeDir(MONO_BUILD_DIR) buildbot_common.RemoveDir(os.path.join(MONO_BUILD_DIR, 'pepper_*')) buildbot_common.BuildStep(build_prefix + 'Setup New SDK') sdk_dir = None sdk_revision = None if options.sdk_version == '': assert buildbot_revision sdk_revision = buildbot_revision.split(':')[0] url = 'gs://nativeclient-mirror/nacl/nacl_sdk/'\ 'trunk.%s/naclsdk_linux.bz2' % sdk_revision buildbot_common.Run([buildbot_common.GetGsutil(), 'cp', url, '.'], cwd=MONO_BUILD_DIR) tar_file = None try: tar_file = tarfile.open( os.path.join(MONO_BUILD_DIR, 'naclsdk_linux.bz2')) pepper_dir = os.path.commonprefix(tar_file.getnames()) tar_file.extractall(path=MONO_BUILD_DIR) sdk_dir = os.path.join(MONO_BUILD_DIR, pepper_dir) finally: if tar_file: tar_file.close() else: buildbot_common.ErrorExit('sdk_version not yet supported') assert sdk_dir assert sdk_revision buildbot_common.BuildStep(build_prefix + 'Checkout Mono') # TODO(elijahtaylor): Get git URL from master/trigger to make this # more flexible for building from upstream and release branches. git_url = 'git://github.com/elijahtaylor/mono.git' git_rev = None if buildbot_revision: git_rev = buildbot_revision.split(':')[1] if not os.path.exists(MONO_DIR): buildbot_common.MakeDir(MONO_DIR) buildbot_common.Run(['git', 'clone', git_url, MONO_DIR]) else: buildbot_common.Run(['git', 'fetch'], cwd=MONO_DIR) if git_rev: buildbot_common.Run(['git', 'checkout', git_rev], cwd=MONO_DIR) arch_to_bitsize = {'x86-32': '32', 'x86-64': '64'} arch_to_output_folder = { 'x86-32': 'runtime-build', 'x86-64': 'runtime64-build' } buildbot_common.BuildStep(build_prefix + 'Configure Mono') os.environ['NACL_SDK_ROOT'] = sdk_dir os.environ['TARGET_BITSIZE'] = arch_to_bitsize[options.arch] buildbot_common.Run(['./autogen.sh'], cwd=MONO_DIR) buildbot_common.Run(['make', 'distclean'], cwd=MONO_DIR) buildbot_common.BuildStep(build_prefix + 'Build and Install Mono') nacl_interp_script = os.path.join(SDK_BUILD_DIR, 'nacl_interp_loader_mono.sh') os.environ['NACL_INTERP_LOADER'] = nacl_interp_script buildbot_common.Run( [ './nacl-mono-runtime.sh', MONO_DIR, # Mono directory with 'configure' arch_to_output_folder[options.arch], # Build dir options.install_dir ], cwd=SDK_BUILD_DIR) buildbot_common.BuildStep(build_prefix + 'Test Mono') buildbot_common.Run(['make', 'check', '-j8'], cwd=os.path.join(SDK_BUILD_DIR, arch_to_output_folder[options.arch])) return 0
def GnNinjaInstall(pepperdir, toolchains): tools_files_x86 = [ ['sel_ldr', 'sel_ldr_x86_32'], ] tools_files_x64 = [ ['sel_ldr', 'sel_ldr_x86_64'], ['ncval_new', 'ncval'], ['clang_newlib_arm/elf_loader.nexe', 'elf_loader_arm.nexe'], ['irt_x86/irt_core.nexe', 'irt_core_x86_32.nexe'], ['irt_x64/irt_core.nexe', 'irt_core_x86_64.nexe'], ] tools_files_arm = [] platform = getos.GetPlatform() # TODO(binji): dump_syms doesn't currently build on Windows. See # http://crbug.com/245456 if platform != 'win': tools_files_x64 += [ ['dump_syms', 'dump_syms'], ['minidump_dump', 'minidump_dump'], ['minidump_stackwalk', 'minidump_stackwalk'] ] if platform == 'linux': tools_files_x86 += [['nonsfi_loader', 'nonsfi_loader_x86_32'], ['nacl_helper_bootstrap', 'nacl_helper_bootstrap_x86_32']] tools_files_x64 += [['nacl_helper_bootstrap', 'nacl_helper_bootstrap_x86_64']] # Add ARM trusted binaries (linux only) if not options.no_arm_trusted: tools_files_x64 += [ ['irt_arm/irt_core.nexe', 'irt_core_arm.nexe'], ] tools_files_arm += [ ['nacl_helper_bootstrap', 'nacl_helper_bootstrap_arm'], ['nonsfi_loader', 'nonsfi_loader_arm'], ['sel_ldr', 'sel_ldr_arm'] ] tools_dir = os.path.join(pepperdir, 'tools') buildbot_common.MakeDir(tools_dir) # Add .exe extensions to all windows tools for pair in tools_files_x86 + tools_files_x64: if platform == 'win' and not os.path.splitext(pair[0])[1]: pair[0] += '.exe' pair[1] += '.exe' InstallFiles(GetNinjaOutDir('x64'), tools_dir, tools_files_x64) InstallFiles(GetNinjaOutDir('x86'), tools_dir, tools_files_x86) if platform == 'linux': InstallFiles(GetNinjaOutDir('arm'), tools_dir, tools_files_arm) stub_dir = os.path.join(SRC_DIR, 'ppapi/native_client/src/untrusted/irt_stub') for tc in toolchains: if tc in ('host', 'clang-newlib'): continue elif tc == 'pnacl': xarches = ('pnacl', 'x86', 'x64', 'arm') elif tc in ('x86_glibc'): xarches = ('x86', 'x64') elif tc == 'arm_glibc': xarches = ('arm',) else: raise AssertionError('unexpected toolchain value: %s' % tc) for xarch in xarches: src_dir = GetGnBuiltLib(tc, xarch) src_dir = os.path.join(src_dir, 'obj', 'ppapi', 'native_client', 'src', 'untrusted', 'irt_stub') dst_dir = GetOutputToolchainLib(pepperdir, tc, xarch) InstallFiles(src_dir, dst_dir, ['libppapi_stub.a']) InstallFiles(stub_dir, dst_dir, ['libppapi.a']) if 'glibc' in tc: InstallFiles(stub_dir, dst_dir, ['libppapi.so'])
def UpdateProjects(pepperdir, project_tree, toolchains, clobber=False, configs=None, first_toolchain=False): if configs is None: configs = ['Debug', 'Release'] if not os.path.exists(os.path.join(pepperdir, 'tools')): buildbot_common.ErrorExit('Examples depend on missing tools.') if not os.path.exists(os.path.join(pepperdir, 'toolchain')): buildbot_common.ErrorExit('Examples depend on missing toolchains.') ValidateToolchains(toolchains) # Create the library output directories libdir = os.path.join(pepperdir, 'lib') platform = getos.GetPlatform() for config in configs: for arch in LIB_DICT[platform]: dirpath = os.path.join(libdir, '%s_%s_host' % (platform, arch), config) if clobber: buildbot_common.RemoveDir(dirpath) buildbot_common.MakeDir(dirpath) landing_page = None for branch, projects in project_tree.iteritems(): dirpath = os.path.join(pepperdir, branch) if clobber: buildbot_common.RemoveDir(dirpath) buildbot_common.MakeDir(dirpath) targets = [desc['NAME'] for desc in projects if 'TARGETS' in desc] deps = GetDeps(projects) # Generate master make for this branch of projects generate_make.GenerateMasterMakefile(pepperdir, os.path.join(pepperdir, branch), targets, deps) if branch.startswith('examples') and not landing_page: landing_page = LandingPage() # Generate individual projects for desc in projects: srcroot = os.path.dirname(desc['FILEPATH']) generate_make.ProcessProject(pepperdir, srcroot, pepperdir, desc, toolchains, configs=configs, first_toolchain=first_toolchain) if branch.startswith('examples'): landing_page.AddDesc(desc) if landing_page: # Generate the landing page text file. index_html = os.path.join(pepperdir, 'examples', 'index.html') index_template = os.path.join(SDK_RESOURCE_DIR, 'index.html.template') with open(index_html, 'w') as fh: out = landing_page.GeneratePage(index_template) fh.write(out) # Generate top Make for examples targets = ['api', 'demo', 'getting_started', 'tutorial'] targets = [x for x in targets if 'examples/' + x in project_tree] branch_name = 'examples' generate_make.GenerateMasterMakefile(pepperdir, os.path.join(pepperdir, branch_name), targets, {})
def main(args): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--qemu', help='Add qemu for ARM.', action='store_true') parser.add_argument('--tar', help='Force the tar step.', action='store_true') parser.add_argument('--archive', help='Force the archive step.', action='store_true') parser.add_argument('--release', help='PPAPI release version.', dest='release', default=None) parser.add_argument('--build-app-engine', help='Build AppEngine demos.', action='store_true') parser.add_argument('--experimental', help='build experimental examples and libraries', action='store_true', dest='build_experimental') parser.add_argument('--skip-toolchain', help='Skip toolchain untar', action='store_true') parser.add_argument('--no-clean', dest='clean', action='store_false', help="Don't clean gn build directories") parser.add_argument('--mac-sdk', help='Set the mac-sdk (e.g. 10.6) to use when building with ninja.') parser.add_argument('--no-arm-trusted', action='store_true', help='Disable building of ARM trusted components (sel_ldr, etc).') parser.add_argument('--no-use-sysroot', action='store_true', help='Disable building against sysroot.') # To setup bash completion for this command first install optcomplete # and then add this line to your .bashrc: # complete -F _optcomplete build_sdk.py try: import optcomplete optcomplete.autocomplete(parser) except ImportError: pass global options options = parser.parse_args(args) buildbot_common.BuildStep('build_sdk') if buildbot_common.IsSDKBuilder(): options.archive = True # TODO(binji): re-enable app_engine build when the linux builder stops # breaking when trying to git clone from github. # See http://crbug.com/412969. options.build_app_engine = False options.tar = True # NOTE: order matters here. This will be the order that is specified in the # Makefiles; the first toolchain will be the default. toolchains = ['pnacl', 'x86_glibc', 'arm_glibc', 'clang-newlib', 'host'] print 'Building: ' + ' '.join(toolchains) platform = getos.GetPlatform() if options.archive and not options.tar: parser.error('Incompatible arguments with archive.') chrome_version = int(build_version.ChromeMajorVersion()) chrome_revision = build_version.ChromeRevision() nacl_revision = build_version.NaClRevision() pepper_ver = str(chrome_version) pepper_old = str(chrome_version - 1) pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) pepperdir_old = os.path.join(OUT_DIR, 'pepper_' + pepper_old) tarname = 'naclsdk_%s.tar.bz2' % platform tarfile = os.path.join(OUT_DIR, tarname) if options.release: pepper_ver = options.release print 'Building PEPPER %s at %s' % (pepper_ver, chrome_revision) if 'NACL_SDK_ROOT' in os.environ: # We don't want the currently configured NACL_SDK_ROOT to have any effect # of the build. del os.environ['NACL_SDK_ROOT'] if platform == 'linux': # Linux-only: make sure the debian/stable sysroot image is installed install_script = os.path.join(SRC_DIR, 'build', 'linux', 'sysroot_scripts', 'install-sysroot.py') buildbot_common.Run([sys.executable, install_script, '--arch=arm']) buildbot_common.Run([sys.executable, install_script, '--arch=i386']) buildbot_common.Run([sys.executable, install_script, '--arch=amd64']) if not options.skip_toolchain: BuildStepCleanPepperDirs(pepperdir, pepperdir_old) BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools']) BuildStepDownloadToolchains(toolchains) BuildStepUntarToolchains(pepperdir, toolchains) if platform == 'linux': buildbot_common.Move(os.path.join(pepperdir, 'toolchain', 'arm_trusted'), os.path.join(OUT_DIR, 'arm_trusted')) if platform == 'linux': # Linux-only: Copy arm libraries from the arm_trusted package. These are # needed to be able to run sel_ldr_arm under qemu. arm_libs = [ 'lib/arm-linux-gnueabihf/librt.so.1', 'lib/arm-linux-gnueabihf/libdl.so.2', 'lib/arm-linux-gnueabihf/libpthread.so.0', 'lib/arm-linux-gnueabihf/libgcc_s.so.1', 'lib/arm-linux-gnueabihf/libc.so.6', 'lib/arm-linux-gnueabihf/ld-linux-armhf.so.3', 'lib/arm-linux-gnueabihf/libm.so.6', ] arm_lib_dir = os.path.join(pepperdir, 'tools', 'lib', 'arm_trusted', 'lib') buildbot_common.MakeDir(arm_lib_dir) for arm_lib in arm_libs: arm_lib = os.path.join(OUT_DIR, 'arm_trusted', arm_lib) buildbot_common.CopyFile(arm_lib, arm_lib_dir) buildbot_common.CopyFile(os.path.join(OUT_DIR, 'arm_trusted', 'qemu-arm'), os.path.join(pepperdir, 'tools')) BuildStepBuildToolchains(pepperdir, toolchains, not options.skip_toolchain, options.clean) BuildStepUpdateHelpers(pepperdir, True) BuildStepUpdateUserProjects(pepperdir, toolchains, options.build_experimental, True) BuildStepCopyTextFiles(pepperdir, pepper_ver, chrome_revision, nacl_revision) # Ship with libraries prebuilt, so run that first. BuildStepBuildLibraries(pepperdir) GenerateNotice(pepperdir) # Verify the SDK contains what we expect. BuildStepVerifyFilelist(pepperdir) if options.tar: BuildStepTarBundle(pepper_ver, tarfile) if platform == 'linux': BuildStepBuildPNaClComponent(pepper_ver, chrome_revision) if options.build_app_engine and platform == 'linux': BuildStepBuildAppEngine(pepperdir, chrome_revision) if options.qemu: qemudir = os.path.join(NACL_DIR, 'toolchain', 'linux_arm-trusted') oshelpers.Copy(['-r', qemudir, pepperdir]) # Archive the results on Google Cloud Storage. if options.archive: BuildStepArchiveBundle('build', pepper_ver, chrome_revision, nacl_revision, tarfile) # Only archive sdk_tools/naclport/pnacl_component on linux. if platform == 'linux': BuildStepArchiveSDKTools() BuildStepArchivePNaClComponent(chrome_revision) return 0
def main(args): parser = optparse.OptionParser() parser.add_option('--pnacl', help='Enable pnacl build.', action='store_true', dest='pnacl', default=False) parser.add_option('--examples', help='Only build the examples.', action='store_true', dest='only_examples', default=False) parser.add_option('--update', help='Only build the updater.', action='store_true', dest='only_updater', default=False) parser.add_option('--skip-tar', help='Skip generating a tarball.', action='store_true', dest='skip_tar', default=False) parser.add_option('--archive', help='Force the archive step.', action='store_true', dest='archive', default=False) parser.add_option('--release', help='PPAPI release version.', dest='release', default=None) options, args = parser.parse_args(args[1:]) platform = getos.GetPlatform() arch = 'x86' builder_name = os.getenv('BUILDBOT_BUILDERNAME', '') if builder_name.find('pnacl') >= 0 and builder_name.find('sdk') >= 0: options.pnacl = True if options.pnacl: toolchains = ['pnacl'] else: toolchains = ['newlib', 'glibc'] print 'Building: ' + ' '.join(toolchains) skip = options.only_examples or options.only_updater skip_examples = skip and not options.only_examples skip_update = skip and not options.only_updater skip_untar = skip skip_build = skip skip_test_updater = skip skip_tar = skip or options.skip_tar if options.archive and (options.only_examples or options.skip_tar): parser.error('Incompatible arguments with archive.') pepper_ver = str(int(build_utils.ChromeMajorVersion())) pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1) clnumber = build_utils.ChromeRevision() if options.release: pepper_ver = options.release print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) if not skip_build: buildbot_common.BuildStep('Rerun hooks to get toolchains') buildbot_common.Run(['gclient', 'runhooks'], cwd=SRC_DIR, shell=(platform == 'win')) buildbot_common.BuildStep('Clean Pepper Dirs') pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) pepperold = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old) buildbot_common.RemoveDir(pepperold) if not skip_untar: buildbot_common.RemoveDir(pepperdir) buildbot_common.MakeDir(os.path.join(pepperdir, 'libraries')) buildbot_common.MakeDir(os.path.join(pepperdir, 'toolchain')) buildbot_common.MakeDir(os.path.join(pepperdir, 'tools')) else: buildbot_common.MakeDir(pepperdir) if not skip_build: buildbot_common.BuildStep('Add Text Files') files = ['AUTHORS', 'COPYING', 'LICENSE', 'NOTICE', 'README'] files = [os.path.join(SDK_SRC_DIR, filename) for filename in files] oshelpers.Copy(['-v'] + files + [pepperdir]) # Clean out the temporary toolchain untar directory if not skip_untar: UntarToolchains(pepperdir, platform, arch, toolchains) if not skip_build: BuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains) InstallHeaders(os.path.join(pepperdir, 'libraries'), pepper_ver, 'libs') if not skip_build: buildbot_common.BuildStep('Copy make OS helpers') buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'), os.path.join(pepperdir, 'tools')) if platform == 'win': buildbot_common.BuildStep('Add MAKE') http_download.HttpDownload( GSTORE + MAKE, os.path.join(pepperdir, 'tools', 'make.exe')) rename_list = [ 'ncval_x86_32', 'ncval_x86_64', 'sel_ldr_x86_32', 'sel_ldr_x86_64' ] tools = os.path.join(pepperdir, 'tools') for name in rename_list: src = os.path.join(pepperdir, 'tools', name) dst = os.path.join(pepperdir, 'tools', name + '.exe') buildbot_common.Move(src, dst) if not skip_examples: CopyExamples(pepperdir, toolchains) tarname = 'naclsdk_' + platform + '.bz2' if 'pnacl' in toolchains: tarname = 'p' + tarname tarfile = os.path.join(OUT_DIR, tarname) if not skip_tar: buildbot_common.BuildStep('Tar Pepper Bundle') buildbot_common.Run([ sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile, 'pepper_' + pepper_ver ], cwd=NACL_DIR) # Run build tests buildbot_common.BuildStep('Run build_tools tests') buildbot_common.Run([ sys.executable, os.path.join(SDK_SRC_DIR, 'build_tools', 'tests', 'test_all.py') ]) # build sdk update if not skip_update: build_updater.BuildUpdater(OUT_DIR) # start local server sharing a manifest + the new bundle if not skip_test_updater and not skip_tar: buildbot_common.BuildStep('Move bundle to localserver dir') buildbot_common.MakeDir(SERVER_DIR) buildbot_common.Move(tarfile, SERVER_DIR) tarfile = os.path.join(SERVER_DIR, tarname) server = None try: buildbot_common.BuildStep('Run local server') server = test_server.LocalHTTPServer(SERVER_DIR) buildbot_common.BuildStep('Generate manifest') with open(tarfile, 'rb') as tarfile_stream: archive_sha1, archive_size = manifest_util.DownloadAndComputeHash( tarfile_stream) archive = manifest_util.Archive(manifest_util.GetHostOS()) archive.CopyFrom({ 'url': server.GetURL(tarname), 'size': archive_size, 'checksum': { 'sha1': archive_sha1 } }) bundle = manifest_util.Bundle('pepper_' + pepper_ver) bundle.CopyFrom({ 'revision': int(clnumber), 'repath': 'pepper_' + pepper_ver, 'version': int(pepper_ver), 'description': 'Chrome %s bundle, revision %s' % (pepper_ver, clnumber), 'stability': 'dev', 'recommended': 'no', 'archives': [archive] }) manifest = manifest_util.SDKManifest() manifest.SetBundle(bundle) manifest_name = 'naclsdk_manifest2.json' with open(os.path.join(SERVER_DIR, manifest_name), 'wb') as \ manifest_stream: manifest_stream.write(manifest.GetDataAsString()) # use newly built sdk updater to pull this bundle buildbot_common.BuildStep('Update from local server') naclsdk_sh = os.path.join(OUT_DIR, 'nacl_sdk', 'naclsdk') if platform == 'win': naclsdk_sh += '.bat' buildbot_common.Run([ naclsdk_sh, '-U', server.GetURL(manifest_name), 'update', 'pepper_' + pepper_ver ]) # If we are testing examples, do it in the newly pulled directory. pepperdir = os.path.join(OUT_DIR, 'nacl_sdk', 'pepper_' + pepper_ver) # kill server finally: if server: server.Shutdown() # build examples. if not skip_examples: buildbot_common.BuildStep('Test Build Examples') example_dir = os.path.join(pepperdir, 'examples') makefile = os.path.join(example_dir, 'Makefile') if os.path.isfile(makefile): print "\n\nMake: " + example_dir buildbot_common.Run(['make', '-j8'], cwd=os.path.abspath(example_dir), shell=True) # Archive on non-trybots. buildername = os.environ.get('BUILDBOT_BUILDERNAME', '') if options.archive or '-sdk' in buildername: buildbot_common.BuildStep('Archive build') bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s' % \ build_utils.ChromeVersion() buildbot_common.Archive(tarname, bucket_path, os.path.dirname(tarfile)) if not skip_update: # Only push up sdk_tools.tgz on the linux buildbot. if buildername == 'linux-sdk-multi': sdk_tools = os.path.join(OUT_DIR, 'sdk_tools.tgz') buildbot_common.Archive('sdk_tools.tgz', bucket_path, OUT_DIR, step_link=False) # generate "manifest snippet" for this archive. if not skip_test_updater: archive = bundle.GetArchive(manifest_util.GetHostOS()) archive.url = 'https://commondatastorage.googleapis.com/' \ 'nativeclient-mirror/nacl/nacl_sdk/%s/%s' % ( build_utils.ChromeVersion(), tarname) manifest_snippet_file = os.path.join(OUT_DIR, tarname + '.json') with open(manifest_snippet_file, 'wb') as manifest_snippet_stream: manifest_snippet_stream.write(bundle.GetDataAsString()) buildbot_common.Archive(tarname + '.json', bucket_path, OUT_DIR, step_link=False) return 0
def BuildStepMakePepperDirs(pepperdir, subdirs): for subdir in subdirs: buildbot_common.MakeDir(os.path.join(pepperdir, subdir))
def GypNinjaInstall(pepperdir, toolchains): tools_files_32 = [ ['sel_ldr', 'sel_ldr_x86_32'], ['irt_core_newlib_x32.nexe', 'irt_core_x86_32.nexe'], ['irt_core_newlib_x64.nexe', 'irt_core_x86_64.nexe'], ] arm_files = [ ['elf_loader_newlib_arm.nexe', 'elf_loader_arm.nexe'], ] tools_files_64 = [] platform = getos.GetPlatform() # TODO(binji): dump_syms doesn't currently build on Windows. See # http://crbug.com/245456 if platform != 'win': tools_files_64 += [['dump_syms', 'dump_syms'], ['minidump_dump', 'minidump_dump'], ['minidump_stackwalk', 'minidump_stackwalk']] tools_files_64.append(['sel_ldr', 'sel_ldr_x86_64']) tools_files_64.append(['ncval_new', 'ncval']) if platform == 'linux': tools_files_32.append( ['nacl_helper_bootstrap', 'nacl_helper_bootstrap_x86_32']) tools_files_64.append( ['nacl_helper_bootstrap', 'nacl_helper_bootstrap_x86_64']) tools_files_32.append( ['nonsfi_loader_newlib_x32_nonsfi.nexe', 'nonsfi_loader_x86_32']) tools_dir = os.path.join(pepperdir, 'tools') buildbot_common.MakeDir(tools_dir) # Add .exe extensions to all windows tools for pair in tools_files_32 + tools_files_64: if platform == 'win' and not pair[0].endswith('.nexe'): pair[0] += '.exe' pair[1] += '.exe' # Add ARM binaries if platform == 'linux' and not options.no_arm_trusted: arm_files += [['irt_core_newlib_arm.nexe', 'irt_core_arm.nexe'], ['nacl_helper_bootstrap', 'nacl_helper_bootstrap_arm'], [ 'nonsfi_loader_newlib_arm_nonsfi.nexe', 'nonsfi_loader_arm' ], ['sel_ldr', 'sel_ldr_arm']] InstallFiles(GetNinjaOutDir('x64'), tools_dir, tools_files_64) InstallFiles(GetNinjaOutDir('ia32'), tools_dir, tools_files_32) InstallFiles(GetNinjaOutDir('arm'), tools_dir, arm_files) for tc in toolchains: if tc in ('host', 'clang-newlib'): continue elif tc == 'pnacl': xarches = (None, 'ia32', 'x64', 'arm') elif tc in ('x86_glibc', 'x86_newlib'): xarches = ('ia32', 'x64') elif tc in ('arm_glibc', 'arm_bionic'): xarches = ('arm', ) else: raise AssertionError('unexpected toolchain value: %s' % tc) for xarch in xarches: src_dir = GetGypBuiltLib(tc, xarch) dst_dir = GetOutputToolchainLib(pepperdir, tc, xarch) libc = GetToolchainLibc(tc) InstallFiles(src_dir, dst_dir, TOOLCHAIN_LIBS[libc])