<rdar://problem/6467376> Race condition in WTF::currentThread can lead to a thread...
[WebKit-https.git] / JavaScriptCore / JavaScriptCore.scons
1 # The keys in sources are the paths to the directories
2 # the values are an array of source files in those directories to compile
3 sources = {}
4 sources['API'] = [
5     'API/JSBase.cpp',
6     'API/JSCallbackConstructor.cpp',
7     'API/JSCallbackFunction.cpp',
8     'API/JSCallbackObject.cpp',
9     'API/JSClassRef.cpp',
10     'API/JSContextRef.cpp',
11     'API/JSObjectRef.cpp',
12     'API/JSProfilerPrivate.cpp',
13     'API/JSStringRef.cpp',
14     'API/JSValueRef.cpp',
15     'API/OpaqueJSString.cpp',
16 ]
17 sources['bytecompiler'] = [
18     'bytecompiler/BytecodeGenerator.cpp',
19 ]
20 sources['debugger'] = [
21     'debugger/Debugger.cpp',
22     'debugger/DebuggerCallFrame.cpp',
23 ]
24 sources['parser'] = [
25     'parser/Lexer.cpp',
26     'parser/Nodes.cpp',
27     'parser/Parser.cpp',
28 ]
29 sources['pcre'] = [
30     'pcre/pcre_compile.cpp',
31     'pcre/pcre_exec.cpp',
32     'pcre/pcre_tables.cpp',
33     'pcre/pcre_ucp_searchfuncs.cpp',
34     'pcre/pcre_xclass.cpp',
35 ]
36 sources['profiler'] = [
37     'profiler/HeavyProfile.cpp',
38     'profiler/Profile.cpp',
39     'profiler/ProfileGenerator.cpp',
40     'profiler/ProfileNode.cpp',
41     'profiler/Profiler.cpp',
42     'profiler/TreeProfile.cpp',
43 ]
44 sources['runtime'] = [
45     'runtime/ArgList.cpp',
46     'runtime/Arguments.cpp',
47     'runtime/ArrayConstructor.cpp',
48     'runtime/ArrayPrototype.cpp',
49     'runtime/BooleanConstructor.cpp',
50     'runtime/BooleanObject.cpp',
51     'runtime/BooleanPrototype.cpp',
52     'runtime/CallData.cpp',
53     'runtime/Collector.cpp',
54     'runtime/Completion.cpp',
55     'runtime/CommonIdentifiers.cpp',
56     'runtime/ConstructData.cpp',
57     'runtime/DateConstructor.cpp',
58     'runtime/DateInstance.cpp',
59     'runtime/DateMath.cpp',
60     'runtime/DatePrototype.cpp',
61     'runtime/Error.cpp',
62     'runtime/ErrorConstructor.cpp',
63     'runtime/ErrorInstance.cpp',
64     'runtime/ErrorPrototype.cpp',
65     'runtime/ExceptionHelpers.cpp',
66     'runtime/FunctionConstructor.cpp',
67     'runtime/FunctionPrototype.cpp',
68     'runtime/GetterSetter.cpp',
69     'runtime/GlobalEvalFunction.cpp',
70     'runtime/Identifier.cpp',
71     'runtime/InitializeThreading.cpp',
72     'runtime/InternalFunction.cpp',
73     'runtime/JSActivation.cpp',
74     'runtime/JSArray.cpp',
75     'runtime/JSCell.cpp',
76     'runtime/JSFunction.cpp',
77     'runtime/JSGlobalData.cpp',
78     'runtime/JSGlobalObject.cpp',
79     'runtime/JSGlobalObjectFunctions.cpp',
80     'runtime/JSImmediate.cpp',
81     'runtime/JSLock.cpp',
82     'runtime/JSNotAnObject.cpp',
83     'runtime/JSNumberCell.cpp',
84     'runtime/JSObject.cpp',
85     'runtime/JSPropertyNameIterator.cpp',
86     'runtime/JSStaticScopeObject.cpp',
87     'runtime/JSString.cpp',
88     'runtime/JSValue.cpp',
89     'runtime/JSVariableObject.cpp',
90     'runtime/JSWrapperObject.cpp',
91     'runtime/Lookup.cpp',
92     'runtime/MathObject.cpp',
93     'runtime/NativeErrorConstructor.cpp',
94     'runtime/NativeErrorPrototype.cpp',
95     'runtime/NumberConstructor.cpp',
96     'runtime/NumberObject.cpp',
97     'runtime/NumberPrototype.cpp',
98     'runtime/ObjectConstructor.cpp',
99     'runtime/ObjectPrototype.cpp',
100     'runtime/Operations.cpp',
101     'runtime/PropertyNameArray.cpp',
102     'runtime/PropertySlot.cpp',
103     'runtime/PrototypeFunction.cpp',
104     'runtime/RegExp.cpp',
105     'runtime/RegExpConstructor.cpp',
106     'runtime/RegExpObject.cpp',
107     'runtime/RegExpPrototype.cpp',
108     'runtime/ScopeChain.cpp',
109     'runtime/SmallStrings.cpp',
110     'runtime/StringConstructor.cpp',
111     'runtime/StringObject.cpp',
112     'runtime/StringPrototype.cpp',
113     'runtime/Structure.cpp',
114     'runtime/StructureChain.cpp',
115     'runtime/UString.cpp',
116 ]
117 sources['bytecode'] = [
118     'bytecode/CodeBlock.cpp',
119     'bytecode/StructureStubInfo.cpp',
120     'bytecode/JumpTable.cpp',
121     'bytecode/Opcode.cpp',
122     'bytecode/SamplingTool.cpp',
123 ]
124 sources['interpreter'] = [
125     'interpreter/CallFrame.cpp',
126     'interpreter/Interpreter.cpp',
127     'interpreter/RegisterFile.cpp',
128 ]
129 sources['jit'] = [
130     'jit/ExecutableAllocator.cpp',
131     'jit/JIT.cpp',
132 ]
133 sources['wrec'] = [
134     'wrec/CharacterClass.cpp',
135     'wrec/CharacterClassConstructor.cpp',
136     'wrec/WREC.cpp',
137     'wrec/WRECFunctors.cpp',
138     'wrec/WRECGenerator.cpp',
139     'wrec/WRECParser.cpp',
140 ]
141 sources['wtf'] = [
142     'wtf/Assertions.cpp',
143     'wtf/FastMalloc.cpp',
144     'wtf/HashTable.cpp',
145     'wtf/RandomNumber.cpp',
146     'wtf/RefCountedLeakCounter.cpp',
147     'wtf/Threading.cpp',
148     'wtf/dtoa.cpp',
149 ]
150 sources['wtf/unicode'] = [
151     'wtf/unicode/CollatorDefault.cpp',
152     'wtf/unicode/UTF8.cpp',
153 ]
154 sources['wtf/unicode/icu'] = [
155     'wtf/unicode/icu/CollatorICU.cpp',
156 ]
157
158 env = Environment()
159
160 building_on_win32 = env['PLATFORM'] == 'win32' or env['PLATFORM'] == 'cygwin'
161
162 # Scons uses gcc when building under cygwin by default
163 # We also have to manually force 8.0 or Scons will try and
164 # look up what version to use using the registry and fail
165 # due to lack of cygwin-python registry support
166 if env['PLATFORM'] == 'cygwin':
167     env['MSVS_VERSION'] = '8.0'
168     # Some systems have PROGRAMFILES, some have ProgramFiles
169     # Scons msvc tool only expects 'ProgramFiles'
170     import os
171     if os.getenv('PROGRAMFILES') and not os.getenv('ProgramFiles'):
172         os.environ['ProgramFiles'] = os.getenv('PROGRAMFILES')
173
174     env.Tool('msvc')
175     env.Tool('mslink')
176     env.Tool('mslib')
177
178 # Scons is failing to carry the %PATH% value through correctly
179 # Hack IncrediBuild into our path so cl.exe doesn't crash
180 if env['PLATFORM'] == 'win32':
181     env.AppendENVPath('PATH', 'c:/Program Files/Xoreax/IncrediBuild')
182
183 if env['PLATFORM'] == 'darwin':
184     sources['API'].append('API/JSStringRefCF.cpp')
185     sources['profiler'].append('profiler/ProfilerServer.mm')
186     sources['wtf'].append('wtf/ThreadingPthreads.cpp')
187     sources['wtf'].append('wtf/MainThread.cpp')
188     sources['wtf/mac'] = ['wtf/mac/MainThreadMac.mm']
189     sources['wtf'].append('wtf/TCSystemAlloc.cpp')
190     sources['jit'].append('jit/ExecutableAllocatorPosix.cpp')
191 elif building_on_win32:
192     sources['wtf'].append('wtf/ThreadingNone.cpp')
193     sources['jit'].append('jit/ExecutableAllocatorWin.cpp')
194     env.Append(CPPDEFINES = ['ENABLE_JSC_MULTIPLE_THREADS=0'])
195
196 derived_sources_path = 'DerivedSources/JavaScriptCore/'
197 def DerivedSources(path):
198     return derived_sources_path + path
199
200 derived_sources_results = map(DerivedSources, [
201     'ArrayPrototype.lut.h',
202     'DatePrototype.lut.h',
203     'MathObject.lut.h',
204     'NumberConstructor.lut.h',
205     'RegExpConstructor.lut.h',
206     'RegExpObject.lut.h',
207     'StringPrototype.lut.h'
208     'chartables.c',
209     'grammar.cpp',
210     'grammar.h',
211     'lexer.lut.h',
212 ])
213
214 derived_sources_sources = [
215     'runtime/ArrayPrototype.cpp',
216     'runtime/DatePrototype.cpp',
217     'runtime/MathObject.cpp',
218     'runtime/NumberConstructor.cpp',
219     'runtime/RegExpConstructor.cpp',
220     'runtime/RegExpObject.cpp',
221     'runtime/StringPrototype.cpp',
222     'parser/Grammar.y',
223     'parser/Lexer.cpp',
224 ]
225
226 # Generate DerivedSources
227 # Make sure Windows knows where bash (and all the other cygwin commands) live
228 if env['PLATFORM'] == 'win32':
229     env.AppendENVPath('PATH', 'C:/cygwin/bin')
230 env.Command(derived_sources_results, derived_sources_sources, 'bash make-generated-sources.sh')
231 sources[derived_sources_path] = [DerivedSources('Grammar.cpp')]
232
233 # Handle os-version specific build settings
234 if env['PLATFORM'] == 'darwin':
235     from subprocess import Popen, PIPE
236     version_pieces = Popen(["sw_vers", "-productVersion"], stdout = PIPE).communicate()[0].split('.')
237     if map(int, version_pieces)[:2] > (10, 5):
238         # Dtrace doesn't exist in Tiger, and was broken in Leopard
239         env.Command(DerivedSources('TracingDtrace.h'), 'runtime/Tracing.d', '/usr/sbin/dtrace -h -o $TARGET -s $SOURCE')
240
241 # This build file builds the Chromium port for now, support for
242 # others could be added later.
243 env.Append(CPPDEFINES = ['BUILDING_CHROMIUM__'])
244
245 # I'm not certain how many of these windows defines are actually required.
246 if building_on_win32:
247     env.Append(CPPDEFINES = ['_WIN32_WINNT=0x0600', 'WINVER=0x0600', 'WIN32', '_WINDOWS', 'NOMINMAX', 'UNICODE', '_UNICODE', '__STD_C', '_HAS_EXCEPTIONS=0'])
248
249 # Scons out-of-the-box only supports precompiled headers for MSVC
250 # remove this when we fix Scons to understand GCC precompiled headers
251 if env['CC'] == 'gcc':
252     env['CCFLAGS'] = '-include JavaScriptCorePrefix.h'
253 # Turns out the MSVC PCH support is badly broken
254 # env['PCH'] = 'JavaScriptCorePrefix.h'
255 # env['PCHSTOP'] = 'JavaScriptCorePrefix.h'
256
257 if env['PLATFORM'] == 'darwin':
258     env['FRAMEWORKS'] = ['CoreFoundation', 'Foundation']
259     env['LIBS'] = ['icucore']
260     # Apple does not ship the ICU headers with Mac OS X, so WebKit includes a copy of 3.2 headers
261     env.Append(CPPPATH = 'icu')
262
263 webkit_libraries_path = "../WebKitLibraries/win/"
264 def WebKitLibraries(path):
265     return webkit_libraries_path + path
266
267 include_paths = ['.', '..', 'ForwardingHeaders'] + sources.keys()
268 env.Append(CPPPATH = include_paths)
269 if building_on_win32:
270     env.Append(CPPPATH = ['os-win32', WebKitLibraries('include')])
271     env.Prepend(LIBPATH = [WebKitLibraries('lib')])
272     env.Append(LIBS = ['icuin', 'icuuc', 'user32', 'winmm'])
273
274 # Save off a copy of the environment for use with jsc
275 jsc_env = env.Clone()
276
277 if building_on_win32:
278     env.StaticLibrary("JavaScriptCore", sources.values())
279 else:
280     env.SharedLibrary("JavaScriptCore", sources.values())
281
282
283 env = jsc_env
284
285 # Build the jsc testing shell
286 shell_sources = ['jsc.cpp']
287 build_directory = '.' # This should be changed to point to wherever JavaScriptCore gets built to
288
289 # It's hacky to re-use the same environment from JavaScriptCore
290 # but it makes building on windows easier for now
291 env['CPPPATH'] = include_paths
292 env['LIBS'] = ['JavaScriptCore']
293 env['LIBPATH'] = [build_directory]
294
295 if env['PLATFORM'] == 'darwin':
296     env.Append(LIBS = ['edit'])
297     env.Append(CPPPATH = 'icu')
298 elif building_on_win32:
299     env.Append(CPPPATH = ['os-win32', WebKitLibraries('include')])
300     env.Prepend(LIBPATH = [WebKitLibraries('lib')])
301     env.Append(LIBS = ['icuin', 'icuuc', 'user32', 'winmm'])
302
303 env.Program('jsc', shell_sources)