Jump to content

UltraEngine Premake Script


reepblue
 Share

Recommended Posts

This lua script will generate a working VS project with Premake. Replace "Game" with the title of your project. I store premake5.exe and this script in a "Tools" folder where my preprocessor also sits. 

I might make a git repo in the future depending how often this will change. 

-- Define Ultra Engine Paths
UltraEnginePath = os.getenv("ULTRAENGINE")
if UltraEnginePath==nil then return end

-- Define Game Directory (Relative to this premake script)
GameDir = path.getabsolute("..")

-- Define Root Source Directory
SourceDir = GameDir .. "/Source"

-- Define Soultion Directory
SoultionDir = GameDir

-- Define tools Directory
ToolsPath = GameDir .."/Tools"

-- Workspace
workspace "Game"
    location "%{SoultionDir}"
    startproject "Game"
    configurations { "Debug", "Release"}

    filter {"system:windows", "configurations:*"}
        architecture "x64"

    project "Game"
        targetname ("Game")
        location "%{SoultionDir}"
        language "C++"
        cppdialect "C++17"
        staticruntime "off"
        editandcontinue "on"
        flags { "MultiProcessorCompile" }
        conformancemode (false)

        -- Game Location
        targetdir("%{GameDir}")
        debugdir ("%{GameDir}")

        -- OBJ Output Location
        objdir ("%{prj.location}/.vs/%{cfg.buildcfg}")

        -- Include Directories
        includedirs
        {
            -- Engine
            "%{UltraEnginePath}/Include",
            "%{UltraEnginePath}/Include/Libraries/zlib",
            "%{UltraEnginePath}/Include/Libraries/Box2D",
            "$(UniversalCRT_LibraryPath)",
            "%{UltraEnginePath}/Include/Libraries/freetype/include",
            "%{UltraEnginePath}/Include/Libraries/OpenAL/include",
            "%{UltraEnginePath}/Include/Libraries/RecastNavigation/RecastDemo/Include",
            "%{UltraEnginePath}/Include/Libraries/RecastNavigation/DetourCrowd/Include",
            "%{UltraEnginePath}/Include/Libraries/RecastNavigation/DetourTileCache/Include",
            "%{UltraEnginePath}/Include/Libraries/RecastNavigation/DebugUtils/Include",
            "%{UltraEnginePath}/Include/Libraries/RecastNavigation/Recast/Include",
            "%{UltraEnginePath}/Include/Libraries/RecastNavigation/Detour/Include",
            "%{UltraEnginePath}/Include/Libraries/sol3/include",
            "%{UltraEnginePath}/Include/Libraries/Lua/src",
            "%{UltraEnginePath}/Include/Libraries/enet/include",
            "%{UltraEnginePath}/Include/Libraries/newton/sdk/dTinyxml",
            "%{UltraEnginePath}/Include/Libraries/newton/sdk/dExtensions",
            "%{UltraEnginePath}/Include/Libraries/newton/sdk/dlkSolver",
            "%{UltraEnginePath}/Include/Libraries/newton/sdk/dJoints",
            "%{UltraEnginePath}/Include/Libraries/newton/sdk/dModels/dVehicle",
            "%{UltraEnginePath}/Include/Libraries/newton/sdk/dModels/dCharacter",
            "%{UltraEnginePath}/Include/Libraries/newton/sdk/dModels",
            "%{UltraEnginePath}/Include/Libraries/newton/sdk/dParticles",
            "%{UltraEnginePath}/Include/Libraries/newton/sdk/dNewton",
            "%{UltraEnginePath}/Include/Libraries/newton/sdk/dCore",
            "%{UltraEnginePath}/Include/Libraries/newton/sdk/dCollision",
            "%{UltraEnginePath}/Include/Libraries/NewtonDynamics/sdk/dVehicle/dMultiBodyVehicle",
            "%{UltraEnginePath}/Include/Libraries/NewtonDynamics/sdk/dVehicle",
            "%{UltraEnginePath}/Include/Libraries/NewtonDynamics/sdk/dMath",
            "%{UltraEnginePath}/Include/Libraries/NewtonDynamics/sdk/dgCore",
            "%{UltraEnginePath}/Include/Libraries/NewtonDynamics/sdk/dgNewton",
            "%{UltraEnginePath}/Include/Libraries/NewtonDynamics/sdk/dAnimation",
            "%{UltraEnginePath}/Include/Libraries/NewtonDynamics/sdk/dgTimeTracker",
            "%{UltraEnginePath}/Include/Libraries/NewtonDynamics/sdk/dContainers",
            "%{UltraEnginePath}/Include/Libraries/NewtonDynamics/sdk/dCustomJoints",

            -- Local Source Directory
            "%{SourceDir}"
        }

        files
        {
            "%{SourceDir}/**.h",
            "%{SourceDir}/**.hpp",
            "%{SourceDir}/**.cpp",
        }

        -- Global Defines:
        defines
        {
            "_NEWTON_STATIC_LIB",
            "_CUSTOM_JOINTS_STATIC_LIB",
        }

        -- Shared PCH
        pchheader "UltraEngine.h"

    ---------------------------------------------------------
    -- Visual Studio Exclusive
    ---------------------------------------------------------
    filter "action:vs*"
        systemversion "latest"
        entrypoint "mainCRTStartup"
        pchsource "%{SourceDir}/UltraEngine.cpp"

        files
        {
            "%{SourceDir}/**.ico",
            "%{SourceDir}/**.rc"
        }

        libdirs 
        { 
            "%{UltraEnginePath}/Library"
        }
            
        defines
        {
            "NOMINMAX",
            "_HAS_STD_BYTE=0",
        }

        linkoptions 
        {
            "/delayload:openvr_api.dll" 
        }    

        -- Preprocessor
        prebuildcommands
		{
			--"\"%{ToolsPath}/preprocessor.exe\" +path ../"
		}

    filter {"system:windows", "configurations:Debug"}            
        links 
        {
            "UltraEngine_d.lib"
        }

    filter {"system:windows", "configurations:Release"}
        links 
        {
            "UltraEngine.lib"
        }            

    filter "configurations:Debug"
         defines
        {
            "DEBUG",
            "_DEBUG"
        }

        kind "WindowedApp"
        targetsuffix "_d"
        runtime "Debug"
        symbols "on"
    
    filter "configurations:Release"
        defines
        {
            "NDEBUG"
        }

        kind "WindowedApp"
        runtime "Release"
        symbols "off"
        optimize "off"
    ---------------------------------------------------------
    ---------------------------------------------------------

My batch script:

@echo off

:: Check to see if Ultra Engine is installed and defined.
if not exist "%ULTRAENGINE%" (
	echo ERROR: Unable to find Ultra Engine installed on this PC! Try running the editor first!
	pause
	EXIT /B 999
)

echo Found Ultra Engine at: "%ULTRAENGINE%"

:: Go into the Tools folder.
pushd .
cd Tools
premake5.exe --file=premake5.lua vs2022
popd

pause

 

  • Like 2

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   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.

 Share

×
×
  • Create New...