forked from luvit/luvit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·154 lines (119 loc) · 3.42 KB
/
configure
File metadata and controls
executable file
·154 lines (119 loc) · 3.42 KB
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
#!/usr/bin/env python
"""
From <https://github.com/joyent/node/blob/master/configure-gyp>
"""
import optparse
import os
import json
import sys
import glob
import shutil
root_dir = os.path.dirname(__file__)
# parse our options
parser = optparse.OptionParser()
parser.add_option("--debug",
action="store_true",
dest="debug",
help="Build debug build")
parser.add_option("--prefix",
action="store",
dest="prefix",
help="Select the install prefix (defaults to /usr/local)")
parser.add_option("--arch",
action="store",
dest="arch",
help="Select the default architecture (ia32,x64,mac,arm)")
(options, args) = parser.parse_args()
def pkg_config(pkg):
cmd = os.popen('pkg-config --libs %s' % pkg, 'r')
libs = cmd.readline().strip()
ret = cmd.close()
if (ret): return None
cmd = os.popen('pkg-config --cflags %s' % pkg, 'r')
cflags = cmd.readline().strip()
ret = cmd.close()
if (ret): return None
return (libs, cflags)
def uname(switch):
f = os.popen('uname %s' % switch)
s = f.read().strip()
f.close()
return s
def host_arch():
"""Host architecture. One of arm, ia32 or x64."""
if sys.platform == "win32":
return 'ia32'
if sys.platform == "darwin":
return 'mac'
arch = uname('-p')
if arch == 'unknown':
arch = uname('-m')
return {
'arm': 'arm',
'x86': 'ia32',
'i386': 'ia32',
'x86_64': 'x64',
'amd64': 'x64',
}.get(arch, arch)
def target_arch():
# TODO act on options.dest_cpu
return host_arch()
def configure_luvit(o):
# TODO add gdb and dest_cpu
o['variables']['luvit_debug'] = 'true' if options.debug else 'false'
o['variables']['luvit_prefix'] = options.prefix if options.prefix else ''
o['variables']['host_arch'] = host_arch()
o['variables']['target_arch'] = options.arch if options.arch else target_arch()
print "configure options:", options
output = {
'variables': {},
'include_dirs': [],
'libraries': [],
'defines': [],
'cflags': [],
}
configure_luvit(output)
# variables should be a root level element,
# move everything else to target_defaults
variables = output['variables']
del output['variables']
output = {
'variables': variables,
'target_defaults': output
}
fn = os.path.join(root_dir, 'options.gypi')
print "creating ", fn
f = open(fn, 'w+')
f.write("# Do not edit. Generated by the configure script.\n")
json.dump(output, f, indent=2, skipkeys=True)
f.write("\n")
f.close()
print "Generating build system with GYP..."
def render_openssl_symlinks(src, dest):
src = os.path.abspath(src)
dest = os.path.abspath(dest)
for x in glob.glob(os.path.join(src, '*.h')):
with open(x) as f:
d = f.read().strip()
srcf = os.path.abspath(os.path.join(src, d))
destf = os.path.join(dest, os.path.basename(srcf))
# use copy2, so we preserve mtimes, reducing rebuilds
shutil.copy2(srcf, destf)
if sys.platform == "win32":
render_openssl_symlinks('deps/openssl/include/openssl', 'deps/openssl-configs/realized/openssl')
code = os.system("python tools\gyp_luvit -f msvs -G msvs_version=2010")
else:
code = os.system("tools/gyp_luvit")
if code == 0:
print ""
print "Done!"
print ""
if sys.platform == "win32":
print "Now run `python build.py` to build!"
else:
print "Now run `make -C out` to build!"
print ""
else:
print ""
print "Error occured. Please investigate details above."
print ""