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

Improve rule() api and add some builtin rules #167

Closed
waruqi opened this Issue Apr 14, 2018 · 6 comments

Comments

Projects
None yet
1 participant
@waruqi
Member

waruqi commented Apr 14, 2018

in version(2.2.1):

add_rules("mode.debug", "mode.release")

target("console_c")
    set_kind("binary")
    add_files("src/*.c") 

Before:

if is_mode("debug") then
    set_symbols("debug")
    set_optimize("none")
end

if is_mode("release") then
    set_symbols("hidden")
    set_optimize("fastest")
    set_strip("all")
end

target("console_c")
    set_kind("binary")
    add_files("src/*.c") 

@waruqi waruqi added the new feature label Apr 14, 2018

@waruqi waruqi added this to the 2.2.1 milestone Apr 14, 2018

@waruqi

This comment has been minimized.

Member

waruqi commented Apr 14, 2018

xmake will provide some builtin rules in xmake/rules, for example:

-- define rule: debug mode
rule("mode.debug")
    on_load(function (target)

        -- is debug mode now? xmake f -m debug
        if is_mode("debug") then
 
            -- enable the debug symbols
            target:set("symbols", "debug")

            -- disable optimization
            target:set("optimize", "none")
        end
    end)
@waruqi

This comment has been minimized.

Member

waruqi commented Apr 14, 2018

@waruqi

This comment has been minimized.

Member

waruqi commented Apr 14, 2018

Some rule apis:

  • add_deps
  • set_extensions
  • on_load
  • on_build
  • on_build_file
  • on_build_files
  • before_build
  • before_build_file
  • before_build_files
  • after_build
  • after_build_file
  • after_build_files
  • on_clean, on_install, on_uninstall, on_run, on_package
  • before_xxx, after_xxx ...

All rules are superimposed on the specified target.

@waruqi

This comment has been minimized.

Member

waruqi commented Apr 14, 2018

We will provide some qt rules #160 to implement it, for example:

target("qt_test1")
    add_rules("qt.console")
    add_files("src/*.cpp")
target("qt_test2")
    add_rules("qt.application")
    add_files("src/*.cpp")
@waruqi

This comment has been minimized.

Member

waruqi commented May 2, 2018

Support multi-rules in same files.

rule("rule1")
    before_build_file(function (target, sourcefile)
    end)
rule("rule2")
    after_build_file(function (target, sourcefile)
    end)
target("console_c")
    set_kind("binary")
    add_files("src/*.c", {rules = {"rule1", "rule2"}}) 
@waruqi

This comment has been minimized.

Member

waruqi commented Jun 7, 2018

@waruqi waruqi added the done label Jun 7, 2018

@waruqi waruqi closed this Jun 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment