maint(build): new version system (#129)
This commit is contained in:
parent
34a67d97c6
commit
64c2f1ef70
4
.gitignore
vendored
4
.gitignore
vendored
@ -149,6 +149,7 @@ user*.bat
|
||||
# VScode
|
||||
.vscode/
|
||||
|
||||
# Output folders
|
||||
renamed/
|
||||
parsed/
|
||||
compiled/
|
||||
@ -157,3 +158,6 @@ assembled/
|
||||
disassembled/
|
||||
|
||||
data/*
|
||||
|
||||
# Version file
|
||||
include/xsk/version.hpp
|
||||
|
4
deps/zlib.lua
vendored
4
deps/zlib.lua
vendored
@ -29,6 +29,10 @@ function zlib:project()
|
||||
"_CRT_NONSTDC_NO_DEPRECATE",
|
||||
"_CRT_SECURE_NO_DEPRECATE",
|
||||
}
|
||||
|
||||
if os.istarget("darwin") then
|
||||
defines "HAVE_UNISTD_H"
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(dependencies, zlib)
|
||||
|
65
premake5.lua
65
premake5.lua
@ -1,3 +1,6 @@
|
||||
-------------------------------------------------
|
||||
-- DEPENDENCIES
|
||||
-------------------------------------------------
|
||||
dependencies = { base = path.getrelative(os.getcwd(), path.getabsolute("deps")) }
|
||||
|
||||
function dependencies.load()
|
||||
@ -11,6 +14,62 @@ function dependencies.load()
|
||||
end
|
||||
|
||||
dependencies.load()
|
||||
|
||||
-------------------------------------------------
|
||||
-- VERSIONING
|
||||
-------------------------------------------------
|
||||
function version_split(version, revision)
|
||||
array = {}
|
||||
|
||||
for num in string.gmatch(version or "", "%d+") do
|
||||
if #array < 3 then
|
||||
table.insert(array, tonumber(num))
|
||||
end
|
||||
end
|
||||
|
||||
while #array < 3 do
|
||||
table.insert(array, 0)
|
||||
end
|
||||
|
||||
table.insert(array, tonumber(revision))
|
||||
|
||||
return array
|
||||
end
|
||||
|
||||
function generate_version()
|
||||
-- get current version
|
||||
local proc1 = assert(io.popen("git describe --tags --abbrev=0", "r"))
|
||||
local version = assert(proc1:read('*a')):gsub("%s+", "")
|
||||
proc1:close()
|
||||
|
||||
-- get current branch
|
||||
local proc2 = assert(io.popen("git symbolic-ref -q --short HEAD", "r"))
|
||||
local branch = assert(proc2:read('*a')):gsub("%s+", "")
|
||||
proc2:close()
|
||||
|
||||
-- get revision number
|
||||
local proc3 = assert(io.popen("git rev-list --count HEAD", "r"))
|
||||
local revision = assert(proc3:read("*a")):gsub("%s+", "")
|
||||
proc3:close()
|
||||
|
||||
local split = version_split(version, revision)
|
||||
local verstr = split[1] .. "." .. split[2] .. "." .. split[3] .. "." .. split[4] .. "-" .. branch
|
||||
|
||||
local file = assert(io.open("include/xsk/version.hpp", "w"))
|
||||
file:write("// Generated by premake - do not edit\n\n")
|
||||
file:write("#define XSK_VERSION_MAJOR " .. split[1] .. "\n")
|
||||
file:write("#define XSK_VERSION_MINOR " .. split[2] .. "\n")
|
||||
file:write("#define XSK_VERSION_PATCH " .. split[3] .. "\n")
|
||||
file:write("#define XSK_VERSION_BUILD " .. split[4] .. "\n")
|
||||
file:write("#define XSK_VERSION_BRANCH \"" .. branch .. "\"\n")
|
||||
file:write("#define XSK_VERSION_STR \"" .. verstr .. "\"\n")
|
||||
file:close()
|
||||
end
|
||||
|
||||
generate_version()
|
||||
|
||||
-------------------------------------------------
|
||||
-- PROJECTS
|
||||
-------------------------------------------------
|
||||
workspace "gsc-tool"
|
||||
startproject "xsk-tool"
|
||||
@ -40,7 +99,7 @@ workspace "gsc-tool"
|
||||
filter {}
|
||||
|
||||
filter { "language:C++", "toolset:not msc*" }
|
||||
buildoptions "-std=c++20"
|
||||
buildoptions "-std=c++20"
|
||||
filter {}
|
||||
|
||||
filter "toolset:msc*"
|
||||
@ -50,11 +109,11 @@ workspace "gsc-tool"
|
||||
filter {}
|
||||
|
||||
filter { "system:windows" }
|
||||
systemversion "latest"
|
||||
systemversion "latest"
|
||||
filter {}
|
||||
|
||||
filter { "system:macosx" }
|
||||
systemversion "12.0"
|
||||
systemversion "12.0"
|
||||
filter {}
|
||||
|
||||
symbols "On"
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "xsk/arc/engine/t7.hpp"
|
||||
#include "xsk/arc/engine/t8.hpp"
|
||||
#include "xsk/arc/engine/t9.hpp"
|
||||
#include "xsk/version.hpp"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
@ -1017,6 +1018,11 @@ auto print_usage() -> void
|
||||
std::cin.get();
|
||||
}
|
||||
|
||||
auto branding() -> void
|
||||
{
|
||||
std::cout << fmt::format("\nGSC Tool {} created by xensik\n\n", XSK_VERSION_STR);
|
||||
}
|
||||
|
||||
auto main(u32 argc, char** argv) -> void
|
||||
{
|
||||
auto path = fs::path{};
|
||||
@ -1024,6 +1030,8 @@ auto main(u32 argc, char** argv) -> void
|
||||
auto game = game::_;
|
||||
auto mach = mach::_;
|
||||
|
||||
branding();
|
||||
|
||||
if (!parse_flags(argc, argv, mode, game, mach, path))
|
||||
{
|
||||
return print_usage();
|
||||
|
Loading…
Reference in New Issue
Block a user