forked from nidium/Nidium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure_frontend
executable file
·365 lines (303 loc) · 12.4 KB
/
configure_frontend
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
#!/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 sys
import os
import json
from konstructor import Deps
from konstructor import CommandLine
from konstructor import Build
from konstructor import Builder
from konstructor import Platform
from konstructor import Konstruct
from konstructor import Utils
from konstructor import Variables
from konstructor import Tests
from konstructor import PackageManger
from konstructor import Log
from konstructor import ROOT
Gyp = Builder.Gyp
Deps.set(
"portaudio",
"zita-resampler",
"depot_tools",
"angle",
"giflib",
"skia",
"libzip",
"lss",
"breakpad",
"basekit",
"libcoroutine",
"SDL2",
"rapidxml",
"ffmpeg",
Deps.Konstruct("libnidiumcore", "configure_libnidiumcore")
)
if Platform.system == "Linux":
Deps.set("libnotify")
Platform.setEnviron("MACOSX_DEPLOYMENT_TARGET=10.7")
Gyp.setArgs("--depth ./ --include=gyp/config.gypi --include=gyp/common.gypi")
Gyp.set("nidium_product_define", "NIDIUM_PRODUCT_FRONTEND")
Gyp.set("nidium_js_disable_window_global", 0)
DEPEDENCY_REPO = Variables.get("depsRepo")
CONFIGURE_PATH = os.path.dirname(os.path.realpath(__file__))
@Deps.register("portaudio")
def portaudio():
return {
"location": DEPEDENCY_REPO + "/portaudio.tgz",
"build": ["./configure --without-jack --without-asihpi --without-winapi", "make -j1", "make src/common/pa_ringbuffer.o"],
"outputs": ["lib/.libs/libportaudio.a"],
"patchs": [os.path.join(CONFIGURE_PATH, "patch", "portaudio.patch")]
}
@Deps.register("zita-resampler")
def zitaresampler():
return {
"location": DEPEDENCY_REPO + "/zita-resampler-1.3.0.tar.bz2",
"patchs": [os.path.join(CONFIGURE_PATH, "patch", "zita.patch")],
"chdir": "libs/",
"build": ["make"],
"outputs": ["libzita-resampler(.a|.lib)"]
}
@Deps.register("giflib")
def giflib():
# skdiff is used during unit-tests and it needs libgif.so.4
Platform.setEnviron("LD_LIBRARY_PATH=$LD_LIBRARY_PATH:%s/giflib/lib/.libs/" % os.getcwd())
return {
"location": "http://downloads.sourceforge.net/project/giflib/giflib-4.x/giflib-4.2.3.tar.gz",
"build": ["./configure", "make coverity"],
"outputs": ["lib/.libs/libgif.a"]
}
@Deps.register("skia")
def skia():
args = {
"extra_cflags_cc": [
"-Wno-unused-function",
"-Wno-array-bounds",
"-Wno-return-local-addr",
"-DGR_GL_CUSTOM_SETUP_HEADER=<../../../../../patch/skia_gl_config.h>"
],
"is_official_build": True,
"cc": Platform.getEnviron("CC"),
"cxx": Platform.getEnviron("CXX")
}
if Platform.system == "Darwin":
args["extra_cflags_cc"].append("-stdlib=libc++")
args["extra_ldflags"] = ["-stdlib=libc++"]
# Add depot_tools to path needed for skia
Platform.setEnviron("PATH+=" + os.path.join(Deps.getDir(), "depot_tools"))
# depot_tools and skia needs python2.7 but use "python" as the default
# interpreter which could be python3.x on some system. Workaround that
# by using a custom python wrapper that will redirect to the correct python version
Platform.setEnviron("PATH=" + os.path.join(ROOT, "tools") + ":" + os.environ.get("PATH", ""))
skiaArgs = ""
for k, v in args.items():
skiaArgs += " %s=%s" % (k, json.dumps(v))
return {
"location": Deps.GitRepo("https://skia.googlesource.com/skia.git", revision="98829b9"),
"build": [
"python tools/git-sync-deps",
"bin/gn gen out/Static --args='%s'" % (skiaArgs),
"ninja %s -C out/Static" % ("-v" if Variables.get("verbose") else ""),
],
"patchs": [
os.path.join(CONFIGURE_PATH, "patch", "skia_gl.patch"),
os.path.join(CONFIGURE_PATH, "patch", "skia_gr_gl_callback.patch")
],
"outputs": [
"out/Static/libskia.a",
{
"src": "out/Static/skdiff",
"dst": os.path.join(ROOT, "tests", "jsunittest", "gr", "skdiff")
}
]
}
@Deps.register("libzip")
def libzip():
return {
#"location": DEPEDENCY_REPO + "/libzip-0.10.1.tar.bz2",
"location": "http://www.nih.at/libzip/libzip-1.1.2.tar.gz",
"build": ["./configure --disable-shared --with-zlib=%s/zlib/" % (Deps.getDir()), "make"],
"outputs": ["lib/.libs/libzip.a"]
}
@Deps.register("lss")
def lss():
return {
"location": Deps.GitRepo("https://chromium.googlesource.com/linux-syscall-support", revision="348bdf8d32b37c8fb2627df7a0a977d1d640e1fc")
}
def fixAngleThinArchive():
# By default ANGLE libs are thin archive, and thus, not relocatable
# which breaks Konstructor way of dealing with archives. We need to
# update ninja build file, to create "normal" archive
if Platform.system == "Linux" or Platform.system == "Darwin":
Utils.run("sed -i.bak \"s/$ar rcsT/$ar rcs/\" out/Release/build.ninja")
@Deps.register("angle")
def angle():
cxxFlags = os.environ.get("CXXFLAGS", "")
# Disable some errors for clang 3.5 & 3.7
cxxFlags += " -Wno-c++11-narrowing -Wno-sign-compare -Wno-error"
if Platform.wordSize == 32:
cxxFlags += " -msse -msse2 -msse3"
if Platform.system == "Darwin":
outPath = "out/Release/"
elif Platform.system == "Linux":
outPath = "out/Release/obj/src/"
return {
"location": Deps.GitRepo("https://chromium.googlesource.com/angle/angle", branch="chromium/2785"),
"build": [
"python scripts/bootstrap.py",
"GYP_GENERATORS=ninja LDFLAGS=\"%s\" CXXFLAGS=\"%s\" gclient sync" % (os.environ.get("LDFLAGS", ""), cxxFlags),
fixAngleThinArchive,
"ninja -C out/Release/"
],
"outputs": [
os.path.join(outPath, "libpreprocessor.a"),
os.path.join(outPath, "libtranslator.a"),
os.path.join(outPath, "libtranslator_lib.a"),
os.path.join(outPath, "libangle_common.a")
]
}
@Deps.register("breakpad")
def breakpad():
return {
"location": Deps.GitRepo("https://chromium.googlesource.com/breakpad/breakpad", revision="48b9a40539689743bacbe20df01182b0c367c2c0")
}
@Deps.register("SDL2")
def SDL2():
# SDL2 Build as framework
#build: ["xcodebuild -configuration 'Release' CONFIGURATION_BUILD_DIR='out' -target 'Framework'"],
#outputs["SDL2/Xcode/SDL/out/SDL2.framework"])
return {
"location": "https://www.libsdl.org/release/SDL2-2.0.3.tar.gz",
"chdir": "build",
"build": ["../configure", "make"],
"outputs": ["build/.libs/libSDL2.a"]
}
@Deps.register("depot_tools")
def depotTools():
Deps.Gclient.setExec(os.path.join("depot_tools", "gclient"))
return {
"location": Deps.GitRepo("https://chromium.googlesource.com/chromium/tools/depot_tools.git", revision="8bf327c")
}
@Deps.register("basekit")
def basekit():
return {
"location": Deps.GitRepo("https://github.com/stevedekorte/basekit.git", revision="a3e54ba83b85f530dc9442a33d2779240ed96189"),
"build": ["make"],
"patchs": [os.path.join(CONFIGURE_PATH, "patch", "basekit.patch")],
"outputs": ["_build/lib/libbasekit(.a|.lib)"]
}
@Deps.register("libcoroutine")
def libcoro():
patchs = [os.path.join(CONFIGURE_PATH, "patch", "libcoroutine.patch")]
if Konstruct.config("valgrind"):
patchs.append(os.path.join(CONFIGURE_PATH, "patch", "libcoroutine.debug.patch"))
return {
"location": Deps.GitRepo("https://github.com/stevedekorte/coroutine.git", revision="b0bf11d8a0ec70bc0f1f5043513d334e1eff15fc"),
"patchs": patchs,
"build": ["make"],
"outputs": [["_build/lib/liblibcoroutine(.a|.lib)", "libcoroutine\\1"]]
}
@Deps.register("rapidxml")
def rapidxml():
return {
"location": "http://downloads.sourceforge.net/project/rapidxml/rapidxml/rapidxml%201.13/rapidxml-1.13.zip",
"patchs": [ os.path.join(CONFIGURE_PATH, "patch", "rapidxml.patch")],
}
@Deps.register("ffmpeg")
def ffmpeg():
return {
"location": Deps.GitRepo("git://git.ffmpeg.org/ffmpeg.git", tag="n3.0.7"),
"patch": [],
"build":
[
"./configure \
--disable-vaapi --disable-avdevice --disable-postproc --disable-avfilter --disable-ffserver --disable-lzma --disable-bzlib \
--enable-decoder=ac3,aac,mp3,vorbis,pcm_s16be_planar,pcm_s16le,pcm_s16le_planar,pcm_s24be,pcm_s24daud,pcm_s24le,pcm_s24le_planar,pcm_s32be,pcm_s32le,pcm_s32le_planar,pcm_s8,pcm_s8_planar,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le,pcm_u32be,pcm_u32le,pcm_u8,h264,mpeg4,mpeg2video,wmv1,wmv2,wmv3,wmv3_crystalhd,wmv3_vdpau,wmv3image,wmalossless,wmapro,wmav1,wmav2,wmavoice,vc1,vc1_crystalhd,vc1_vdpau,vc1image\
--enable-parser=vorbis,mpegaudio,mpegvideo,mpeg4video,h264,vp8,aac,vc1\
--enable-demuxer=matroska,mp3,ogg,vorbis,pcm_alaw,pcm_f32be,pcm_f32le,pcm_f64be,pcm_f64le,pcm_mulaw,pcm_s16be,pcm_s16le,pcm_s24be,pcm_s24le,pcm_s32be,pcm_s32le,pcm_s8,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le,pcm_u32be,pcm_u32le,pcm_u8,h264,mpegvideo,aac,mov,avi,wav,asf",
"make"
],
"outputs":
[
"libavcodec/libavcodec(.a|.lib)",
"libswresample/libswresample(.a|.lib)",
"libavutil/libavutil(.a|.lib)",
"libavformat/libavformat(.a|.lib)",
"libswscale/libswscale(.a|.lib)"
]
}
@Deps.register("libnotify")
def libnotify():
return {
"location": DEPEDENCY_REPO + "/libnotify-0.7.6.tar.gz",
"build": ["./configure", "make"],
"outputs": ["libnotify/.libs/libnotify.a"]
}
def getNidiumPath():
nidium = ""
if Platform.system == "Linux":
return ("bin/", "./nidium")
elif Platform.system == "Darwin":
return ("bin/", "./nidium.app/Contents/MacOS/nidium")
else:
raise Exception("TODO : Unsupported platform, cannot find nidum executable")
def addEmbed():
# Build dir2nvfs
if not os.path.exists("tools/dir2nvfs"):
Gyp("gyp/tools.gyp", defines={"nidium_js_disable_window_global": 1,
"nidium_product_define": "DIR2NVFS"}).run("dir2nvfs")
# Generate the embed file with dir2nvfs
Gyp("gyp/actions.gyp").run("generate-embed", parallel=False)
# Now that the embed are packaged
# we can add add nidium_package_embed flag
Gyp.set("nidium_package_embed", 1)
@CommandLine.option("--embed", default=False)
def embed(embed):
if embed:
@Konstruct.hook("preBuild")
def preBuildAddEmbed():
addEmbed()
@CommandLine.option("--auto-tests", default=False)
def autoTestStudio(autoTests):
if not autoTests:
return
tests = []
nidium = getNidiumPath()
# Find Konstrutor path, to run Dokumentor
dokumentor = os.path.dirname(os.path.abspath(sys.modules[Konstruct.__module__].__file__))
dokumentor = os.path.join(dokumentor, "dokumentor.py")
Utils.run(dokumentor + " exampletest docs/ > tests/jsautotest/autotests.js")
Gyp.set("nidium_ui_console", "0")
tests.append((nidium[1] + " ../tests/jsautotest/autotests.nml", nidium[0]))
Tests.register(tests)
@CommandLine.option("--unit-tests")
def testStudio(unitTests):
if not unitTests:
return
tests = []
nidium = getNidiumPath()
# Log unit-tests to stdout
Gyp.set("nidium_ui_console", "0")
tests.append((nidium[1] + " ../tests/jsunittest/unittests.nml --frontend", nidium[0]))
Tests.register(tests)
@CommandLine.option("--debug-opengl", default=False)
def glDebug(debug):
if not debug:
return
Gyp.set("nidium_gl_debug", 1);
@CommandLine.option("--debug")
def debug(debug):
if not debug:
return
glDebug(True)
Build.add(Gyp("gyp/all.gyp"));
if __name__ == '__main__':
Log.info("Checking for required software...")
if not Utils.findExec("yasm"):
if not PackageManger.detect():
Utils.exit("Couldn't find a package manager to install \"yasm\" software. Please install it manually and make sure \"yasm\" executable is in your path before building nidium.")
if not PackageManger.install("yasm", prompt=True):
Utils.exit("configure script aborted, couldn't install \"yasm\" dependency. Please install it manually and make sure \"yasm\" executable is in your path.")
Konstruct.start()