diff options
author | noelallen@chromium.org <noelallen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 20:55:12 +0000 |
---|---|---|
committer | noelallen@chromium.org <noelallen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 20:55:12 +0000 |
commit | a73de12185259c6d64ee3e7d4c035f9ea6d724bc (patch) | |
tree | 6394495b5d878c47558d1ac7e64f6e656b770606 /native_client_sdk | |
parent | 0333290378df304cfa2cd7de5ef90e8162e94dd1 (diff) | |
download | chromium_src-a73de12185259c6d64ee3e7d4c035f9ea6d724bc.zip chromium_src-a73de12185259c6d64ee3e7d4c035f9ea6d724bc.tar.gz chromium_src-a73de12185259c6d64ee3e7d4c035f9ea6d724bc.tar.bz2 |
Fix random example issues with make system.
1- Fix extra comma in PPAPI files, breaks scons build.
2- Fix missing eol properties on hello_world_gles sources
3- Support building library
4- Add gles2 library
R=binji@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10541154
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142215 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rwxr-xr-x | native_client_sdk/src/build_tools/build_sdk.py | 33 | ||||
-rwxr-xr-x | native_client_sdk/src/build_tools/generate_make.py | 77 | ||||
-rw-r--r-- | native_client_sdk/src/build_tools/library.mk | 100 | ||||
-rw-r--r-- | native_client_sdk/src/examples/debugging/example.dsc | 2 | ||||
-rw-r--r-- | native_client_sdk/src/examples/dlopen/dlopen.cc | 3 | ||||
-rw-r--r-- | native_client_sdk/src/examples/dlopen/dlopen.html | 13 | ||||
-rw-r--r-- | native_client_sdk/src/examples/hello_world_newlib/hello_world.c | 18 | ||||
-rw-r--r-- | native_client_sdk/src/libraries/gles2/library.dsc | 18 |
8 files changed, 230 insertions, 34 deletions
diff --git a/native_client_sdk/src/build_tools/build_sdk.py b/native_client_sdk/src/build_tools/build_sdk.py index 67b5fc5..4519e89 100755 --- a/native_client_sdk/src/build_tools/build_sdk.py +++ b/native_client_sdk/src/build_tools/build_sdk.py @@ -35,6 +35,7 @@ from tests import test_server 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_LIBRARY_DIR = os.path.join(SDK_SRC_DIR, 'libraries') SDK_DIR = os.path.dirname(SDK_SRC_DIR) SRC_DIR = os.path.dirname(SDK_DIR) NACL_DIR = os.path.join(SRC_DIR, 'native_client') @@ -230,6 +231,10 @@ def InstallHeaders(tc_dst_inc, pepper_ver, tc_name): os.path.join(PPAPI_DIR,'lib','gl','include','KHR', '*.h'), os.path.join(tc_dst_inc, 'KHR')) + # Copy the lib files + buildbot_common.MakeDir(os.path.join(tc_dst_inc, 'lib')) + buildbot_common.CopyDir(os.path.join(PPAPI_DIR,'lib'), tc_dst_inc) + def UntarToolchains(pepperdir, platform, arch, toolchains): buildbot_common.BuildStep('Untar Toolchains') @@ -328,9 +333,9 @@ def BuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains): EXAMPLE_MAP = { 'newlib': [ -# 'debugging', + 'debugging', 'file_histogram', -# 'file_io', + 'file_io', 'fullscreen_tumbler', 'gamepad', 'geturl', @@ -348,7 +353,7 @@ EXAMPLE_MAP = { 'websocket' ], 'glibc': [ -# 'dlopen', + 'dlopen', ], 'pnacl': [ # 'hello_world_pnacl', @@ -356,6 +361,15 @@ EXAMPLE_MAP = { } +LIBRARY_MAP = { + 'newlib': [ + 'gles2', + ], + 'glibc': [], + 'pnacl': [] +} + + def CopyExamples(pepperdir, toolchains): buildbot_common.BuildStep('Copy examples') @@ -378,11 +392,20 @@ def CopyExamples(pepperdir, toolchains): for tc in toolchains: examples.extend(EXAMPLE_MAP[tc]) + libraries = [] + for tc in toolchains: + libraries.extend(LIBRARY_MAP[tc]) + print 'Process: ' + ' '.join(examples) + print 'Process: ' + ' '.join(libraries) args = ['--dstroot=%s' % pepperdir, '--master'] for example in examples: dsc = os.path.join(SDK_EXAMPLE_DIR, example, 'example.dsc') args.append(dsc) + for library in libraries: + dsc = os.path.join(SDK_LIBRARY_DIR, library, 'library.dsc') + args.append(dsc) + if generate_make.main(args): buildbot_common.ErrorExit('Failed to build examples.') @@ -445,7 +468,7 @@ def main(args): 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, 'src')) buildbot_common.MakeDir(os.path.join(pepperdir, 'toolchain')) buildbot_common.MakeDir(os.path.join(pepperdir, 'tools')) else: @@ -464,7 +487,7 @@ def main(args): if not skip_build: BuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains) - InstallHeaders(os.path.join(pepperdir, 'libraries'), pepper_ver, 'libs') + InstallHeaders(os.path.join(pepperdir, 'src'), pepper_ver, 'libs') if not skip_build: buildbot_common.BuildStep('Copy make OS helpers') diff --git a/native_client_sdk/src/build_tools/generate_make.py b/native_client_sdk/src/build_tools/generate_make.py index 97f632c..d6a0825 100755 --- a/native_client_sdk/src/build_tools/generate_make.py +++ b/native_client_sdk/src/build_tools/generate_make.py @@ -23,7 +23,8 @@ SRC_EXT = { 'c': 'CC', 'cc' : 'CXX', '.so' : '.so', - '.nexe': '.nexe' + '.nexe': '.nexe', + '.a' : '.a' } @@ -42,6 +43,8 @@ def WriteMakefile(srcpath, dstpath, replacements): def GetExtType(desc): if desc['TYPE'] in ['main', 'nexe']: ext = '.nexe' + elif desc['TYPE'] == 'lib': + ext = '.a' else: ext = '.so' return ext @@ -75,9 +78,10 @@ def GenerateCopyList(desc): # Add sources for each target for target in desc['TARGETS']: sources.extend(target['SOURCES']) + if target['TYPE'] == 'main': + sources.append(desc['NAME'] + '.html') # And HTML and data files - sources.append(desc['NAME'] + '.html') sources.extend(desc.get('DATA', [])) return sources @@ -115,7 +119,7 @@ def GenerateNEXE(toolchain, name, ext, cc_sources, cxx_sources): COMPILE_RULE = """ <OBJS>:=$(patsubst %.<ext>, <tc>/%_<ARCH>.o,$(<PROJ>_<EXT>)) $(<OBJS>) : <tc>/%_<ARCH>.o : %.<ext> $(THIS_MAKE) | <tc> -<TAB>$(<CC>) -o $@ $< -m<ARCH> $(<PROJ>_<EXT>FLAGS) -DTCNAME=\\"<tc>\\" +<TAB>$(<CC>) -o $@ $< -m<ARCH> $(<PROJ>_<EXT>FLAGS) -DTCNAME=<tc> """ LINK_RULE = """ <tc>/<TARG> : $(<OBJS>) @@ -139,6 +143,9 @@ $(<OBJS>) : <tc>/%_<ARCH>.o : %.<ext> $(THIS_MAKE) | <tc> objs = ' '.join(object_sets) replace = BuildToolDict(toolchain, name, arch, ext, OBJS=objs) rules += Replace(LINK_RULE, replace) + if ext == '.a': + rules += '\n' + continue if ext == '.so': remap = ' -n %s,%s.so' % (replace['<TARG>'], name) rules += '%s_NMF+=%s/%s\n' % (replace['<TC>'], toolchain, replace['<TARG>']) @@ -189,6 +196,7 @@ def GenerateReplacements(desc): settings += SetVar(macro + '_LDFLAGS', flags) for tc in tools: + nexe = None rules += '#\n# Rules for %s toolchain\n#\n%s:\n\t$(MKDIR) %s\n' % ( tc, tc, tc) for target in desc['TARGETS']: @@ -201,14 +209,23 @@ def GenerateReplacements(desc): if target['TYPE'] == 'main': nexe = name targets.append('%s/%s.nmf' % (tc, name)) - replace = BuildToolDict(tc, nexe) - rules += Replace(NMF_RULE, replace) - + if nexe: + replace = BuildToolDict(tc, nexe) + rules += Replace(NMF_RULE, replace) + + prereqs = desc.get('PREREQ', []) + target_def = '' + if prereqs: + target_def = '.PHONY : PREREQS\nPREREQS:\n' + for prereq in prereqs: + target_def += '\t+$(MAKE) -C %s all\n' % prereq + target_def+= '\nall : PREREQS ' + (' '.join(targets)) + else: + target_def += 'all : ' + ' '.join(targets) - targets = 'all : '+ ' '.join(targets) return { '__PROJECT_SETTINGS__' : settings, - '__PROJECT_TARGETS__' : targets, + '__PROJECT_TARGETS__' : target_def, '__PROJECT_RULES__' : rules, '__PROJECT_PRELAUNCH__' : prelaunch, '__PROJECT_PRERUN__' : prerun, @@ -219,14 +236,16 @@ def GenerateReplacements(desc): # 'KEY' : ( <TYPE>, [Accepted Values], <Required?>) DSC_FORMAT = { 'TOOLS' : (list, ['newlib', 'glibc', 'pnacl'], True), + 'PREREQ' : (list, '', False), 'TARGETS' : (list, { 'NAME': (str, '', True), - 'TYPE': (str, ['main', 'nexe', 'so'], True), + 'TYPE': (str, ['main', 'nexe', 'lib', 'so'], True), 'SOURCES': (list, '', True), 'CCFLAGS': (list, '', False), 'CXXFLAGS': (list, '', False), 'LDFLAGS': (list, '', False) }, True), + 'SEARCH': (list, '', False), 'POST': (str, '', False), 'PRE': (str, '', False), 'DEST': (str, ['examples', 'src'], True), @@ -337,10 +356,30 @@ def AddMakeBat(pepperdir, makepath): fp.close() -def ProcessProject(dstroot, template, filename): +def FindFile(name, srcroot, srcdirs): + checks = [] + for srcdir in srcdirs: + srcfile = os.path.join(srcroot, srcdir, name) + srcfile = os.path.abspath(srcfile) + if os.path.exists(srcfile): + return srcfile + else: + checks.append(srcfile) + + ErrorMsgFunc('%s not found in:\n\t%s' % (name, '\n\t'.join(checks))) + return None + + +def IsNexe(desc): + for target in desc['TARGETS']: + if target['TYPE'] == 'main': + return True + return False + +def ProcessProject(dstroot, filename): print '\n\nProcessing %s...' % filename # Default src directory is the directory the description was found in - src_dir = os.path.dirname(os.path.abspath(filename)) + srcroot = os.path.dirname(os.path.abspath(filename)) desc = open(filename, 'rb').read() desc = eval(desc, {}, {}) if not ValidateFormat(desc, DSC_FORMAT): @@ -350,13 +389,23 @@ def ProcessProject(dstroot, template, filename): out_dir = os.path.join(dstroot, desc['DEST'], name) buildbot_common.MakeDir(out_dir) + srcdirs = desc.get('SEARCH', ['.']) + # Copy sources to example directory sources = GenerateCopyList(desc) for src_name in sources: - src_file = os.path.join(src_dir, src_name) + src_file = FindFile(src_name, srcroot, srcdirs) + if not src_file: + return (None, None) dst_file = os.path.join(out_dir, src_name) buildbot_common.CopyFile(src_file, dst_file) + if IsNexe(desc): + template=os.path.join(SCRIPT_DIR, 'template.mk') + else: + template=os.path.join(SCRIPT_DIR, 'library.mk') + + # Add Makefile repdict = GenerateReplacements(desc) make_path = os.path.join(out_dir, 'Makefile') @@ -400,15 +449,13 @@ def main(argv): parser = optparse.OptionParser() parser.add_option('--dstroot', help='Set root for destination.', dest='dstroot', default=OUT_DIR) - parser.add_option('--template', help='Set the makefile template.', - dest='template', default=os.path.join(SCRIPT_DIR, 'template.mk')) parser.add_option('--master', help='Create master Makefile.', action='store_true', dest='master', default=False) examples = [] options, args = parser.parse_args(argv) for filename in args: - name, dest = ProcessProject(options.dstroot, options.template, filename) + name, dest = ProcessProject(options.dstroot, filename) if not name: print '\n*** Failed to process project: %s ***' % filename return 1 diff --git a/native_client_sdk/src/build_tools/library.mk b/native_client_sdk/src/build_tools/library.mk new file mode 100644 index 0000000..2c35dfa --- /dev/null +++ b/native_client_sdk/src/build_tools/library.mk @@ -0,0 +1,100 @@ +# Copyright (c) 2012 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# GNU Make based build file. For details on GNU Make see: +# http://www.gnu.org/software/make/manual/make.html +# + +# +# Get pepper directory for toolchain and includes. +# +# If NACL_SDK_ROOT is not set, then assume it can be found a two directories up, +# from the default example directory location. +# +THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) +NACL_SDK_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) +CHROME_PATH?=Undefined + +# +# Defaults +# +NACL_WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -Werror -pedantic +NACL_CCFLAGS:=-O0 -g -pthread $(NACL_WARNINGS) +NACL_CXXFLAGS:= -O0 -g -pthread -std=gnu++98 $(NACL_WARNINGS) +NACL_LDFLAGS:=-Wl,-as-needed -g -pthread -lppapi_cpp -lppapi + +# +# Project Settings +# +__PROJECT_SETTINGS__ + +# +# Project Targets +# +__PROJECT_TARGETS__ + + +# +# Alias for standard commands +# +CP:=python $(NACL_SDK_ROOT)/tools/oshelpers.py cp +MKDIR:=python $(NACL_SDK_ROOT)/tools/oshelpers.py mkdir +MV:=python $(NACL_SDK_ROOT)/tools/oshelpers.py mv + + +# +# Verify we selected a valid toolchain for this example +# +ifeq (,$(findstring $(TOOLCHAIN),$(VALID_TOOLCHAINS))) +$(warning Availbile choices are: $(VALID_TOOLCHAINS)) +$(error Can not use TOOLCHAIN=$(TOOLCHAIN) on this example.) +endif + + +# +# Compute path to requested NaCl Toolchain +# +OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py) +TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain) + + +# +# Verify we have a valid NACL_SDK_ROOT by looking for the toolchain directory +# +ifeq (,$(wildcard $(TC_PATH))) +$(warning No valid NACL_SDK_ROOT at $(NACL_SDK_ROOT)) +ifeq ($(origin NACL_SDK_ROOT), 'file') +$(error Override the default value via enviornment variable, or command-line.) +else +$(error Fix the NACL_SDK_ROOT specified in the environment or command-line.) +endif +endif + + +# +# Disable DOS PATH warning when using Cygwin based NaCl tools on Windows +# +CYGWIN ?= nodosfilewarning +export CYGWIN + + +# +# NaCl Tools +# +NEWLIB_CC?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-gcc -c +NEWLIB_CXX?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -c +NEWLIB_LINK?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ +NEWLIB_DUMP?=$(TC_PATH)/$(OSNAME)_x86_newlib/x86_64-nacl/bin/objdump +NEWLIB_PATHS:= + +GLIBC_CC?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-gcc -c +GLIBC_CXX?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-g++ -c +GLIBC_LINK?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-g++ +GLIBC_DUMP?=$(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/bin/objdump +GLIBC_PATHS:=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib32 +GLIBC_PATHS+=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib + +__PROJECT_RULES__ + diff --git a/native_client_sdk/src/examples/debugging/example.dsc b/native_client_sdk/src/examples/debugging/example.dsc index 71da84d..a6b1a03 100644 --- a/native_client_sdk/src/examples/debugging/example.dsc +++ b/native_client_sdk/src/examples/debugging/example.dsc @@ -1,5 +1,5 @@ { - 'TOOLS': ['newlib', 'glibc'], + 'TOOLS': ['newlib'], 'TARGETS': [ { 'NAME' : 'debugging', diff --git a/native_client_sdk/src/examples/dlopen/dlopen.cc b/native_client_sdk/src/examples/dlopen/dlopen.cc index 4d8bf89..567c7c81 100644 --- a/native_client_sdk/src/examples/dlopen/dlopen.cc +++ b/native_client_sdk/src/examples/dlopen/dlopen.cc @@ -110,8 +110,9 @@ class dlOpenInstance : public pp::Instance { std::string message = var_message.AsString(); if (message == "query") { fprintf(stdout, "%s(%d) Got this far.\n", __FILE__, __LINE__); - std::string ballmessage = "!The Magic 8-Ball says: "; + std::string ballmessage = "The Magic 8-Ball says: "; ballmessage += this->_eightball(); + ballmessage += "!"; logmsg(ballmessage.c_str()); fprintf(stdout, "%s(%d) Got this far.\n", __FILE__, __LINE__); diff --git a/native_client_sdk/src/examples/dlopen/dlopen.html b/native_client_sdk/src/examples/dlopen/dlopen.html index cd454bb..69a93d9 100644 --- a/native_client_sdk/src/examples/dlopen/dlopen.html +++ b/native_client_sdk/src/examples/dlopen/dlopen.html @@ -44,14 +44,6 @@ } function handleMessage(message_event) { - var consolec = document.getElementById('consolec'); - if(message_event.data[0]=='!') { - document.getElementById('answerlog').innerHTML += - (consolec.value + ": " + message_event.data +"<br />"); - } else { - document.getElementById('answerlog').innerHTML += - (message_event.data +"<br />"); - } updateStatus(message_event.data); } @@ -91,14 +83,15 @@ statusField.innerHTML = statusText; } if (answerLog) { - answerLog.innerHTML += (message_event.data +"<br />"); + answerLog.innerHTML += (opt_message +"<br />"); } } function askBall() { naclModule = document.getElementById('nacl_module'); - updateStatus('Posing...'); + var consolec = document.getElementById('consolec'); + updateStatus('ASK: ' + consolec.value); naclModule.postMessage('query'); return false; } diff --git a/native_client_sdk/src/examples/hello_world_newlib/hello_world.c b/native_client_sdk/src/examples/hello_world_newlib/hello_world.c index 79ecc75..fb90e40 100644 --- a/native_client_sdk/src/examples/hello_world_newlib/hello_world.c +++ b/native_client_sdk/src/examples/hello_world_newlib/hello_world.c @@ -22,6 +22,21 @@ #include "ppapi/c/ppp_instance.h" #include "ppapi/c/ppp_messaging.h" +/** + * The toolchain name macro will be once of these three values, so we will use + * it to select which string we print. + */ +enum { + newlib = 0, + glibc = 1, + pnacl = 2 +}; + +static const char* s_HelloMsg[3] = { + "Hello World (newlib)", + "Hello World (glibc)", + "Hello World (pnacl)" +}; static PPB_Messaging* ppb_messaging_interface = NULL; static PPB_Var* ppb_var_interface = NULL; @@ -68,8 +83,7 @@ static PP_Bool Instance_DidCreate(PP_Instance instance, uint32_t argc, const char* argn[], const char* argv[]) { - ppb_messaging_interface->PostMessage(instance, - CStrToVar("Hello World: " TCNAME)); + ppb_messaging_interface->PostMessage(instance, CStrToVar(s_HelloMsg[TCNAME])); return PP_TRUE; } diff --git a/native_client_sdk/src/libraries/gles2/library.dsc b/native_client_sdk/src/libraries/gles2/library.dsc new file mode 100644 index 0000000..8bdaf9d --- /dev/null +++ b/native_client_sdk/src/libraries/gles2/library.dsc @@ -0,0 +1,18 @@ +{ + 'TOOLS': ['newlib', 'glibc'], + 'SEARCH' : ['../../../../ppapi/lib/gl/gles2'], + 'TARGETS': [ + { + 'NAME' : 'libgles2', + 'TYPE' : 'lib', + 'SOURCES' : [ + 'gl2ext_ppapi.c', + 'gl2ext_ppapi.h', + 'gles2.c' + ], + } + ], + 'DEST': 'src', + 'NAME': 'gles2', +} + |