Build/Package: Fix executable binaries not being packaged under Linux (Close #77)

Former-commit-id: 5c885f70af44968f33ee1dbd93646293bcea5d2e [formerly 8edfc3654005393c28e27f8c6cbe427a43152f3f] [formerly b66fb4ef5b275e63c649c336170f22bd3155f67b [formerly ac7655fa1c6e2e4d429dca86c5fd78a499481fd6]]
Former-commit-id: 0cf284996de8d81ddec55cbabda9d950d45f4d1b [formerly f11faabb2157f8f546a51ed27484b8d5859fbf7e]
Former-commit-id: 2a5c0b57a2451980b89c4dbe36e089dd13fabc3a
This commit is contained in:
Lynix 2016-10-04 11:26:45 +02:00
parent d7b7135e27
commit e234044290
1 changed files with 29 additions and 54 deletions

View File

@ -29,16 +29,19 @@ ACTION.Function = function ()
["x64"] = false,
["x86"] = false
}
local enabledArchs = {}
for k,v in pairs(os.matchdirs(realLibDir .. "*")) do
local arch = path.getname(v)
if (archEnabled[arch] ~= nil) then
archEnabled[arch] = true
print(arch .. " arch found")
table.insert(enabledArchs, arch)
else
print("Unknown directory " .. v .. " found, ignored")
end
end
enabledArchs = table.concat(enabledArchs, ", ")
print(enabledArchs .. " arch found")
local packageDir = "../package/"
@ -79,18 +82,25 @@ ACTION.Function = function ()
local binFileMasks
local libFileMasks
local exeFileExt
local exeFilterFunc
if (os.is("windows")) then
binFileMasks = {"**.dll"}
libFileMasks = {"**.lib", "**.a"}
exeFileExt = ".exe"
exeFilterFunc = function (filePath) return true end
elseif (os.is("macosx")) then
binFileMasks = {"**.dynlib"}
libFileMasks = {"**.a"}
exeFileExt = ""
exeFilterFunc = function (filePath) return path.getextension(filePath):contains('/') end
else
binFileMasks = {"**.so"}
libFileMasks = {"**.a"}
exeFileExt = ""
exeFilterFunc = function (filePath) return path.getextension(filePath):contains('/') end
end
local enabledArchs = {}
for arch, enabled in pairs(archEnabled) do
if (enabled) then
local archLibSrc = realLibDir .. arch .. "/"
@ -118,59 +128,24 @@ ACTION.Function = function ()
Source = arch3rdPartyBinSrc,
Target = archBinDst
})
table.insert(enabledArchs, arch)
end
end
if (os.is("windows")) then
-- Demo executable (Windows)
table.insert(copyTargets, {
Masks = {"Demo*.exe"},
Source = "../examples/bin/",
Target = "examples/bin/"
})
-- Unit test (Windows)
table.insert(copyTargets, {
Masks = {"*.exe"},
Source = "../tests/",
Target = "tests/"
})
elseif (os.is("macosx")) then
-- Demo executable (OS X)
table.insert(copyTargets, {
Masks = {"Demo*"},
Filter = function (filePath) return path.getextension(filePath) == "" end,
Source = "../examples/bin/",
Target = "examples/bin/"
})
-- Demo executable
table.insert(copyTargets, {
Masks = {"Demo*" .. exeFileExt},
Filter = exeFilterFunc,
Source = "../examples/bin/",
Target = "examples/bin/"
})
-- Unit test (OS X)
table.insert(copyTargets, {
Masks = {"*.*"},
Filter = function (filePath) return path.getextension(filePath) == "" end,
Source = "../tests/",
Target = "tests/"
})
else
-- Demo executable (Linux)
table.insert(copyTargets, {
Masks = {"Demo*"},
Filter = function (filePath) return path.getextension(filePath) == "" end,
Source = "../examples/bin/",
Target = "examples/bin/"
})
-- Unit test (Linux)
table.insert(copyTargets, {
Masks = {"*.*"},
Filter = function (filePath) return path.getextension(filePath) == "" end,
Source = "../tests/",
Target = "tests/"
})
end
-- Unit test
table.insert(copyTargets, {
Masks = {"*" .. exeFileExt},
Filter = exeFilterFunc,
Source = "../tests/",
Target = "tests/"
})
-- Processing
os.mkdir(packageDir)
@ -212,7 +187,7 @@ ACTION.Function = function ()
if (os.is("windows")) then
ok, err = os.copyfile(v, targetPath)
else
-- Workaround: As premake is translating this to "cp %s %s", it fails if there are space in the paths.
-- Workaround: As premake is translating this to "cp %s %s", it fails if space are presents in source/destination paths.
ok, err = os.copyfile(string.format("\"%s\"", v), string.format("\"%s\"", targetPath))
end
@ -227,6 +202,6 @@ ACTION.Function = function ()
end
end
local config = libDir .. " - " .. table.concat(enabledArchs, ", ")
local config = libDir .. " - " .. enabledArchs
print(string.format("Package successfully created at \"%s\" (%u MB, %s)", packageDir, size / (1024 * 1024), config))
end