Skip to content

Commit b9f7a26

Browse files
committed
Improve premake script
1 parent 97fd6e6 commit b9f7a26

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

premake5.lua

+18-19
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,14 @@ newoption {
1111
}
1212

1313
workspace "wrenpp"
14+
local project_location = ""
1415
if _ACTION then
15-
-- guard this in case the user is calling `premake5 --help`
16-
-- in which case there will be no action
17-
location( "build/" .. _ACTION )
16+
project_location = "build/" .._ACTION
1817
end
19-
configurations { "Debug", "Release" }
20-
platforms { "Win32", "x64" }
2118

22-
filter "platforms:Win32"
23-
architecture "x86"
19+
configurations { "Debug", "Release", "Test" }
2420

25-
filter "platforms:x64"
26-
architecture "x86_64"
21+
architecture "x86_64"
2722

2823
-- global configuration
2924
filter "configurations:Debug"
@@ -41,9 +36,10 @@ workspace "wrenpp"
4136
buildoptions { "-std=c++14" }
4237

4338
project "lib"
39+
location(project_location)
4440
kind "StaticLib"
4541
language "C++"
46-
targetdir "lib/"
42+
targetdir "lib/%{cfg.buildcfg}"
4743
targetname "wrenpp"
4844
if _OPTIONS["include"] then
4945
includedirs { _OPTIONS["include"] }
@@ -52,28 +48,31 @@ workspace "wrenpp"
5248
includedirs { "src" }
5349

5450
project "test"
51+
location(project_location)
5552
kind "ConsoleApp"
5653
language "C++"
57-
targetdir "bin"
54+
targetdir "bin/%{cfg.buildcfg}"
5855
targetname "test"
5956
files { "Wren++.cpp", "test/**.cpp", "test/***.h", "test/**.wren" }
6057
includedirs { "./", "test" }
6158
if _OPTIONS["include"] then
6259
includedirs { _OPTIONS["include"] }
6360
end
6461
if _OPTIONS["link"] then
65-
libdirs {
66-
_OPTIONS["link"]
67-
}
68-
end
62+
libdirs {
63+
_OPTIONS["link"]
64+
}
65+
end
66+
67+
prebuildcommands { "{MKDIR} %{cfg.targetdir}" }
6968

7069
filter "files:**.wren"
71-
buildcommands { "{COPY} ../../test/%{file.name} ../../bin" }
72-
buildoutputs { "../../bin/%{file.name}" }
73-
filter {}
70+
buildcommands { "{COPY} %{file.abspath} %{cfg.targetdir}" }
71+
buildoutputs { "%{cfg.targetdir}/%{file.name}" }
72+
filter {}
7473

7574
filter "configurations:Debug"
76-
debugdir "bin"
75+
debugdir "bin/%{cfg.buildcfg}"
7776

7877
filter { "action:vs*", "Debug" }
7978
links { "lib", "wren_static_d" }

0 commit comments

Comments
 (0)