forked from nidium/Nidium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure_libnidiumcore
executable file
·185 lines (152 loc) · 6 KB
/
configure_libnidiumcore
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
#!/usr/bin/env python2.7
# Copyright 2016 Nidium Inc. All rights reserved.
# Use of this source code is governed by a MIT license
# that can be found in the LICENSE file.
import os
from konstructor import Deps
from konstructor import CommandLine
from konstructor import Build
from konstructor import Builder
from konstructor import Platform
from konstructor import Variables
from konstructor import Konstruct
from konstructor import Tests
from konstructor import Utils
from konstructor import Log
from konstructor import ROOT, OUTPUT
Deps.set(
"libnspr4",
"mozilla-central",
"leveldb",
"http-parser",
"jsoncpp",
Deps.Konstruct("network", "src/libapenetwork/configure")
)
if Platform.system == "Darwin":
Platform.setEnviron("CXXFLAGS+=-stdlib=libc++ -mmacosx-version-min=10.7")
Platform.setEnviron("CPPFLAGS+=-stdlib=libc++ -mmacosx-version-min=10.7")
# Some third-party librairires (skia, angle, mozilla-central)
# produce binaries. So we need to set LDFLAGS too.
Platform.setEnviron("LDFLAGS+=-stdlib=libc++ -mmacosx-version-min=10.7")
DEPEDENCY_REPO = Variables.get("depsRepo")
CONFIGURE_PATH = os.path.dirname(os.path.realpath(__file__))
Gyp = Builder.Gyp
@Deps.register("leveldb")
def leveldb():
cxxFlags = os.environ.get("CXXFLAGS", "")
if Konstruct.config("asan"):
# Fix ASAN container overflow false positive :
# https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow#false-positives
cxxFlags += " -fsanitize=address"
return {
"location": Deps.GitRepo("https://github.com/google/leveldb.git", tag="v1.18"),
# leveldb make doest not detect CXXFLAGS changes, so we force "make clean"
"build": ["make clean", "CXXFLAGS='%s' make" % (cxxFlags)],
"patchs": [os.path.join(CONFIGURE_PATH, "patch", "leveldb.patch")],
"outputs": ["libleveldb(.a|.lib)"]
}
@Deps.register("libnspr4")
def libnspr():
configure = "./configure"
if Platform.wordSize == 64:
configure += " --enable-64bit"
return {
"chdir": "mozilla-central/nsprpub/",
"build": [configure, "make"],
"outputs": ["dist/lib/libnspr4(.a|.lib)"]
}
@Deps.register("mozilla-central")
def mozilla():
nsprDir = os.path.realpath(os.path.join("mozilla-central/nsprpub/"))
nsprFlags = "--with-nspr-cflags=\"-I%s/dist/include/nspr/\" \
--with-nspr-libs=\"-L%s/dist/lib/ -lnspr4 -lplds4 -lplc4\"" % (nsprDir, nsprDir)
configure = "../configure\
--disable-shared-js\
--disable-jemalloc\
--enable-ctypes %s" % (nsprFlags)
if Konstruct.config("debug", "valgring"):
configure += " --enable-debug --disable-optimize"
if Konstruct.config("valgrind"):
configure += " --enable-valgrind "
return {
"chdir": "js/src/obj",
"location": DEPEDENCY_REPO + "/mozjs-45.5.3.tar.bz2",
"build": [configure, "make"],
"outputs": ["mozglue/build/libmozglue.a$", "js/src/libjs_static.a$", "js/src/js-config.h$"]
}
@Deps.register("http-parser")
def httpParser():
return {
"location": Deps.GitRepo("https://github.com/nodejs/http-parser.git", tag="v2.6.2"),
"build": ["make package"],
"outputs": ["libhttp_parser.a"]
}
@Deps.register("jsoncpp")
def jsoncpp():
return {
"location": Deps.GitRepo("https://github.com/open-source-parsers/jsoncpp.git", tag="1.7.2"),
"build": ["python amalgamate.py"]
}
@CommandLine.option("--unit-tests")
def testCore(unitTests):
if not unitTests:
return
cwd = os.path.dirname(os.path.realpath(__file__))
Tests.register([
"build/tests/libnidiumcore-unittests"
], builders=[
Gyp("gyp/libnidiumcore-tests.gyp",
defines={"nidium_js_disable_window_global": 1,
"nidium_product_define": "NIDIUM_UNIT_TESTS"})
])
@CommandLine.option("--asan", default=False)
def asan(asan):
if asan:
Konstruct.setConfigs(["asan"])
Gyp.set("asan", 1)
@CommandLine.option("--cpu-profiling", default=False)
def profiler(profiler):
if profiler:
Gyp.set("profiler", 1)
Deps.set("gperftools")
Deps.set("pprof")
@Konstruct.hook("postBuild")
def profilerPostBuild(success):
if not success:
return
Log.info("-------------------------------------")
Log.info("You have enabled CPU profiling, you must set the following environement variables to enable CPU profiling when running your application : ")
Log.info("CPUPROFILE=/tmp/profile.nidium")
Log.info("LD_LIBRARY_PATH=" + ROOT + "/build/third-party/${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH:-}")
Log.info("-------------------------------------")
@CommandLine.option("--unit-tests")
def nidiumCoreTests(unitTests):
if not unitTests:
return
def query(port, useSSL=False):
import urllib2
try:
urllib2.urlopen("http%s://tests.nidium.com:%d/http/hello" % ("s" if useSSL else "", port)).read()
return True
except Exception as e:
Log.info("Failed to contact tests server %s" % (e))
return False
@Konstruct.hook("preTests")
def preNidiumCoreTests():
if not query(8888) or not query(8443, useSSL=True):
Utils.exit("Tests server is down. Cannot run tests.")
@CommandLine.option("--auto-tests", default=False)
def autoTestStudio(autoTests):
if not autoTests:
return
@Konstruct.hook("postBuild")
def runNidiumAutoTests(success):
Tests.runTest(success)
if __name__ == '__main__':
if not Builder.Gyp._defines.has_key('nidium_version'):
Gyp.set('nidium_version', 'library')
Gyp.setArgs("--depth ./ --include=gyp/config.gypi --include=gyp/common.gypi --include=src/libapenetwork/gyp/config.gypi")
Gyp.set("nidium_product_define", "NIDIUM_PRODUCT_SERVER")
Build.add(Gyp("src/libapenetwork/gyp/network.gyp"));
Build.add(Gyp("gyp/libnidiumcore.gyp"))
Konstruct.start()