Build: Add package action
Former-commit-id: 515307c1cb9d10f2a6060f7ae107b969637e8882 [formerly bcb26c49c374e502732e3bff35f8367047accdc5] [formerly 72385d39c30f735fb43d70da3c44840468360efa [formerly 6563ce60169674309fdf8e36e16686b1b0be128e]] Former-commit-id: fbc9522ed2c0e75f58a3517344d780be3eb99ac4 [formerly ce264fe175de40c051229183d458273ad6cbead1] Former-commit-id: e312993f3cab7e1587bc09feb0e25ec289237224
This commit is contained in:
parent
948273fe99
commit
10a1e16566
|
|
@ -1,14 +1,23 @@
|
|||
# Nazara build
|
||||
build/config.lua
|
||||
|
||||
# Nazara libraries
|
||||
lib/*
|
||||
|
||||
# Nazara package
|
||||
package/*
|
||||
|
||||
# Example files
|
||||
examples/bin/*.exe
|
||||
examples/bin/*.pdb
|
||||
examples/bin/*.dll
|
||||
examples/bin/*.so
|
||||
|
||||
# Unit tests
|
||||
tests/*.exe
|
||||
tests/*.pdb
|
||||
tests/*.dll
|
||||
tests/*.so
|
||||
lib/*
|
||||
|
||||
# Example generated files
|
||||
examples/bin/HardwareInfo.txt
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
premake5 --pack-libdir=msvc package
|
||||
|
|
@ -0,0 +1 @@
|
|||
premake5 --pack-libdir=mingw package
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
newoption({
|
||||
trigger = "pack-libdir",
|
||||
description = "Specifiy the subdirectory in lib/ to be used when packaging the project"
|
||||
})
|
||||
|
||||
ACTION.Name = "Package"
|
||||
ACTION.Description = "Pack Nazara binaries/include/lib together"
|
||||
|
||||
ACTION.Function = function ()
|
||||
local libDir = _OPTIONS["pack-libdir"]
|
||||
if (not libDir or #libDir == 0) then
|
||||
local libDirs = os.matchdirs("../lib/*")
|
||||
if (#libDirs > 1) then
|
||||
error("More than one subdirectory was found in the lib directory, please use the --pack-libdir command to clarify which directory should be used")
|
||||
elseif (#libDirs == 0) then
|
||||
error("No subdirectory was found in the lib directory, have you built the engine yet?")
|
||||
else
|
||||
libDir = libDirs[1]
|
||||
print("No directory was set by the --pack-libdir command, \"" .. libDir .. "\" will be used")
|
||||
end
|
||||
else
|
||||
libDir = "../lib/" .. libDir .. "/"
|
||||
end
|
||||
|
||||
if (not os.isdir(libDir)) then
|
||||
error(string.format("\"%s\" doesn't seem to be an existing directory", libDir))
|
||||
end
|
||||
|
||||
local packageDir = "../package/"
|
||||
|
||||
local copyTargets = {
|
||||
{ -- Engine headers
|
||||
Masks = {"**.hpp", "**.inl"},
|
||||
Source = "../include/",
|
||||
Target = "include/"
|
||||
},
|
||||
{ -- SDK headers
|
||||
Masks = {"**.hpp", "**.inl"},
|
||||
Source = "../SDK/include/",
|
||||
Target = "include/"
|
||||
},
|
||||
{ -- Examples files
|
||||
Masks = {"**.hpp", "**.inl", "**.cpp"},
|
||||
Source = "../examples/",
|
||||
Target = "examples/"
|
||||
},
|
||||
{ -- Demo resources
|
||||
Masks = {"**.*"},
|
||||
Source = "../examples/bin/resources/",
|
||||
Target = "examples/bin/resources/"
|
||||
}
|
||||
}
|
||||
|
||||
if (os.is("windows")) then
|
||||
-- Engine/SDK binaries
|
||||
table.insert(copyTargets, {
|
||||
Masks = {"**.dll"},
|
||||
Source = libDir,
|
||||
Target = "bin/"
|
||||
})
|
||||
|
||||
-- Engine/SDK libraries
|
||||
table.insert(copyTargets, {
|
||||
Masks = {"**.lib"},
|
||||
Source = libDir,
|
||||
Target = "lib/"
|
||||
})
|
||||
|
||||
-- 3rd party binary dep
|
||||
table.insert(copyTargets, {
|
||||
Masks = {"**.dll"},
|
||||
Source = "../extlibs/lib/common/",
|
||||
Target = "bin/"
|
||||
})
|
||||
|
||||
-- Demo executable (Windows)
|
||||
table.insert(copyTargets, {
|
||||
Masks = {"Demo*.exe"},
|
||||
Source = "../examples/bin",
|
||||
Target = "examples/bin"
|
||||
})
|
||||
elseif (os.is("macosx")) then
|
||||
-- Engine/SDK binaries
|
||||
table.insert(copyTargets, {
|
||||
Masks = {"**.dynlib"},
|
||||
Source = libDir,
|
||||
Target = "bin/"
|
||||
})
|
||||
|
||||
-- Engine/SDK libraries
|
||||
table.insert(copyTargets, {
|
||||
Masks = {"**.a"},
|
||||
Source = libDir,
|
||||
Target = "lib/"
|
||||
})
|
||||
|
||||
-- 3rd party binary dep
|
||||
table.insert(copyTargets, {
|
||||
Masks = {"**.dynlib"},
|
||||
Source = "../extlibs/lib/common/",
|
||||
Target = "bin/"
|
||||
})
|
||||
|
||||
-- Demo executable (Windows)
|
||||
table.insert(copyTargets, {
|
||||
Masks = {"Demo*"},
|
||||
Filter = function (path) return path.getextension(path) == "" end,
|
||||
Source = "../examples/bin",
|
||||
Target = "examples/bin"
|
||||
})
|
||||
else
|
||||
-- Engine/SDK binaries
|
||||
table.insert(copyTargets, {
|
||||
Masks = {"**.so"},
|
||||
Source = libDir,
|
||||
Target = "bin/"
|
||||
})
|
||||
|
||||
-- Engine/SDK libraries
|
||||
table.insert(copyTargets, {
|
||||
Masks = {"**.a"},
|
||||
Source = libDir,
|
||||
Target = "lib/"
|
||||
})
|
||||
|
||||
-- 3rd party binary dep
|
||||
table.insert(copyTargets, {
|
||||
Masks = {"**.so"},
|
||||
Source = "../extlibs/lib/common/",
|
||||
Target = "bin/"
|
||||
})
|
||||
|
||||
-- Demo executable (Windows)
|
||||
table.insert(copyTargets, {
|
||||
Masks = {"Demo*"},
|
||||
Filter = function (path) return path.getextension(path) == "" end,
|
||||
Source = "../examples/bin",
|
||||
Target = "examples/bin"
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
-- Processing
|
||||
os.mkdir(packageDir)
|
||||
|
||||
for k,v in pairs(copyTargets) do
|
||||
local target = packageDir .. v.Target
|
||||
local includePrefix = v.Source
|
||||
for k,v in pairs(os.matchdirs(includePrefix .. "**")) do
|
||||
local relPath = v:sub(#includePrefix + 1)
|
||||
|
||||
local targetPath = target .. relPath
|
||||
|
||||
if (not os.isdir(targetPath)) then
|
||||
local ok, err = os.mkdir(targetPath)
|
||||
if (not ok) then
|
||||
print("Failed to create directory \"" .. targetPath .. "\": " .. err)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local targetFiles = {}
|
||||
for k, mask in pairs(v.Masks) do
|
||||
local files = os.matchfiles(includePrefix .. mask)
|
||||
if (v.Filter) then
|
||||
for k,path in pairs(files) do
|
||||
if (not v.Filter(v)) then
|
||||
files[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
targetFiles = table.join(targetFiles, files)
|
||||
end
|
||||
|
||||
for k,v in pairs(targetFiles) do
|
||||
local relPath = v:sub(#includePrefix + 1)
|
||||
|
||||
local targetPath = target .. relPath
|
||||
|
||||
local ok, err = os.copyfile(v, targetPath)
|
||||
if (not ok) then
|
||||
print("Failed to copy \"" .. v .. "\" to \"" .. targetPath .. "\": " .. err)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print(string.format("Package successfully created at \"%s\"", packageDir))
|
||||
end
|
||||
Loading…
Reference in New Issue