-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpremake5.lua
More file actions
150 lines (127 loc) · 5.02 KB
/
premake5.lua
File metadata and controls
150 lines (127 loc) · 5.02 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
require "vstudio"
table.insert(premake.option.get("os").allowed, { "android", "Google Android" })
table.insert(premake.option.get("os").allowed, { "ios", "Apple iOS" })
filter {}
newoption {
trigger = "has-python",
description = "Adds Python sample to solution"
}
newoption {
trigger = "udsdk",
value = "Path",
description = "Path to udSDK",
default = os.getenv("UDSDK_HOME")
}
if _OPTIONS["udsdk"] == nil then
error "udSDK not installed correctly. (No UDSDK_HOME environment variable or --udsdk=[PATH] argument!)"
end
function getosinfo()
local osname = os.target()
local distroExtension = ""
if os.target() == premake.LINUX then
osname = os.outputof('lsb_release -ir | head -n2 | cut -d ":" -f 2 | tr -d "\n\t" | tr [:upper:] [:lower:]')
if osname:startswith("centos") then
osname = os.outputof('lsb_release -ir | head -n2 | cut -d ":" -f 2 | tr -d "\n\t" | tr [:upper:] [:lower:] | cut -d "." -f 1')
distroExtension = "_rpm"
else
distroExtension = "_deb"
end
end
return osname, distroExtension
end
function IncludeUDSDK()
includedirs(_OPTIONS["udsdk"] .. "/include")
libdirs { _OPTIONS["udsdk"] .. "/include" }
local osname, distroExtension = getosinfo()
if os.target() == premake.MACOSX then
links { "udSDK.framework" }
else
links { "udSDK" }
end
if os.target() == premake.WINDOWS then
postbuildcommands { 'XCOPY /f /d /y "' .. _OPTIONS["udsdk"] .. '\\lib\\win_x64\\udSDK.dll" "$(TargetDir)\\"' }
os.copyfile(_OPTIONS["udsdk"] .. "/lib/win_x64/udSDK.dll", "builds/udSDK.dll")
libdirs { _OPTIONS["udsdk"] .. "/lib/win_x64" }
elseif os.target() == premake.MACOSX then
os.execute("mkdir -p builds")
-- copy dmg, mount, extract framework, unmount then remove.
os.copyfile(_OPTIONS["udsdk"] .. "/lib/osx_x64/udSDK.dmg", "builds/udSDK.dmg")
local device = os.outputof("/usr/bin/hdiutil attach -noverify -noautoopen builds/udSDK.dmg | egrep '^/dev/' | sed 1q | awk '{print $1}'")
os.execute("cp -a -f /Volumes/udSDK/udSDK.framework builds/")
os.execute("/usr/bin/hdiutil detach /Volumes/udSDK")
os.execute("/usr/bin/hdiutil detach " .. device)
os.execute("rm -r builds/udSDK.dmg")
prelinkcommands {
"rm -rf %{prj.targetdir}/%{prj.targetname}.app/Contents/Frameworks",
"mkdir -p %{prj.targetdir}/%{prj.targetname}.app/Contents/Frameworks",
"cp -af builds/udSDK.framework %{prj.targetdir}/%{prj.targetname}.app/Contents/Frameworks/",
"cp -af /Library/Frameworks/SDL2.framework %{prj.targetdir}/%{prj.targetname}.app/Contents/Frameworks/",
}
linkoptions { "-rpath @executable_path/../Frameworks/" }
frameworkdirs { "builds" }
elseif os.target() == premake.ANDROID then
filter { "architecture:x64" }
libdirs { _OPTIONS["udsdk"] .. "/lib/android_x64" }
filter { "architecture:arm64" }
libdirs { _OPTIONS["udsdk"] .. "/lib/android_arm64" }
filter {}
else
linkoptions { "-Wl,-rpath '-Wl,$$ORIGIN'" } -- Check beside the executable for the SDK
libdirs { _OPTIONS["udsdk"] .. '/lib/' .. osname .. '_GCC_x64' }
prebuildcommands { 'cp "' .. _OPTIONS["udsdk"] .. '/lib/' .. osname .. '_GCC_x64/libudSDK.so" "%{cfg.targetdir}/"' }
end
end
solution "udSDKSamples"
-- This hack just makes the VS project and also the makefile output their configurations in the idiomatic order
if (_ACTION == "gmake" or _ACTION == "gmake2") and os.target() == "linux" then
configurations { "Release", "Debug", "ReleaseClang", "DebugClang" }
linkgroups "On"
filter { "configurations:*Clang" }
toolset "clang"
filter { }
elseif os.target() == "macosx" or os.target() == "ios" then
configurations { "Release", "Debug" }
toolset "clang"
else
configurations { "Debug", "Release" }
end
if os.target() == "android" or os.target() == "ios" then
platforms { "x64", "arm64" }
else
platforms { "x64" }
end
cppdialect "C++14"
pic "On"
startproject "cSample"
filter { "system:not windows" }
visibility "Hidden"
filter {}
--Uncomment this when looking for memory leaks in code using udCore memory tracking
--defines { "__MEMORY_DEBUG__" }
group "external"
--dofile "external/udCore/project.lua"
group "languages"
if os.target() ~= "android" and os.target() ~= "ios" and os.target() ~= "emscripten" then
dofile "languages/c/project.lua"
dofile "languages/cpp/project.lua"
end
if os.target() == premake.WINDOWS then
dofile "languages/csharp/project.lua"
dofile "integrations/winforms-csharp/project.lua"
end
group "features"
if os.target() ~= "android" and os.target() ~= "ios" and os.target() ~= "emscripten" then
dofile "features/convertcustomdata/project.lua"
dofile "features/convertdem/project.lua"
dofile "features/renderingcustomvoxelshaders/project.lua"
dofile "features/getscenesfromudcloud/project.lua"
dofile "features/excludeStreamedAttributes/project.lua"
end
group "viewer"
if os.target() ~= "android" and os.target() ~= "ios" and os.target() ~= "emscripten" then
dofile "viewer/project.lua"
end
group "libraries"
if os.target() ~= "android" and os.target() ~= "ios" and os.target() ~= "emscripten" then
dofile "external/udcore/project.lua"
end