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

Support for dynamic creation and injection of rules and targets #2874

Merged
merged 19 commits into from
Sep 28, 2022
Merged

Conversation

waruqi
Copy link
Member

@waruqi waruqi commented Sep 27, 2022

@waruqi waruqi marked this pull request as ready for review September 27, 2022 07:20
@waruqi waruqi changed the title Support for dynamic creation and injection of rules Support for dynamic creation and injection of rules and targets Sep 27, 2022
@waruqi
Copy link
Member Author

waruqi commented Sep 28, 2022

@Arthapz @SirLynix @xq114 Can you help me test your project, like, project generator, ..

I have changed a lot of the logic related to target/rule.

@Arthapz
Copy link
Member

Arthapz commented Sep 28, 2022

@waruqi seem like Ok, doesn't break my projects, but didn't found a way to make my cppfront rule work

@waruqi
Copy link
Member Author

waruqi commented Sep 28, 2022

@waruqi seem like Ok, doesn't break my projects, but didn't found a way to make my cppfront rule work

Even though I was able to get the cppfront rules executed first by injecting dependencies, the c++modules dependency scan analysis is not executed in the batchjob, it is still executed early because it is executed during the build batchjob dependency graph phase.

rule("cppfront")
    set_extensions(".cpp2")
    on_load(function (target)
        -- modify and replace the builtin rule
        local rule = target:rule("c++.build.modules.builder"):clone()
        rule:add("deps", "cppfront", {order = true})
        target:rule_add(rule)
    end)
    before_build_file(function (target, sourcefile, opt)
        print("build cppfront file")
    end)

target("test")
    set_kind("binary")
    add_rules("cppfront")
    set_languages("c++20")
    add_files("src/*.cpp", "src/*.mpp")
    add_files("src/*.cpp2")

here

local modules = common.get_module_dependencies(target, sourcebatch, opt)

[  0%]: generating.cxx.module.deps src/main.cpp. -> generate module deps, it is not called in batchjob
[  0%]: generating.cxx.module.deps src/hello.mpp
build cppfront file.   -----------------------------------> before build modules and generate headerunits
[ 25%]: generating.cxx.module.bmi hello
[ 62%]: cache compiling.release src/main.cpp
[ 75%]: linking.release test
[100%]: build ok!

@waruqi waruqi added this to the v2.7.2 milestone Sep 28, 2022
@waruqi waruqi merged commit 73c2223 into dev Sep 28, 2022
@waruqi waruqi deleted the rule branch September 28, 2022 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants