1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
# -*- python -*-
# Copyright (c) 2011 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.
# TODO(polina): for Mac build check if no longer need .r files and/or document
# target browsers for each bundle target.
Import('env')
if not env.Bit('mac'):
env['COMPONENT_STATIC'] = False
plugin_env = env.Clone()
if env.Bit('linux'):
plugin_env.Append(
CCFLAGS=['-fPIC', '-Wno-long-long',],
CPPDEFINES = ['XP_UNIX', 'MOZ_X11'],
)
if not env.Bit('asan'):
plugin_env.Append(
# Catch unresolved symbols in libraries.
LINKFLAGS=['-Wl,-z,defs'],
)
# We usually try to build things statically, but the plugin is a .so
plugin_env.FilterOut(LINKFLAGS=['-static'])
if env.Bit('mac'):
plugin_env.Append(
CCFLAGS=['-Wno-long-long',
# warning: Basically all of our 2d Mac stuff is deprecated.
'-Wno-deprecated',
'-Wno-deprecated-declarations'],
CPPDEFINES = [
'XP_MACOSX',
'XP_UNIX',
['TARGET_API_MAC_CARBON', '1'],
# TODO(robertm): NO_X11 may be obsolete
'NO_X11',
'USE_SYSTEM_CONSOLE',
],
FRAMEWORKS = ['Carbon'],
# TODO(jrg): it's a little awkward to, when you want a bundle:
# 1) add -bundle to your LINKFLAGS
# 2) create a "program" (which shows up in all_programs target)
# 3) create a bundle out of it, specifying the bundle extension
# Ideally that all happens inside a CompleteBundlePseudoBuilder().
LINKFLAGS = ['-bundle', '-framework', 'Foundation']
)
if env.Bit('windows'):
plugin_env.Append(
CPPDEFINES = ['XP_WIN', 'WIN32', '_WINDOWS'],
)
common_inputs = [
'file_downloader.cc',
'json_manifest.cc',
'module_ppapi.cc',
'nacl_subprocess.cc',
'nexe_arch.cc',
'plugin.cc',
'pnacl_coordinator.cc',
'pnacl_resources.cc',
'scriptable_plugin.cc',
'sel_ldr_launcher_chrome.cc',
'service_runtime.cc',
'srpc_client.cc',
'srpc_params.cc',
'utility.cc',
]
if env.Bit('target_x86'):
common_inputs += ['arch_x86/sandbox_isa.cc']
elif env.Bit('target_arm'):
common_inputs += ['arch_arm/sandbox_isa.cc']
else:
# Unrecognized architecture - this is a build failure.
print "Unrecognized architecture: %s" % env['TARGET_ARCHITECTURE']
Return()
# The libraries used by both the PPAPI plugin. They and the PPAPI specific
# libraries must come before OS libraries, because they may generate references
# that are resolved by the OS libraries. E.g., libplatform.a contains
# references to symbols from libcrypto.so.
common_libs = [
'nonnacl_util',
'nonnacl_srpc',
'gio_wrapped_desc',
'nrd_xfer',
'nacl_perf_counter',
'nacl_base',
'imc',
'weak_ref',
'platform',
'platform_qual_lib',
'reverse_service',
'gio',
'jsoncpp',
'sel',
'simple_service',
'thread_interface',
'env_cleanser',
'nacl_error_code',
]
os_libs = [ ]
if plugin_env.Bit('linux'):
os_libs += ['dl', 'crypto']
if plugin_env.Bit('windows'):
os_libs += ['gdi32', 'user32', ]
###############################################################################
# PPAPI Plugin Build
###############################################################################
# We build a shared library with this build script to allow easier build
# testing. This library can also be loaded into Chrome using --no-sandbox
# --register-pepper-plugins="path/to/library;application/x-nacl".
#
# The .gyp files include rules used to link the plugin statically into Chrome.
# (This is still work in progress as of mid-Nov 2010.)
#
ppNaClPlugin = 'ppNaClPlugin'
ppapi_libs = common_libs + [ 'ppapi_cpp', 'ppapi_browser', 'nonnacl_srpc' ]
if plugin_env['SHARED_LIBS_SPECIAL']:
plugin_env.Append(LIBS=[l + '_shared' for l in ppapi_libs] + os_libs)
else:
plugin_env.Append(LIBS=ppapi_libs + os_libs)
if not env.Bit('mac'): # linux, windows, arm
# This builds with
# MODE=... ppNaClPlugin sel_ldr
# with the output going to
# scons-out/.../staging/libppNaClPlugin.so on Linux and
# scons-out/.../staging/ppNaClPlugin.dll on Windows.
ppapi_plugin = plugin_env.ComponentLibrary(ppNaClPlugin,
common_inputs,
no_import_lib=True)
else: # mac
# This builds with
# MODE=... scons-out/.../staging/ppNaClPlugin.bundle sel_ldr
# This places both ppNaClPlugin.bundle/ and sel_ldr into staging/.
# One must either set $NACL_SEL_LDR=path/to/sel_ldr or manually
# copy sel_ldr to path/to/ppNaClPlugin.bundle/Contents/Resources/.
# (the 2nd option has been disabled:
# see ../nonnacl_util/osx/get_plugin_dirname.mm).
REZ = '/Developer/Tools/Rez'
plugin_env.Command(target='ppNaClPlugin.rsrc',
source='osx_ppapi/ppNaClPlugin.r',
action=[Action(REZ + ' -o ${TARGET} ${SOURCE} -useDF')])
ppapi_plugin = plugin_env.ComponentProgram(ppNaClPlugin,
common_inputs,
no_import_lib=True)
# Bundle pattern can be found in
# site_scons/site_tools/target_platform_mac.py
bundle_name = '${STAGING_DIR}/' + ppNaClPlugin + '.bundle'
plugin_env.Bundle(bundle_name,
BUNDLE_EXE = ppapi_plugin,
BUNDLE_PKGINFO_FILENAME = 0,
BUNDLE_RESOURCES = 'ppNaClPlugin.rsrc',
BUNDLE_INFO_PLIST = 'osx_ppapi/Info.plist')
plugin_env.Alias('plugin', plugin_env.GetPPAPIPluginPath(False))
if env.Bit('windows'):
env.SDKInstallBin(ppNaClPlugin + '.dll', ppapi_plugin)
else:
env.SDKInstallBin(ppNaClPlugin + '.so', ppapi_plugin)
###############################################################################
# PPAPI Plugin Test
###############################################################################
# Rather than link ppNaClPlugin statically, this unittest uses the dynamic
# library. Note that these tests do not yet run on ARM.
unittest_sources = ['dylib_unittest.cc', 'plugin_unittest.cc']
if env.Bit('target_x86'):
if env.Bit('linux'):
unittest = env.ComponentProgram('ppapi_plugin_unittest',
unittest_sources,
no_import_lib=True,
EXTRA_LIBS=['dl'])
elif env.Bit('mac'):
unittest = env.ComponentProgram('ppapi_plugin_unittest', unittest_sources)
elif env.Bit('windows'):
unittest = env.ComponentProgram('ppapi_plugin_unittest',
unittest_sources,
no_import_lib=True)
node = env.CommandTest('ppapi_plugin_unittest.out',
command=[unittest,
ppapi_plugin,
env['BUILD_ISA_NAME']])
env.AddNodeToTestSuite(node, ['small_tests'], 'run_ppapi_plugin_unittest')
# TODO(polina,sehr): add a test for the PPAPI plugin on ARM.
|