Cory McWilliams
d6018736d5
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3423 ed5197a5-7fde-0310-b194-c3ffbd925b24
164 lines
5.0 KiB
Python
164 lines
5.0 KiB
Python
#!/usr/bin/python
|
|
|
|
import os
|
|
import platform
|
|
import sys
|
|
|
|
options = Variables('options.cache', ARGUMENTS)
|
|
options.AddVariables(PathVariable('uv', 'Location of libuv', 'deps/%s/uv' % sys.platform))
|
|
options.AddVariables(PathVariable('v8', 'Location of v8', 'deps/%s/v8' % sys.platform))
|
|
options.AddVariables(PathVariable('lmdb', 'Location of liblmdb', 'deps/%s/lmdb' % sys.platform))
|
|
options.AddVariables(BoolVariable('package', 'Build a package', False))
|
|
|
|
VariantDir('build/src', 'src', duplicate=0)
|
|
VariantDir('build/deps', 'deps', duplicate=0)
|
|
kwargs = {}
|
|
if sys.platform == 'darwin':
|
|
kwargs['CXX'] = 'clang++'
|
|
|
|
env = Environment(options=options, tools=['default', 'packaging'], **kwargs)
|
|
options.Save('options.cache', env)
|
|
Help(options.GenerateHelpText(env))
|
|
|
|
v8 = env['v8']
|
|
uv = env['uv']
|
|
liblmdb = env['lmdb']
|
|
env.Append(CPPPATH=[
|
|
os.path.join(v8, 'include'),
|
|
v8,
|
|
os.path.join(uv, 'include'),
|
|
os.path.join(liblmdb, 'libraries', 'liblmdb'),
|
|
])
|
|
|
|
objectSuffix = '.obj' if sys.platform == 'win32' else '.o'
|
|
raspi = platform.machine() == 'armv7l'
|
|
if raspi:
|
|
env.Append(LIBS = [
|
|
os.path.join(v8, 'out', 'arm.release', 'obj.target', 'src', 'libv8_libplatform.a'),
|
|
os.path.join(v8, 'out', 'arm.release', 'obj.target', 'src', 'libv8_base.a'),
|
|
os.path.join(v8, 'out', 'arm.release', 'obj.target', 'src', 'libv8_libbase.a'),
|
|
os.path.join(v8, 'out', 'arm.release', 'obj.target', 'src', 'libv8_libsampler.a'),
|
|
os.path.join(v8, 'out', 'arm.release', 'obj.target', 'src', 'libv8_nosnapshot.a'),
|
|
os.path.join(v8, 'out', 'arm.release', 'obj.target', 'third_party', 'icu', 'libicui18n.a'),
|
|
os.path.join(v8, 'out', 'arm.release', 'obj.target', 'third_party', 'icu', 'libicuuc.a'),
|
|
])
|
|
else:
|
|
env.Append(LIBPATH = [
|
|
os.path.join(v8, 'out', 'obj'),
|
|
os.path.join(v8, 'out', 'obj', 'third_party', 'icu'),
|
|
])
|
|
if sys.platform == 'win32':
|
|
env.Append(LIBS = [
|
|
'v8_base_0',
|
|
'v8_base_1',
|
|
])
|
|
else:
|
|
env.Append(LIBS = [
|
|
'v8_base',
|
|
])
|
|
env.Append(LIBS = [
|
|
'v8_libplatform',
|
|
'v8_libbase',
|
|
'v8_libsampler',
|
|
'v8_snapshot',
|
|
'icui18n',
|
|
'icuuc',
|
|
])
|
|
|
|
if sys.platform == 'win32':
|
|
env.Append(LIBS=['libuv', 'advapi32', 'winmm', 'wsock32', 'ws2_32', 'psapi', 'iphlpapi', 'userenv', 'user32', 'dbghelp', 'shlwapi'])
|
|
env.Append(CXXFLAGS=['/EHsc', '/MTd', '/Zi', '/Gy'])
|
|
env.Append(CFLAGS=['/EHsc', '/MTd', '/Zi', '/Gy'])
|
|
env.Append(LIBPATH=[
|
|
os.path.join(uv, 'Release/lib'),
|
|
])
|
|
env.Append(LINKFLAGS=['/RELEASE', '/OPT:REF', '/OPT:ICF', '/NODEFAULTLIB:libcmt', '/LTCG'])
|
|
elif sys.platform == 'darwin':
|
|
env.Append(LIBS=['pthread', 'uv'])
|
|
env.Append(CXXFLAGS=['--std=c++11', '-g', '-Wall', '-stdlib=libc++'])
|
|
env.Append(CFLAGS=['-g', '-Wall'])
|
|
env.Append(LINKFLAGS=['-g', '-stdlib=libc++'])
|
|
env.Append(LIBPATH=[
|
|
os.path.join(uv, 'build/Release'),
|
|
])
|
|
else:
|
|
env.Append(LIBS=['uv', 'rt', 'dl', 'pthread'])
|
|
env.Append(CXXFLAGS=['--std=c++11', '-g', '-Wall'])
|
|
env.Append(CFLAGS=['-g', '-Wall'])
|
|
env.Append(LINKFLAGS=['-g'])
|
|
env.Append(LIBPATH=[
|
|
os.path.join(uv, 'out/Debug/obj.target'),
|
|
])
|
|
|
|
env.Command('icudtl.dat', os.path.join(v8, 'out/arm.release/icudtl.dat' if raspi else 'out/icudtl.dat'), Copy("$TARGET", "$SOURCE"))
|
|
|
|
ldapEnv = env.Clone()
|
|
if sys.platform == 'win32':
|
|
ldapEnv.Append(CPPPATH=['deps/win32'])
|
|
lmdb = ldapEnv.Library('build/lmdb', [
|
|
os.path.join(liblmdb, 'libraries', 'liblmdb', 'mdb.c'),
|
|
os.path.join(liblmdb, 'libraries', 'liblmdb', 'midl.c'),
|
|
])
|
|
env.Append(LIBS=[lmdb])
|
|
|
|
if sys.platform == 'linux2':
|
|
env.Append(LIBS=['crypto', 'ssl'])
|
|
env.Append(LINKFLAGS=['-std=c++0x'])
|
|
|
|
quickjsEnv = env.Clone()
|
|
quickjsEnv.Append(CPPDEFINES=[
|
|
'CONFIG_VERSION=\\"' + open('deps/quickjs/VERSION').read().strip() + '\\"',
|
|
'_GNU_SOURCE',
|
|
])
|
|
quickjs = quickjsEnv.Library('build/quickjs', [
|
|
'build/deps/quickjs/bjson.c',
|
|
'build/deps/quickjs/cutils.c',
|
|
'build/deps/quickjs/jscompress.c',
|
|
'build/deps/quickjs/libbf.c',
|
|
'build/deps/quickjs/libregexp.c',
|
|
'build/deps/quickjs/libunicode.c',
|
|
'build/deps/quickjs/quickjs-libc.c',
|
|
'build/deps/quickjs/quickjs.c',
|
|
'build/deps/quickjs/unicode_gen.c',
|
|
])
|
|
env.Append(LIBS=[quickjs])
|
|
env.Append(CPPPATH=['deps/quickjs'])
|
|
|
|
env.Program('qjst', ['build/src/quickjstest.c'], LIBS=['m', 'dl', quickjs])
|
|
|
|
source = [s for s in Glob('build/src/*.cpp') if not os.path.basename(str(s)).startswith("SecureSocket_")]
|
|
|
|
if sys.platform == 'darwin':
|
|
env.Append(FRAMEWORKS=['CoreFoundation', 'Security'])
|
|
elif sys.platform == 'win32':
|
|
env.Append(LIBS=['Crypt32'])
|
|
env.Program('tildefriends', source)
|
|
|
|
def listAllFiles(root):
|
|
for root, dirs, files in os.walk(root):
|
|
for f in files:
|
|
if not f.startswith('.'):
|
|
yield os.path.join(root, f)
|
|
hidden = [d for d in dirs if d.startswith('.')]
|
|
for d in hidden:
|
|
dirs.remove(d)
|
|
|
|
if env['package'] and sys.platform == 'win32':
|
|
files = [
|
|
'COPYING',
|
|
'LICENSE',
|
|
'SConstruct',
|
|
'tildefriends.exe',
|
|
'icudtl.dat',
|
|
]
|
|
files += listAllFiles('src')
|
|
files += listAllFiles('packages')
|
|
files += listAllFiles('core')
|
|
env.Package(
|
|
NAME='TildeFriends',
|
|
target='dist/TildeFriends-win32.zip',
|
|
PACKAGETYPE='zip',
|
|
PACKAGEROOT='TildeFriends-win32',
|
|
source=files
|
|
)
|