From 0d103e24a56d5c9c7a4078798399e6701a9e3004 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 22 Oct 2019 02:40:06 +0200 Subject: [PATCH] Add premake scripts for projects --- premake5.lua | 52 ++++++++++++++++++++++++++++----- src/Crypto.lua | 36 +++++++++++++++++++++++ src/Linker.lua | 33 +++++++++++++++++++++ src/Unlinker.lua | 33 +++++++++++++++++++++ src/Utils.lua | 30 +++++++++++++++++++ src/ZoneCodeGenerator.lua | 0 src/ZoneCommon.lua | 30 +++++++++++++++++++ src/ZoneLoading.lua | 38 ++++++++++++++++++++++++ src/ZoneWriting.lua | 38 ++++++++++++++++++++++++ test/ZoneCodeGeneratorTests.lua | 38 ++++++++++++++++++++++++ test/ZoneCommonTests.lua | 32 ++++++++++++++++++++ thirdparty/libtomcrypt.lua | 5 +++- thirdparty/libtommath.lua | 1 - thirdparty/salsa20.lua | 1 - thirdparty/zlib.lua | 6 +++- 15 files changed, 361 insertions(+), 12 deletions(-) create mode 100644 src/Crypto.lua create mode 100644 src/Linker.lua create mode 100644 src/Unlinker.lua create mode 100644 src/Utils.lua create mode 100644 src/ZoneCodeGenerator.lua create mode 100644 src/ZoneCommon.lua create mode 100644 src/ZoneLoading.lua create mode 100644 src/ZoneWriting.lua create mode 100644 test/ZoneCodeGeneratorTests.lua create mode 100644 test/ZoneCommonTests.lua diff --git a/premake5.lua b/premake5.lua index 14f2bdf7..b1869b28 100644 --- a/premake5.lua +++ b/premake5.lua @@ -68,19 +68,55 @@ workspace "OpenAssetTools" -- ======================== -- ThirdParty -- ======================== - include "thirdparty/libtomcrypt.lua" include "thirdparty/libtommath.lua" include "thirdparty/salsa20.lua" include "thirdparty/zlib.lua" --- All projects here should be in the thirdparty folder -group "thirdparty" +-- ThirdParty group: All projects that are external dependencies +group "ThirdParty" + libtommath:project() + libtomcrypt:project() + salsa20:project() + zlib:project() +group "" -libtommath:project() -libtomcrypt:project() -salsa20:project() -zlib:project() +-- ======================== +-- Projects +-- ======================== +include "src/Crypto.lua" +include "src/Linker.lua" +include "src/Unlinker.lua" +include "src/Utils.lua" +include "src/ZoneCodeGenerator.lua" +include "src/ZoneCommon.lua" +include "src/ZoneLoading.lua" +include "src/ZoneWriting.lua" --- Reset group +-- Components group: All projects assist or are part of a tool +group "Components" + Crypto:project() + Utils:project() + --ZoneCodeGenerator:project() + ZoneCommon:project() + ZoneLoading:project() + ZoneWriting:project() +group "" + +-- Tools group: All projects that compile into the final tools +group "Tools" + Linker:project() + Unlinker:project() +group "" + +-- ======================== +-- Tests +-- ======================== +include "test/ZoneCodeGeneratorTests.lua" +include "test/ZoneCommonTests.lua" + +-- Tests group: Unit test and other tests projects +group "Tests" + --ZoneCodeGeneratorTests:project() + ZoneCommonTests:project() group "" \ No newline at end of file diff --git a/src/Crypto.lua b/src/Crypto.lua new file mode 100644 index 00000000..c1b136dd --- /dev/null +++ b/src/Crypto.lua @@ -0,0 +1,36 @@ +Crypto = {} + +function Crypto:include() + includedirs { + path.join(ProjectFolder(), "Crypto") + } +end + +function Crypto:link() + libtomcrypt:link() + libtommath:link() + salsa20:link() + links { + "Crypto" + } +end + +function Crypto:project() + local folder = ProjectFolder(); + + project "Crypto" + targetdir(TargetDirectoryLib) + location "%{wks.location}/src" + kind "StaticLib" + language "C++" + + files { + path.join(folder, "Crypto/**.h"), + path.join(folder, "Crypto/**.cpp") + } + + self:include() + libtomcrypt:include() + libtommath:include() + salsa20:include() +end diff --git a/src/Linker.lua b/src/Linker.lua new file mode 100644 index 00000000..1fb813af --- /dev/null +++ b/src/Linker.lua @@ -0,0 +1,33 @@ +Linker = {} + +function Linker:include() + includedirs { + path.join(ProjectFolder(), "Linker") + } +end + +function Linker:link() + +end + +function Linker:project() + local folder = ProjectFolder(); + + project "Linker" + targetdir(TargetDirectoryBin) + location "%{wks.location}/src" + kind "ConsoleApp" + language "C++" + + files { + path.join(folder, "Linker/**.h"), + path.join(folder, "Linker/**.cpp") + } + + self:include() + Utils:include() + ZoneWriting:include() + + Utils:link() + --ZoneWriting:link() +end diff --git a/src/Unlinker.lua b/src/Unlinker.lua new file mode 100644 index 00000000..1b33b746 --- /dev/null +++ b/src/Unlinker.lua @@ -0,0 +1,33 @@ +Unlinker = {} + +function Unlinker:include() + includedirs { + path.join(ProjectFolder(), "Unlinker") + } +end + +function Unlinker:link() + +end + +function Unlinker:project() + local folder = ProjectFolder(); + + project "Unlinker" + targetdir(TargetDirectoryBin) + location "%{wks.location}/src" + kind "ConsoleApp" + language "C++" + + files { + path.join(folder, "Unlinker/**.h"), + path.join(folder, "Unlinker/**.cpp") + } + + self:include() + Utils:include() + ZoneLoading:include() + + Utils:link() + ZoneLoading:link() +end diff --git a/src/Utils.lua b/src/Utils.lua new file mode 100644 index 00000000..c20af075 --- /dev/null +++ b/src/Utils.lua @@ -0,0 +1,30 @@ +Utils = {} + +function Utils:include() + includedirs { + path.join(ProjectFolder(), "Utils") + } +end + +function Utils:link() + links { + "Utils" + } +end + +function Utils:project() + local folder = ProjectFolder(); + + project "Utils" + targetdir(TargetDirectoryLib) + location "%{wks.location}/src" + kind "StaticLib" + language "C++" + + files { + path.join(folder, "Utils/**.h"), + path.join(folder, "Utils/**.cpp") + } + + self:include() +end diff --git a/src/ZoneCodeGenerator.lua b/src/ZoneCodeGenerator.lua new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCommon.lua b/src/ZoneCommon.lua new file mode 100644 index 00000000..9782059c --- /dev/null +++ b/src/ZoneCommon.lua @@ -0,0 +1,30 @@ +ZoneCommon = {} + +function ZoneCommon:include() + includedirs { + path.join(ProjectFolder(), "ZoneCommon") + } +end + +function ZoneCommon:link() + links { + "ZoneCommon" + } +end + +function ZoneCommon:project() + local folder = ProjectFolder(); + + project "ZoneCommon" + targetdir(TargetDirectoryLib) + location "%{wks.location}/src" + kind "StaticLib" + language "C++" + + files { + path.join(folder, "ZoneCommon/**.h"), + path.join(folder, "ZoneCommon/**.cpp") + } + + self:include() +end diff --git a/src/ZoneLoading.lua b/src/ZoneLoading.lua new file mode 100644 index 00000000..7118ca28 --- /dev/null +++ b/src/ZoneLoading.lua @@ -0,0 +1,38 @@ +ZoneLoading = {} + +function ZoneLoading:include() + ZoneCommon:include() + includedirs { + path.join(ProjectFolder(), "ZoneLoading") + } +end + +function ZoneLoading:link() + Crypto:link() + Utils:link() + ZoneCommon:link() + zlib:link() + links { + "ZoneLoading" + } +end + +function ZoneLoading:project() + local folder = ProjectFolder(); + + project "ZoneLoading" + targetdir(TargetDirectoryLib) + location "%{wks.location}/src" + kind "StaticLib" + language "C++" + + files { + path.join(folder, "ZoneLoading/**.h"), + path.join(folder, "ZoneLoading/**.cpp") + } + + self:include() + Crypto:include() + Utils:include() + zlib:include() +end diff --git a/src/ZoneWriting.lua b/src/ZoneWriting.lua new file mode 100644 index 00000000..40edfaa2 --- /dev/null +++ b/src/ZoneWriting.lua @@ -0,0 +1,38 @@ +ZoneWriting = {} + +function ZoneWriting:include() + ZoneCommon:include() + includedirs { + path.join(ProjectFolder(), "ZoneWriting") + } +end + +function ZoneWriting:link() + Crypto:link() + Utils:link() + ZoneCommon:link() + zlib:link() + links { + "ZoneWriting" + } +end + +function ZoneWriting:project() + local folder = ProjectFolder(); + + project "ZoneWriting" + targetdir(TargetDirectoryLib) + location "%{wks.location}/src" + kind "StaticLib" + language "C++" + + files { + path.join(folder, "ZoneWriting/**.h"), + path.join(folder, "ZoneWriting/**.cpp") + } + + self:include() + Crypto:include() + Utils:include() + zlib:include() +end diff --git a/test/ZoneCodeGeneratorTests.lua b/test/ZoneCodeGeneratorTests.lua new file mode 100644 index 00000000..a24ec535 --- /dev/null +++ b/test/ZoneCodeGeneratorTests.lua @@ -0,0 +1,38 @@ +ZoneCodeGeneratorTests = {} + +function ZoneCodeGeneratorTests:include() + +end + +function ZoneCodeGeneratorTests:link() + +end + +function ZoneCodeGeneratorTests:project() + local folder = TestFolder(); + + project "ZoneCodeGeneratorTests" + targetdir(TargetDirectoryTest) + location "%{wks.location}/test" + kind "SharedLib" + language "C#" + + files { + path.join(folder, "Zone/src/**.h"), + path.join(folder, "libtomcrypt/src/**.c") + } + + defines { + "_CRT_SECURE_NO_WARNINGS", + "_CRT_NONSTDC_NO_DEPRECATE", + "LTC_SOURCE", + "LTC_NO_TEST", + "LTC_NO_PROTOTYPES" + } + + self:include() + libtommath:include() + + -- Disable warnings. They do not have any value to us since it is not our code. + warnings "off" +end diff --git a/test/ZoneCommonTests.lua b/test/ZoneCommonTests.lua new file mode 100644 index 00000000..0f94b5e9 --- /dev/null +++ b/test/ZoneCommonTests.lua @@ -0,0 +1,32 @@ +ZoneCommonTests = {} + +function ZoneCommonTests:include() + +end + +function ZoneCommonTests:link() + +end + +function ZoneCommonTests:project() + local folder = TestFolder(); + + project "ZoneCommonTests" + targetdir(TargetDirectoryTest) + location "%{wks.location}/test" + kind "SharedLib" + language "C++" + + files { + path.join(folder, "ZoneCommonTests/**.h"), + path.join(folder, "ZoneCommonTests/**.cpp") + } + + self:include() + ZoneCommon:include() + + ZoneCommon:link() + + -- Disable warnings. They do not have any value to us since it is not our code. + warnings "off" +end diff --git a/thirdparty/libtomcrypt.lua b/thirdparty/libtomcrypt.lua index ea414513..2fe9be02 100644 --- a/thirdparty/libtomcrypt.lua +++ b/thirdparty/libtomcrypt.lua @@ -1,13 +1,16 @@ libtomcrypt = {} function libtomcrypt:include() + defines{ + "LTM_DESC" + } + includedirs { path.join(ThirdPartyFolder(), "libtomcrypt/src/headers") } end function libtomcrypt:link() - self:include() links { "libtomcrypt" } diff --git a/thirdparty/libtommath.lua b/thirdparty/libtommath.lua index e7d67f75..16d73440 100644 --- a/thirdparty/libtommath.lua +++ b/thirdparty/libtommath.lua @@ -7,7 +7,6 @@ function libtommath:include() end function libtommath:link() - self:include() links { "libtommath" } diff --git a/thirdparty/salsa20.lua b/thirdparty/salsa20.lua index 19d758bd..5474b2db 100644 --- a/thirdparty/salsa20.lua +++ b/thirdparty/salsa20.lua @@ -7,7 +7,6 @@ function salsa20:include() end function salsa20:link() - self:include() links { "salsa20" } diff --git a/thirdparty/zlib.lua b/thirdparty/zlib.lua index 2547d5cb..cc25b0ef 100644 --- a/thirdparty/zlib.lua +++ b/thirdparty/zlib.lua @@ -1,13 +1,17 @@ zlib = {} function zlib:include() + + defines { + "ZLIB_CONST" + } + includedirs { path.join(ThirdPartyFolder(), "zlib") } end function zlib:link() - self:include() links { "zlib" }