diff options
author | noelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-22 20:33:21 +0000 |
---|---|---|
committer | noelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-22 20:33:21 +0000 |
commit | b70d57c69a1389e3d64568fd8637ed814101a322 (patch) | |
tree | e5d34c76230746bb3f15b93fe751d33df77945e0 /native_client_sdk | |
parent | 283fa9d004f8468823261622b62ad772f0211a6a (diff) | |
download | chromium_src-b70d57c69a1389e3d64568fd8637ed814101a322.zip chromium_src-b70d57c69a1389e3d64568fd8637ed814101a322.tar.gz chromium_src-b70d57c69a1389e3d64568fd8637ed814101a322.tar.bz2 |
Fix Updater Generation
Renable generation of the updater components. This adds the ability to
create the bootload nacl_sdk.zip used by all platforms, as well as the
sdk_tools.tgz which does the actual work.
Add a naclsdk_manifest0.json which sets up the state of the original
bundle (just the updater nothing else).
Add CopyFile method similar to RemoveFile
Change 'copyfile' to 'copy' so that we keep mode bits (executable)
Add debugging example to newlib bundle.
R=bradnelson@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9816025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128284 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rwxr-xr-x | native_client_sdk/src/build_tools/build_sdk.py | 55 | ||||
-rw-r--r-- | native_client_sdk/src/build_tools/buildbot_common.py | 6 | ||||
-rw-r--r-- | native_client_sdk/src/tools/getos.py | 151 | ||||
-rw-r--r-- | native_client_sdk/src/tools/oshelpers.py | 2 |
4 files changed, 199 insertions, 15 deletions
diff --git a/native_client_sdk/src/build_tools/build_sdk.py b/native_client_sdk/src/build_tools/build_sdk.py index de10e69..f781fcb 100755 --- a/native_client_sdk/src/build_tools/build_sdk.py +++ b/native_client_sdk/src/build_tools/build_sdk.py @@ -19,6 +19,7 @@ and whether it should upload an SDK to file storage (GSTORE) import optparse import os import sys +import zipfile # local includes import buildbot_common @@ -185,7 +186,7 @@ def InstallHeaders(tc_dst_inc, pepper_ver, tc_name): src = os.path.join(NACL_DIR, tc_map[filename]) dst = os.path.join(tc_dst_inc, filename) buildbot_common.MakeDir(os.path.dirname(dst)) - oshelpers.Copy(['-v', src, dst]) + buildbot_common.CopyFile(src, dst) # Clean out per toolchain ppapi directory ppapi = os.path.join(tc_dst_inc, 'ppapi') @@ -340,6 +341,7 @@ def BuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains): EXAMPLE_MAP = { 'newlib': [ + 'debugging', 'fullscreen_tumbler', 'gamepad', 'geturl', @@ -393,17 +395,50 @@ def CopyExamples(pepperdir, toolchains): def BuildUpdater(): buildbot_common.BuildStep('Create Updater') - tooldir = os.path.join(SRC_DIR, 'out', 'sdk_tools') + + naclsdkdir = os.path.join(OUT_DIR, 'nacl_sdk') + tooldir = os.path.join(naclsdkdir, 'sdk_tools') + cachedir = os.path.join(naclsdkdir, 'sdk_cache') + buildtoolsdir = os.path.join(SDK_SRC_DIR, 'build_tools') + + # Build SDK directory + buildbot_common.RemoveDir(naclsdkdir) + buildbot_common.MakeDir(naclsdkdir) + buildbot_common.MakeDir(tooldir) + buildbot_common.MakeDir(cachedir) + + # Copy launch scripts + buildbot_common.CopyFile(os.path.join(buildtoolsdir, 'naclsdk'), naclsdkdir) + buildbot_common.CopyFile(os.path.join(buildtoolsdir, 'naclsdk.bat'), + naclsdkdir) + + # Copy base manifest + json = os.path.join(buildtoolsdir, 'json', 'naclsdk_manifest0.json') + buildbot_common.CopyFile(json, + os.path.join(cachedir, 'naclsdk_manifest2.json')) + + # Copy SDK tools sdkupdate = os.path.join(SDK_SRC_DIR, 'build_tools', 'sdk_tools', 'sdk_update.py') license = os.path.join(SDK_SRC_DIR, 'LICENSE') - buildbot_common.RemoveDir(tooldir) - buildbot_common.MakeDir(tooldir) + buildbot_common.CopyFile(sdkupdate, tooldir) + buildbot_common.CopyFile(license, tooldir) + buildbot_common.CopyFile(CYGTAR, tooldir) + + buildbot_common.RemoveFile(os.path.join(OUT_DIR, 'nacl_sdk.zip')) + buildbot_common.Run(['zip', '-r', 'nacl_sdk.zip', + 'nacl_sdk/naclsdk', + 'nacl_sdk/naclsdk.bat', + 'nacl_sdk/sdk_tools/LICENSE', + 'nacl_sdk/sdk_tools/cygtar.py', + 'nacl_sdk/sdk_tools/sdk_update.py', + 'nacl_sdk/sdk_cache/naclsdk_manifest2.json'], + cwd=OUT_DIR) args = ['-v', sdkupdate, license, CYGTAR, tooldir] - oshelpers.Copy(args) - tarname = 'sdk_tools.tgz' - tarfile = os.path.join(OUT_DIR, tarname) - buildbot_common.Run([sys.executable, CYGTAR, '-C', tooldir, '-czf', tarfile, + tarname = os.path.join(OUT_DIR, 'sdk_tools.tgz') + + buildbot_common.RemoveFile(tarname) + buildbot_common.Run([sys.executable, CYGTAR, '-C', tooldir, '-czf', tarname, 'sdk_update.py', 'LICENSE', 'cygtar.py'], cwd=NACL_DIR) sys.stdout.write('\n') @@ -521,8 +556,8 @@ def main(args): cwd=os.path.abspath(dirnode), shell=True) # Build SDK Tools -# if not skip_update: -# BuildUpdater() + if not skip_update: + BuildUpdater() return 0 diff --git a/native_client_sdk/src/build_tools/buildbot_common.py b/native_client_sdk/src/build_tools/buildbot_common.py index c30a1a1..3c37ed9 100644 --- a/native_client_sdk/src/build_tools/buildbot_common.py +++ b/native_client_sdk/src/build_tools/buildbot_common.py @@ -56,6 +56,12 @@ def CopyDir(src, dst, excludes=['.svn', '*/.svn']): oshelpers.Copy(args) +def CopyFile(src, dst): + print 'cp -r %s %s' % (src, dst) + args = [src, dst] + oshelpers.Copy(args) + + def RemoveDir(dst): """Remove the provided path.""" print 'rm -fr ' + dst diff --git a/native_client_sdk/src/tools/getos.py b/native_client_sdk/src/tools/getos.py index f41bb47..b16870d 100644 --- a/native_client_sdk/src/tools/getos.py +++ b/native_client_sdk/src/tools/getos.py @@ -10,8 +10,26 @@ Determine the name of the platform used to determine the correct Toolchain to invoke. """ +import optparse +import os +import re +import subprocess import sys + +TOOL_PATH=os.path.dirname(os.path.abspath(__file__)) + + +def ErrOut(text): + sys.stderr.write(text + '\n') + sys.exit(1) + + + +def GetSDKPath(): + return os.getenv('NACL_SDK_ROOT', os.path.dirname(TOOL_PATH)) + + def GetPlatform(): if sys.platform.startswith('cygwin') or sys.platform.startswith('win'): return 'win' @@ -23,12 +41,137 @@ def GetPlatform(): return 'linux' return None -if __name__ == '__main__': + +def UseWin64(): + arch32 = os.environ.get('PROCESSOR_ARCHITECTURE', 'unk') + arch64 = os.environ.get('PROCESSOR_ARCHITEW6432', 'unk') + + if arch32 == 'AMD64' or arch64 == 'AMD64': + return True + return False + + +def GetSystemArch(platform): + if platform == 'win': + if UseWin64(): + return 'x86_64' + return 'x86_32' + + if platform in ['mac', 'linux']: + try: + pobj = subprocess.Popen(['uname', '-m'],stdout= subprocess.PIPE) + arch, serr = pobj.communicate() + arch = arch.split()[0] + except: + arch = None + return arch + + +def GetChromeArch(platform): + if platform == 'win': + if UseWin64(): + return 'x86_64' + return 'x86_32' + + if platform in ['mac', 'linux']: + chrome_path = os.getenv('CHROME_PATH', None) + if not chrome_path: + ErrOut('CHROME_PATH is undefined.') + + try: + pobj = subprocess.Popen(['objdump', '-f', chrome_path], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + arch, serr = pobj.communicate() + format = re.compile(r'(file format) ([a-zA-Z0-9_\-]+)') + arch = format.search(arch).group(2) + if '64' in arch: + return 'x86_64' + return 'x86_32' + except: + print "FAILED" + arch = None + return arch + + +def GetLoaderPath(platform): + sdk_path = GetSDKPath() + arch = GetChromeArch(platform) + return os.path.join(sdk_path, 'tools', 'sel_ldr_' + arch) + + +def GetHelperPath(platform): + sdk_path = GetSDKPath() + if platform != 'linux': + return '' + arch = GetChromeArch(platform) + return os.path.join(sdk_path, 'tools', 'nacl_helper_bootstrap_' + arch) + + +def GetIrtBinPath(platform): + sdk_path = GetSDKPath() + arch = GetChromeArch(platform) + return os.path.join(sdk_path, 'tools', 'irt_%s.nexe' % arch) + + +def GetPluginPath(platform): + sdk_path = GetSDKPath() + arch = GetChromeArch(platform) + if platform == 'win': + return os.path.join(sdk_path, 'tools', 'ppNaClPlugin_x86_32.dll') + else: + return os.path.join(sdk_path, 'tools', 'ppNaClPlugin_%s.so' % arch) + + +def main(args): + parser = optparse.OptionParser() + parser.add_option('--arch', help='Return architecture type.', + action='store_true', dest='arch', default=False) + parser.add_option('--chrome', help='Return chrome architecture type.', + action='store_true', dest='chrome', default=False) + parser.add_option('--helper', help='Return chrome helper path.', + action='store_true', dest='helper', default=False) + parser.add_option('--irtbin', help='Return irt binary path.', + action='store_true', dest='irtbin', default=False) + parser.add_option('--loader', help='Return NEXE loader path.', + action='store_true', dest='loader', default=False) + parser.add_option('--plugin', help='Return NaCl plugin path.', + action='store_true', dest='plugin', default=False) + + options, _ = parser.parse_args(args[1:]) + platform = GetPlatform() if platform is None: print 'Unknown platform.' - sys.exit(1) + return 1 + + if len(args) > 2: + print 'Only specify one platform item.' + return 1 - print platform - sys.exit(0) + if len(args) == 1: + print platform + return 0 + if len(args) == 2: + if options.arch: + out = GetSystemArch(platform) + if options.chrome: + out = GetChromeArch(platform) + if options.helper: + out = GetHelperPath(platform) + if options.irtbin: + out = GetIrtBinPath(platform) + if options.loader: + out = GetLoaderPath(platform) + if options.plugin: + out = GetPluginPath(platform) + print out + return 0 + + print 'Failed with args: ' + ' '.join(args) + return 1 + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/native_client_sdk/src/tools/oshelpers.py b/native_client_sdk/src/tools/oshelpers.py index 93648a9..9e878d3 100644 --- a/native_client_sdk/src/tools/oshelpers.py +++ b/native_client_sdk/src/tools/oshelpers.py @@ -69,7 +69,7 @@ def CopyPath(options, src, dst): os.remove(dst) # Now copy to the non-existent fully qualified target - shutil.copyfile(src, dst) + shutil.copy(src, dst) return # Otherwise it's a directory, ignore it unless allowed |