summaryrefslogtreecommitdiff
path: root/tests/projects/xmake_cli/ide_integration/assets/targetpath.lua
blob: 2e8c65fe95fad579be7ee985f78035d1cb4cfb4d (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
import("core.project.config")
import("core.project.project")
import("lib.lni")

function main (targetname)
    config.load()
    if not os.isfile(os.projectfile()) then
        return
    end

    local target = nil
    if targetname then
        target = project.target(targetname)
    end
    if not target then
        for _, t in pairs(project.targets()) do
            local default = t:get("default")
            if (default == nil or default == true) and t:get("kind") == "binary" then
                target = t
                break
            end
        end
    end

    if target then
        local targetfile = target:targetfile()
        if not path.is_absolute(targetfile) then
            targetfile = path.absolute(targetfile, os.projectdir())
        end
        lni.result = targetfile
    end
end