Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The option:set_default interface is inconsistent with the documentation description in xmake.io #5159

Open
trunkszi opened this issue May 28, 2024 · 1 comment
Labels

Comments

@trunkszi
Copy link

Xmake Version

2.9.2

Operating System Version and Architecture

Ubuntu 24.04 LTS

Describe Bug

# Code from xmake.io documentation
option("myoption")
    set_default("hello world")
    set_showmenu(true)
option_end()

target("test")
    set_kind("binary")
    add_files("src/*.cpp")
    set_options("myoption")
    on_config(function(target)
         local myoption = get_config("myoption")

        -- Expected to return string type, but returned bool type
        print("myoption: ", myoption)

        -- error: invalid replacement value (a boolean)
        print("myoption: ", "$(myoption)")
    end)

error info

~/ xmake f --myoption=y
checking for platform ... linux
checking for architecture ... x86_64
myoption:  true
error: invalid replacement value (a boolean)

Expected Behavior

# Code from xmake.io documentation
option("myoption")
    set_default("hello world")
    set_showmenu(true)
option_end()

target("test")
    set_kind("binary")
    add_files("src/*.cpp")
    set_options("myoption")
    on_config(function(target)
         local myoption = get_config("myoption")

        -- Expected to return string type, but returned bool type
        print("myoption: ", myoption)

        -- error: invalid replacement value (a boolean)
        print("myoption: ", "$(myoption)")
    end)

Project Configuration

# Code from xmake.io documentation
option("myoption")
    set_default("hello world")
    set_showmenu(true)
option_end()

target("test")
    set_kind("binary")
    add_files("src/*.cpp")
    set_options("myoption")
    on_config(function(target)
         local myoption = get_config("myoption")

        -- Expected to return string type, but returned bool type
        print("myoption: ", myoption)

        -- error: invalid replacement value (a boolean)
        print("myoption: ", "$(myoption)")
    end)

Additional Information and Error Logs

error info

xmake f --myoption=y
checking for platform ... linux
checking for architecture ... x86_64
myoption:  true
error: invalid replacement value (a boolean)
@trunkszi trunkszi added the bug label May 28, 2024
@waruqi
Copy link
Member

waruqi commented May 28, 2024

xmake f --myoption=y

Because you entered y/n, which are boolean values, and you rewrote the default value.

if you want to get string value, please enter other string value instead of y/n

ruki:test2 ruki$ xmake f --myoption=aasda
myoption:  aasda
myoption:  aasda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants