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 InstallHeaders(tc_dst_inc, pepper_ver, tc_name): """Copies NaCl headers to expected locations in the toolchain.""" 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 buildbot_common.Run([ sys.executable, 'generator.py', '--wnone', '--cgen', '--release=M' + pepper_ver, '--verbose', '--dstroot=%s/c' % ppapi ], 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.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')) # 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'))
def BuildStepUntarToolchains(pepperdir, platform, arch, toolchains): buildbot_common.BuildStep('Untar Toolchains') tcname = platform + '_' + arch tmpdir = os.path.join(OUT_DIR, '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 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/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) 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 CopyFilesFromTo(filelist, srcdir, dstdir): for filename in filelist: srcpath = os.path.join(srcdir, filename) dstpath = os.path.join(dstdir, filename) buildbot_common.CopyFile(srcpath, dstpath)
def BuildStepBuildToolchains(pepperdir, toolchains): buildbot_common.BuildStep('SDK Items') # Remove all gypbuild-* dirs. buildbot_common.RemoveDir(os.path.join(OUT_DIR, GYPBUILD_DIR)) buildbot_common.RemoveDir(os.path.join(OUT_DIR, GYPBUILD_DIR) + '-arm') buildbot_common.RemoveDir(os.path.join(OUT_DIR, GYPBUILD_DIR) + '-64') buildbot_common.RemoveDir( os.path.join(OUT_DIR, GYPBUILD_DIR) + '-pnacl-ia32') buildbot_common.RemoveDir( os.path.join(OUT_DIR, GYPBUILD_DIR) + '-pnacl-arm') GypNinjaBuild_NaCl(GYPBUILD_DIR) GypNinjaBuild_Breakpad(GYPBUILD_DIR) platform = getos.GetPlatform() newlibdir = os.path.join(pepperdir, 'toolchain', platform + '_x86_newlib') glibcdir = os.path.join(pepperdir, 'toolchain', platform + '_x86_glibc') armdir = os.path.join(pepperdir, 'toolchain', platform + '_arm_newlib') pnacldir = os.path.join(pepperdir, 'toolchain', platform + '_pnacl') bionicdir = os.path.join(pepperdir, 'toolchain', platform + '_arm_bionic') if set(toolchains) & set(['glibc', 'newlib']): GypNinjaBuild_PPAPI('ia32', GYPBUILD_DIR) GypNinjaBuild_PPAPI('x64', GYPBUILD_DIR) if 'arm' in toolchains: GypNinjaBuild_PPAPI('arm', GYPBUILD_DIR + '-arm') GypNinjaInstall(pepperdir, toolchains) if 'newlib' in toolchains: InstallNaClHeaders(GetToolchainNaClInclude('newlib', newlibdir, 'x86'), 'newlib') if 'glibc' in toolchains: InstallNaClHeaders(GetToolchainNaClInclude('glibc', glibcdir, 'x86'), 'glibc') if 'arm' in toolchains: InstallNaClHeaders(GetToolchainNaClInclude('newlib', armdir, 'arm'), 'arm') if 'bionic' in toolchains: InstallNaClHeaders(GetToolchainNaClInclude('bionic', bionicdir, 'arm'), 'bionic') if 'pnacl' in toolchains: # NOTE: For ia32, gyp builds both x86-32 and x86-64 by default. for arch in ('ia32', 'arm'): # Fill in the latest native pnacl shim library from the chrome build. build_dir = GYPBUILD_DIR + '-pnacl-' + arch GypNinjaBuild_Pnacl(build_dir, arch) if arch == 'ia32': nacl_arches = ['x86-32', 'x86-64'] elif arch == 'arm': nacl_arches = ['arm'] else: buildbot_common.ErrorExit('Unknown architecture: %s' % arch) for nacl_arch in nacl_arches: release_build_dir = os.path.join(OUT_DIR, build_dir, 'Release', 'gen', 'tc_pnacl_translate', 'lib-' + nacl_arch) pnacl_translator_lib_dir = GetPNaClTranslatorLib( pnacldir, nacl_arch) if not os.path.isdir(pnacl_translator_lib_dir): buildbot_common.ErrorExit( 'Expected %s directory to exist.' % pnacl_translator_lib_dir) buildbot_common.CopyFile( os.path.join(release_build_dir, 'libpnacl_irt_shim.a'), pnacl_translator_lib_dir) InstallNaClHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'), 'newlib')
def BuildStepBuildToolchains(pepperdir, platform, toolchains): buildbot_common.BuildStep('SDK Items') GypNinjaBuild_NaCl(platform, GYPBUILD_DIR) GypNinjaBuild_Breakpad(platform, GYPBUILD_DIR) tcname = platform + '_x86' newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl') if set(toolchains) & set(['glibc', 'newlib']): GypNinjaBuild_PPAPI('ia32', GYPBUILD_DIR) if 'arm' in toolchains: GypNinjaBuild_PPAPI('arm', GYPBUILD_DIR + '-arm') GypNinjaInstall(pepperdir, platform, toolchains) if 'newlib' in toolchains: InstallNaClHeaders(GetToolchainNaClInclude('newlib', newlibdir, 'x86'), 'newlib') if 'glibc' in toolchains: InstallNaClHeaders(GetToolchainNaClInclude('glibc', glibcdir, 'x86'), 'glibc') if 'arm' in toolchains: tcname = platform + '_arm_newlib' armdir = os.path.join(pepperdir, 'toolchain', tcname) InstallNaClHeaders(GetToolchainNaClInclude('newlib', armdir, 'arm'), 'arm') if 'pnacl' in toolchains: # shell=True is needed on windows to enable searching of the PATH: # http://bugs.python.org/issue8557 shell = platform == 'win' buildbot_common.Run(GetSconsArgs(pnacldir, pepperdir, 'x86', '32'), cwd=NACL_DIR, shell=shell) for arch in ('ia32', 'arm'): # Fill in the latest native pnacl shim library from the chrome build. build_dir = GYPBUILD_DIR + '-pnacl-' + arch GypNinjaBuild_Pnacl(build_dir, arch) pnacl_libdir_map = {'ia32': 'x86-64', 'arm': 'arm'} release_build_dir = os.path.join(OUT_DIR, build_dir, 'Release', 'gen', 'tc_pnacl_translate', 'lib-' + pnacl_libdir_map[arch]) buildbot_common.CopyFile( os.path.join(release_build_dir, 'libpnacl_irt_shim.a'), GetPNaClNativeLib(pnacldir, pnacl_libdir_map[arch])) release_build_dir = os.path.join(OUT_DIR, build_dir, 'Release', 'gen', 'tc_pnacl_newlib', 'lib') buildbot_common.CopyFile( os.path.join(release_build_dir, 'libminidump_generator.a'), GetPNaClNativeLib(pnacldir, pnacl_libdir_map[arch])) buildbot_common.CopyFile( os.path.join(release_build_dir, 'libnacl_exception.a'), GetPNaClNativeLib(pnacldir, pnacl_libdir_map[arch])) InstallNaClHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'), 'newlib')
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 = 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 BuildStepBuildToolchains(pepperdir, toolchains, build, clean): buildbot_common.BuildStep('SDK Items') if clean: for dirname in glob.glob(os.path.join(OUT_DIR, GYPBUILD_DIR + '*')): buildbot_common.RemoveDir(dirname) build = True if build: GypNinjaBuild_NaCl(GYPBUILD_DIR) GypNinjaBuild_Breakpad(GYPBUILD_DIR + '-x64') if set(toolchains) & set(['x86_glibc', 'x86_newlib']): GypNinjaBuild_PPAPI('ia32', GYPBUILD_DIR + '-ia32', ['use_nacl_clang=0']) GypNinjaBuild_PPAPI('x64', GYPBUILD_DIR + '-x64', ['use_nacl_clang=0']) if 'arm_glibc' in toolchains: GypNinjaBuild_PPAPI('arm', GYPBUILD_DIR + '-arm', ['use_nacl_clang=0']) if 'pnacl' in toolchains: GypNinjaBuild_PPAPI('ia32', GYPBUILD_DIR + '-clang-ia32', ['use_nacl_clang=1']) GypNinjaBuild_PPAPI('x64', GYPBUILD_DIR + '-clang-x64', ['use_nacl_clang=1']) GypNinjaBuild_PPAPI('arm', GYPBUILD_DIR + '-clang-arm', ['use_nacl_clang=1']) # NOTE: For ia32, gyp builds both x86-32 and x86-64 by default. for arch in ('ia32', 'arm'): # Fill in the latest native pnacl shim library from the chrome build. build_dir = GYPBUILD_DIR + '-pnacl-' + arch GypNinjaBuild_Pnacl(build_dir, arch) GypNinjaInstall(pepperdir, toolchains) for toolchain in toolchains: if toolchain not in ('host', 'clang-newlib'): InstallNaClHeaders(GetToolchainNaClInclude(pepperdir, toolchain), toolchain) if 'pnacl' in toolchains: # NOTE: For ia32, gyp builds both x86-32 and x86-64 by default. for arch in ('ia32', 'arm'): # Fill in the latest native pnacl shim library from the chrome build. build_dir = GYPBUILD_DIR + '-pnacl-' + arch if arch == 'ia32': nacl_arches = ['x86-32', 'x86-64'] elif arch == 'arm': nacl_arches = ['arm'] else: buildbot_common.ErrorExit('Unknown architecture: %s' % arch) for nacl_arch in nacl_arches: release_build_dir = os.path.join(OUT_DIR, build_dir, 'Release', 'gen', 'tc_pnacl_translate', 'lib-' + nacl_arch) pnacldir = GetToolchainDir(pepperdir, 'pnacl') pnacl_translator_lib_dir = GetPNaClTranslatorLib( pnacldir, nacl_arch) if not os.path.isdir(pnacl_translator_lib_dir): buildbot_common.ErrorExit( 'Expected %s directory to exist.' % pnacl_translator_lib_dir) buildbot_common.CopyFile( os.path.join(release_build_dir, 'libpnacl_irt_shim.a'), pnacl_translator_lib_dir) InstallNaClHeaders(GetToolchainNaClInclude(pepperdir, 'pnacl', 'x86'), 'pnacl') InstallNaClHeaders(GetToolchainNaClInclude(pepperdir, 'pnacl', 'arm'), 'pnacl')