-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpremake5.lua
163 lines (132 loc) · 3.63 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
------------------------------
-- Global Variable
------------------------------
-- Prefix Install specify where it should look for custom
-- project header & library files
if G_Install == nil then
G_Install = {}
-- Default Value on Windows & Unix Platform
if os.is("windows") then
G_Install.Root = "C:/Premake/"
else
G_Install.Root = "/usr/local/"
end
end
if not G_Install.Header then G_Install.Header = G_Install.Root.."include" end
if not G_Install.Lib then G_Install.Lib = G_Install.Root.."lib" end
if SolutionRoot == nil then
SolutionRoot = os.getcwd()
end
------------------------------
-- Solution
------------------------------
solution "Muon"
configurations { "DebugDLL", "DebugLib", "ReleaseLib", "ReleaseDLL", "FinalDLL", "FinalLib" }
implibdir "bin/lib"
if os.is("windows") then
buildoptions { "" }
else
buildoptions { "--std=c++11" }
end
-- If option exists, then override G_Install
if _OPTIONS["installdir"] then
G_Install.Root = _OPTIONS["installdir"]
G_Install.Header = _OPTIONS["installdir"].."/include"
G_Install.Lib = _OPTIONS["installdir"].."/bin/lib"
print("Base directory has been overwritten to '"..G_Install.Root.."'")
end
includedirs {
SolutionRoot.."/include",
G_Install.Header,
}
libdirs {
SolutionRoot.."/bin/lib",
G_Install.Lib
}
flags {
"NoImplicitLink",
"NoIncrementalLink",
"NoEditAndContinue",
}
filter "Debug*"
targetsuffix "-d"
optimize "Debug"
flags { "Symbols" }
defines { "MUON_DEBUG"}
filter "Release*"
targetsuffix "-r"
optimize "Speed"
flags { "Symbols" }
filter "Final*"
targetsuffix "-f"
optimize "Full"
flags { "LinkTimeOptimization" }
filter "*Lib"
kind "StaticLib"
flags { "StaticRuntime" }
defines { "MUON_STATIC" }
filter "*DLL"
kind "SharedLib"
filter {}
------------------------------
-- Project
------------------------------
include("project_Lib")
------------------------------
-- Options
------------------------------
newoption {
trigger = "installdir",
value = "PATH",
description = "Folder to search lib & include; default: '"..G_Install.Root.."'",
}
------------------------------
-- Actions
------------------------------
newaction {
trigger = "install",
description = "Install developpment files & library",
execute = function ()
print("** Installing Header files in: "..G_Install.Header.." **")
local incDir = SolutionRoot.."/include/"
local libDir = SolutionRoot.."/bin/lib/"
-- HEADER
-- Create required folders
local dirList = os.matchdirs(incDir.."**")
for _,fdir in pairs(dirList) do
local destDir = G_Install.Header..string.sub(fdir, #incDir)
if(not os.isdir(destDir)) then
if os.mkdir(destDir) then print("Creating "..destDir) end
end
end
-- Copy files
local fileList = os.matchfiles(incDir.."**")
for _,fpath in pairs(fileList) do
local destFile = G_Install.Header..string.sub(fpath, #incDir)
if os.copyfile(fpath, destFile) then print("Installing "..destFile) end
end
-- LIBRARY
print("** Installing Library files in: "..G_Install.Lib.." **")
local destDir = G_Install.Lib
-- Create required folders
if(not os.isdir(destDir)) then
if os.mkdir(destDir) then print("Creating "..destDir) end
end
local exts = {}
if os.is("windows") then
exts[0] = ".dll"
exts[1] = ".lib"
else
exts[0] = ".so"
exts[1] = ".a"
end
-- Copy files
for _,ext in pairs(exts) do
local fileList = os.matchfiles(libDir.."**"..ext)
for _,fpath in pairs(fileList) do
local destFile = G_Install.Lib..string.sub(fpath, #libDir)
if os.copyfile(fpath, destFile) then print("Installing "..destFile) end
end
end
end
}