-
Notifications
You must be signed in to change notification settings - Fork 4
/
make_pch.rb
60 lines (48 loc) · 1.12 KB
/
make_pch.rb
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
#!ruby
source_dir = "."
target_dir = "build"
debug_mode = !true
# debug_mode = true
cc = "clang"
arch = "x86_64-darwin13"
opt = 3
debug = 0
if debug_mode
opt = 0
debug = 3
end
if ARGV.size > 0
target_dir = ARGV[0]
end
if ARGV.size > 1
source_dir = ARGV[1]
end
if ARGV.size > 2
cc = ARGV[2]
end
if ARGV.size > 3
arch = ARGV[3]
end
target_path = File.realpath(File.dirname(target_dir))
source_path = File.realpath(source_dir)
header_paths = "-I#{target_path}"
header_paths += " -I#{source_path}"
header_paths += " -I#{target_path}/.ext/include/#{arch}/"
header_paths += " -I#{source_path}/include/"
cmd = "#{cc} -pipe -O#{opt} -g#{debug} -x c-header #{header_paths} \
#{source_path}/ruby_jit.h -o #{target_path}/ruby_jit.h.pch"
#puts cmd
`#{cmd}`
path = File.join(target_path, 'ruby_jit.h.pch')
print "static const char cmd_template[] = "
print "\"#{cc} -pipe -fPIC -O#{opt} -g#{debug} -x c #{header_paths}"
print " -I#{source_path}"
if cc == "clang"
print " -include-pch #{path}"
end
if arch.include?("darwin")
print " -dynamiclib"
else
print " -shared"
end
print " -Wall -o %s %s\";";