1053fe2b2ef42762a66640e00c2580a54a69bb3f
[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/dtoa.cpp',
148 ]
149 sources['wtf/unicode'] = [
150     'wtf/unicode/CollatorDefault.cpp',
151     'wtf/unicode/UTF8.cpp',
152 ]
153 sources['wtf/unicode/icu'] = [
154     'wtf/unicode/icu/CollatorICU.cpp',
155 ]
156
157 env = Environment()
158
159 building_on_win32 = env['PLATFORM'] == 'win32' or env['PLATFORM'] == 'cygwin'
160
161 # Scons uses gcc when building under cygwin by default
162 # We also have to manually force 8.0 or Scons will try and
163 # look up what version to use using the registry and fail
164 # due to lack of cygwin-python registry support
165 if env['PLATFORM'] == 'cygwin':
166     env['MSVS_VERSION'] = '8.0'
167     # Some systems have PROGRAMFILES, some have ProgramFiles
168     # Scons msvc tool only expects 'ProgramFiles'
169     import os
170     if os.getenv('PROGRAMFILES') and not os.getenv('ProgramFiles'):
171         os.environ['ProgramFiles'] = os.getenv('PROGRAMFILES')
172
173     env.Tool('msvc')
174     env.Tool('mslink')
175     env.Tool('mslib')
176
177 # Scons is failing to carry the %PATH% value through correctly
178 # Hack IncrediBuild into our path so cl.exe doesn't crash
179 if env['PLATFORM'] == 'win32':
180     env.AppendENVPath('PATH', 'c:/Program Files/Xoreax/IncrediBuild')
181
182 if env['PLATFORM'] == 'darwin':
183     sources['API'].append('API/JSStringRefCF.cpp')
184     sources['profiler'].append('profiler/ProfilerServer.mm')
185     sources['wtf'].append('wtf/ThreadingPthreads.cpp')
186     sources['wtf'].append('wtf/MainThread.cpp')
187     sources['wtf/mac'] = ['wtf/mac/MainThreadMac.mm']
188     sources['wtf'].append('wtf/TCSystemAlloc.cpp')
189     sources['jit'].append('jit/ExecutableAllocatorPosix.cpp')
190 elif building_on_win32:
191     sources['wtf'].append('wtf/ThreadingNone.cpp')
192     sources['jit'].append('jit/ExecutableAllocatorWin.cpp')
193     env.Append(CPPDEFINES = ['ENABLE_JSC_MULTIPLE_THREADS=0'])
194
195 derived_sources_path = 'DerivedSources/JavaScriptCore/'
196 def DerivedSources(path):
197     return derived_sources_path + path
198
199 derived_sources_results = map(DerivedSources, [
200     'ArrayPrototype.lut.h',
201     'DatePrototype.lut.h',
202     'MathObject.lut.h',
203     'NumberConstructor.lut.h',
204     'RegExpConstructor.lut.h',
205     'RegExpObject.lut.h',
206     'StringPrototype.lut.h'
207     'chartables.c',
208     'grammar.cpp',
209     'grammar.h',
210     'lexer.lut.h',
211 ])
212
213 derived_sources_sources = [
214     'runtime/ArrayPrototype.cpp',
215     'runtime/DatePrototype.cpp',
216     'runtime/MathObject.cpp',
217     'runtime/NumberConstructor.cpp',
218     'runtime/RegExpConstructor.cpp',
219     'runtime/RegExpObject.cpp',
220     'runtime/StringPrototype.cpp',
221     'parser/Grammar.y',
222     'parser/Lexer.cpp',
223 ]
224
225 # Generate DerivedSources
226 # Make sure Windows knows where bash (and all the other cygwin commands) live
227 if env['PLATFORM'] == 'win32':
228     env.AppendENVPath('PATH', 'C:/cygwin/bin')
229 env.Command(derived_sources_results, derived_sources_sources, 'bash make-generated-sources.sh')
230 sources[derived_sources_path] = [DerivedSources('Grammar.cpp')]
231
232 # Handle os-version specific build settings
233 if env['PLATFORM'] == 'darwin':
234     from subprocess import Popen, PIPE
235     version_pieces = Popen(["sw_vers", "-productVersion"], stdout = PIPE).communicate()[0].split('.')
236     if map(int, version_pieces)[:2] > (10, 5):
237         # Dtrace doesn't exist in Tiger, and was broken in Leopard
238         env.Command(DerivedSources('TracingDtrace.h'), 'runtime/Tracing.d', '/usr/sbin/dtrace -h -o $TARGET -s $SOURCE')
239
240 # This build file builds the Chromium port for now, support for
241 # others could be added later.
242 env.Append(CPPDEFINES = ['BUILDING_CHROMIUM__'])
243
244 # I'm not certain how many of these windows defines are actually required.
245 if building_on_win32:
246     env.Append(CPPDEFINES = ['_WIN32_WINNT=0x0600', 'WINVER=0x0600', 'WIN32', '_WINDOWS', 'NOMINMAX', 'UNICODE', '_UNICODE', '__STD_C', '_HAS_EXCEPTIONS=0'])
247
248 # Scons out-of-the-box only supports precompiled headers for MSVC
249 # remove this when we fix Scons to understand GCC precompiled headers
250 if env['CC'] == 'gcc':
251     env['CCFLAGS'] = '-include JavaScriptCorePrefix.h'
252 # Turns out the MSVC PCH support is badly broken
253 # env['PCH'] = 'JavaScriptCorePrefix.h'
254 # env['PCHSTOP'] = 'JavaScriptCorePrefix.h'
255
256 if env['PLATFORM'] == 'darwin':
257     env['FRAMEWORKS'] = ['CoreFoundation', 'Foundation']
258     env['LIBS'] = ['icucore']
259     # Apple does not ship the ICU headers with Mac OS X, so WebKit includes a copy of 3.2 headers
260     env.Append(CPPPATH = 'icu')
261
262 webkit_libraries_path = "../WebKitLibraries/win/"
263 def WebKitLibraries(path):
264     return webkit_libraries_path + path
265
266 include_paths = ['.', '..', 'ForwardingHeaders'] + sources.keys()
267 env.Append(CPPPATH = include_paths)
268 if building_on_win32:
269     env.Append(CPPPATH = ['os-win32', WebKitLibraries('include')])
270     env.Prepend(LIBPATH = [WebKitLibraries('lib')])
271     env.Append(LIBS = ['icuin', 'icuuc', 'user32', 'winmm'])
272
273 # Save off a copy of the environment for use with jsc
274 jsc_env = env.Clone()
275
276 if building_on_win32:
277     env.StaticLibrary("JavaScriptCore", sources.values())
278 else:
279     env.SharedLibrary("JavaScriptCore", sources.values())
280
281
282 env = jsc_env
283
284 # Build the jsc testing shell
285 shell_sources = ['jsc.cpp']
286 build_directory = '.' # This should be changed to point to wherever JavaScriptCore gets built to
287
288 # It's hacky to re-use the same environment from JavaScriptCore
289 # but it makes building on windows easier for now
290 env['CPPPATH'] = include_paths
291 env['LIBS'] = ['JavaScriptCore']
292 env['LIBPATH'] = [build_directory]
293
294 if env['PLATFORM'] == 'darwin':
295     env.Append(LIBS = ['edit'])
296     env.Append(CPPPATH = 'icu')
297 elif building_on_win32:
298     env.Append(CPPPATH = ['os-win32', WebKitLibraries('include')])
299     env.Prepend(LIBPATH = [WebKitLibraries('lib')])
300     env.Append(LIBS = ['icuin', 'icuuc', 'user32', 'winmm'])
301
302 env.Program('jsc', shell_sources)