From 74cbc95e95ccb4865d9add3fc7b746975c531109 Mon Sep 17 00:00:00 2001 From: Sebastian Kylander Date: Tue, 19 Feb 2019 00:50:25 +0100 Subject: [PATCH] Modularize premake script for easier external usage --- src/generate.sh | 2 +- src/premake/all.lua | 18 ++++ src/premake/demos.lua | 57 ++++++++++++ src/premake/libs.lua | 34 +++++++ src/premake/main.lua | 207 ------------------------------------------ 5 files changed, 110 insertions(+), 208 deletions(-) create mode 100644 src/premake/all.lua create mode 100644 src/premake/demos.lua create mode 100644 src/premake/libs.lua delete mode 100644 src/premake/main.lua diff --git a/src/generate.sh b/src/generate.sh index 23735c5..7a02a49 100644 --- a/src/generate.sh +++ b/src/generate.sh @@ -18,4 +18,4 @@ fi # Generate project files -../bin/premake5 "--file=premake/main.lua" "$action" \ No newline at end of file +../bin/premake5 "--file=premake/all.lua" "$action" \ No newline at end of file diff --git a/src/premake/all.lua b/src/premake/all.lua new file mode 100644 index 0000000..233fb17 --- /dev/null +++ b/src/premake/all.lua @@ -0,0 +1,18 @@ +require 'extensions/premake-qt/qt' + +QTDIR_X86 = io.readfile('../../tmp/.qtdir_x86') +QTDIR_X64 = io.readfile('../../tmp/.qtdir_x64') + +workspace ('QDiscord') + location ('../') + configurations { + 'Debug', + 'Release', + } + platforms { + 'x86', + 'x64', + } + + dofile 'libs.lua' + dofile 'demos.lua' diff --git a/src/premake/demos.lua b/src/premake/demos.lua new file mode 100644 index 0000000..6d5b99f --- /dev/null +++ b/src/premake/demos.lua @@ -0,0 +1,57 @@ +local function demo(prettyname, dirname) + project (prettyname) + premake.extensions.qt.enable() + debugdir ('../../bin/%{cfg.platform}/') + kind ('ConsoleApp') + location ('../projects/demos/') + objdir ('../../bin/%{cfg.platform}/obj/') + qtgenerateddir ('../demos/' .. dirname .. '/GeneratedFiles/') + qtprefix ('Qt5') + targetdir ('../../bin/%{cfg.platform}/') + + files { + '../demos/' .. dirname .. '/**.h', + '../demos/' .. dirname .. '/**.cpp', + '../demos/' .. dirname .. '/**.ui', + '../demos/' .. dirname .. '/**.qrc', + } + flags { + "MultiProcessorCompile", + } + includedirs { + '../core/', + '../demos/' .. dirname .. '/', + } + links { + 'QDiscordCore', + } + qtmodules { + 'core', + 'gui', + 'network', + 'websockets', + 'widgets', + } + + filter {'configurations:Debug'} + qtsuffix ('d') + + filter {'configurations:Release'} + optimize ('Full') + defines { + 'QT_NO_DEBUG', + } + + filter {'platforms:x86'} + qtpath (QTDIR_X86) + + filter {'platforms:x64'} + qtpath (QTDIR_X64) + + filter {} +end + +group ('Demos') + demo ('BotDemo01', 'botdemo01') + demo ('BotUser', 'botuser') + demo ('Embeds', 'embeds') diff --git a/src/premake/libs.lua b/src/premake/libs.lua new file mode 100644 index 0000000..243d834 --- /dev/null +++ b/src/premake/libs.lua @@ -0,0 +1,34 @@ +project ('QDiscordCore') + premake.extensions.qt.enable() + location ('../projects/') + kind ('StaticLib') + qtgenerateddir ('../core/GeneratedFiles/') + qtprefix ('Qt5') + files { + '../core/**.h', + '../core/**.cpp', + } + flags { + "MultiProcessorCompile", + } + includedirs { + '../core/', + } + + filter {'configurations:Release'} + optimize ('Full') + defines { + 'QT_NO_DEBUG', + } + + filter {'platforms:x86'} + objdir ('../../bin/x86/obj/') + qtpath (QTDIR_X86) + targetdir ('../../bin/x86/') + + filter {'platforms:x86_64 or x64'} + objdir ('../../bin/x64/obj/') + qtpath (QTDIR_X64) + targetdir ('../../bin/x64/') + + filter {} diff --git a/src/premake/main.lua b/src/premake/main.lua deleted file mode 100644 index 72bff72..0000000 --- a/src/premake/main.lua +++ /dev/null @@ -1,207 +0,0 @@ -require 'extensions/premake-qt/qt' - -local qtdir_x86 = io.readfile('../../tmp/.qtdir_x86') -local qtdir_x64 = io.readfile('../../tmp/.qtdir_x64') - -workspace ('QDiscord') - location ('../') - configurations { - 'Debug', - 'Release', - } - platforms { - 'x86', - 'x64', - } - -project ('QDiscordCore') - premake.extensions.qt.enable() - location ('../projects/') - kind ('StaticLib') - qtgenerateddir ('../core/GeneratedFiles/') - qtprefix ('Qt5') - files { - '../core/**.h', - '../core/**.cpp', - } - flags { - "MultiProcessorCompile", - } - includedirs { - '../core/', - } - - filter {'configurations:Release'} - optimize ('Full') - defines { - 'QT_NO_DEBUG', - } - - filter {'platforms:x86'} - objdir ('../../bin/x86/obj/') - qtpath (qtdir_x86) - targetdir ('../../bin/x86/') - - filter {'platforms:x64'} - objdir ('../../bin/x64/obj/') - qtpath (qtdir_x64) - targetdir ('../../bin/x64/') - - filter {} - -group ('Demos') - project ('BotDemo01') - premake.extensions.qt.enable() - dependson ('QDiscordCore') - location ('../projects/demos/') - kind ('ConsoleApp') - qtgenerateddir ('../demos/botdemo01/GeneratedFiles/') - qtprefix ('Qt5') - files { - '../demos/botdemo01/**.h', - '../demos/botdemo01/**.cpp', - '../demos/botdemo01/**.ui', - '../demos/botdemo01/**.qrc', - } - flags { - "MultiProcessorCompile", - } - includedirs { - '../core/', - '../demos/botdemo01/', - } - links { - 'QDiscordCore', - } - qtmodules { - 'core', - 'gui', - 'network', - 'websockets', - 'widgets', - } - - filter {'configurations:Debug'} - qtsuffix ('d') - - filter {'configurations:Release'} - optimize ('Full') - defines { - 'QT_NO_DEBUG', - } - - filter {'platforms:x86'} - debugdir ('../../bin/x86/') - objdir ('../../bin/x86/obj/') - qtpath (qtdir_x86) - targetdir ('../../bin/x86/') - - filter {'platforms:x64'} - debugdir ('../../bin/x64/') - objdir ('../../bin/x64/obj/') - qtpath (qtdir_x64) - targetdir ('../../bin/x64/') - - project ('BotUser') - premake.extensions.qt.enable() - dependson ('QDiscordCore') - location ('../projects/demos/') - kind ('ConsoleApp') - qtgenerateddir ('../demos/botuser/GeneratedFiles/') - qtprefix ('Qt5') - files { - '../demos/botuser/**.h', - '../demos/botuser/**.cpp', - '../demos/botuser/**.ui', - '../demos/botuser/**.qrc', - } - flags { - "MultiProcessorCompile", - } - includedirs { - '../core/', - '../demos/botuser/', - } - links { - 'QDiscordCore', - } - qtmodules { - 'core', - 'gui', - 'network', - 'websockets', - 'widgets', - } - - filter {'configurations:Debug'} - qtsuffix ('d') - - filter {'configurations:Release'} - optimize ('Full') - defines { - 'QT_NO_DEBUG', - } - - filter {'platforms:x86'} - debugdir ('../../bin/x86/') - objdir ('../../bin/x86/obj/') - qtpath (qtdir_x86) - targetdir ('../../bin/x86/') - - filter {'platforms:x64'} - debugdir ('../../bin/x64/') - objdir ('../../bin/x64/obj/') - qtpath (qtdir_x64) - targetdir ('../../bin/x64/') - - project ('Embeds') - premake.extensions.qt.enable() - dependson ('QDiscordCore') - location ('../projects/demos/') - kind ('ConsoleApp') - qtgenerateddir ('../demos/embeds/GeneratedFiles/') - qtprefix ('Qt5') - files { - '../demos/embeds/**.h', - '../demos/embeds/**.cpp', - '../demos/embeds/**.ui', - '../demos/embeds/**.qrc', - } - flags { - "MultiProcessorCompile", - } - includedirs { - '../core/', - '../demos/embeds/', - } - links { - 'QDiscordCore', - } - qtmodules { - 'core', - 'gui', - 'network', - 'websockets', - 'widgets', - } - - filter {'configurations:Debug'} - qtsuffix ('d') - - filter {'configurations:Release'} - optimize ('Full') - defines { - 'QT_NO_DEBUG', - } - - filter {'platforms:x86'} - debugdir ('../../bin/x86/') - objdir ('../../bin/x86/obj/') - qtpath (qtdir_x86) - targetdir ('../../bin/x86/') - - filter {'platforms:x64'} - debugdir ('../../bin/x64/') - objdir ('../../bin/x64/obj/') - qtpath (qtdir_x64) - targetdir ('../../bin/x64/')