summaryrefslogtreecommitdiff
path: root/tests/apis/custom_scopeapis/xmake.lua
blob: 3f20836a5b73edbcc174a8f7212d5eabe1244f16 (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
add_rules("mode.debug", "mode.release")

interp_add_scopeapis("myscope.set_name", "myscope.add_list", {kind = "values"})
interp_add_scopeapis("myscope.on_script", {kind = "script"})

myscope("hello")
    set_name("foo")
    add_list("value1", "value2")
    on_script(function ()
        print("hello")
    end)

target("test")
    set_kind("binary")
    add_files("src/*.cpp")
    on_config(function (target)
        import("core.project.project")
        local myscope = project.scope("myscope")
        for name, scope in pairs(myscope) do
            print("myscope(%s)", name)
            print("    name: %s", scope:get("name"))
            print("    list: %s", table.concat(scope:get("list"), ", "))
            print("    script:")
            local script = scope:get("script")
            if script then
                script()
            end
        end
    end)