Jump to content
  • entries
    51
  • comments
    106
  • views
    31,715

Leadwerks and Premake


reepblue

2,256 views

 Share

Premake is multiplication project maker.Unlike CMake, it simply generates a project file for the given IDE giving you a clean result. You only need the one light weight executable and a lua script for this to work.  I've spent today setting it up with Leadwerks. I haven't tested Linux yet, but it should work.

My premake5.lua file:

g_LeadwerksHeaderPath = "./Engine/Include"
g_LeadwerksLibPath = "./Engine/Libs"

function GlobalSettings()
	-- Include Directories
	includedirs
	{
		"%{prj.name}",
		"%{g_LeadwerksHeaderPath}",
		"%{g_LeadwerksHeaderPath}/Libraries/SDL2-2.0.10/include",
		"%{g_LeadwerksHeaderPath}/Libraries/NewtonDynamics/sdk/dgCore",
		"%{g_LeadwerksHeaderPath}/Libraries/NewtonDynamics/sdk/dgNewton",
		"%{g_LeadwerksHeaderPath}/Libraries/libvorbis/include",
		"%{g_LeadwerksHeaderPath}/Libraries/libogg/include",
		"%{g_LeadwerksHeaderPath}/Libraries/openssl/include",
		"%{g_LeadwerksHeaderPath}/Libraries/VHACD/src/VHACD_Lib/inc",
		"%{g_LeadwerksHeaderPath}/Libraries/glslang",
		"%{g_LeadwerksHeaderPath}/Libraries/freetype-2.4.7/include",
		"%{g_LeadwerksHeaderPath}/Libraries/OpenAL/include",
		"%{g_LeadwerksHeaderPath}/Libraries/NewtonDynamics/sdk/dMath",
		"%{g_LeadwerksHeaderPath}/Libraries/NewtonDynamics/sdk/dgTimeTracker",
		"%{g_LeadwerksHeaderPath}/Libraries/NewtonDynamics/sdk/dContainers",
		"%{g_LeadwerksHeaderPath}/Libraries/NewtonDynamics/sdk/dCustomJoints",
		"%{g_LeadwerksHeaderPath}/Libraries/RecastNavigation/RecastDemo/Include",
		"%{g_LeadwerksHeaderPath}/Libraries/RecastNavigation/DetourCrowd/Include",
		"%{g_LeadwerksHeaderPath}/Libraries/RecastNavigation/DetourTileCache/Include",
		"%{g_LeadwerksHeaderPath}/Libraries/RecastNavigation/DebugUtils/Include",
		"%{g_LeadwerksHeaderPath}/Libraries/RecastNavigation/Recast/Include",
		"%{g_LeadwerksHeaderPath}/Libraries/RecastNavigation/Detour/Include",
		"%{g_LeadwerksHeaderPath}/Libraries/tolua++-1.0.93/include",
		"%{g_LeadwerksHeaderPath}/Libraries/lua-5.1.4",
		"%{g_LeadwerksHeaderPath}/Libraries/glew-1.6.0/include/GL",
		"%{g_LeadwerksHeaderPath}/Libraries/glew-1.6.0/include",
		"%{g_LeadwerksHeaderPath}/Libraries/enet-1.3.1/include",
		"%{g_LeadwerksHeaderPath}/Libraries/zlib-1.2.5",
		"%{g_LeadwerksHeaderPath}/Libraries/freetype-2.4.3/include"
	}

	-- Global Defines:
	defines
	{
		"__STEAM__",
		"_CUSTOM_JOINTS_STATIC_LIB",
		"FT2_BUILD_LIBRARY",
		"LEADWERKS_3_1",
		"DG_DISABLE_ASSERT",
		"OPENGL",
		"_NEWTON_STATIC_LIB",
		"_STATICLIB"
	}

	-- Windows Exclusive:
	filter "system:windows"
		systemversion "latest"
		pchsource "%{prj.name}/stdafx.cpp"

		links 
		{
			"libcryptoMT.lib",
			"libsslMT.lib",
			"Rpcrt4.lib",
			"crypt32.lib",
			"libcurl.lib",
			"msimg32.lib",
			"lua51.lib",
			"steam_api.lib",
			"ws2_32.lib",
			"Glu32.lib",
			"libovrd.lib",
			"OpenGL32.lib",
			"winmm.lib",
			"Psapi.lib",
			"OpenAL32.lib",
			"SDL2.lib",
			"Leadwerks.lib"
		}

		libdirs 
		{ 
			"%{g_LeadwerksLibPath}/Windows/x86",
			"%{g_LeadwerksLibPath}/Windows/x86/%{cfg.buildcfg}" 
		}
		
		defines
		{
			"PSAPI_VERSION=1",
			"PTW32_STATIC_LIB",
			"PTW32_BUILD",
			"_NEWTON_USE_LIB",
			"_LIB",
			"DG_USE_NORMAL_PRIORITY_THREAD",
			"GLEW_STATIC",
			"WINDOWS",
			"WIN32",
			"OS_WINDOWS",
			"PLATFORM_WINDOWS",
			"_WIN_32_VER"
		}

		buildoptions
		{	
			"/D \"SLB_LIBRARY\"", 
		}

		flags
		{
			"NoMinimalRebuild"
		}

		linkoptions
		{
			"/NODEFAULTLIB:MSVCRT.lib",
			"/NODEFAULTLIB:MSVCRTD.lib"
		}		


	-- Linux Exclusive:
	filter "system:linux"
		systemversion "latest"
		
		linkoptions
		{
			"-ldl",
			"-lopenal",
			"-lGL",
			"-lGLU",
			"-lX11",
			"-lXext",
			"-lXrender",
			"-lXft",
			"-lpthread",
			"-lcurl",
			--"-lSDL2",
			"%{g_LeadwerksLibPath}/Linux/libluajit.a",
			"%{gameDir}/libopenvr_api.so"
		}

		defines
		{
			"ZLIB",
			"PLATFORM_LINUX",
			"unix",
			"_POSIX_VER",
			"_POSIX_VER_64",
			"DG_THREAD_EMULATION",
			"DG_USE_THREAD_EMULATION",
			"GL_GLEXT_PROTOTYPES",
			"LUA_USE_LINUX",
			"_GLIBCXX_USE_CXX11_ABI",
			"_CUSTOM_JOINTS_STATIC_LIB"
		}

		linkoptions
		{
			"%{g_LeadwerksLibPath}/Linux/%{cfg.buildcfg}/Leadwerks.a"
		}
			
	-- Debug Build:
	filter "configurations:Debug"
		runtime "Debug"
		symbols "on"
		targetsuffix ".debug"
		defines
		{
			"DEBUG",
			"_DEBUG"
		}

		if os.target() == "windows" then
			links 
			{
				"newton_d.lib",
				"dContainers_d.lib",
				"dCustomJoints_d.lib"
			}
		end

	-- Release Build:
	filter "configurations:Release"
		runtime "Release"
		optimize "on"

		if os.target() == "windows" then
			buildoptions
			{
				"/MP"
			}
			
			links 
			{
				"newton.lib",
				"dContainers.lib",
				"dCustomJoints.lib"
			}
		end
end

function GenerateLuaApp()
	workspace "PremakeTest"
		architecture "x86"
		--architecture "x86_64"
		startproject "LuaApp"

		configurations
		{
			"Debug",
			"Release"
		}
			
	-- Test application	
	project "LuaApp"
		kind "ConsoleApp"
		language "C++"
		location "%{prj.name}"
		staticruntime "on"

		-- Project Directory:
		projectDir = "%{prj.name}/"

		-- Game Directory:
		gameDir = _WORKING_DIR .. "/../Projects/%{prj.name}"

		-- OBJ Directory
		objdir (projectDir .. "%{cfg.buildcfg}_%{prj.name}")
		targetdir (gameDir)

		files 
		{ 
			"%{prj.name}/**.h", 
			"%{prj.name}/**.cpp" 
		}
		pchheader "stdafx.h"
		
		-- Custom Defines
		defines
		{
			"__TEST_ME_",
		}

		GlobalSettings()
		
end

newaction 
{
	trigger     = "luaapp",
	description = "Builds the stock lua app",
	execute = GenerateLuaApp()
 }

 if _ACTION == "luaapp" then
	GenerateLuaApp()
 end

Then I just have batch file that builds the project file.

"devtools/premake5.exe" vs2017 luaapp
pause

My impressions are more positive on this than CMake as CMake creates a lot of extra files to do real time updating if the CMakeList file is updated. Premake simply just builds the project file and that's it. It really reminds me of VPC stuff I had to deal with in my modding days. Really interested to how codelite projects generate on Linux.

  • Like 2
 Share

1 Comment


Recommended Comments

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...