Skip to content

How to get all included files used by batchcmds:compile(file.cpp) command to fill a batchcmds:add_depfiles(h1.hpp, h2.hpp....) ? #5946

Closed Answered by PierreEVEN
PierreEVEN asked this question in Q&A
Discussion options

You must be logged in to vote

Yay found the solution 🥳
Thanks @waruqi !

rule("generated_cpp", function (rule)
    set_extensions(".hpp")
    before_buildcmd_file(function (target, batchcmds, source_header, opt)

        -- Guess generated source file path
        local generated_path = string.sub(os.projectdir().."/"..source_header, string.len(target:scriptdir()) + 2)
        -- replace .hpp extension with .gen.cpp
        local generated_source = target:autogendir().."/"..string.sub(generated_path, 1, string.len(generated_path) - 3).."gen.cpp"

        -- generated classes are always private
        generated_source = generated_source:gsub("public", "private", 1)
        
        if (os.exists(generated_source)) then

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@waruqi
Comment options

Answer selected by PierreEVEN
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