1 | import os
|
---|
2 | import sys
|
---|
3 | from subprocess import Popen, PIPE
|
---|
4 |
|
---|
5 | # The keys in sources are the paths to the directories
|
---|
6 | # the values are an array of source files in those directories to compile
|
---|
7 | sources = {}
|
---|
8 | sources['API'] = [
|
---|
9 | 'API/JSBase.cpp',
|
---|
10 | 'API/JSCallbackConstructor.cpp',
|
---|
11 | 'API/JSCallbackFunction.cpp',
|
---|
12 | 'API/JSCallbackObject.cpp',
|
---|
13 | 'API/JSClassRef.cpp',
|
---|
14 | 'API/JSContextRef.cpp',
|
---|
15 | 'API/JSObjectRef.cpp',
|
---|
16 | 'API/JSProfilerPrivate.cpp',
|
---|
17 | 'API/JSStringRef.cpp',
|
---|
18 | 'API/JSValueRef.cpp',
|
---|
19 | 'API/OpaqueJSString.cpp',
|
---|
20 | ]
|
---|
21 | sources['bytecompiler'] = [
|
---|
22 | 'bytecompiler/BytecodeGenerator.cpp',
|
---|
23 | ]
|
---|
24 | sources['debugger'] = [
|
---|
25 | 'debugger/Debugger.cpp',
|
---|
26 | 'debugger/DebuggerCallFrame.cpp',
|
---|
27 | ]
|
---|
28 | sources['parser'] = [
|
---|
29 | 'parser/Lexer.cpp',
|
---|
30 | 'parser/Nodes.cpp',
|
---|
31 | 'parser/Parser.cpp',
|
---|
32 | ]
|
---|
33 | sources['pcre'] = [
|
---|
34 | 'pcre/pcre_compile.cpp',
|
---|
35 | 'pcre/pcre_exec.cpp',
|
---|
36 | 'pcre/pcre_tables.cpp',
|
---|
37 | 'pcre/pcre_ucp_searchfuncs.cpp',
|
---|
38 | 'pcre/pcre_xclass.cpp',
|
---|
39 | ]
|
---|
40 | sources['profiler'] = [
|
---|
41 | 'profiler/HeavyProfile.cpp',
|
---|
42 | 'profiler/Profile.cpp',
|
---|
43 | 'profiler/ProfileGenerator.cpp',
|
---|
44 | 'profiler/ProfileNode.cpp',
|
---|
45 | 'profiler/Profiler.cpp',
|
---|
46 | 'profiler/TreeProfile.cpp',
|
---|
47 | ]
|
---|
48 | sources['runtime'] = [
|
---|
49 | 'runtime/ArgList.cpp',
|
---|
50 | 'runtime/Arguments.cpp',
|
---|
51 | 'runtime/ArrayConstructor.cpp',
|
---|
52 | 'runtime/ArrayPrototype.cpp',
|
---|
53 | 'runtime/BooleanConstructor.cpp',
|
---|
54 | 'runtime/BooleanObject.cpp',
|
---|
55 | 'runtime/BooleanPrototype.cpp',
|
---|
56 | 'runtime/CallData.cpp',
|
---|
57 | 'runtime/Collector.cpp',
|
---|
58 | 'runtime/CommonIdentifiers.cpp',
|
---|
59 | 'runtime/ConstructData.cpp',
|
---|
60 | 'runtime/DateConstructor.cpp',
|
---|
61 | 'runtime/DateInstance.cpp',
|
---|
62 | 'runtime/DateMath.cpp',
|
---|
63 | 'runtime/DatePrototype.cpp',
|
---|
64 | 'runtime/Error.cpp',
|
---|
65 | 'runtime/ErrorConstructor.cpp',
|
---|
66 | 'runtime/ErrorInstance.cpp',
|
---|
67 | 'runtime/ErrorPrototype.cpp',
|
---|
68 | 'runtime/ExceptionHelpers.cpp',
|
---|
69 | 'runtime/FunctionConstructor.cpp',
|
---|
70 | 'runtime/FunctionPrototype.cpp',
|
---|
71 | 'runtime/GetterSetter.cpp',
|
---|
72 | 'runtime/GlobalEvalFunction.cpp',
|
---|
73 | 'runtime/Identifier.cpp',
|
---|
74 | 'runtime/InitializeThreading.cpp',
|
---|
75 | 'runtime/InternalFunction.cpp',
|
---|
76 | 'runtime/JSActivation.cpp',
|
---|
77 | 'runtime/JSArray.cpp',
|
---|
78 | 'runtime/JSCell.cpp',
|
---|
79 | 'runtime/JSFunction.cpp',
|
---|
80 | 'runtime/JSGlobalData.cpp',
|
---|
81 | 'runtime/JSGlobalObject.cpp',
|
---|
82 | 'runtime/JSGlobalObjectFunctions.cpp',
|
---|
83 | 'runtime/JSImmediate.cpp',
|
---|
84 | 'runtime/JSLock.cpp',
|
---|
85 | 'runtime/JSNotAnObject.cpp',
|
---|
86 | 'runtime/JSNumberCell.cpp',
|
---|
87 | 'runtime/JSObject.cpp',
|
---|
88 | 'runtime/JSPropertyNameIterator.cpp',
|
---|
89 | 'runtime/JSStaticScopeObject.cpp',
|
---|
90 | 'runtime/JSString.cpp',
|
---|
91 | 'runtime/JSValue.cpp',
|
---|
92 | 'runtime/JSVariableObject.cpp',
|
---|
93 | 'runtime/JSWrapperObject.cpp',
|
---|
94 | 'runtime/Lookup.cpp',
|
---|
95 | 'runtime/MathObject.cpp',
|
---|
96 | 'runtime/NativeErrorConstructor.cpp',
|
---|
97 | 'runtime/NativeErrorPrototype.cpp',
|
---|
98 | 'runtime/NumberConstructor.cpp',
|
---|
99 | 'runtime/NumberObject.cpp',
|
---|
100 | 'runtime/NumberPrototype.cpp',
|
---|
101 | 'runtime/ObjectConstructor.cpp',
|
---|
102 | 'runtime/ObjectPrototype.cpp',
|
---|
103 | 'runtime/Operations.cpp',
|
---|
104 | 'runtime/PropertyNameArray.cpp',
|
---|
105 | 'runtime/PropertySlot.cpp',
|
---|
106 | 'runtime/PrototypeFunction.cpp',
|
---|
107 | 'runtime/RegExp.cpp',
|
---|
108 | 'runtime/RegExpConstructor.cpp',
|
---|
109 | 'runtime/RegExpObject.cpp',
|
---|
110 | 'runtime/RegExpPrototype.cpp',
|
---|
111 | 'runtime/ScopeChain.cpp',
|
---|
112 | 'runtime/SmallStrings.cpp',
|
---|
113 | 'runtime/StringConstructor.cpp',
|
---|
114 | 'runtime/StringObject.cpp',
|
---|
115 | 'runtime/StringPrototype.cpp',
|
---|
116 | 'runtime/Structure.cpp',
|
---|
117 | 'runtime/StructureChain.cpp',
|
---|
118 | 'runtime/UString.cpp',
|
---|
119 | ]
|
---|
120 | sources['bytecode'] = [
|
---|
121 | 'bytecode/CodeBlock.cpp',
|
---|
122 | 'bytecode/Opcode.cpp',
|
---|
123 | 'bytecode/SamplingTool.cpp',
|
---|
124 | ]
|
---|
125 | sources['interpreter'] = [
|
---|
126 | 'interpreter/CallFrame.cpp',
|
---|
127 | 'interpreter/Interpreter.cpp',
|
---|
128 | 'interpreter/RegisterFile.cpp',
|
---|
129 | ]
|
---|
130 | sources['jit'] = [
|
---|
131 | 'jit/JIT.cpp',
|
---|
132 | ]
|
---|
133 | sources['wrec'] = [
|
---|
134 | 'wrec/CharacterClassConstructor.cpp',
|
---|
135 | 'wrec/WREC.cpp'
|
---|
136 | ]
|
---|
137 | sources['wtf'] = [
|
---|
138 | 'wtf/Assertions.cpp',
|
---|
139 | 'wtf/FastMalloc.cpp',
|
---|
140 | 'wtf/HashTable.cpp',
|
---|
141 | 'wtf/MainThread.cpp',
|
---|
142 | 'wtf/RefCountedLeakCounter.cpp',
|
---|
143 | 'wtf/TCSystemAlloc.cpp',
|
---|
144 | 'wtf/dtoa.cpp',
|
---|
145 | ]
|
---|
146 | sources['wtf/unicode'] = [
|
---|
147 | 'wtf/unicode/CollatorDefault.cpp',
|
---|
148 | 'wtf/unicode/UTF8.cpp',
|
---|
149 | ]
|
---|
150 | sources['wtf/unicode/icu'] = [
|
---|
151 | 'wtf/unicode/icu/CollatorICU.cpp',
|
---|
152 | ]
|
---|
153 |
|
---|
154 | env = Environment()
|
---|
155 |
|
---|
156 | if env['PLATFORM'] == 'darwin':
|
---|
157 | sources['API'].append('API/JSStringRefCF.cpp')
|
---|
158 | sources['profiler'].append('profiler/ProfilerServer.mm')
|
---|
159 | sources['wtf'].append('wtf/ThreadingPthreads.cpp')
|
---|
160 | sources['wtf/mac'] = ['wtf/mac/MainThreadMac.mm']
|
---|
161 | elif env['PLATFORM'] == 'win32':
|
---|
162 | sources['API'].append('API/JSStringRefBSTR.cpp')
|
---|
163 | sources['wtf'].append('wtf/ThreadingWin.cpp')
|
---|
164 | sources['wtf/win'] = ['wtf/win/MainThreadWin.cpp']
|
---|
165 |
|
---|
166 |
|
---|
167 | derived_sources_path = 'DerivedSources/JavaScriptCore/'
|
---|
168 | def DerivedSources(path):
|
---|
169 | return derived_sources_path + path
|
---|
170 |
|
---|
171 | derived_sources_results = map(DerivedSources, [
|
---|
172 | 'ArrayPrototype.lut.h',
|
---|
173 | 'DatePrototype.lut.h',
|
---|
174 | 'MathObject.lut.h',
|
---|
175 | 'NumberConstructor.lut.h',
|
---|
176 | 'RegExpConstructor.lut.h',
|
---|
177 | 'RegExpObject.lut.h',
|
---|
178 | 'StringPrototype.lut.h'
|
---|
179 | 'chartables.c',
|
---|
180 | 'grammar.cpp',
|
---|
181 | 'grammar.h',
|
---|
182 | 'lexer.lut.h',
|
---|
183 | ])
|
---|
184 |
|
---|
185 | derived_sources_sources = [
|
---|
186 | 'runtime/ArrayPrototype.cpp',
|
---|
187 | 'runtime/DatePrototype.cpp',
|
---|
188 | 'runtime/MathObject.cpp',
|
---|
189 | 'runtime/NumberConstructor.cpp',
|
---|
190 | 'runtime/RegExpConstructor.cpp',
|
---|
191 | 'runtime/RegExpObject.cpp',
|
---|
192 | 'runtime/StringPrototype.cpp',
|
---|
193 | 'parser/Grammar.y',
|
---|
194 | 'parser/Lexer.cpp',
|
---|
195 | ]
|
---|
196 |
|
---|
197 | # Generate DerivedSources
|
---|
198 | env.Command(derived_sources_results, derived_sources_sources, './make-generated-sources.sh')
|
---|
199 | sources[derived_sources_path] = [DerivedSources('grammar.cpp')]
|
---|
200 |
|
---|
201 | # Handle os-version specific build settings
|
---|
202 | if env['PLATFORM'] == 'darwin':
|
---|
203 | version_pieces = Popen(["sw_vers", "-productVersion"], stdout = PIPE).communicate()[0].split('.')
|
---|
204 | if map(int, version_pieces)[:2] > (10, 5):
|
---|
205 | # Dtrace doesn't exist in Tiger, and was broken in Leopard
|
---|
206 | env.Command(DerivedSources('TracingDtrace.h'), 'runtime/Tracing.d', '/usr/sbin/dtrace -h -o $TARGET -s $SOURCE')
|
---|
207 |
|
---|
208 | # This build file builds the Chromium port for now, support for
|
---|
209 | # others could be added later.
|
---|
210 | env['CPPDEFINES'] = 'BUILDING_CHROMIUM__'
|
---|
211 |
|
---|
212 | # Scons out-of-the-box only supports precompiled headers for MSVC
|
---|
213 | # remove this when we fix Scons to understand GCC precompiled headers
|
---|
214 | if env['CC'] == 'gcc':
|
---|
215 | env['CCFLAGS'] = '-include JavaScriptCorePrefix.h'
|
---|
216 | env['PCH'] = 'JavaScriptCorePrefix.h'
|
---|
217 |
|
---|
218 | if env['PLATFORM'] == 'darwin':
|
---|
219 | env['FRAMEWORKS'] = ['CoreFoundation', 'Foundation']
|
---|
220 | env['LIBS'] = ['icucore']
|
---|
221 |
|
---|
222 | include_paths = ['.', '..', 'ForwardingHeaders', 'icu'] + sources.keys()
|
---|
223 | env['CPPPATH'] = include_paths
|
---|
224 | env.SharedLibrary("JavaScriptCore", sources.values())
|
---|
225 |
|
---|
226 |
|
---|
227 | # Build the jsc testing shell
|
---|
228 | shell_sources = ['jsc.cpp']
|
---|
229 | build_directory = '.' # This should be changed to point to wherever JavaScriptCore gets built to
|
---|
230 |
|
---|
231 | env = Environment(CPPPATH = include_paths, LIBS = ['JavaScriptCore', 'edit'], LIBPATH = [build_directory])
|
---|
232 | env.Program('jsc', shell_sources)
|
---|