Skip to content
Discussion options

You must be logged in to vote

正常。这里的 is_kind() 不是读取某个 target 的 set_kind("shared"),而是读取当前配置里的 kind:源码里它是 config.get("kind")。没有配置时会返回 false;有配置但不匹配时函数走到结尾,所以打印出来就是 nil

所以:

print(is_kind("shared"))

只有在当前构建配置的 kind 正好是 shared 时才会是 true;否则可能是 falsenil,不要把它当作 target kind 判断。

如果你是在 target 回调里判断某个目标本身,应该用传进来的 target 对象,例如:

target("foo")
    set_kind("shared")
    on_load(function (target)
        print(target:is_shared())
        print(target:kind())
    end)

如果你想判断配置项,可以先 xmake f --kind=shared 后再测。

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by yybbwc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants