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