summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/JavaScriptCore.scons
blob: 24e5003f1b29cec5dc85353a2d56032fb5017a4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# The keys in sources are the paths to the directories
# the values are an array of source files in those directories to compile
sources = {}
sources['API'] = [
    'API/JSBase.cpp',
    'API/JSCallbackConstructor.cpp',
    'API/JSCallbackFunction.cpp',
    'API/JSCallbackObject.cpp',
    'API/JSClassRef.cpp',
    'API/JSContextRef.cpp',
    'API/JSObjectRef.cpp',
    'API/JSProfilerPrivate.cpp',
    'API/JSStringRef.cpp',
    'API/JSValueRef.cpp',
    'API/OpaqueJSString.cpp',
]
sources['bytecompiler'] = [
    'bytecompiler/BytecodeGenerator.cpp',
]
sources['debugger'] = [
    'debugger/Debugger.cpp',
    'debugger/DebuggerActivation.cpp',
    'debugger/DebuggerCallFrame.cpp',
]
sources['parser'] = [
    'parser/Lexer.cpp',
    'parser/Nodes.cpp',
    'parser/Parser.cpp',
]
sources['pcre'] = [
    'pcre/pcre_compile.cpp',
    'pcre/pcre_exec.cpp',
    'pcre/pcre_tables.cpp',
    'pcre/pcre_ucp_searchfuncs.cpp',
    'pcre/pcre_xclass.cpp',
]
sources['profiler'] = [
    'profiler/HeavyProfile.cpp',
    'profiler/Profile.cpp',
    'profiler/ProfileGenerator.cpp',
    'profiler/ProfileNode.cpp',
    'profiler/Profiler.cpp',
    'profiler/TreeProfile.cpp',
]
sources['runtime'] = [
    'runtime/ArgList.cpp',
    'runtime/Arguments.cpp',
    'runtime/ArrayConstructor.cpp',
    'runtime/ArrayPrototype.cpp',
    'runtime/BooleanConstructor.cpp',
    'runtime/BooleanObject.cpp',
    'runtime/BooleanPrototype.cpp',
    'runtime/CallData.cpp',
    'runtime/Collector.cpp',
    'runtime/Completion.cpp',
    'runtime/CommonIdentifiers.cpp',
    'runtime/ConstructData.cpp',
    'runtime/DateConstructor.cpp',
    'runtime/DateInstance.cpp',
    'runtime/DateMath.cpp',
    'runtime/DatePrototype.cpp',
    'runtime/Error.cpp',
    'runtime/ErrorConstructor.cpp',
    'runtime/ErrorInstance.cpp',
    'runtime/ErrorPrototype.cpp',
    'runtime/ExceptionHelpers.cpp',
    'runtime/FunctionConstructor.cpp',
    'runtime/FunctionPrototype.cpp',
    'runtime/GetterSetter.cpp',
    'runtime/GlobalEvalFunction.cpp',
    'runtime/Identifier.cpp',
    'runtime/InitializeThreading.cpp',
    'runtime/InternalFunction.cpp',
    'runtime/JSActivation.cpp',
    'runtime/JSArray.cpp',
    'runtime/JSByteArray.cpp',
    'runtime/JSCell.cpp',
    'runtime/JSFunction.cpp',
    'runtime/JSGlobalData.cpp',
    'runtime/JSGlobalObject.cpp',
    'runtime/JSGlobalObjectFunctions.cpp',
    'runtime/JSImmediate.cpp',
    'runtime/JSLock.cpp',
    'runtime/JSNotAnObject.cpp',
    'runtime/JSNumberCell.cpp',
    'runtime/JSObject.cpp',
    'runtime/JSPropertyNameIterator.cpp',
    'runtime/JSStaticScopeObject.cpp',
    'runtime/JSString.cpp',
    'runtime/JSValue.cpp',
    'runtime/JSVariableObject.cpp',
    'runtime/JSWrapperObject.cpp',
    'runtime/Lookup.cpp',
    'runtime/MathObject.cpp',
    'runtime/NativeErrorConstructor.cpp',
    'runtime/NativeErrorPrototype.cpp',
    'runtime/NumberConstructor.cpp',
    'runtime/NumberObject.cpp',
    'runtime/NumberPrototype.cpp',
    'runtime/ObjectConstructor.cpp',
    'runtime/ObjectPrototype.cpp',
    'runtime/Operations.cpp',
    'runtime/PropertyNameArray.cpp',
    'runtime/PropertySlot.cpp',
    'runtime/PrototypeFunction.cpp',
    'runtime/RegExp.cpp',
    'runtime/RegExpConstructor.cpp',
    'runtime/RegExpObject.cpp',
    'runtime/RegExpPrototype.cpp',
    'runtime/ScopeChain.cpp',
    'runtime/SmallStrings.cpp',
    'runtime/StringConstructor.cpp',
    'runtime/StringObject.cpp',
    'runtime/StringPrototype.cpp',
    'runtime/Structure.cpp',
    'runtime/StructureChain.cpp',
    'runtime/UString.cpp',
]
sources['bytecode'] = [
    'bytecode/CodeBlock.cpp',
    'bytecode/StructureStubInfo.cpp',
    'bytecode/JumpTable.cpp',
    'bytecode/Opcode.cpp',
    'bytecode/SamplingTool.cpp',
]
sources['interpreter'] = [
    'interpreter/CallFrame.cpp',
    'interpreter/Interpreter.cpp',
    'interpreter/RegisterFile.cpp',
]
sources['jit'] = [
    'jit/ExecutableAllocator.cpp',
    'jit/JIT.cpp',
]
sources['wrec'] = [
    'wrec/CharacterClass.cpp',
    'wrec/CharacterClassConstructor.cpp',
    'wrec/WREC.cpp',
    'wrec/WRECFunctors.cpp',
    'wrec/WRECGenerator.cpp',
    'wrec/WRECParser.cpp',
]
sources['wtf'] = [
    'wtf/Assertions.cpp',
    'wtf/ByteArray.cpp',
    'wtf/CurrentTime.cpp',
    'wtf/FastMalloc.cpp',
    'wtf/HashTable.cpp',
    'wtf/RandomNumber.cpp',
    'wtf/RefCountedLeakCounter.cpp',
    'wtf/Threading.cpp',
    'wtf/dtoa.cpp',
]
sources['wtf/unicode'] = [
    'wtf/unicode/CollatorDefault.cpp',
    'wtf/unicode/UTF8.cpp',
]
sources['wtf/unicode/icu'] = [
    'wtf/unicode/icu/CollatorICU.cpp',
]

env = Environment()

building_on_win32 = env['PLATFORM'] == 'win32' or env['PLATFORM'] == 'cygwin'

# Scons uses gcc when building under cygwin by default
# We also have to manually force 8.0 or Scons will try and
# look up what version to use using the registry and fail
# due to lack of cygwin-python registry support
if env['PLATFORM'] == 'cygwin':
    env['MSVS_VERSION'] = '8.0'
    # Some systems have PROGRAMFILES, some have ProgramFiles
    # Scons msvc tool only expects 'ProgramFiles'
    import os
    if os.getenv('PROGRAMFILES') and not os.getenv('ProgramFiles'):
        os.environ['ProgramFiles'] = os.getenv('PROGRAMFILES')

    env.Tool('msvc')
    env.Tool('mslink')
    env.Tool('mslib')

# Scons is failing to carry the %PATH% value through correctly
# Hack IncrediBuild into our path so cl.exe doesn't crash
if env['PLATFORM'] == 'win32':
    env.AppendENVPath('PATH', 'c:/Program Files/Xoreax/IncrediBuild')

if env['PLATFORM'] == 'darwin':
    sources['API'].append('API/JSStringRefCF.cpp')
    sources['profiler'].append('profiler/ProfilerServer.mm')
    sources['wtf'].append('wtf/ThreadingPthreads.cpp')
    sources['wtf'].append('wtf/MainThread.cpp')
    sources['wtf/mac'] = ['wtf/mac/MainThreadMac.mm']
    sources['wtf'].append('wtf/TCSystemAlloc.cpp')
    sources['jit'].append('jit/ExecutableAllocatorPosix.cpp')
elif building_on_win32:
    sources['wtf'].append('wtf/ThreadingNone.cpp')
    sources['jit'].append('jit/ExecutableAllocatorWin.cpp')
    env.Append(CPPDEFINES = ['ENABLE_JSC_MULTIPLE_THREADS=0'])

derived_sources_path = 'DerivedSources/JavaScriptCore/'
def DerivedSources(path):
    return derived_sources_path + path

derived_sources_results = map(DerivedSources, [
    'ArrayPrototype.lut.h',
    'DatePrototype.lut.h',
    'MathObject.lut.h',
    'NumberConstructor.lut.h',
    'RegExpConstructor.lut.h',
    'RegExpObject.lut.h',
    'StringPrototype.lut.h'
    'chartables.c',
    'grammar.cpp',
    'grammar.h',
    'lexer.lut.h',
])

derived_sources_sources = [
    'runtime/ArrayPrototype.cpp',
    'runtime/DatePrototype.cpp',
    'runtime/MathObject.cpp',
    'runtime/NumberConstructor.cpp',
    'runtime/RegExpConstructor.cpp',
    'runtime/RegExpObject.cpp',
    'runtime/StringPrototype.cpp',
    'parser/Grammar.y',
    'parser/Lexer.cpp',
]

# Generate DerivedSources
# Make sure Windows knows where bash (and all the other cygwin commands) live
if env['PLATFORM'] == 'win32':
    env.AppendENVPath('PATH', 'C:/cygwin/bin')
env.Command(derived_sources_results, derived_sources_sources, 'bash make-generated-sources.sh')
sources[derived_sources_path] = [DerivedSources('Grammar.cpp')]

# Handle os-version specific build settings
if env['PLATFORM'] == 'darwin':
    from subprocess import Popen, PIPE
    version_pieces = Popen(["sw_vers", "-productVersion"], stdout = PIPE).communicate()[0].split('.')
    if map(int, version_pieces)[:2] > (10, 5):
        # Dtrace doesn't exist in Tiger, and was broken in Leopard
        env.Command(DerivedSources('TracingDtrace.h'), 'runtime/Tracing.d', '/usr/sbin/dtrace -h -o $TARGET -s $SOURCE')

# This build file builds the Chromium port for now, support for
# others could be added later.
env.Append(CPPDEFINES = ['BUILDING_CHROMIUM__'])

# I'm not certain how many of these windows defines are actually required.
if building_on_win32:
    env.Append(CPPDEFINES = ['_WIN32_WINNT=0x0600', 'WINVER=0x0600', 'WIN32', '_WINDOWS', 'NOMINMAX', 'UNICODE', '_UNICODE', '__STD_C', '_HAS_EXCEPTIONS=0'])

# Scons out-of-the-box only supports precompiled headers for MSVC
# remove this when we fix Scons to understand GCC precompiled headers
if env['CC'] == 'gcc':
    env['CCFLAGS'] = '-include JavaScriptCorePrefix.h'
# Turns out the MSVC PCH support is badly broken
# env['PCH'] = 'JavaScriptCorePrefix.h'
# env['PCHSTOP'] = 'JavaScriptCorePrefix.h'

if env['PLATFORM'] == 'darwin':
    env['FRAMEWORKS'] = ['CoreFoundation', 'Foundation']
    env['LIBS'] = ['icucore']
    # Apple does not ship the ICU headers with Mac OS X, so WebKit includes a copy of 3.2 headers
    env.Append(CPPPATH = 'icu')

webkit_libraries_path = "../WebKitLibraries/win/"
def WebKitLibraries(path):
    return webkit_libraries_path + path

include_paths = ['.', '..', 'ForwardingHeaders'] + sources.keys()
env.Append(CPPPATH = include_paths)
if building_on_win32:
    env.Append(CPPPATH = ['os-win32', WebKitLibraries('include')])
    env.Prepend(LIBPATH = [WebKitLibraries('lib')])
    env.Append(LIBS = ['icuin', 'icuuc', 'user32', 'winmm'])

# Save off a copy of the environment for use with jsc
jsc_env = env.Clone()

if building_on_win32:
    env.StaticLibrary("JavaScriptCore", sources.values())
else:
    env.SharedLibrary("JavaScriptCore", sources.values())


env = jsc_env

# Build the jsc testing shell
shell_sources = ['jsc.cpp']
build_directory = '.' # This should be changed to point to wherever JavaScriptCore gets built to

# It's hacky to re-use the same environment from JavaScriptCore
# but it makes building on windows easier for now
env['CPPPATH'] = include_paths
env['LIBS'] = ['JavaScriptCore']
env['LIBPATH'] = [build_directory]

if env['PLATFORM'] == 'darwin':
    env.Append(LIBS = ['edit'])
    env.Append(CPPPATH = 'icu')
elif building_on_win32:
    env.Append(CPPPATH = ['os-win32', WebKitLibraries('include')])
    env.Prepend(LIBPATH = [WebKitLibraries('lib')])
    env.Append(LIBS = ['icuin', 'icuuc', 'user32', 'winmm'])

env.Program('jsc', shell_sources)