-
Notifications
You must be signed in to change notification settings - Fork 0
/
premake5.lua
168 lines (125 loc) · 4.8 KB
/
premake5.lua
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
--[[
MIT License
Copyright (c) 2016-2022 Raúl Ramos
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--]]
-- check out https://github.com/premake/premake-core/wiki/Tokens
workspace "tutorial-callstack-tracker"
language "C++"
cppdialect "C++17"
configurations { "Debug", "Release" }
platforms { "x64" }
location ".build"
flags { "FatalCompileWarnings", "FatalLinkWarnings" }
filter { "configurations:Debug" } defines { "DEBUG" } symbols "On"
filter { "configurations:Release" } defines { "NDEBUG" } optimize "Speed"
filter { "platforms:*64" } architecture "x86_64"
filter { "platforms:*86" } architecture "x86"
filter { "system:macosx", "action:gmake" } toolset "clang"
filter { "system:windows", "action:vs*" } buildoptions { "/W3", "/EHsc" }
filter { "system:linux" } links "pthread"
filter { "toolset:clang or toolset:gcc" } buildoptions { "-Wall", "-Wextra", "-fno-exceptions", "-msse4.2" }
startproject "host"
-- Library that will receive the call stacks
project "qcstudio"
kind "SharedLib"
targetdir ".out/%{cfg.platform}/%{cfg.buildcfg}"
objdir ".tmp/%{prj.name}"
defines { "BUILDING_QCSTUDIO" }
links {
"dbghelp"
}
files { "src/qcstudio/*" }
-- Test shared libraries
project "foo"
kind "SharedLib"
includedirs { "src" }
targetdir ".out/%{cfg.platform}/%{cfg.buildcfg}"
objdir ".tmp/%{prj.name}"
dependson { "qcstudio" }
libdirs { "%{cfg.buildtarget.directory}" }
links {
"qcstudio.lib"
}
files { "src/foo/*" }
project "bar"
kind "SharedLib"
includedirs { "src" }
targetdir ".out/%{cfg.platform}/%{cfg.buildcfg}"
objdir ".tmp/%{prj.name}"
dependson { "qcstudio" }
libdirs { "%{cfg.buildtarget.directory}" }
links {
"qcstudio.lib"
}
files { "src/bar/*" }
-- Host application that produces the data
project "host"
kind "ConsoleApp"
dependson { "foo", "bar", "baz", "qcstudio" }
includedirs { "src" }
targetdir ".out/%{cfg.platform}/%{cfg.buildcfg}"
objdir ".tmp/%{prj.name}"
libdirs { "%{cfg.buildtarget.directory}" }
links {
"foo.lib",
"qcstudio.lib"
}
files { "src/host/*" }
project "viewer"
kind "ConsoleApp"
dependson { "qcstudio" }
includedirs { "src" }
targetdir ".out/%{cfg.platform}/%{cfg.buildcfg}"
objdir ".tmp/%{prj.name}"
libdirs { "%{cfg.buildtarget.directory}" }
links {
"qcstudio.lib",
"dbghelp"
}
files { "src/viewer/*" }
-- Handle Dropbox annoying sync of temporary folders
print("[] Excluding .build, .tmp and .out from Dropbox sync...");
if os.target() == "windows" then
-- Do not allow Dropbox to sync these temporary folders
local script = [[
New-Item .build -type directory -force | Out-Null
New-Item .tmp -type directory -force | Out-Null
New-Item .out -type directory -force | Out-Null
Set-Content -Path '.build' -Stream com.dropbox.ignored -Value 1
Set-Content -Path '.tmp' -Stream com.dropbox.ignored -Value 1
Set-Content -Path '.out' -Stream com.dropbox.ignored -Value 1
]]
-- Feed the script to powershell process stdin
local pipe = io.popen("powershell -command -", "w")
pipe:write(script)
pipe:close()
elseif os.target() == "macosx" then
-- Do not allow Dropbox to sync these temporary folders
local script = [[
mkdir -p .build
mkdir -p .tmp
mkdir -p .out
xattr -w com.dropbox.ignored 1 .build
xattr -w com.dropbox.ignored 1 .tmp
xattr -w com.dropbox.ignored 1 .out
]]
-- Run the script
local pipe = io.popen("bash", "w")
pipe:write(script)
pipe:close()
end