| [20366] | 1 | ---
|
|---|
| 2 | -- Premake 5.x build configuration script
|
|---|
| 3 | -- Use this script to configure the project with Premake5.
|
|---|
| 4 | ---
|
|---|
| 5 |
|
|---|
| 6 | --
|
|---|
| 7 | -- Remember my location; I will need it to locate sub-scripts later.
|
|---|
| 8 | --
|
|---|
| 9 |
|
|---|
| 10 | local corePath = _SCRIPT_DIR
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | --
|
|---|
| 14 | -- Disable deprecation warnings for myself, so that older development
|
|---|
| 15 | -- versions of Premake can be used to bootstrap new builds.
|
|---|
| 16 | --
|
|---|
| 17 |
|
|---|
| 18 | premake.api.deprecations "off"
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | --
|
|---|
| 22 | -- Register supporting actions and options.
|
|---|
| 23 | --
|
|---|
| 24 |
|
|---|
| 25 | newaction {
|
|---|
| 26 | trigger = "embed",
|
|---|
| 27 | description = "Embed scripts in scripts.c; required before release builds",
|
|---|
| 28 | execute = function ()
|
|---|
| 29 | include (path.join(corePath, "scripts/embed.lua"))
|
|---|
| 30 | end
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | newaction {
|
|---|
| 35 | trigger = "package",
|
|---|
| 36 | description = "Creates source and binary packages",
|
|---|
| 37 | execute = function ()
|
|---|
| 38 | include (path.join(corePath, "scripts/package.lua"))
|
|---|
| 39 | end
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | newaction {
|
|---|
| 44 | trigger = "test",
|
|---|
| 45 | description = "Run the automated test suite",
|
|---|
| 46 | execute = function ()
|
|---|
| 47 | test = require "self-test"
|
|---|
| 48 | premake.action.call("self-test")
|
|---|
| 49 | end
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 | newoption {
|
|---|
| 54 | trigger = "test-only",
|
|---|
| 55 | description = "When testing, run only the specified suite or test"
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 | newoption {
|
|---|
| 60 | trigger = "to",
|
|---|
| 61 | value = "path",
|
|---|
| 62 | description = "Set the output location for the generated files"
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | newoption {
|
|---|
| 67 | trigger = "no-curl",
|
|---|
| 68 | description = "Disable Curl 3rd party lib"
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 | newoption {
|
|---|
| 73 | trigger = "no-zlib",
|
|---|
| 74 | description = "Disable Zlib/Zip 3rd party lib"
|
|---|
| 75 | }
|
|---|
| [22021] | 76 |
|
|---|
| 77 | newoption {
|
|---|
| 78 | trigger = "no-luasocket",
|
|---|
| 79 | description = "Disable Luasocket 3rd party lib"
|
|---|
| 80 | }
|
|---|
| [20366] | 81 |
|
|---|
| 82 | newoption {
|
|---|
| 83 | trigger = "bytecode",
|
|---|
| 84 | description = "Embed scripts as bytecode instead of stripped souce code"
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | --
|
|---|
| 88 | -- Define the project. Put the release configuration first so it will be the
|
|---|
| 89 | -- default when folks build using the makefile. That way they don't have to
|
|---|
| 90 | -- worry about the /scripts argument and all that.
|
|---|
| 91 | --
|
|---|
| 92 | -- TODO: Switch to these new APIs once they've had a chance to land everywhere
|
|---|
| 93 | --
|
|---|
| 94 | -- defaultConfiguration "Release"
|
|---|
| 95 | -- symbols "On"
|
|---|
| 96 | --
|
|---|
| 97 |
|
|---|
| 98 | solution "Premake5"
|
|---|
| 99 | configurations { "Release", "Debug" }
|
|---|
| 100 | location ( _OPTIONS["to"] )
|
|---|
| 101 |
|
|---|
| [22021] | 102 | flags { "StaticRuntime", "MultiProcessorCompile" }
|
|---|
| [20366] | 103 | warnings "Extra"
|
|---|
| 104 |
|
|---|
| 105 | if not _OPTIONS["no-zlib"] then
|
|---|
| 106 | defines { "PREMAKE_COMPRESSION" }
|
|---|
| 107 | end
|
|---|
| [22021] | 108 |
|
|---|
| [20366] | 109 | if not _OPTIONS["no-curl"] then
|
|---|
| 110 | defines { "CURL_STATICLIB", "PREMAKE_CURL"}
|
|---|
| 111 | end
|
|---|
| 112 |
|
|---|
| [22021] | 113 | filter { 'system:windows' }
|
|---|
| 114 | platforms { 'x86', 'x64' }
|
|---|
| 115 |
|
|---|
| [20366] | 116 | filter "configurations:Debug"
|
|---|
| 117 | defines "_DEBUG"
|
|---|
| 118 | flags { "Symbols" }
|
|---|
| 119 |
|
|---|
| 120 | filter "configurations:Release"
|
|---|
| 121 | defines "NDEBUG"
|
|---|
| 122 | optimize "Full"
|
|---|
| 123 | flags { "NoBufferSecurityCheck", "NoRuntimeChecks" }
|
|---|
| 124 |
|
|---|
| 125 | filter "action:vs*"
|
|---|
| 126 | defines { "_CRT_SECURE_NO_DEPRECATE", "_CRT_SECURE_NO_WARNINGS", "_CRT_NONSTDC_NO_WARNINGS" }
|
|---|
| 127 |
|
|---|
| 128 | filter { "system:windows", "configurations:Release" }
|
|---|
| [24387] | 129 | flags { "NoIncrementalLink" }
|
|---|
| [20366] | 130 |
|
|---|
| [24387] | 131 | -- MinGW AR does not handle LTO out of the box and need a plugin to be setup
|
|---|
| 132 | filter { "system:windows", "configurations:Release", "toolset:not mingw" }
|
|---|
| 133 | flags { "LinkTimeOptimization" }
|
|---|
| 134 |
|
|---|
| [20366] | 135 | project "Premake5"
|
|---|
| 136 | targetname "premake5"
|
|---|
| 137 | language "C"
|
|---|
| 138 | kind "ConsoleApp"
|
|---|
| 139 | includedirs { "contrib/lua/src", "contrib/luashim" }
|
|---|
| 140 | links { "lua-lib" }
|
|---|
| 141 |
|
|---|
| 142 | -- optional 3rd party libraries
|
|---|
| 143 | if not _OPTIONS["no-zlib"] then
|
|---|
| 144 | includedirs { "contrib/zlib", "contrib/libzip" }
|
|---|
| 145 | links { "zip-lib", "zlib-lib" }
|
|---|
| 146 | end
|
|---|
| [22021] | 147 |
|
|---|
| [20366] | 148 | if not _OPTIONS["no-curl"] then
|
|---|
| 149 | includedirs { "contrib/curl/include" }
|
|---|
| 150 | links { "curl-lib" }
|
|---|
| 151 | end
|
|---|
| 152 |
|
|---|
| 153 | files
|
|---|
| 154 | {
|
|---|
| 155 | "*.txt", "**.lua",
|
|---|
| 156 | "src/**.h", "src/**.c",
|
|---|
| 157 | "modules/**"
|
|---|
| 158 | }
|
|---|
| 159 |
|
|---|
| 160 | excludes
|
|---|
| 161 | {
|
|---|
| 162 | "contrib/**.*",
|
|---|
| 163 | "binmodules/**.*"
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | filter "configurations:Debug"
|
|---|
| 167 | targetdir "bin/debug"
|
|---|
| [22021] | 168 | debugargs { "--scripts=%{prj.location}/%{path.getrelative(prj.location, prj.basedir)}", "test" }
|
|---|
| 169 | debugdir "."
|
|---|
| [20366] | 170 |
|
|---|
| 171 | filter "configurations:Release"
|
|---|
| 172 | targetdir "bin/release"
|
|---|
| 173 |
|
|---|
| 174 | filter "system:windows"
|
|---|
| [24387] | 175 | links { "ole32", "ws2_32", "advapi32", "version" }
|
|---|
| [20366] | 176 |
|
|---|
| [24387] | 177 | filter "toolset:mingw"
|
|---|
| 178 | links { "crypt32" }
|
|---|
| 179 |
|
|---|
| [20366] | 180 | filter "system:linux or bsd or hurd"
|
|---|
| 181 | defines { "LUA_USE_POSIX", "LUA_USE_DLOPEN" }
|
|---|
| 182 | links { "m" }
|
|---|
| 183 | linkoptions { "-rdynamic" }
|
|---|
| 184 |
|
|---|
| 185 | filter "system:linux or hurd"
|
|---|
| 186 | links { "dl", "rt" }
|
|---|
| 187 |
|
|---|
| 188 | filter { "system:not windows", "system:not macosx" }
|
|---|
| 189 | if not _OPTIONS["no-curl"] then
|
|---|
| 190 | links { "mbedtls-lib" }
|
|---|
| 191 | end
|
|---|
| 192 |
|
|---|
| 193 | filter "system:macosx"
|
|---|
| 194 | defines { "LUA_USE_MACOSX" }
|
|---|
| 195 | links { "CoreServices.framework", "Foundation.framework", "Security.framework", "readline" }
|
|---|
| 196 |
|
|---|
| 197 | filter { "system:macosx", "action:gmake" }
|
|---|
| 198 | toolset "clang"
|
|---|
| 199 |
|
|---|
| 200 | filter { "system:solaris" }
|
|---|
| [22021] | 201 | links { "m", "socket", "nsl" }
|
|---|
| [20366] | 202 |
|
|---|
| 203 | filter "system:aix"
|
|---|
| 204 | defines { "LUA_USE_POSIX", "LUA_USE_DLOPEN" }
|
|---|
| 205 | links { "m" }
|
|---|
| 206 |
|
|---|
| [24387] | 207 | filter "system:haiku"
|
|---|
| 208 | defines { "LUA_USE_POSIX", "LUA_USE_DLOPEN", "_BSD_SOURCE" }
|
|---|
| 209 | links { "network", "bsd" }
|
|---|
| [20366] | 210 |
|
|---|
| [24387] | 211 |
|
|---|
| [20366] | 212 | -- optional 3rd party libraries
|
|---|
| 213 | group "contrib"
|
|---|
| 214 | include "contrib/lua"
|
|---|
| 215 | include "contrib/luashim"
|
|---|
| [22021] | 216 |
|
|---|
| [20366] | 217 | if not _OPTIONS["no-zlib"] then
|
|---|
| 218 | include "contrib/zlib"
|
|---|
| 219 | include "contrib/libzip"
|
|---|
| 220 | end
|
|---|
| [22021] | 221 |
|
|---|
| [20366] | 222 | if not _OPTIONS["no-curl"] then
|
|---|
| 223 | include "contrib/mbedtls"
|
|---|
| 224 | include "contrib/curl"
|
|---|
| [22021] | 225 | end
|
|---|
| [20366] | 226 |
|
|---|
| 227 | group "Binary Modules"
|
|---|
| 228 | include "binmodules/example"
|
|---|
| [22021] | 229 |
|
|---|
| 230 | if not _OPTIONS["no-luasocket"] then
|
|---|
| 231 | include "binmodules/luasocket"
|
|---|
| 232 | end
|
|---|
| [20366] | 233 |
|
|---|
| 234 | --
|
|---|
| 235 | -- A more thorough cleanup.
|
|---|
| 236 | --
|
|---|
| 237 |
|
|---|
| 238 | if _ACTION == "clean" then
|
|---|
| 239 | os.rmdir("bin")
|
|---|
| 240 | os.rmdir("build")
|
|---|
| 241 | end
|
|---|