Index: native_client_sdk/src/build_tools/build_sdk.py |
=================================================================== |
--- native_client_sdk/src/build_tools/build_sdk.py (revision 134587) |
+++ native_client_sdk/src/build_tools/build_sdk.py (working copy) |
@@ -17,18 +17,15 @@ |
# std python includes |
-import multiprocessing |
import optparse |
import os |
import platform |
-import subprocess |
import sys |
# local includes |
import buildbot_common |
import build_utils |
import lastchange |
-import manifest_util |
# Create the various paths of interest |
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
@@ -39,7 +36,6 @@ |
NACL_DIR = os.path.join(SRC_DIR, 'native_client') |
OUT_DIR = os.path.join(SRC_DIR, 'out') |
PPAPI_DIR = os.path.join(SRC_DIR, 'ppapi') |
-SERVER_DIR = os.path.join(OUT_DIR, 'local_server') |
# Add SDK make tools scripts to the python path. |
@@ -55,76 +51,17 @@ |
CYGTAR = os.path.join(NACL_DIR, 'build', 'cygtar.py') |
-def HTTPServerProcess(conn, serve_dir): |
- """Run a local httpserver with a randomly-chosen port. |
- |
- This function assumes it is run as a child process using multiprocessing. |
- |
- Args: |
- conn: A connection to the parent process. The child process sends |
- the local port, and waits for a message from the parent to |
- stop serving. |
- serve_dir: The directory to serve. All files are accessible through |
- http://localhost:<port>/path/to/filename. |
- """ |
- import BaseHTTPServer |
- import SimpleHTTPServer |
- |
- os.chdir(serve_dir) |
- httpd = BaseHTTPServer.HTTPServer(('', 0), |
- SimpleHTTPServer.SimpleHTTPRequestHandler) |
- conn.send(httpd.server_address[1]) # the chosen port number |
- httpd.timeout = 0.5 # seconds |
- running = True |
- while running: |
- httpd.handle_request() |
- if conn.poll(): |
- running = conn.recv() |
- conn.close() |
- |
- |
-class LocalHTTPServer(object): |
- """Class to start a local HTTP server as a child process.""" |
- |
- def __init__(self, serve_dir): |
- parent_conn, child_conn = multiprocessing.Pipe() |
- self.process = multiprocessing.Process(target=HTTPServerProcess, |
- args=(child_conn, serve_dir)) |
- self.process.start() |
- if parent_conn.poll(10): # wait 10 seconds |
- self.port = parent_conn.recv() |
- else: |
- raise Exception('Unable to launch HTTP server.') |
- |
- self.conn = parent_conn |
- |
- def Shutdown(self): |
- """Send a message to the child HTTP server process and wait for it to |
- finish.""" |
- self.conn.send(False) |
- self.process.join() |
- |
- def GetURL(self, rel_url): |
- """Get the full url for a file on the local HTTP server. |
- |
- Args: |
- rel_url: A URL fragment to convert to a full URL. For example, |
- GetURL('foobar.baz') -> 'http://localhost:1234/foobar.baz' |
- """ |
- return 'http://localhost:%d/%s' % (self.port, rel_url) |
- |
- |
def AddMakeBat(pepperdir, makepath): |
"""Create a simple batch file to execute Make. |
- |
+ |
Creates a simple batch file named make.bat for the Windows platform at the |
given path, pointing to the Make executable in the SDK.""" |
- |
+ |
makepath = os.path.abspath(makepath) |
if not makepath.startswith(pepperdir): |
buildbot_common.ErrorExit('Make.bat not relative to Pepper directory: ' + |
makepath) |
- |
+ |
makeexe = os.path.abspath(os.path.join(pepperdir, 'tools')) |
relpath = os.path.relpath(makeexe, makepath) |
@@ -265,7 +202,7 @@ |
buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'c', 'dev', '*.h'), |
os.path.join(ppapi, 'c', 'dev')) |
- # Run the generator to overwrite IDL files |
+ # 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')) |
@@ -322,7 +259,7 @@ |
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') |
@@ -333,7 +270,7 @@ |
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') |
@@ -412,7 +349,7 @@ |
'fullscreen_tumbler', |
'gamepad', |
'geturl', |
- 'hello_world_interactive', |
+ 'hello_world_interactive', |
'hello_world_newlib', |
'input_events', |
'load_progress', |
@@ -521,17 +458,17 @@ |
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('--examples', help='Rebuild the examples.', |
+ action='store_true', dest='examples', default=False) |
+ parser.add_option('--update', help='Rebuild the updater.', |
+ action='store_true', dest='update', 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' |
@@ -545,19 +482,23 @@ |
else: |
toolchains = ['newlib', 'glibc'] |
print 'Building: ' + ' '.join(toolchains) |
- skip = options.only_examples or options.only_updater |
+ skip = options.examples or options.update |
- skip_examples = skip and not options.only_examples |
- skip_update = skip and not options.only_updater |
+ skip_examples = skip |
+ skip_update = skip |
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): |
+ |
+ if options.examples: skip_examples = False |
+ skip_update = not options.update |
+ |
+ if options.archive and (options.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 = lastchange.FetchVersionInfo(None).revision |
if options.release: |
pepper_ver = options.release |
@@ -568,20 +509,19 @@ |
buildbot_common.Run(['gclient', 'runhooks'], |
cwd=SRC_DIR, shell=(platform=='win')) |
- pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) |
+ 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.BuildStep('Clean Pepper Dir') |
buildbot_common.RemoveDir(pepperdir) |
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]) |
+ 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 |
@@ -591,85 +531,41 @@ |
if not skip_build: |
BuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains) |
- 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')) |
+ 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')) |
+ # Add missing extention to Windows apps |
+ rename_list = ['ncval_x86_32', 'ncval_x86_64', |
+ 'sel_ldr_x86_32', 'sel_ldr_x86_64'] |
binji
2012/05/01 17:24:18
remove tabs
|
+ tools = os.path.join(pepperdir, 'tools') |
+ for name in rename_list: |
+ buildbot_common.Move(os.path.join(tools, name), |
+ os.path.join(tools, name + '.exe')) |
binji
2012/05/01 17:24:18
remove tabs
|
+ |
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') |
+ tarname = 'naclsdk_' + platform + '.bz2' |
+ if 'pnacl' in toolchains: |
+ tarname = 'p' + tarname |
+ tarfile = os.path.join(OUT_DIR, tarname) |
buildbot_common.Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile, |
'pepper_' + pepper_ver], cwd=NACL_DIR) |
- # build sdk update |
- if not skip_update: |
- BuildUpdater() |
+ # Archive on non-trybots. |
+ if options.archive or '-sdk' in os.environ.get('BUILDBOT_BUILDERNAME', ''): |
+ buildbot_common.BuildStep('Archive build') |
+ buildbot_common.Archive(tarname, |
+ 'nativeclient-mirror/nacl/nacl_sdk/%s' % build_utils.ChromeVersion(), |
+ OUT_DIR) |
- # start local server sharing a manifest + the new bundle |
- if not skip_test_updater: |
- 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 = 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': clnumber, |
- 'repath': 'pepper_' + pepper_ver, |
- 'version': 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') |
- updater_py = os.path.join(OUT_DIR, 'nacl_sdk', 'sdk_tools', |
- 'sdk_update.py') |
- buildbot_common.Run([sys.executable, updater_py, '-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') |
filelist = os.listdir(os.path.join(pepperdir, 'examples')) |
@@ -681,26 +577,10 @@ |
buildbot_common.Run(['make', 'all', '-j8'], |
cwd=os.path.abspath(dirnode), shell=True) |
- # Archive on non-trybots. |
- if options.archive or '-sdk' in os.environ.get('BUILDBOT_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)) |
+ # Build SDK Tools |
+ if not skip_update: |
+ BuildUpdater() |
- # 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.ToJSON()) |
- |
- buildbot_common.Archive(tarname + '.json', bucket_path, OUT_DIR, |
- step_link=False) |
- |
return 0 |