-
Notifications
You must be signed in to change notification settings - Fork 3
/
mrb_config.rb
149 lines (128 loc) · 4.49 KB
/
mrb_config.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
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
require 'set'
require_relative 'lib/platform'
toolchain_name = (ENV['MOON_MRUBY_TOOLCHAIN'] || :gcc).to_sym
platform = Platform.new
rootdir = File.dirname(__FILE__)
MRuby::Build.new 'host', File.expand_path("build", rootdir) do |conf|
toolchain toolchain_name
puts "\t\\\\ Using #{toolchain_name} Toolchain \\\\"
# Full backtraces
conf.enable_debug
# include the default GEMs
conf.gembox 'default'
conf.gembox File.expand_path('modules/moon', rootdir)
conf.gem core: 'mruby-eval'
conf.gem core: 'mruby-bin-debugger'
conf.gem github: 'IceDragon200/mruby-patch-core'
conf.gem github: 'iij/mruby-io' # General IO stuff, File system blah de dah.
conf.gem github: 'iij/mruby-dir' # Directory access
conf.gem github: 'iij/mruby-regexp-pcre' # Regular expression engine :3
conf.gem github: 'iij/mruby-tempfile' # required by iij/mruby-require
conf.gem github: 'iij/mruby-require' # require
# nice things
#conf.gem github: 'AndrewBelt/mruby-yaml' # YAML :3
conf.gem github: 'IceDragon200/mruby-yaml', branch: 'args_req-fix' # YAML :3
conf.cxx do |c|
std = 'c++11'
comp = toolchain_name == :clang ? 'clang' : 'gcc'
result = `#{comp} -dumpversion`.chomp
case toolchain_name
when :clang
# nothing yet
#if ver < '2.9'
# end
when :gcc
if result < '4.7'
std = 'c++0x'
end
end
puts "\t\\\\ Using #{comp}(#{result}) c++ std: #{std} \\\\"
c.flags << "-std=#{std}"
end
vd = File.expand_path('vendor', rootdir)
bvd = File.expand_path('build/vendor', rootdir)
puts "VendorDir: #{vd}"
puts "Build.VendorDir: #{bvd}"
[conf.cc, conf.cxx].each do |c|
flags = Set.new(c.flags)
# remove other optimization flags
flags.delete("-O0")
flags.delete("-O1")
flags.delete("-O2")
# enable debugging
flags << '-g3'
# optimize level 3
flags << '-O3'
# Its a good idea to get all the warnings
flags << '-Wall'
flags << '-Wextra'
# shuts up those unusued-parameter warnings, trust me, you'll be swimming
# in them from a mruby extension.
flags << '-Wno-unused-parameter'
c.defines << 'ENABLE_DEBUG'
if platform.darwin?
# GLFW
c.defines << 'MOON_GL_GLFW'
else
# GLEW
c.defines << 'MOON_GL_GLEW'
end
# enable mruby-yaml: null, Null and NULL
flags << "-DMRUBY_YAML_NULL=1"
# disable all the extra mruby-yaml aliases, this makes it more like ruby
flags << "-DMRUBY_YAML_BOOLEAN_ON=0"
flags << "-DMRUBY_YAML_BOOLEAN_YES=0"
flags << "-DMRUBY_YAML_BOOLEAN_SHORTHAND_YES=0"
flags << "-DMRUBY_YAML_BOOLEAN_OFF=0"
flags << "-DMRUBY_YAML_BOOLEAN_NO=0"
flags << "-DMRUBY_YAML_BOOLEAN_SHORTHAND_NO=0"
# required system includes
c.include_paths << File.expand_path('glm', vd)
# required graphics includes
c.include_paths << File.expand_path('glfw/include', vd)
c.include_paths << File.expand_path('glfw/src', bvd) # has the glfw_config.h
c.include_paths << File.expand_path('glfw/include', vd)
c.include_paths << File.expand_path('soil/include', vd)
c.include_paths << File.expand_path('sil/include', vd)
c.include_paths << File.expand_path('freetype-gl', vd)
# required audio includes
c.include_paths << File.expand_path('gorilla-audio/include', vd)
c.include_paths.uniq!
c.flags = flags.to_a
end
conf.linker do |l|
l.library_paths << File.expand_path('glfw/src', bvd)
l.library_paths << File.expand_path('freetype-gl', bvd)
l.library_paths << File.expand_path('gorilla-audio/build', bvd)
l.library_paths << File.expand_path('sil', bvd)
l.library_paths << File.expand_path('soil', bvd)
l.library_paths.uniq!
l.libraries << 'glfw'
l.libraries << 'freetype-gl'
l.libraries << 'gorilla'
l.libraries << 'freetype'
l.libraries << 'SOIL'
l.libraries << 'SIL'
if platform.linux?
l.libraries << 'GLEW'
l.libraries << 'GL'
l.libraries << 'openal'
elsif platform.windows?
l.libraries << 'glew32'
l.libraries << 'opengl32'
l.libraries << 'OpenAL32'
elsif platform.darwin?
l.libraries << 'GLEW'
l.flags_after_libraries << '-framework OpenGL'
l.flags_after_libraries << '-framework OpenAL'
l.flags_after_libraries << '-framework CoreFoundation'
end
if platform.unix?
l.libraries << 'pthread'
end
puts "Linking these libraries:"
l.libraries.each do |lib|
puts "\t#{lib}"
end
end
end