-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
157 lines (141 loc) · 4.73 KB
/
Copy pathxmake.lua
File metadata and controls
157 lines (141 loc) · 4.73 KB
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
add_rules("mode.debug", "mode.release")
set_project("Tiny.cpp")
set_version("0.2.0")
set_languages("c++11")
option("build_test")
set_default(true)
set_showmenu(true)
set_description("Build test module")
option_end()
option("build_demo")
set_default(true)
set_showmenu(true)
set_description("Build demo module")
option_end()
option("include_docs")
set_default(true)
set_showmenu(true)
set_description("Include docs directory when installing library")
option_end()
option("use_gpm")
set_default(false)
set_showmenu(true)
set_description("Include gpm library for project (Only for linux).")
option_end()
-- Target for static library (Needed build this):
target("Tiny.cpp")
set_kind("static")
add_files("src/**.cpp")
add_headerfiles("src/(**.hpp)", {
prefixdir = "Tiny",
install = true,
public = true
})
if is_plat("windows") then
add_links("pdh", "advapi32", "ws2_32", "user32", "shell32")
end
on_load(function (target)
if has_config("use_gpm") then
if not is_plat("linux") then
raise("You are not using Linux, please disable `use_gpm` config.")
end
import("lib.detect.find_library")
local gpm_lib = find_library("libgpm")
if gpm_lib then
add_links("libgpm")
add_defines("TINY_CPP_USE_GPM=1")
else
print("-- WARNING: You have not installed libgpm! It will be ignored!")
end
end
end)
if has_config("include_docs") then
add_installfiles("$(projectdir)/docs/(**.md)", {
prefixdir = "share/Tiny/docs"
})
add_installfiles("$(projectdir)/README*.md", {
prefixdir = "share/Tiny"
})
add_installfiles("$(projectdir)/LICENSE", {
prefixdir = "share/Tiny"
})
end
if has_config("build_test") then
add_installfiles("$(projectdir)/test/assets/(**)", {
prefixdir = "bin/assets"
})
end
target_end()
if has_config("build_test") then
-- print("Building Test module...")
add_requires("gtest 1.12.1")
for _, name in ipairs(os.files("test/Test*.cpp|Test_*.cpp")) do
local file = path.basename(name)
target(file)
set_kind("binary")
add_packages("gtest")
add_includedirs("src")
add_deps("Tiny.cpp")
set_default(true)
add_files(name)
add_tests(file)
target_end()
end
for _, name in ipairs(os.files("test/Test_*.cpp")) do
local file = path.basename(name)
target(file)
set_kind("binary")
add_includedirs("src")
add_deps("Tiny.cpp")
set_default(true)
add_files(name)
add_tests(file)
target_end()
end
end
if has_config("build_demo") then
-- print("Building Demo module...")
for _, name in ipairs(os.files("demos/**.cpp")) do
local file = path.basename(name)
local dir = path.directory(name)
local dir_name = path.basename(dir)
target(dir_name)
set_kind("binary")
set_default(true)
add_includedirs("src")
add_deps("Tiny.cpp")
add_files(name)
add_tests(dir_name)
target_end()
end
end
package("Tiny.cpp")
set_homepage("https://github.com/CatIsNotFound/Tiny.cpp/")
set_description("An extremely small, lightweight, and easy-to-use foundational library.")
set_license("MIT")
set_urls("https://github.com/CatIsNotFound/Tiny.cpp.git")
add_configs("build_test", {description = "Build test module", default = false, type = "boolean"})
add_configs("build_demo", {description = "Build demo module", default = false, type = "boolean"})
add_configs("include_docs", {description = "Install docs", default = false, type = "boolean"})
add_configs("use_gpm", {description = "Enable libgpm (Linux only) ", default = false, type = "boolean"})
on_load(function (package)
if package:is_plat("windows") then
package:add("syslinks", "pdh", "advapi32", "ws2_32", "user32", "shell32")
else
package:add("syslinks")
end
if package:config("use_gpm") and package:is_plat("linux") then
package:add("gpm")
end
end)
on_install(function (package)
import("package.tools.xmake").install(package, {
configs = {
build_test = package:config("build_test"),
build_demo = package:config("build_demo"),
include_docs = package:config("include_docs"),
use_gpm = package:config("use_gpm")
}
})
end)
package_end()