diff options
author | noelallen@chromium.org <noelallen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-24 00:38:04 +0000 |
---|---|---|
committer | noelallen@chromium.org <noelallen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-24 00:38:04 +0000 |
commit | 14ca8d024ee9d0771ea502bcdd7eb1563d59044f (patch) | |
tree | 9ae695088a42bfa916f530f4fd2e2b2321040c77 /native_client_sdk | |
parent | 946175e5d93ef0a380ef33e82d017a77b5a60eec (diff) | |
download | chromium_src-14ca8d024ee9d0771ea502bcdd7eb1563d59044f.zip chromium_src-14ca8d024ee9d0771ea502bcdd7eb1563d59044f.tar.gz chromium_src-14ca8d024ee9d0771ea502bcdd7eb1563d59044f.tar.bz2 |
Make use of -lppapi explicit to allow for correct library order.
This CL removes the implicit -lppapi and pthread in the Makefiles. Since ppapi lib
does not exist on the host (on NaCl it's actually a linker script), we need to
create a bogus ppapi.lib for host Pepper development. In addition, on Windows we
do not have a pthread library so we create a mini pthread library to support the
examples.
This CL also fixes tries which are broken on Windows.
Review URL: https://chromiumcodereview.appspot.com/10815039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148006 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
26 files changed, 140 insertions, 29 deletions
diff --git a/native_client_sdk/src/build_tools/build_sdk.py b/native_client_sdk/src/build_tools/build_sdk.py index bc8de75..a376162 100755 --- a/native_client_sdk/src/build_tools/build_sdk.py +++ b/native_client_sdk/src/build_tools/build_sdk.py @@ -365,6 +365,8 @@ EXAMPLE_LIST = [ ] LIBRARY_LIST = [ + 'pthread', + 'ppapi', 'ppapi_cpp', 'ppapi_gles2', ] diff --git a/native_client_sdk/src/build_tools/make_rules.py b/native_client_sdk/src/build_tools/make_rules.py index 5531dcb..bb94467 100755 --- a/native_client_sdk/src/build_tools/make_rules.py +++ b/native_client_sdk/src/build_tools/make_rules.py @@ -9,31 +9,31 @@ # NEWLIB_DEFAULTS = """ NEWLIB_CC?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-gcc -c -NEWLIB_CXX?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -c -std=gnu++98 +NEWLIB_CXX?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -c -std=gnu++98 NEWLIB_LINK?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -Wl,-as-needed NEWLIB_DUMP?=$(TC_PATH)/$(OSNAME)_x86_newlib/x86_64-nacl/bin/objdump NEWLIB_CCFLAGS?=-O0 -g -pthread $(NACL_WARNINGS) -NEWLIB_LDFLAGS?=-g -lppapi +NEWLIB_LDFLAGS?=-g -pthread """ GLIBC_DEFAULTS = """ GLIBC_CC?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-gcc -c -GLIBC_CXX?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-g++ -c -std=gnu++98 +GLIBC_CXX?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-g++ -c -std=gnu++98 GLIBC_LINK?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-g++ -Wl,-as-needed 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 GLIBC_CCFLAGS?=-O0 -g -pthread $(NACL_WARNINGS) -GLIBC_LDFLAGS?=-g -lppapi +GLIBC_LDFLAGS?=-g -pthread """ PNACL_DEFAULTS = """ PNACL_CC?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang -c -PNACL_CXX?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang++ -c -std=gnu++98 +PNACL_CXX?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang++ -c -std=gnu++98 PNACL_LINK?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang++ PNACL_DUMP?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/objdump PNACL_CCFLAGS?=-O0 -g -pthread $(NACL_WARNINGS) -PNACL_LDFLAGS?=-g -lppapi +PNACL_LDFLAGS?=-g -pthread TRANSLATE:=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-translate """ diff --git a/native_client_sdk/src/examples/debugging/example.dsc b/native_client_sdk/src/examples/debugging/example.dsc index ee269db..ca6ec3b 100644 --- a/native_client_sdk/src/examples/debugging/example.dsc +++ b/native_client_sdk/src/examples/debugging/example.dsc @@ -11,7 +11,8 @@ 'untrusted_crash_dump.c', 'untrusted_crash_dump.h' ], - 'CCFLAGS': ['$(NACL_CCFLAGS)', '-fno-omit-frame-pointer'] + 'CCFLAGS': ['$(NACL_CCFLAGS)', '-fno-omit-frame-pointer'], + 'LIBS' : ['ppapi', 'pthread'] } ], 'POST': 'include Makefile.inc\n', diff --git a/native_client_sdk/src/examples/dlopen/example.dsc b/native_client_sdk/src/examples/dlopen/example.dsc index 6a75179..95491a3 100644 --- a/native_client_sdk/src/examples/dlopen/example.dsc +++ b/native_client_sdk/src/examples/dlopen/example.dsc @@ -5,14 +5,14 @@ 'NAME': 'dlopen', 'TYPE': 'main', 'SOURCES': ['dlopen.cc'], - 'LIBS': ['dl', 'ppapi_cpp'] + 'LIBS': ['dl', 'ppapi_cpp', 'ppapi', 'pthread'] }, { 'NAME' : 'libeightball', 'TYPE' : 'so', 'SOURCES' : ['eightball.cc', 'eightball.h'], 'CXXFLAGS': ['$(NACL_CXXFLAGS)', '-fPIC'], - 'LIBS' : ['ppapi_cpp'] + 'LIBS' : ['ppapi_cpp', 'ppapi', 'pthread'] } ], 'DEST': 'examples', diff --git a/native_client_sdk/src/examples/file_histogram/example.dsc b/native_client_sdk/src/examples/file_histogram/example.dsc index d0db1c3..01efa87 100644 --- a/native_client_sdk/src/examples/file_histogram/example.dsc +++ b/native_client_sdk/src/examples/file_histogram/example.dsc @@ -5,7 +5,7 @@ 'NAME' : 'file_histogram', 'TYPE' : 'main', 'SOURCES' : ['file_histogram.cc'], - 'LIBS': ['ppapi_cpp'] + 'LIBS' : ['ppapi_cpp', 'ppapi', 'pthread'] } ], 'DEST': 'examples', diff --git a/native_client_sdk/src/examples/file_io/example.dsc b/native_client_sdk/src/examples/file_io/example.dsc index 91aa02d..a1ce5d4 100644 --- a/native_client_sdk/src/examples/file_io/example.dsc +++ b/native_client_sdk/src/examples/file_io/example.dsc @@ -1,11 +1,11 @@ { - 'TOOLS': ['newlib', 'glibc', 'pnacl', 'win'], + 'TOOLS': ['newlib', 'glibc', 'pnacl'], 'TARGETS': [ { 'NAME' : 'file_io', 'TYPE' : 'main', 'SOURCES' : ['file_io.cc'], - 'LIBS': ['ppapi_cpp'] + 'LIBS' : ['ppapi_cpp', 'ppapi', 'pthread'] } ], 'DEST': 'examples', diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/example.dsc b/native_client_sdk/src/examples/fullscreen_tumbler/example.dsc index 3fc4831..3070397 100644 --- a/native_client_sdk/src/examples/fullscreen_tumbler/example.dsc +++ b/native_client_sdk/src/examples/fullscreen_tumbler/example.dsc @@ -2,9 +2,9 @@ 'TOOLS': ['newlib', 'pnacl'], 'TARGETS': [ { - 'NAME' : 'fullscreen_tumbler', - 'TYPE' : 'main', - 'SOURCES' : [ + 'NAME': 'fullscreen_tumbler', + 'TYPE': 'main', + 'SOURCES': [ 'callback.h', 'cube.cc', 'cube.h', @@ -21,7 +21,7 @@ 'tumbler.h', 'tumbler_module.cc' ], - 'LIBS': ['ppapi_cpp', 'ppapi_gles2'] + 'LIBS': ['ppapi_gles2', 'ppapi_cpp', 'ppapi', 'pthread'] } ], 'DATA': [ diff --git a/native_client_sdk/src/examples/gamepad/example.dsc b/native_client_sdk/src/examples/gamepad/example.dsc index 296ee6e..8c3da70 100644 --- a/native_client_sdk/src/examples/gamepad/example.dsc +++ b/native_client_sdk/src/examples/gamepad/example.dsc @@ -5,7 +5,7 @@ 'NAME' : 'gamepad', 'TYPE' : 'main', 'SOURCES' : ['gamepad.cc', 'gamepad_module.cc', 'gamepad.h'], - 'LIBS': ['ppapi_cpp'] + 'LIBS': ['ppapi_cpp', 'ppapi', 'pthread'] } ], 'DEST': 'examples', diff --git a/native_client_sdk/src/examples/geturl/example.dsc b/native_client_sdk/src/examples/geturl/example.dsc index fb0a230..461d5ec 100644 --- a/native_client_sdk/src/examples/geturl/example.dsc +++ b/native_client_sdk/src/examples/geturl/example.dsc @@ -5,7 +5,7 @@ 'NAME' : 'geturl', 'TYPE' : 'main', 'SOURCES' : ['geturl.cc', 'geturl_handler.cc', 'geturl_handler.h'], - 'LIBS': ['ppapi_cpp'] + 'LIBS': ['ppapi_cpp', 'ppapi', 'pthread'] } ], 'DATA': ['geturl_success.html'], diff --git a/native_client_sdk/src/examples/hello_world/example.dsc b/native_client_sdk/src/examples/hello_world/example.dsc index eba1339..6b09fde 100644 --- a/native_client_sdk/src/examples/hello_world/example.dsc +++ b/native_client_sdk/src/examples/hello_world/example.dsc @@ -5,6 +5,7 @@ 'NAME' : 'hello_world', 'TYPE' : 'main', 'SOURCES' : ['hello_world.c'], + 'LIBS': ['ppapi', 'pthread'] } ], 'DEST': 'examples', diff --git a/native_client_sdk/src/examples/hello_world_gles/example.dsc b/native_client_sdk/src/examples/hello_world_gles/example.dsc index d107ff2..1f6bda3 100644 --- a/native_client_sdk/src/examples/hello_world_gles/example.dsc +++ b/native_client_sdk/src/examples/hello_world_gles/example.dsc @@ -10,7 +10,7 @@ '-I../../src', '-I../../src/ppapi/lib/gl' ], - 'LIBS': ['ppapi_gles2'] + 'LIBS': ['ppapi_gles2', 'ppapi', 'pthread'] } ], 'DATA': [ diff --git a/native_client_sdk/src/examples/hello_world_interactive/example.dsc b/native_client_sdk/src/examples/hello_world_interactive/example.dsc index 690f344..0da0829 100644 --- a/native_client_sdk/src/examples/hello_world_interactive/example.dsc +++ b/native_client_sdk/src/examples/hello_world_interactive/example.dsc @@ -9,7 +9,7 @@ 'helper_functions.cc', 'helper_functions.h' ], - 'LIBS': ['ppapi_cpp'] + 'LIBS': ['ppapi_cpp', 'ppapi', 'pthread'] } ], 'DEST': 'examples', diff --git a/native_client_sdk/src/examples/input_events/example.dsc b/native_client_sdk/src/examples/input_events/example.dsc index 3d52ba3..822e4fe 100644 --- a/native_client_sdk/src/examples/input_events/example.dsc +++ b/native_client_sdk/src/examples/input_events/example.dsc @@ -5,7 +5,7 @@ 'NAME' : 'input_events', 'TYPE' : 'main', 'SOURCES' : ['input_events.cc'], - 'LIBS': ['ppapi_cpp'] + 'LIBS': ['ppapi_cpp', 'ppapi', 'pthread'] } ], 'DEST': 'examples', diff --git a/native_client_sdk/src/examples/load_progress/example.dsc b/native_client_sdk/src/examples/load_progress/example.dsc index 8474d98..cb23231 100644 --- a/native_client_sdk/src/examples/load_progress/example.dsc +++ b/native_client_sdk/src/examples/load_progress/example.dsc @@ -5,7 +5,7 @@ 'NAME' : 'load_progress', 'TYPE' : 'main', 'SOURCES' : ['load_progress.cc'], - 'LIBS': ['ppapi_cpp'] + 'LIBS': ['ppapi_cpp', 'ppapi', 'pthread'] } ], 'DATA': ['check_browser.js'], diff --git a/native_client_sdk/src/examples/mouselock/example.dsc b/native_client_sdk/src/examples/mouselock/example.dsc index d9c42e9..4add2cd 100644 --- a/native_client_sdk/src/examples/mouselock/example.dsc +++ b/native_client_sdk/src/examples/mouselock/example.dsc @@ -5,7 +5,7 @@ 'NAME' : 'mouselock', 'TYPE' : 'main', 'SOURCES' : ['mouselock.cc', 'mouselock.h'], - 'LIBS': ['ppapi_cpp'] + 'LIBS': ['ppapi_cpp', 'ppapi', 'pthread'] } ], 'DATA': ['check_browser.js'], diff --git a/native_client_sdk/src/examples/multithreaded_input_events/example.dsc b/native_client_sdk/src/examples/multithreaded_input_events/example.dsc index 5b9bc17..4b7cfd1 100644 --- a/native_client_sdk/src/examples/multithreaded_input_events/example.dsc +++ b/native_client_sdk/src/examples/multithreaded_input_events/example.dsc @@ -10,7 +10,7 @@ 'mt_input_events.cc', 'shared_queue.h', ], - 'LIBS': ['ppapi_cpp'] + 'LIBS': ['ppapi_cpp', 'ppapi', 'pthread'] } ], 'DEST': 'examples', diff --git a/native_client_sdk/src/examples/pi_generator/example.dsc b/native_client_sdk/src/examples/pi_generator/example.dsc index 3297a63..4bf2ede 100644 --- a/native_client_sdk/src/examples/pi_generator/example.dsc +++ b/native_client_sdk/src/examples/pi_generator/example.dsc @@ -9,7 +9,7 @@ 'pi_generator.h', 'pi_generator_module.cc' ], - 'LIBS': ['ppapi_cpp'] + 'LIBS': ['ppapi_cpp', 'ppapi', 'pthread'] } ], 'DEST': 'examples', diff --git a/native_client_sdk/src/examples/pong/example.dsc b/native_client_sdk/src/examples/pong/example.dsc index 26a5232..079e079 100644 --- a/native_client_sdk/src/examples/pong/example.dsc +++ b/native_client_sdk/src/examples/pong/example.dsc @@ -11,7 +11,7 @@ 'view.cc', 'view.h', ], - 'LIBS': ['ppapi_cpp'] + 'LIBS': ['ppapi_cpp', 'ppapi', 'pthread'] } ], 'DEST': 'examples', diff --git a/native_client_sdk/src/examples/sine_synth/example.dsc b/native_client_sdk/src/examples/sine_synth/example.dsc index 4ee3881..b3f7da9 100644 --- a/native_client_sdk/src/examples/sine_synth/example.dsc +++ b/native_client_sdk/src/examples/sine_synth/example.dsc @@ -5,7 +5,7 @@ 'NAME' : 'sine_synth', 'TYPE' : 'main', 'SOURCES' : ['sine_synth.cc'], - 'LIBS': ['ppapi_cpp'] + 'LIBS': ['ppapi_cpp', 'ppapi', 'pthread'] } ], 'DEST': 'examples', diff --git a/native_client_sdk/src/examples/tumbler/example.dsc b/native_client_sdk/src/examples/tumbler/example.dsc index 90b2b7b..a5aafc9 100644 --- a/native_client_sdk/src/examples/tumbler/example.dsc +++ b/native_client_sdk/src/examples/tumbler/example.dsc @@ -21,7 +21,7 @@ 'tumbler.h', 'tumbler_module.cc' ], - 'LIBS': ['ppapi_cpp', 'ppapi_gles2'] + 'LIBS': ['ppapi_gles2', 'ppapi_cpp', 'ppapi', 'pthread'] } ], 'DATA': [ diff --git a/native_client_sdk/src/examples/websocket/example.dsc b/native_client_sdk/src/examples/websocket/example.dsc index 72fbf7c..27fa8e6 100644 --- a/native_client_sdk/src/examples/websocket/example.dsc +++ b/native_client_sdk/src/examples/websocket/example.dsc @@ -5,7 +5,7 @@ 'NAME' : 'websocket', 'TYPE' : 'main', 'SOURCES' : ['websocket.cc'], - 'LIBS': ['ppapi_cpp'] + 'LIBS': ['ppapi_cpp', 'ppapi'] } ], 'DEST': 'examples', diff --git a/native_client_sdk/src/libraries/ppapi/library.dsc b/native_client_sdk/src/libraries/ppapi/library.dsc new file mode 100644 index 0000000..04979cc --- /dev/null +++ b/native_client_sdk/src/libraries/ppapi/library.dsc @@ -0,0 +1,15 @@ +{ + 'TOOLS': ['win'], + 'TARGETS': [ + { + 'NAME' : 'ppapi', + 'TYPE' : 'lib', + 'SOURCES' : [ + 'ppapi_externs.c' + ], + } + ], + 'DEST': 'src', + 'NAME': 'ppapi', +} + diff --git a/native_client_sdk/src/libraries/ppapi/ppapi_externs.c b/native_client_sdk/src/libraries/ppapi/ppapi_externs.c new file mode 100644 index 0000000..b082244 --- /dev/null +++ b/native_client_sdk/src/libraries/ppapi/ppapi_externs.c @@ -0,0 +1,4 @@ +#include "ppapi/c/ppp.h" + +/* Add a global symbol to force the linker to generate a LIB. */ +const char *g_BogusSymbol; diff --git a/native_client_sdk/src/libraries/pthread/library.dsc b/native_client_sdk/src/libraries/pthread/library.dsc new file mode 100644 index 0000000..9f649ea --- /dev/null +++ b/native_client_sdk/src/libraries/pthread/library.dsc @@ -0,0 +1,16 @@ +{ + 'TOOLS': ['win'], + 'TARGETS': [ + { + 'NAME' : 'pthread', + 'TYPE' : 'lib', + 'SOURCES' : [ + 'pthread.c', + 'pthread.h' + ], + } + ], + 'DEST': 'src', + 'NAME': 'pthread', +} + diff --git a/native_client_sdk/src/libraries/pthread/pthread.c b/native_client_sdk/src/libraries/pthread/pthread.c new file mode 100644 index 0000000..68f4fc2 --- /dev/null +++ b/native_client_sdk/src/libraries/pthread/pthread.c @@ -0,0 +1,43 @@ +/* Copyright (c) 2012 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include <windows.h> +#include <errno.h> +#include "pthread.h" + +int pthread_mutex_init(pthread_mutex_t* m, void* traits) { + *m = (int) CreateMutex(NULL, 0, NULL); + return 0; +} + +int pthread_mutex_destroy(pthread_mutex_t* m) { + CloseHandle((HANDLE) *m); + return 0; +} + +int pthread_mutex_lock(pthread_mutex_t* m) { + if (WaitForSingleObject((HANDLE) *m, INFINITE) == WAIT_OBJECT_0) + return 0; + + return EINVAL; +} + +int pthread_mutex_unlock(pthread_mutex_t* m) { + if (ReleaseMutex((HANDLE) *m)) return 0; + + return EINVAL; +} + +int pthread_mutex_trylock(pthread_mutex_t* m) { + int val = WaitForSingleObject((HANDLE) *m, 0); + + if (val == WAIT_OBJECT_0) return 0; + + if (val == WAIT_TIMEOUT) { + errno = EBUSY; + } else { + errno = EINVAL; + } + return -1; +}
\ No newline at end of file diff --git a/native_client_sdk/src/libraries/pthread/pthread.h b/native_client_sdk/src/libraries/pthread/pthread.h new file mode 100644 index 0000000..6647861 --- /dev/null +++ b/native_client_sdk/src/libraries/pthread/pthread.h @@ -0,0 +1,29 @@ +/* Copyright (c) 2012 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef LIBRARIES_PTHREAD_PTHREAD_H_ +#define LIBRARIES_PTHREAD_PTHREAD_H_ + +/** +* Implementation of pthread.h for building the SDK natively on Windows. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int pthread_mutex_t; + +int pthread_mutex_init(pthread_mutex_t* m, void* traits); +int pthread_mutex_destroy(pthread_mutex_t* m); + +int pthread_mutex_lock(pthread_mutex_t* m); +int pthread_mutex_unlock(pthread_mutex_t* m); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBRARIES_PTHREAD_PTHREAD_H_ */
\ No newline at end of file |