-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpremake5.lua
211 lines (184 loc) · 4.87 KB
/
premake5.lua
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
require 'third_party/premake-android-studio'
OUTDIR = 'build/%{_ACTION}/%{cfg.platform}/%{cfg.buildcfg}/'
FRAMEWORK_NAME = '00-Framework'
-- Allow Objective C++ files on macOS and iOS
premake.api.addAllowed( 'language', 'ObjCpp' )
-- Set system to android
if( _ACTION == 'android-studio' ) then
_TARGET_OS = 'android'
system( 'android' )
end
if( _TARGET_OS == 'macosx' ) then
newoption {
trigger = 'ios',
description = 'Target iOS'
}
if( _OPTIONS[ 'ios' ] ) then
_TARGET_OS = 'ios'
end
end
local function get_platforms()
if( _ACTION == 'android-studio' ) then
return { }
elseif( os.host() == 'windows' ) then
return os.is64bit() and { 'x64', 'x86' } or { 'x86' }
else
local arch = os.outputof( 'uname -m' )
return { arch }
end
end
local function base_config()
location( 'build/%{_ACTION}/' )
objdir( OUTDIR )
targetdir( OUTDIR )
debugdir( 'assets' )
cppdialect( 'C++17' )
warnings( 'Extra' )
rtti( 'Off' )
exceptionhandling( 'Off' )
minsdkversion( '23' )
maxsdkversion( '28' )
includedirs { 'src/' }
sysincludedirs { 'src/' }
flags { 'MultiProcessorCompile' }
filter { 'configurations:Debug' }
optimize( 'Off' )
symbols( 'On' )
filter { 'configurations:Release' }
optimize( 'Full' )
symbols( 'Off' )
defines { 'NDEBUG' }
filter { 'system:windows' }
toolset( 'msc' )
defines { 'NOMINMAX' }
filter { 'system:not windows' }
toolset( 'gcc' )
filter { 'system:linux' }
debugenvs { 'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../%{OUTDIR}' }
filter { 'system:android' }
androidabis { 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' }
buildoptions { '-Wfatal-errors' }
filter{ }
end
local function foreach_system( functor )
local field = premake.field.get( 'system' )
for i=1,#field.allowed do
functor( field.allowed[ i ] )
end
functor( 'android' )
end
local modules = { }
local function decl_module( name )
local up = name:upper()
group( 'Engine' )
project( name )
kind( 'SharedLib' )
defines { 'ORB_BUILD', 'ORB_BUILD_' .. up }
links( modules )
appid( 'com.gaztin.orbit.libs.' .. name:lower() )
base_config()
files {
'src/Orbit/' .. name .. '/**.cpp',
'src/Orbit/' .. name .. '/**.h',
}
filter { 'toolset:msc' }
defines { '_CRT_SECURE_NO_WARNINGS' }
filter { 'system:macosx or ios' }
files { 'src/Orbit/' .. name .. '/**.mm' }
filter { 'system:macosx or ios', 'files:**.cpp' }
language( 'ObjCpp' )
filter { 'system:android' }
includedirs { ANDROID_NATIVE_APP_GLUE_DIR }
filter { }
project()
group()
table.insert( modules, name )
end
local function decl_framework()
group( 'Samples' )
project( FRAMEWORK_NAME )
kind( 'StaticLib' )
appid( 'com.gaztin.orbit.libs.framework')
base_config()
files {
string.format( 'src/Samples/%s/**', FRAMEWORK_NAME ),
}
filter { 'system:macosx or ios', 'files:**.cpp' }
language( 'ObjCpp' )
filter { }
project()
group()
end
local samples = { }
local function decl_sample( name )
local id = string.format( '%02d', 1 + #samples )
local fullname = id .. '-' .. name
group( 'Samples' )
project( fullname )
kind( 'WindowedApp' )
links( modules )
xcodebuildresources( 'assets' )
appid( 'com.gaztin.orbit.samples.' .. name:lower() )
base_config()
files {
'src/Samples/' .. fullname .. '/*.cpp',
'src/Samples/' .. fullname .. '/*.h',
}
includedirs {
string.format( 'src/Samples/%s/', FRAMEWORK_NAME ),
}
links {
FRAMEWORK_NAME,
}
filter { 'system:linux' }
linkoptions { '-Wl,-rpath=\\$$ORIGIN' }
filter { 'system:macosx or ios', 'files:**.cpp' }
language( 'ObjCpp' )
filter { 'system:ios' }
files { 'res/Info.plist', 'assets' }
filter { 'system:android' }
files { 'src/Samples/' .. fullname .. '/Android/**' }
filter { 'system:android' }
assetdirs { 'assets/' }
filter { }
project()
group()
table.insert( samples, fullname )
end
local workspace_name = 'Orbit'
workspace( workspace_name )
platforms( get_platforms() )
configurations { 'Debug', 'Release' }
gradleversion( '3.1.4' )
decl_module( 'Core' )
filter { 'system:macosx' }
links { 'Cocoa.framework', 'Carbon.framework' }
filter { 'system:android' }
links { 'log', 'android' }
filter { 'system:ios' }
links { 'UIKit.framework', 'QuartzCore.framework' }
filter { }
decl_module( 'Math' )
decl_module( 'Graphics' )
filter { 'system:windows' }
links { 'opengl32', 'd3d11', 'dxgi', 'dxguid', 'D3DCompiler' }
filter { 'system:linux' }
links { 'X11', 'GL' }
filter { 'system:macosx' }
links { 'Cocoa.framework', 'OpenGL.framework' }
defines { 'GL_SILENCE_DEPRECATION' }
filter { 'system:android' }
links { 'android', 'EGL', 'GLESv1_CM', 'GLESv2' }
filter { 'system:ios' }
links { 'UIKit.framework', 'GLKit.framework', 'OpenGLES.framework' }
defines { 'GLES_SILENCE_DEPRECATION' }
filter { }
decl_module( 'ShaderGen' )
decl_framework()
decl_sample( 'Triangle' )
decl_sample( 'Cube' )
decl_sample( 'Model' )
decl_sample( 'Animation' )
decl_sample( 'PostFX' )
workspace( workspace_name )
startproject( samples[ 1 ] )