OLD | NEW |
| (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 import __builtin__ | |
31 import os | |
32 import sys | |
33 import SCons.Script.SConsOptions | |
34 | |
35 Import('env') | |
36 | |
37 try: | |
38 _ = __builtin__.v8_built | |
39 Return() | |
40 except AttributeError: | |
41 __builtin__.v8_built = True | |
42 | |
43 | |
44 if env.Bit('windows'): | |
45 script_suffix = '.bat' | |
46 else: | |
47 script_suffix = '.sh' | |
48 | |
49 env = env.Clone( | |
50 V8_MODE = 'release', | |
51 V8_MODE_DIR = '$V8_SRC_DIR/obj/$V8_MODE', | |
52 V8_SCONS_COM = '$PYTHON $SCONS -C $V8_SRC_DIR -f SConstruct ' | |
53 '$DEBUG_OPTS mode=$V8_MODE importenv=INCLUDE,LIB,CCFLAGS', | |
54 SCONS = '$SCONS_DIR/scons.py', | |
55 DEBUG_OPTS = ['--debug=%s' % item for item in GetOption('debug')] | |
56 ) | |
57 | |
58 # Rather than build v8 with our own commands, we just shell out to v8's | |
59 # own SCons-based build, since their build system is complicated. | |
60 # This SConscript just declares dependencies on the outputs of that build. | |
61 | |
62 mksnapshot_exe = env.File('$V8_MODE_DIR/mksnapshot${PROGSUFFIX}') | |
63 libraries_obj = env.File('$V8_MODE_DIR/libraries${OBJSUFFIX}') | |
64 libraries_empty_obj = env.File('$V8_MODE_DIR/libraries-empty${OBJSUFFIX}') | |
65 snapshot_obj = env.File('$V8_MODE_DIR/snapshot${OBJSUFFIX}') | |
66 snapshot_empty_obj = env.File('$V8_MODE_DIR/snapshot-empty${OBJSUFFIX}') | |
67 v8_bin = env.File('$V8_SRC_DIR/shell${PROGSUFFIX}') | |
68 v8_lib = env.File('$V8_SRC_DIR/${LIBPREFIX}v8${LIBSUFFIX}'), | |
69 | |
70 v8_scons_targets_snapshot = [ | |
71 libraries_empty_obj, | |
72 snapshot_obj, | |
73 ] | |
74 | |
75 v8_scons_targets_no_snapshot = [ | |
76 mksnapshot_exe, | |
77 libraries_obj, | |
78 snapshot_empty_obj, | |
79 v8_bin, | |
80 v8_lib, | |
81 ] | |
82 | |
83 v8_env = env.Clone() | |
84 | |
85 if v8_env.Bit('windows'): | |
86 v8_env['ENV']['VSCOMNTOOLS'] = env.subst('$VC80_DIR/Common7/Tools') | |
87 | |
88 # SCons crashes if USERPROFILE isn't defined, and it's not defined | |
89 # on Vista for some reason, so this is to make the Vista build work. | |
90 try: | |
91 v8_env['ENV']['USERPROFILE'] = os.environ['USERPROFILE'] | |
92 except KeyError: | |
93 v8_env['ENV']['USERPROFILE'] = "" | |
94 | |
95 include_path = ";".join( | |
96 [v8_env.subst("$PLATFORM_SDK_VISTA_6_0_DIR/Include"), | |
97 v8_env.subst("$INCLUDE")]) | |
98 | |
99 try: | |
100 v8_env['ENV']['INCLUDE'] = include_path + ";" + v8_env['ENV']['INCLUDE'] | |
101 except KeyError: | |
102 v8_env['ENV']['INCLUDE'] = include_path | |
103 | |
104 lib_path = ";".join( | |
105 [v8_env.subst("$PLATFORM_SDK_VISTA_6_0_DIR/Lib"), | |
106 v8_env.subst("$LIB")]) | |
107 | |
108 try: | |
109 v8_env['ENV']['LIB'] = lib_path + ";" + v8_env['ENV']['LIB'] | |
110 except KeyError: | |
111 v8_env['ENV']['LIB'] = lib_path | |
112 elif v8_env.Bit('linux'): | |
113 v8_env['ENV']['CCFLAGS'] = '-fvisibility=hidden' | |
114 | |
115 v8_no_snapshot = v8_env.Command( | |
116 v8_scons_targets_no_snapshot, | |
117 [], | |
118 ['$V8_SCONS_COM msvcltcg=off snapshot=off sample=shell']) | |
119 | |
120 v8_snapshot = v8_env.Command( | |
121 v8_scons_targets_snapshot, | |
122 [], | |
123 ['$V8_SCONS_COM msvcltcg=off snapshot=on']) | |
124 | |
125 v8_env.AlwaysBuild(v8_no_snapshot) | |
126 v8_env.AlwaysBuild(v8_snapshot) | |
127 | |
128 # Tell our SCons invocation to *not* delete v8.lib and the other targets | |
129 # before building them, so the subsidiary v8 SCons call doesn't always | |
130 # rebuild them (thereby causing us to always rebuild their dependents). | |
131 v8_env.Precious(v8_no_snapshot) | |
132 v8_env.Precious(v8_snapshot) | |
133 | |
134 v8_env.Install('$LIB_DIR', v8_lib) | |
OLD | NEW |