-
Notifications
You must be signed in to change notification settings - Fork 8
/
premake5.lua
107 lines (91 loc) · 3.09 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
newoption {
trigger = "install-dir",
value = "PATH",
description = "Target directory for installation (Default: /usr/local)"
}
newaction {
trigger = "install",
description = "Install the software",
execute = function ()
local function copyFile(srcFile, destPath)
local destFile = destPath .. '/' .. path.getname(srcFile)
os.mkdir(destPath)
os.copyfile(srcFile, destFile)
if os.is("linux") then
-- hook up version-less symbolic links for libs
local extPos = string.findlast(destFile, ".so")
if extPos then
local ext = destFile:sub(extPos)
if ext:len() > 5 then
-- print("Creating links to shared libs...")
print(" " .. destFile:sub(1,extPos + 2 + 2))
os.execute("ln -snf " .. destFile .. " " .. destFile:sub(1,extPos + 2 + 2))
print(" " .. destFile:sub(1,extPos + 2))
os.execute("ln -snf " .. destFile .. " " .. destFile:sub(1,extPos + 2))
end
end
end
end
local function copyFiles(srcPath, destPath, ...)
-- append srcPath to the patterns --
local patterns = { }
for _, f in ipairs(arg) do
table.insert(patterns, srcPath .. "/" .. f)
end
-- gather and copy files --
files = os.matchfiles(unpack(patterns))
for _, f in ipairs(files) do
dest = destPath .. "/" .. path.getrelative(srcPath, f)
print(" " .. dest)
copyFile(f, path.getdirectory(dest))
end
end
local installDir = _OPTIONS["install-dir"]
includePath = iif(installDir, installDir, "/usr/local") .. "/include"
libPath = iif(installDir, installDir, "/usr/local") .. "/lib"
docPath = iif(installDir, installDir, "/usr/local") .. "/share/doc"
-- copy includes --
print("Copying includes to: " .. includePath)
copyFiles("dist/include/Fuji", includePath .. "/Fuji", "**.h", "**.inl")
copyFiles("dist/include/Haku", includePath .. "/Haku", "**.h", "**.inl")
copyFiles("dist/include/d2", includePath .. "/d2", "**.d", "**.di")
-- copy libs --
print("Copying libs to: " .. libPath)
if os.is64bit() then
copyFiles("dist/lib/linux-x86_64", libPath, "libFuji*", "libHaku*")
else
copyFiles("dist/lib/linux-i386", libPath, "libFuji*", "libHaku*")
end
-- install documentation --
print("Installing documentation to: " .. docPath)
copyFiles("dist/doc", docPath .. "/Fuji", "**.chm")
end
}
solution "Fuji"
if _ACTION == "gmake" then
configurations { "Release", "Debug", "DebugOpt", "Retail" }
else
configurations { "Debug", "DebugOpt", "Release", "Retail" }
end
if os.target() == "windows" then
platforms { "x32", "x64" }
end
-- Static lib project
dofile "Fuji/Project/fujiproj.lua"
-- Shared lib project
fujiDll = true
dofile "Fuji/Project/fujiproj.lua"
-- Haku project
dofile "Haku/Project/hakuproj.lua"
-- D bindings
dofile "Fuji/Project/fujidproj.lua"
if os.target("windows") then
solution "FujiMiddleware"
platforms { "x32", "x64" }
if _ACTION == "gmake" then
configurations { "Release", "Debug" }
else
configurations { "Debug", "Release" }
end
dofile "Fuji/Project/fujimiddleware.lua"
end