blob: 564a55989bc637431a108345477129a5bba2f7e0 (
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
|
rule("xx")
add_deps("c++")
on_load(function (target)
-- add .xx
local rule = target:rule("c++.build"):clone()
rule:set("extensions", ".xx")
target:rule_add(rule)
-- patch sourcebatch for .xx
local sourcebatch = target:sourcebatches()["c++.build"]
sourcebatch.sourcekind = "cxx"
sourcebatch.objectfiles = {}
sourcebatch.dependfiles = {}
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
local objectfile = target:objectfile(sourcefile)
local dependfile = target:dependfile(objectfile)
table.insert(sourcebatch.objectfiles, objectfile)
table.insert(sourcebatch.dependfiles, dependfile)
end
-- force as c++ source file
if target:is_plat("windows") then
target:add("cxxflags", "/TP")
else
target:add("cxxflags", "-x c++")
end
end)
target("test")
set_kind("binary")
add_rules("xx")
add_files("src/*.xx", "src/*.cc")
|