aboutsummaryrefslogtreecommitdiff
path: root/premake5.lua
blob: 710bf1c892722e2a123a60fe05f1f0b60492521e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
output_dir = "%{cfg.buildcfg}-%{cfg.system}"

function setup_target()
	targetdir ("bin/" .. output_dir)
	objdir ("bin-int/" .. output_dir .. "/%{prj.name}")
	staticruntime "On"
end

function setup_c_target()
	setup_target()

	filter "configurations:debug"
		runtime "Debug"
		symbols "On"
	filter { "configurations:release", "configurations:dist" }
		runtime "Release"
		optimize "Speed"
	filter "configurations:dist"
		symbols "Off"
	filter {}
end

newaction {
	trigger = "clean",
	description = "Remove build output and generated project files",

	execute = function()
		os.rmdir("bin")
		os.rmdir("bin-int")
		os.remove("Makefile")

		for _, file in ipairs(os.matchfiles("*.make")) do
			os.remove(file)
		end

		print("Cleaned build output and generated project files")
	end
}

workspace "hdass"
	architecture "x64"
	startproject "hdass"
	multiprocessorcompile "On"

	configurations {
		"debug",
		"release",
		"dist",
	}

	filter "system:windows"
		defines "HDASS_WINDOWS"
	filter "system:linux"
		defines "HDASS_LINUX"
	filter "system:macosx"
		architecture "ARM64"
		defines "HDASS_MACOS"
	filter {}

project "hdass"
	kind "ConsoleApp"
	language "C"
	cdialect "C17"

	setup_c_target()

	files {
		"src/**.h",
		"src/**.c",
	}

	includedirs "src"

	filter { "system:macosx or system:linux" }
		buildoptions {
			"-Wall",
			"-Wextra",
			"-Werror",
			"-pedantic",
		}
	filter {}

	filter "system:windows"
		systemversion "latest"

	filter "configurations:debug"
		defines "HDASS_DEBUG"
	filter "configurations:release"
		defines "HDASS_RELEASE"
	filter "configurations:dist"
		defines "HDASS_DIST"
	filter {}