diff options
author | noelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-11 20:50:45 +0000 |
---|---|---|
committer | noelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-11 20:50:45 +0000 |
commit | faad2573b247e6c6721d086bdf7e6f056f1ef1b3 (patch) | |
tree | 81a66fc0b531528c7629f2188ce79f7857691853 /native_client_sdk | |
parent | 759017e03abb02554ad06a1745290631c43d7751 (diff) | |
download | chromium_src-faad2573b247e6c6721d086bdf7e6f056f1ef1b3.zip chromium_src-faad2573b247e6c6721d086bdf7e6f056f1ef1b3.tar.gz chromium_src-faad2573b247e6c6721d086bdf7e6f056f1ef1b3.tar.bz2 |
Build cleanups
Speed up slow "pong" example.
Update "updater" to support new manifest format.
Fix '.svn' exclude.
Add list of files for SDK
Add list of examples for SDK
Committing TBR to green SDK tree, SDK changes do not affect Chrome.
TBR= bradnelson@chromium.org
BUG= 109207
Review URL: https://chromiumcodereview.appspot.com/9383038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121656 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rwxr-xr-x | native_client_sdk/src/build_tools/buildbot_run.py | 223 | ||||
-rw-r--r-- | native_client_sdk/src/examples/Makefile | 5 | ||||
-rw-r--r-- | native_client_sdk/src/examples/dlopen/dlopen.cc | 3 | ||||
-rw-r--r-- | native_client_sdk/src/examples/pong/view.cc | 7 | ||||
-rw-r--r-- | native_client_sdk/src/tools/oshelpers.py | 2 |
5 files changed, 147 insertions, 93 deletions
diff --git a/native_client_sdk/src/build_tools/buildbot_run.py b/native_client_sdk/src/build_tools/buildbot_run.py index 40f6e2d..8e08570 100755 --- a/native_client_sdk/src/build_tools/buildbot_run.py +++ b/native_client_sdk/src/build_tools/buildbot_run.py @@ -28,6 +28,7 @@ import lastchange # Create the various paths of interest SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR) +SDK_EXAMPLE_DIR = os.path.join(SDK_SRC_DIR, 'examples') SDK_DIR = os.path.dirname(SDK_SRC_DIR) SRC_DIR = os.path.dirname(SDK_DIR) NACL_DIR = os.path.join(SRC_DIR, 'native_client') @@ -108,7 +109,7 @@ def AddMakeBat(makepath): fp.close() -def CopyDir(src, dst, excludes=['.svn']): +def CopyDir(src, dst, excludes=['.svn','*/.svn']): """Recursively copy a directory using.""" args = ['-r', src, dst] for exc in excludes: @@ -283,44 +284,142 @@ def InstallHeaders(tc_dst_inc, pepper_ver, tc_name): os.path.join(tc_dst_inc, 'KHR')) +def UntarToolchains(pepperdir, platform, arch): + BuildStep('Untar Toolchains') + tcname = platform + '_' + arch + tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') + RemoveDir(tmpdir) + MakeDir(tmpdir) + + # Untar the newlib toolchains + tarfile = GetNewlibToolchain(platform, arch) + 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') + print "Buildbot mv %s to %s" % (srcdir, newlibdir) + MoveDir(srcdir, newlibdir) + print "Done with buildbot move" + # Untar the glibc toolchains + tarfile = GetGlibcToolchain(platform, arch) + 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') + MoveDir(srcdir, glibcdir) + + +def BuildToolchains(pepperdir, platform, arch, pepper_ver): + BuildStep('SDK Items') + + tcname = platform + '_' + arch + newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') + glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') + + # Run scons TC build steps + if arch == 'x86': + Run(GetBuildArgs('newlib', newlibdir, 'x86', '32'), cwd=NACL_DIR) + Run(GetBuildArgs('newlib', newlibdir, 'x86', '64'), cwd=NACL_DIR) + + Run(GetBuildArgs('glibc', glibcdir, 'x86', '32'), cwd=NACL_DIR) + Run(GetBuildArgs('glibc', glibcdir, 'x86', '64'), cwd=NACL_DIR) + else: + ErrorExit('Missing arch %s' % arch) + + # Copy headers + if arch == 'x86': + InstallHeaders(GetToolchainNaClInclude(newlibdir, 'x86'), + pepper_ver, + 'newlib') + InstallHeaders(GetToolchainNaClInclude(glibcdir, 'x86'), + pepper_ver, + 'glibc') + else: + ErrorExit('Missing arch %s' % arch) + + +def CopyExamples(pepperdir, extras = []): + BuildStep('Copy examples') + examples = [ + 'dlopen', 'fullscreen_tumbler', 'gamepad', 'geturl', + 'hello_world_glibc', 'hello_world_interactive', 'hello_world_newlib', + 'input_events', 'load_progress', 'mouselock', + 'multithreaded_input_events', 'pi_generator', 'pong', 'sine_synth', + 'tumbler'] + extras + files = ['favicon.ico', 'httpd.cmd', 'httpd.py', 'index.html', 'Makefile'] + if not os.path.exists(os.path.join(pepperdir, 'tools')): + ErrorExit('Examples depend on missing tools.') + if not os.path.exists(os.path.join(pepperdir, 'toolchain')): + ErrorExit('Examples depend on missing toolchains.') + exampledir = os.path.join(pepperdir, 'examples') + RemoveDir(exampledir) + MakeDir(exampledir) + AddMakeBat(exampledir) + for filename in files: + oshelpers.Copy(['-v', os.path.join(SDK_EXAMPLE_DIR, filename), exampledir]) + for example in examples: + CopyDir(os.path.join(SDK_EXAMPLE_DIR, example), exampledir) + + +def BuildUpdater(): + BuildStep('Create Installer/Updater') + tooldir = os.path.join(SRC_DIR, 'out', 'sdk_tools') + sdkupdate = os.path.join(SDK_SRC_DIR, 'build_tools', 'sdk_tools', 'sdk_update.py') + license = os.path.join(SDK_SRC_DIR, 'LICENSE') + RemoveDir(tooldir) + MakeDir(tooldir) + args = ['-v', sdkupdate, license, CYGTAR, tooldir] + oshelpers.Copy(args) + tarname = 'sdk_tools.tgz' + tarfile = os.path.join(OUT_DIR, tarname) + Run([sys.executable, CYGTAR, '-C', tooldir, '-czf', tarfile, + 'sdk_update.py', 'LICENSE', 'cygtar.py'], cwd=NACL_DIR) + sys.stdout.write('\n') + + def main(args): parser = optparse.OptionParser() - # Modes - parser.add_option('--examples-only', help='Rebuild the examples.', - action='store_true', dest='examples_only', 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') - + 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' - skip_examples = False - skip_untar = False - skip_build = False - skip_headers = False - skip_tar = False - force_archive = options.archive + skip = options.examples or options.update - if options.examples_only: - skip_untar = True - skip_build = True - skip_headers = True - skip_tar = True + skip_examples = skip + skip_update = skip + skip_untar = skip + skip_build = skip + skip_tar = skip or options.skip_tar - if options.skip_tar: - skip_tar = True + if options.examples: skip_examples = False + if options.update: skip_update = False - if options.archive and (options.examples_only or options.skip_tar): + if options.archive and (options.examples or options.skip_tar): parser.error('Incompatible arguments with archive.') - pepper_ver = build_utils.ChromeMajorVersion() + # TODO(noelallen): Remove force build to 18... + pepper_ver = str(int(build_utils.ChromeMajorVersion()) - 1) clnumber = lastchange.FetchVersionInfo(None).revision + if options.release: + pepper_ver = options.release print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) + BuildStep('Clean Pepper Dir') pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) if not skip_untar: @@ -328,83 +427,39 @@ def main(args): MakeDir(os.path.join(pepperdir, 'toolchain')) MakeDir(os.path.join(pepperdir, 'tools')) - BuildStep('Untar Toolchains') - tcname = platform + '_' + arch - tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') + 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: - RemoveDir(tmpdir) - MakeDir(tmpdir) - tcname = platform + '_' + arch - - # Untar the newlib toolchains - tarfile = GetNewlibToolchain(platform, arch) - 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') - print "Buildbot mv %s to %s" % (srcdir, newlibdir) - MoveDir(srcdir, newlibdir) - print "Done with buildbot move" - # Untar the glibc toolchains - tarfile = GetGlibcToolchain(platform, arch) - 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') - MoveDir(srcdir, glibcdir) - else: - newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') - glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') + UntarToolchains(pepperdir, platform, arch) - BuildStep('SDK Items') if not skip_build: - if arch == 'x86': - Run(GetBuildArgs('newlib', newlibdir, 'x86', '32'), cwd=NACL_DIR) - Run(GetBuildArgs('newlib', newlibdir, 'x86', '64'), cwd=NACL_DIR) - - Run(GetBuildArgs('glibc', glibcdir, 'x86', '32'), cwd=NACL_DIR) - Run(GetBuildArgs('glibc', glibcdir, 'x86', '64'), cwd=NACL_DIR) - else: - ErrorExit('Missing arch %s' % arch) - - if not skip_headers: - BuildStep('Copy Toolchain headers') - if arch == 'x86': - InstallHeaders(GetToolchainNaClInclude(newlibdir, 'x86'), - pepper_ver, - 'newlib') - InstallHeaders(GetToolchainNaClInclude(glibcdir, 'x86'), - pepper_ver, - 'glibc') - else: - ErrorExit('Missing arch %s' % arch) - - BuildStep('Copy make helpers') + BuildToolchains(pepperdir, platform, arch, pepper_ver) + + BuildStep('Copy make OS helpers') CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'), - os.path.join(pepperdir, 'tools')) + os.path.join(pepperdir, 'tools')) if platform == 'win': BuildStep('Add MAKE') http_download.HttpDownload(GSTORE + MAKE, - os.path.join(pepperdir, 'tools' ,'make.exe')) + os.path.join(pepperdir, 'tools' ,'make.exe')) if not skip_examples: - BuildStep('Copy examples') - RemoveDir(os.path.join(pepperdir, 'examples')) - CopyDir(os.path.join(SDK_SRC_DIR, 'examples'), pepperdir) + CopyExamples(pepperdir) - tarname = 'naclsdk_' + platform + '.bz2' - BuildStep('Tar Pepper Bundle') if not skip_tar: - tarfile = os.path.join(OUT_DIR, 'naclsdk_' + platform + '.bz2') + BuildStep('Tar Pepper Bundle') + tarname = 'naclsdk_' + platform + '.bz2' + tarfile = os.path.join(OUT_DIR, tarname) Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile, 'pepper_' + pepper_ver], cwd=NACL_DIR) # Archive on non-trybots. - if force_archive or '-sdk' in os.environ.get('BUILDBOT_BUILDERNAME', ''): + if options.archive or '-sdk' in os.environ.get('BUILDBOT_BUILDERNAME', ''): BuildStep('Archive build') Archive(tarname) @@ -415,11 +470,13 @@ def main(args): dirnode = os.path.join(pepperdir, 'examples', filenode) makefile = os.path.join(dirnode, 'Makefile') if os.path.isfile(makefile): - if platform == 'win': - AddMakeBat(dirnode) print "\n\nMake: " + dirnode Run(['make', 'all', '-j8'], cwd=os.path.abspath(dirnode), shell=True) +# Build SDK Tools + if not skip_update: + BuildUpdater() + return 0 diff --git a/native_client_sdk/src/examples/Makefile b/native_client_sdk/src/examples/Makefile index 468269e..6f022d5 100644 --- a/native_client_sdk/src/examples/Makefile +++ b/native_client_sdk/src/examples/Makefile @@ -15,7 +15,6 @@ PROJECTS+=tumbler # Define the default target all: - # # Target Macro # @@ -26,7 +25,7 @@ define TARGET TARGET_LIST+=$(1)_TARGET .PHONY: $(1)_TARGET $(1)_TARGET: - +cd $(1) && $(MAKE) + +$(MAKE) -C $(1) endef @@ -35,7 +34,7 @@ $(foreach proj,$(PROJECTS),$(eval $(call TARGET,$(proj)))) all: $(TARGET_LIST) - echo "Done building targets, running webserver." + echo "Done building targets." RUN: all echo "Staring up python webserver." diff --git a/native_client_sdk/src/examples/dlopen/dlopen.cc b/native_client_sdk/src/examples/dlopen/dlopen.cc index 27f7c7c..4d8bf89 100644 --- a/native_client_sdk/src/examples/dlopen/dlopen.cc +++ b/native_client_sdk/src/examples/dlopen/dlopen.cc @@ -81,7 +81,8 @@ class dlOpenInstance : public pp::Instance { if(_dlhandle == NULL) { logmsg("libeightball.so did not load"); } else { - _eightball = (TYPE_eightball) dlsym(this->_dlhandle, "Magic8Ball"); + intptr_t offset = (intptr_t) dlsym(this->_dlhandle, "Magic8Ball"); + _eightball = (TYPE_eightball) offset; if (NULL == _eightball) { std::string ballmessage = "dlsym() returned NULL: "; ballmessage += dlerror(); diff --git a/native_client_sdk/src/examples/pong/view.cc b/native_client_sdk/src/examples/pong/view.cc index 2938275..0801712 100644 --- a/native_client_sdk/src/examples/pong/view.cc +++ b/native_client_sdk/src/examples/pong/view.cc @@ -75,6 +75,7 @@ void View::Draw() { // Clear the buffer const int32_t height = pixel_buffer_->size().height(); const int32_t width = pixel_buffer_->size().width(); + const float radius2 = (ball_rect_.width() / 2) * (ball_rect_.width() / 2); for (int32_t py = 0; py < height; ++py) { for (int32_t px = 0; px < width; ++px) { const int32_t pos = px + py * width; @@ -85,13 +86,11 @@ void View::Draw() { color |= kWhiteMask; } else { pp::Point center_point = ball_rect_.CenterPoint(); - float radius = ball_rect_.width() / 2; float distance_x = px - center_point.x(); float distance_y = py - center_point.y(); - float distance = - sqrt(distance_x * distance_x + distance_y * distance_y); + float distance2 = distance_x * distance_x + distance_y * distance_y; // Draw the ball - if (distance <= radius) + if (distance2 <= radius2) color |= kWhiteMask; } pixels[pos] = color; diff --git a/native_client_sdk/src/tools/oshelpers.py b/native_client_sdk/src/tools/oshelpers.py index 53b6c64..9248a05 100644 --- a/native_client_sdk/src/tools/oshelpers.py +++ b/native_client_sdk/src/tools/oshelpers.py @@ -132,8 +132,6 @@ def Copy(args): src_list.extend(files) for src in src_list: - if options.verbose: - print 'cp %s %s' % (src, dst) # If the destination is a directory, then append the basename of the src # to the destination. if os.path.isdir(dst): |