Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: plugin/build.scons

Issue 354011: This change kills the SCons build, since we have switched completely... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/o3d/
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « nbguidgen/build.scons ('k') | plugin/idl_list.scons » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2009, Google Inc.
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7 #
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
13 # distribution.
14 # * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30
31 import os.path
32 import sys
33 Import('env')
34 env.SConscript('$SCONSTRUCT_DIR/plugin/idl_list.scons')
35 Import('O3D_IDL_SOURCES')
36
37 env.Tool('replace_strings')
38 env.Append(O3D_PLUGIN_DESCRIPTION=
39 '$O3D_PLUGIN_NAME version:$O3D_PLUGIN_VERSION',
40 O3D_PLUGIN_MIME_TYPE='application/vnd.o3d.auto')
41
42 plugin_replace_strings = [
43 ('@@@PluginName@@@', env.subst('$O3D_PLUGIN_NAME')),
44 ('@@@ProductVersionCommas@@@',
45 env.subst('$O3D_PLUGIN_VERSION_COMMAS')),
46 ('@@@ProductVersion@@@', env.subst('$O3D_PLUGIN_VERSION')),
47 ('@@@PluginDescription@@@', env.subst('$O3D_PLUGIN_DESCRIPTION')),
48 ('@@@PluginMimeType@@@', env.subst('$O3D_PLUGIN_MIME_TYPE')),
49 ]
50
51 # TODO: collapse these if possible.
52 env.Append(GLUE_DIR = env.Dir('glue'),
53 NIXYSA_STATIC_GLUE = '$NIXYSA_DIR/static_glue/npapi')
54
55 if env.Bit('windows'):
56 testing_inputs = [
57 'win/plugin_metrics-win32.cc',
58 'win/plugin_logging-win32.cc',
59 ]
60 elif env.Bit('mac'):
61 testing_inputs = [
62 'mac/plugin_metrics-mac.cc',
63 'mac/plugin_logging-mac.mm',
64 ]
65
66 # Add Skia include paths
67 env.Append(CPPPATH=['$SKIA_DIR/include/core',
68 '$SKIA_DIR/include/effects'])
69
70 # Build a library for testing.
71 # Currently windows and mac.
72 if env.Bit('windows') or env.Bit('mac'):
73 logging_lib = env.ComponentLibrary('o3dPlugin_logging', testing_inputs)
74
75 # vista SDK provides an incompatible version of npapi.h, so make sure we
76 # prepend our blessed version.
77 env.Prepend(CPPPATH = ['$NPAPI_DIR/include'])
78 env.Append(
79 CPPPATH = [
80 'cross',
81 '$GLUE_DIR',
82 '$NIXYSA_STATIC_GLUE',
83 '$SCONSTRUCT_DIR/plugin/win', # for RES resource.h
84 '$WTL_71_DIR/include',
85 '$THIRD_PARTY',
86 ],
87 LIBPATH = [
88 '$NACL_LIB_DIR',
89 ],
90 LIBS = [
91 # 'o3dBreakpad',
92 'o3dArchive',
93 'o3dCore',
94 'o3dArchive',
95 'o3dCorePlatform',
96 'o3dUtils',
97 'google_nacl_imc',
98 'o3d_base',
99 'v8',
100 'skia',
101 ],
102 )
103
104
105 if env.Bit('windows'):
106 env.Append(
107 LIBS = [
108 'advapi32',
109 'o3dBreakpad',
110 'o3dStatsreport_Common',
111 'o3dStatsreport',
112 'shell32',
113 'shlwapi',
114 ],
115 CPPDEFINES = ['XP_WIN']
116 )
117
118
119
120 if env.Bit('mac'):
121 if env['DEBUG']:
122 env['MAC_BREAKPAD_CONFIG'] = 'Debug'
123 else:
124 env['MAC_BREAKPAD_CONFIG'] = 'Release'
125 env.Append(
126 MAC_BREAKPAD_SRC_DIR = '$BREAKPAD_DIR/client/mac',
127 # TODO: is there a way to tell xcodebuild to output the build in
128 # scons-out instead of the source tree ?
129 MAC_BREAKPAD_DIR = '$MAC_BREAKPAD_SRC_DIR/build/$MAC_BREAKPAD_CONFIG',
130 LIBS = [
131 'o3dStatsreport_Common',
132 'o3dStatsreport',
133 'event',
134 logging_lib,
135 ],
136 FRAMEWORKS = [
137 'Carbon',
138 'OpenGL',
139 'Cg',
140 'AGL',
141 'Foundation',
142 'Breakpad',
143 'Cocoa',
144 'IOKit',
145 'QuickTime',
146 ],
147 CCFLAGS = ['-F$MAC_BREAKPAD_DIR',
148 '-F$CG_DIR'],
149 CPPPATH = ['mac', '$MAC_BREAKPAD_SRC_DIR/Framework'],
150 CPPDEFINES = ['XP_MACOSX']
151 )
152
153 if env.Bit('linux'):
154 env.Append(
155 CPPDEFINES = ['XP_UNIX', 'MOZ_X11'],
156 LIBS = [
157 'event',
158 ],
159 );
160
161 # Add libraries based on the requested renderer
162 env.Append(CPPPATH = env['RENDERER_INCLUDE_PATH'],
163 LIBPATH = env['RENDERER_LIB_PATH'],
164 LIBS = env['RENDERER_LIBS'] + env['ICU_LIBS'])
165
166
167 def NixysaEmitter(target, source, env):
168 bases = [os.path.splitext(s.name)[0] for s in source] + ['globals']
169 targets = ['glue/%s_glue.cc' % b for b in bases]
170 targets += ['glue/%s_glue.h' % b for b in bases]
171 return targets, source
172
173 AUTOGEN_ARGS = ['$NIXYSA_DIR/codegen.py',
174 '--binding-module=o3d:plugin/o3d_binding.py',
175 '--generate=npapi',
176 '--output-dir=$GLUE_DIR',
177 '$SOURCES']
178
179 env['PYTHONPATH'] = ['$NIXYSA_DIR',
180 '$GFLAGS_DIR/python',
181 '$PLY_DIR']
182 env['BUILDERS']['Nixysa'] = Builder(action=env.Python(AUTOGEN_ARGS),
183 emitter=NixysaEmitter)
184 AUTOGEN_OUTPUT = env.Nixysa(O3D_IDL_SOURCES)
185 env.SideEffect('glue/hash', AUTOGEN_OUTPUT)
186 AUTOGEN_CC_FILES = [f for f in AUTOGEN_OUTPUT if f.suffix == '.cc']
187
188 inputs = AUTOGEN_CC_FILES + [
189 'cross/async_loading.cc',
190 'cross/archive_request_static_glue.cc',
191 'cross/blacklist.cc',
192 'cross/main_thread_task_poster.cc',
193 'cross/o3d_glue.cc',
194 'cross/np_v8_bridge.cc',
195 'cross/out_of_memory.cc',
196 'cross/stream_manager.cc',
197 'cross/texture_static_glue.cc',
198 'cross/config_common.cc',
199 ]
200
201 env_version = env.Clone()
202 env_version.Append(
203 CPPDEFINES = [
204 ('O3D_PLUGIN_NAME', '\\"$O3D_PLUGIN_NAME\\"'),
205 ('O3D_PLUGIN_DESCRIPTION', '\\"$O3D_PLUGIN_DESCRIPTION\\"'),
206 ('O3D_PLUGIN_MIME_TYPE', '\\"$O3D_PLUGIN_MIME_TYPE\\"')
207 ])
208
209 idlglue_static_sources = [
210 'common',
211 'static_object',
212 'npn_api',
213 ]
214 env_idlglue = env.Clone()
215
216 # TODO: figure out resources on the mac.
217 if env.Bit('windows'):
218 env.ReplaceStrings(
219 'win/o3dPlugin.rc', 'win/o3dPlugin.rc_template',
220 REPLACE_STRINGS = plugin_replace_strings
221 )
222 if env['DEBUG']:
223 # release v8 brings libcmt that conflicts with libcmtd
224 env.Append(LINKFLAGS=['/NODEFAULTLIB:LIBCMT'])
225 env_idlglue.Append(CPPDEFINES=['OS_WINDOWS'])
226 inputs += [env_idlglue.ComponentObject(s, '$NIXYSA_STATIC_GLUE/%s.cc' % s)
227 for s in idlglue_static_sources]
228 inputs += env_version.ComponentObject('cross/main', 'cross/main.cc')
229 inputs += [
230 logging_lib,
231 'win/main_win.cc',
232 'win/config.cc',
233 'win/o3dPlugin.def',
234 'win/update_lock.cc',
235 env.RES('win/o3dPlugin.rc'),
236 ]
237
238
239 if env.Bit('linux'):
240 env_idlglue.Append(CPPDEFINES=['OS_LINUX'])
241 inputs += [env_idlglue.SharedObject(s, '$NIXYSA_STATIC_GLUE/%s.cc' % s)
242 for s in idlglue_static_sources]
243 inputs += env_version.SharedObject('cross/main', 'cross/main.cc')
244 inputs += [
245 'linux/main_linux.cc',
246 'linux/config.cc',
247 ]
248 # This sets the rpath property on the generated shared object, which specifies
249 # additional paths that the run-time linker/loader will search for its
250 # dependent shared libraries. We install libGLEW, libCg, and libCgGL to here.
251 env.Append(RPATH=['/opt/google/o3d/lib'])
252
253
254 # SCons doesn't really know about MacOSX bundles, so we need to override a
255 # lot of its behavior to make one, ie -bundle flag, no lib prefix, no .dylib suf fix.
256 if env.Bit('mac'):
257 breakpad_framework = env.Command(
258 env.Dir('$MAC_BREAKPAD_DIR/Breakpad.framework'),
259 env.Dir('$MAC_BREAKPAD_SRC_DIR/Breakpad.xcodeproj'),
260 ' '.join(['cd $MAC_BREAKPAD_SRC_DIR &&',
261 'xcodebuild',
262 '-project Breakpad.xcodeproj',
263 '-target Breakpad',
264 '-configuration $MAC_BREAKPAD_CONFIG']))
265 plugin_mac_object = env.SharedObject('mac/plugin_mac', 'mac/plugin_mac.mm')
266 env.Requires(plugin_mac_object, breakpad_framework)
267
268 env_idlglue.Append(CPPDEFINES=['OS_MACOSX'])
269 inputs += [env_idlglue.SharedObject(s, '$NIXYSA_STATIC_GLUE/%s.cc' % s)
270 for s in idlglue_static_sources]
271 inputs += env_version.SharedObject('cross/main', 'cross/main.cc')
272 inputs += [
273 'mac/main_mac.mm',
274 'mac/config_mac.mm',
275 'mac/graphics_utils_mac.mm',
276 plugin_mac_object
277 ]
278
279 env['SHLINKFLAGS'] = ['-bundle',
280 '-F$MAC_BREAKPAD_DIR',
281 '-F$CG_DIR',
282 ]
283 env['SHLIBPREFIX'] = ['']
284 env['SHLIBSUFFIX'] = ['']
285 plugin_dll = env.SharedLibrary('O3D', inputs)
286 plugin_artifacts = env.Replicate('$ARTIFACTS_DIR/O3D.plugin/Contents/MacOS/', plugin_dll)
287
288 # insert version number into Info.plist
289 env.ReplaceStrings(
290 'mac/processed/Info.plist', '$SCONSTRUCT_DIR/plugin/mac/Info.plist',
291 REPLACE_STRINGS = plugin_replace_strings
292 )
293
294 # copy mac resource data
295 env.Replicate('$ARTIFACTS_DIR/O3D.plugin/Contents/',
296 '$SCONSTRUCT_DIR/plugin/mac/Resources')
297 env.Replicate('$ARTIFACTS_DIR/O3D.plugin/Contents',
298 'mac/processed/Info.plist')
299
300 # Make a string substituted version of o3d_plugin.r in the artifacts
301 # directory.
302 env.ReplaceStrings(
303 '$ARTIFACTS_DIR/o3d_plugin.r', 'mac/o3d_plugin.r',
304 REPLACE_STRINGS = plugin_replace_strings
305 )
306 # Compile the string substituted o3d_plugin.r to make O3D.rsrc
307 env.Command('$ARTIFACTS_DIR/O3D.plugin/Contents/Resources/O3D.rsrc',
308 ['$ARTIFACTS_DIR/o3d_plugin.r'],
309 [
310 'Rez -useDF "$ARTIFACTS_DIR/o3d_plugin.r" -o "$ARTIFACTS_DIR/O3D.pl ugin/Contents/Resources/O3D.rsrc"'
311 ])
312
313 if env['DEBUG']:
314 stripCmd = 'echo debug build, no strip'
315 else:
316 stripCmd = 'strip -S "$ARTIFACTS_DIR/O3D.plugin/Contents/MacOS/O3D"'
317
318 # Cleanup end result
319 created_installer = env.Command('$ARTIFACTS_DIR/plugin_done',
320 [env.Dir('$ARTIFACTS_DIR/O3D.plugin')],
321 [
322 'xcodebuild -project installer/mac/O3D_Stats/O3D_Stats.xcodeproj - configuration Release',
323 'ditto "$SCONSTRUCT_DIR/installer/mac/O3D_Stats/build/Release/O3D_ Stats.bundle" "$ARTIFACTS_DIR/O3D_Stats.bundle"',
324 # Because the frameworks are inside a plugin bundle (not applicati on bundle) the plugin executable needs to be
325 # tweaked to reference their paths via @loader_path instead of @ex ecutable_path.
326 '$SCONSTRUCT_DIR/plugin/mac/Tools/fix_install_names.sh $ARTIFACTS_ DIR/O3D.plugin/Contents/MacOS/O3D',
327
328 # make a copy of the executable, before we strip all the symbols
329 'rm -f "$ARTIFACTS_DIR/O3D"',
330 'cp -f "$ARTIFACTS_DIR/O3D.plugin/Contents/MacOS/O3D" "$ARTIFACTS_ DIR/O3D"',
331 stripCmd,
332 # Delete frameworks so we start fresh, and ditto can't get confuse d
333 Delete("$ARTIFACTS_DIR/O3D.plugin/Contents/Frameworks/"),
334 # Use ditto, not Replicate() as Replicate mangles the symlinks.
335 # The use of ditto also lets us strip the frameworks down to just i386, which saves a lot of space.
336 'ditto --arch i386 "$MAC_BREAKPAD_DIR/Breakpad.framework" "$ARTIFA CTS_DIR/O3D.plugin/Contents/Frameworks/Breakpad.framework"',
337 '/usr/bin/install_name_tool -change '
338 '@executable_path/../Frameworks/Breakpad.framework/Resources/break padUtilities.dylib '
339 '@loader_path/Resources/breakpadUtilities.dylib '
340 '"$ARTIFACTS_DIR/O3D.plugin/Contents/Frameworks/Breakpad.framework /Breakpad"',
341 'ditto --arch i386 "$CG_DIR/Cg.framework" "$ARTIFACTS_DIR/O3D.plug in/Contents/Frameworks/Cg.framework"',
342 # Delete private frameworks headers.
343 'find "$ARTIFACTS_DIR/O3D.plugin/Contents/Frameworks" -iname "*.h" -delete',
344 'find "$ARTIFACTS_DIR/O3D.plugin/Contents/Frameworks" -iname "Head ers" -type l -delete',
345 'find "$ARTIFACTS_DIR/O3D.plugin/Contents/Frameworks" -iname "Head ers" -type d -prune -delete',
346 Touch("$ARTIFACTS_DIR/O3D.plugin/"),
347 Touch('$ARTIFACTS_DIR/plugin_done')
348 ])
349
350 # Upload crash symbols to crash server.
351 if int(ARGUMENTS.get('O3D_ENABLE_BREAKPAD', 0)):
352 env.Command('$ARTIFACTS_DIR/O3D.sym.breakpad',
353 created_installer,
354 ['echo "UPLOADING SYMBOLS TO go/crash"',
355 ' '.join(['"$MAC_BREAKPAD_PREBUILT_DIR/dump_syms"',
356 '"$ARTIFACTS_DIR/O3D"',
357 '> $ARTIFACTS_DIR/O3D.sym.breakpad']),
358 ' '.join(['"$MAC_BREAKPAD_PREBUILT_DIR/symupload"',
359 '"$ARTIFACTS_DIR/O3D.sym.breakpad"',
360 'http://crash-symbols:3842/upload'])
361 ])
362
363 env['MAC_INSTALLER_DIR'] = env['SCONSTRUCT_DIR'] + '/../o3d-internal/mac_insta ller'
364 env['MAC_INSTALLER_PROJECT'] = 'o3d.packproj'
365 # Default is to make the installer.
366 make_installer = int(ARGUMENTS.get('MAKE_INSTALLER', 1)) and os.path.exists(en v['MAC_INSTALLER_DIR'] + '/' + env['MAC_INSTALLER_PROJECT'])
367
368
369 if make_installer:
370 env.ReplaceStrings(
371 "$ARTIFACTS_DIR/postflight.sh", '$MAC_INSTALLER_DIR/postflight.sh',
372 REPLACE_STRINGS = plugin_replace_strings
373 )
374 if int(ARGUMENTS.get('MAC_KILLSWITCH', 0)):
375 kill_command = 'rm "$ARTIFACTS_DIR/O3D.plugin/Contents/MacOS/O3D"'
376 else:
377 kill_command = 'echo normal binary'
378 # Cleanup end result and build the installer
379 env.Command(env.Dir('$ARTIFACTS_DIR/O3D.mpkg'),
380 [
381 "$ARTIFACTS_DIR/plugin_done",
382 "$ARTIFACTS_DIR/postflight.sh",
383 ],
384 [
385 # Delete first as Copy can fail to overwrite if the packproj is locked
386 Delete("$ARTIFACTS_DIR/$MAC_INSTALLER_PROJECT"),
387 # Copy installer project file into artifacts so it can operate o n files local to own directory
388 # and so work on debug or release builds without change.
389 Copy("$ARTIFACTS_DIR/$MAC_INSTALLER_PROJECT",
390 '$MAC_INSTALLER_DIR/$MAC_INSTALLER_PROJECT'),
391 'ditto "$MAC_INSTALLER_DIR/GoogleSoftwareUpdate.pkg" "$ARTIFACT S_DIR/GoogleSoftwareUpdate.pkg"',
392 # Make the installer.
393 kill_command,
394 'freeze "$ARTIFACTS_DIR/$MAC_INSTALLER_PROJECT"',
395 # Delete temp files in artifacts now we are done.
396 Delete("$ARTIFACTS_DIR/$MAC_INSTALLER_PROJECT")
397 ])
398
399 env.Command('$ARTIFACTS_DIR/o3d.dmg',
400 [
401 env.Dir('$ARTIFACTS_DIR/O3D.mpkg'),
402 ],
403 [
404 Delete("$ARTIFACTS_DIR/DMG_SRC"),
405 'mkdir "$ARTIFACTS_DIR/DMG_SRC"',
406 'cp "$MAC_INSTALLER_DIR/.keystone_install" "$ARTIFACTS_DIR/DMG_SRC "',
407 'ditto "$ARTIFACTS_DIR/O3D.mpkg" "$ARTIFACTS_DIR/DMG_SRC/O3D.mpkg" ',
408 'hdiutil create -srcfolder "$ARTIFACTS_DIR/DMG_SRC" -size 30mb -ov -fs HFS+ -imagekey zlib-level=9 -volname "O3D $O3D_PLUGIN_VERSION" "$ARTIFACTS_ DIR/o3d.dmg"',
409 Delete("$ARTIFACTS_DIR/DMG_SRC"),
410 ])
411
412
413 # else build the shared library in a platform independent way
414 else:
415 plugin_dll = env.SharedLibrary('npo3dautoplugin', inputs)
416 # copy to artifacts
417 plugin_artifacts = env.Replicate('$ARTIFACTS_DIR', plugin_dll)
418
419 if env.Bit('linux'):
420 env.Requires(plugin_artifacts, env.Replicate(
421 '$ARTIFACTS_DIR', [
422 '$CG_DIR/lib/libCg.so',
423 '$CG_DIR/lib/libCgGL.so',
424 '$GLEW_DIR/lib/libGLEW.so.1.5',
425 ]
426 ))
427
428
429 # alias 'plugin' to build the plug-in in artifacts
430 env.Alias('plugin', plugin_artifacts)
431
432 # TODO: have a common way to do colliding installs like this.
433 # Do the install step only if this variant is the first target.
434 if (env['BUILD_TYPE'] == ARGUMENTS.get('MODE') or
435 (ARGUMENTS.get('MODE', 'default') == 'default' and
436 env['BUILD_TYPE'] == 'dbg-d3d')):
437 plugin_install = env.Replicate('$FIREFOX_PLUGIN_DIR', plugin_dll[0])
438 env.Alias('install', plugin_install)
439
440 if env.Bit('windows'):
441 # Copy SwiftShader to plugin dir.
442 swiftshader_path = env.subst('$SWIFTSHADER_DIR/swiftshader_d3d9.dll')
443 if os.path.exists(swiftshader_path):
444 env.Requires(plugin_install,
445 env.Replicate('$FIREFOX_PLUGIN_DIR/O3DExtras', swiftshader_path))
446
447 if env.Bit('windows'):
448 # Make the logging program
449 exe = env.ComponentProgram('statsLogger',
450 logging_lib + ['win/logger_main.cc'])
451 # Copy the resulting executable to the Artifacts directory.
452 env.Replicate('$ARTIFACTS_DIR', [exe])
OLDNEW
« no previous file with comments | « nbguidgen/build.scons ('k') | plugin/idl_list.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698