diff options
| author | Arthur LAURENT <[email protected]> | 2025-05-05 17:13:25 +0200 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2025-05-09 15:56:33 +0200 |
| commit | 5d6d36e0db45d90dfa7f0cdf2937d989de683833 (patch) | |
| tree | 2d1fbb82ee8d38921af1863fd3ce968f7c5cea75 /xmake/rules/c++/modules/gcc/builder.lua | |
| parent | d88bd9c5ace6c64981420569fb886f7c646135c0 (diff) | |
(C++ module support) improve jobgraph support
Diffstat (limited to 'xmake/rules/c++/modules/gcc/builder.lua')
| -rw-r--r-- | xmake/rules/c++/modules/gcc/builder.lua | 473 |
1 files changed, 152 insertions, 321 deletions
diff --git a/xmake/rules/c++/modules/gcc/builder.lua b/xmake/rules/c++/modules/gcc/builder.lua index 94c35c852..2d202d699 100644 --- a/xmake/rules/c++/modules/gcc/builder.lua +++ b/xmake/rules/c++/modules/gcc/builder.lua @@ -21,6 +21,7 @@ -- imports import("core.base.json") import("core.base.option") +import("core.base.bytes") import("core.base.semver") import("utils.progress") import("private.action.build.object", {alias = "objectbuilder"}) @@ -28,31 +29,29 @@ import("core.tool.compiler") import("core.project.config") import("core.project.depend") import("support") +import(".mapper") import(".builder", {inherit = true}) -- get flags for building a headerunit -function _make_headerunitflags(target, headerunit, headerunit_mapper) +function _make_headerunitflags(target, headerunit_mapper, headerunit) local module_headerflag = support.get_moduleheaderflag(target) - local module_onlyflag = support.get_moduleonlyflag(target) local module_mapperflag = support.get_modulemapperflag(target) - assert(module_headerflag and module_onlyflag, "compiler(gcc): does not support c++ header units!") + assert(module_headerflag, "compiler(gcc): does not support c++ header units!") - local local_directory = (headerunit.type == ":quote") and {"-I" .. path.directory(path.normalize(headerunit.path))} or {} - local headertype = (headerunit.type == ":angle") and "system" or "user" - local flags = table.join(local_directory, {module_mapperflag .. headerunit_mapper, - module_headerflag .. headertype, - module_onlyflag, - "-xc++-header"}) - return flags + local headertype = (headerunit.method == "include-angle") and "system" or "user" + local includedir = headertype == "user" and "-I" .. path.directory(headerunit.sourcefile) + return table.join(includedir and {includedir} or {}, + {"-x", "c++-" .. headertype .. "-header", + module_mapperflag .. headerunit_mapper, + module_headerflag .. headertype}) end -- do compile function _compile(target, flags, sourcefile, outputfile) - local dryrun = option.get("dry-run") local compinst = target:compiler("cxx") - local compflags = compinst:compflags({sourcefile = sourcefile, target = target}) - local flags = table.join(compflags or {}, flags) + local compflags = compinst:compflags({sourcefile = sourcefile, target = target, sourcekind = "cxx"}) + flags = table.join(compflags or {}, flags) -- trace if option.get("verbose") then @@ -69,8 +68,8 @@ end -- @note we need to use batchcmds:compilev to translate paths in compflags for generator, e.g. -Ixx function _batchcmds_compile(batchcmds, target, flags, sourcefile, outputfile) local compinst = target:compiler("cxx") - local compflags = compinst:compflags({sourcefile = sourcefile, target = target}) - local flags = table.join("-c", compflags or {}, flags, {"-o", outputfile, sourcefile}) + local compflags = compinst:compflags({sourcefile = sourcefile, target = target, sourcekind = "cxx"}) + flags = table.join("-c", compflags or {}, flags, {"-o", outputfile, sourcefile}) batchcmds:compilev(flags, {compiler = compinst, sourcekind = "cxx"}) end @@ -80,46 +79,40 @@ function _module_map_cachekey(target) end -- generate a module mapper file for build a headerunit -function _generate_headerunit_modulemapper_file(module) - local mapper_path = os.tmpfile() +function _generate_headerunit_modulemapper_file(target, headerunit) + local mapper_path = _get_modulemapper_file(target, headerunit) local mapper_file = io.open(mapper_path, "wb") - mapper_file:write("root " .. path.unix(os.projectdir())) - mapper_file:write("\n") - mapper_file:write(mapper_file, path.unix(module.name) .. " " .. path.unix(module.bmifile)) + mapper_file:write("root " .. path.directory(headerunit.sourcefile) .. "\n") + mapper_file:write(mapper_file, path.unix(headerunit.sourcefile) .. " " .. path.unix(path.absolute(headerunit.bmifile)) .. "\n") mapper_file:write("\n") mapper_file:close() return mapper_path end function _get_maplines(target, module) + local maplines = {} - local m_name, m, _ = support.get_provided_module(module) - if m then - table.insert(maplines, m_name .. " " .. support.get_bmi_path(m.bmi)) + if module.interface or module.implementation then + table.insert(maplines, module.name .. " " .. path.absolute(module.bmifile)) end - for required, _ in table.orderpairs(module.requires) do - local dep_module = get_from_target_mapper(target, required) - assert(dep_module, "module dependency %s required for %s not found", required, m_name or module.cppfile) - - local bmifile = dep_module.bmi + for dep_name, dep_module in table.orderpairs(module.deps) do + local key = dep_name + if dep_module.headerunit then + key = dep_name .. dep_module.key + end + local dep_module_mapped = mapper.get(target, key) + assert(dep_module_mapped, "module dependency %s required for %s not found", dep_name, module.name or module.sourcefile) local mapline - -- aliased headerunit - if dep_module.aliasof then - local aliased = get_from_target_mapper(target, dep_module.aliasof) - bmifile = aliased.bmi - mapline = path.unix(dep_module.headerunit.path) .. " " .. path.unix(bmifile) - -- headerunit - elseif dep_module.headerunit then - mapline = path.unix(dep_module.headerunit.path) .. " " .. path.unix(bmifile) - -- named module - else - mapline = required .. " " .. path.unix(bmifile) + local name = dep_name + if dep_module_mapped.headerunit then + name = dep_module_mapped.method == "include-angle" and dep_module_mapped.sourcefile or path.join("./", path.directory(module.sourcefile), dep_name) end + mapline = path.unix(name) .. " " .. path.unix(path.absolute(dep_module_mapped.bmifile)) table.insert(maplines, mapline) -- append deps - if dep_module.opt and dep_module.opt.deps then - local deps = _get_maplines(target, {name = dep_module.name, bmi = bmifile, requires = dep_module.opt.deps}) + if dep_module.deps then + local deps = _get_maplines(target, {name = dep_module.name, deps = dep_module.deps, sourcefile = dep_module.sourcefile}) table.join2(maplines, deps) end end @@ -128,15 +121,21 @@ function _get_maplines(target, module) return table.unique(maplines) end +function _get_modulemapper_file(target, module) + return path.join(os.tmpdir(), hash.md5(bytes(target:fullname() .. "/" .. module.sourcefile)), path.filename(module.sourcefile) .. ".mapper.txt") +end + -- generate a module mapper file for build a module -- e.g -- /usr/include/c++/11/iostream build/.gens/stl_headerunit/linux/x86_64/release/stlmodules/cache/iostream.gcm -- hello build/.gens/stl_headerunit/linux/x86_64/release/rules/modules/cache/hello.gcm -- -function _generate_modulemapper_file(target, module, cppfile) +function _generate_modulemapper_file(target, module) local maplines = _get_maplines(target, module) - local mapper_path = path.join(os.tmpdir(), (target:fullname():replace(" ", "_")), - name or (cppfile:replace("[%s:]", "_"))) -- @see https://github.com/xmake-io/xmake/issues/6350 + local mapper_path = _get_modulemapper_file(target, module) + if os.isfile(mapper_path) then + os.rm(mapper_path) + end local mapper_content = {} table.insert(mapper_content, "root " .. path.unix(os.projectdir())) for _, mapline in ipairs(maplines) do @@ -149,322 +148,154 @@ function _generate_modulemapper_file(target, module, cppfile) return mapper_path end --- populate module map -function populate_module_map(target, modules) - for _, module in pairs(modules) do - local name, provide = support.get_provided_module(module) - if provide then - local bmifile = support.get_bmi_path(provide.bmi) - add_module_to_target_mapper(target, name, provide.sourcefile, bmifile, {deps = module.requires}) - end - end -end - --- get defines for a module -function get_module_required_defines(target, sourcefile) - local compinst = compiler.load("cxx", {target = target}) - local compflags = compinst:compflags({sourcefile = sourcefile, target = target}) - local defines - for _, flag in ipairs(compflags) do - if flag:startswith("-D") then - defines = defines or {} - table.insert(defines, flag:sub(3)) - end - end - return defines -end +-- build module file for batchjobs / jobgraph +function make_module_job(target, module, opt) --- build module file for batchjobs -function make_module_buildjobs(target, batchjobs, job_name, deps, opt) - - local name, provide, _ = support.get_provided_module(opt.module) - local bmifile = provide and support.get_bmi_path(provide.bmi) local module_mapperflag = support.get_modulemapperflag(target) + local module_onlyflag = support.get_moduleonlyflag(target) + local module_flag = support.get_modulesflag(target) + local dryrun = option.get("dry-run") - return { - name = job_name, - deps = table.join(target:fullname() .. "/module/populate_module_map", deps), - sourcefile = opt.cppfile, - job = batchjobs:newjob(target:fullname() .. "/module/" .. (name or opt.cppfile), function(index, total, jobopt) - local mapped_bmi - if provide and support.memcache():get2(target:fullname() .. name, "reuse") then - mapped_bmi = get_from_target_mapper(target, name).bmi - end - - -- generate and append module mapper file - local module_mapper - if provide or opt.module.requires then - module_mapper = _generate_modulemapper_file(target, opt.module, opt.cppfile) - target:fileconfig_add(opt.cppfile, {force = {cxxflags = {module_mapperflag .. module_mapper}}}) - end + -- generate and append module mapper file + local module_mapper + if module.deps then + module_mapper = _get_modulemapper_file(target, module) + target:fileconfig_add(module.sourcefile, {force = {cxxflags = {module_mapperflag .. module_mapper}}}) + end - local dependfile = target:dependfile(bmifile or opt.objectfile) - local build, dependinfo = should_build(target, opt.cppfile, bmifile, {name = name, objectfile = opt.objectfile, requires = opt.module.requires}) + local build = should_build(target, module) + local bmi = opt and opt.bmi + local objectfile = opt and opt.objectfile - -- needed to detect rebuild of dependencies - if provide and build then - mark_build(target, name) + if build then + if not dryrun then + local objectdir = path.directory(module.objectfile) + if not os.isdir(objectdir) then + os.mkdir(objectdir) end - - if build then - -- compile if it's a named module - if provide or support.has_module_extension(opt.cppfile) then - local fileconfig = target:fileconfig(opt.cppfile) - local public = fileconfig and fileconfig.public - local external = fileconfig and fileconfig.external - local from_moduleonly = external and external.moduleonly - local bmifile = mapped_bmi or bmifile - local flags = {"-x", "c++"} - local sourcefile - if external and not from_moduleonly then - if not mapped_bmi then - progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:fullname(), name or opt.cppfile) - local module_onlyflag = support.get_moduleonlyflag(target) - table.insert(flags, module_onlyflag) - sourcefile = opt.cppfile - end - else - progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:fullname(), name or opt.cppfile) - sourcefile = opt.cppfile - end - if option.get("diagnosis") then - print("mapper file --------\n%s--------", io.readfile(module_mapper)) - end - if sourcefile then - _compile(target, flags, sourcefile, opt.objectfile) - end - os.tryrm(module_mapper) - else - os.tryrm(opt.objectfile) -- force rebuild for .cpp files + if module.bmifile then + local bmidir = path.directory(module.bmifile) + if not os.isdir(bmidir) then + os.mkdir(bmidir) end - depend.save(dependinfo, dependfile) end - end)} -end - --- build module file for jobgraph -function make_module_jobgraph(target, jobgraph, opt) - local name, provide, _ = support.get_provided_module(opt.module) - local bmifile = provide and support.get_bmi_path(provide.bmi) - local module_mapperflag = support.get_modulemapperflag(target) - - local jobname = target:fullname() .. "/module/" .. (name or opt.cppfile) - jobgraph:add(jobname, function(index, total, jobopt) - local mapped_bmi - if provide and support.memcache():get2(target:fullname() .. name, "reuse") then - mapped_bmi = get_from_target_mapper(target, name).bmi end - -- generate and append module mapper file - local module_mapper - if provide or opt.module.requires then - module_mapper = _generate_modulemapper_file(target, opt.module, opt.cppfile) - target:fileconfig_add(opt.cppfile, {force = {cxxflags = {module_mapperflag .. module_mapper}}}) - end - - local dependfile = target:dependfile(bmifile or opt.objectfile) - local build, dependinfo = should_build(target, opt.cppfile, bmifile, {name = name, objectfile = opt.objectfile, requires = opt.module.requires}) - - -- needed to detect rebuild of dependencies - if provide and build then - mark_build(target, name) + if module.deps then + _generate_modulemapper_file(target, module) end - if build then - -- compile if it's a named module - if provide or support.has_module_extension(opt.cppfile) then - local fileconfig = target:fileconfig(opt.cppfile) - local public = fileconfig and fileconfig.public - local external = fileconfig and fileconfig.external - local from_moduleonly = external and external.moduleonly - local bmifile = mapped_bmi or bmifile - local flags = {"-x", "c++"} - local sourcefile - if external and not from_moduleonly then - if not mapped_bmi then - progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:fullname(), name or opt.cppfile) - local module_onlyflag = support.get_moduleonlyflag(target) - table.insert(flags, module_onlyflag) - sourcefile = opt.cppfile - end - else - progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:fullname(), name or opt.cppfile) - sourcefile = opt.cppfile - end - if option.get("diagnosis") then - print("mapper file --------\n%s--------", io.readfile(module_mapper)) - end - if sourcefile then - _compile(target, flags, sourcefile, opt.objectfile) - end - os.tryrm(module_mapper) + local flags = {"-x", "c++"} + if module.interface or module.implementation then + if bmi and objectfile then + progress.show(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:fullname(), module.name) + table.insert(flags, module_flag) + elseif bmi then + progress.show(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.bmi.$(mode) %s", target:fullname(), module.name) + table.insert(flags, module_flag) + table.insert(flags, module_onlyflag) else - os.tryrm(opt.objectfile) -- force rebuild for .cpp files + progress.show(opt.progress, "compiling.$(mode) %s", module.sourcefile) end - depend.save(dependinfo, dependfile) + _compile(target, flags, module.sourcefile, module.objectfile) + -- os.tryrm(module_mapper) -- force rebuild for .cpp files + else + os.tryrm(module.objectfile) -- force rebuild for .cpp files end - end) + end end -- build module file for batchcmds -function make_module_buildcmds(target, batchcmds, opt) +function make_module_buildcmds(target, batchcmds, module, opt) - local name, provide, _ = support.get_provided_module(opt.module) - local bmifile = provide and support.get_bmi_path(provide.bmi) local module_mapperflag = support.get_modulemapperflag(target) + local module_onlyflag = support.get_moduleonlyflag(target) + local module_flag = support.get_modulesflag(target) - local mapped_bmi - if provide and support.memcache():get2(target:fullname() .. name, "reuse") then - mapped_bmi = get_from_target_mapper(target, name).bmi + local module_mapper + if module.implementation or module.interface or module.deps then + module_mapper = _get_modulemapper_file(target, module) + target:fileconfig_add(module.sourcefile, {force = {cxxflags = {module_mapperflag .. module_mapper}}}) end -- generate and append module mapper file - local module_mapper - if provide or opt.module.requires then - module_mapper = _generate_modulemapper_file(target, opt.module, opt.cppfile) - target:fileconfig_add(opt.cppfile, {force = {cxxflags = {module_mapperflag .. module_mapper}}}) - end + local build = should_build(target, module) - -- compile if it's a named module - if provide or support.has_module_extension(opt.cppfile) then - batchcmds:mkdir(path.directory(opt.objectfile)) - local fileconfig = target:fileconfig(opt.cppfile) - local public = fileconfig and fileconfig.public - local external = fileconfig and fileconfig.external - local from_moduleonly = external and external.moduleonly - local bmifile = mapped_bmi or bmifile - local flags = {"-x", "c++"} - local sourcefile - if external and not from_moduleonly then - if not mapped_bmi then - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:fullname(), name or opt.cppfile) - local module_onlyflag = support.get_moduleonlyflag(target) - table.insert(flags, module_onlyflag) - sourcefile = opt.cppfile - end - else - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:fullname(), name or opt.cppfile) - sourcefile = opt.cppfile + local fileconfig = target:fileconfig(module.sourcefile) + local external = fileconfig and fileconfig.external + local bmionly = external and external.bmionly + local reused = external and external.reused + if build and not reused then + if module.implementation or module.interface or module.deps then + _generate_modulemapper_file(target, module) end + if option.get("diagnosis") then - batchcmds:print("mapper file: %s", io.readfile(module_mapper)) + if module.name then + batchcmds:show("mapper file for %s (%s) --------\n%s--------", module.name, module.sourcefile, io.readfile(module_mapper)) + else + batchcmds:show("mapper file for %s --------\n%s--------", module.sourcefile, io.readfile(module_mapper)) + end end - if sourcefile then - _batchcmds_compile(batchcmds, target, flags, sourcefile, opt.objectfile) + if support.has_module_extension(module.sourcefile) then + batchcmds:mkdir(path.directory(module.objectfile)) + local flags = {"-x", "c++"} + table.insert(flags, module_flag) + local name = module.name or module.sourcefile + if bmionly then + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.bmi.$(mode) %s", target:fullname(), name) + table.insert(flags, module_onlyflag) + else + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:fullname(), name) + end + _batchcmds_compile(batchcmds, target, flags, module.sourcefile, module.objectfile) + batchcmds:rm(module_mapper) + else + batchcmds:rm(module.objectfile) -- force rebuild for .cpp files end - batchcmds:rm(module_mapper) - else - batchcmds:rm(opt.objectfile) -- force rebuild for .cpp files - end - batchcmds:add_depfiles(opt.cppfile) - return os.mtime(opt.objectfile) -end - --- build headerunit file for batchjobs -function make_headerunit_buildjobs(target, job_name, batchjobs, headerunit, bmifile, outputdir, opt) - local _headerunit = headerunit - _headerunit.path = headerunit.type == ":quote" and "./" .. path.relative(headerunit.path) or headerunit.path - local already_exists = add_headerunit_to_target_mapper(target, _headerunit, bmifile) - if not already_exists then - return { - name = job_name, - sourcefile = headerunit.path, - job = batchjobs:newjob(job_name, function(index, total, jobopt) - if not os.isdir(outputdir) then - os.mkdir(outputdir) - end - - local compinst = compiler.load("cxx", {target = target}) - local compflags = compinst:compflags({sourcefile = headerunit.path, target = target}) - - local dependfile = target:dependfile(bmifile) - local dependinfo = depend.load(dependfile) or {} - dependinfo.files = {} - local depvalues = {compinst:program(), compflags} - - if opt.build then - local headerunit_mapper = _generate_headerunit_modulemapper_file({name = path.normalize(headerunit.path), bmifile = bmifile}) - progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s", target:fullname(), headerunit.name) - if option.get("diagnosis") then - print("mapper file:\n%s", io.readfile(headerunit_mapper)) - end - local headerfile = headerunit.unique and headerunit.name or headerunit.path - _compile(target, - _make_headerunitflags(target, headerunit, headerunit_mapper, opt), - path.translate(headerfile), bmifile) - os.tryrm(headerunit_mapper) - end - - table.insert(dependinfo.files, headerunit.path) - dependinfo.values = depvalues - depend.save(dependinfo, dependfile) - end)} + batchcmds:add_depfiles(module.sourcefile) + support.memcache():set2(target:fullname(), "has_built_" .. module.sourcefile, true) end + return os.mtime(module.objectfile) end --- build headerunit file for jobgraph -function make_headerunit_jobgraph(target, job_name, jobgraph, headerunit, bmifile, outputdir, opt) - local _headerunit = headerunit - _headerunit.path = headerunit.type == ":quote" and "./" .. path.relative(headerunit.path) or headerunit.path - local already_exists = add_headerunit_to_target_mapper(target, _headerunit, bmifile) - if not already_exists then - jobgraph:add(job_name, function(index, total, jobopt) - if not os.isdir(outputdir) then - os.mkdir(outputdir) - end - - local compinst = compiler.load("cxx", {target = target}) - local compflags = compinst:compflags({sourcefile = headerunit.path, target = target}) - - local dependfile = target:dependfile(bmifile) - local dependinfo = depend.load(dependfile) or {} - dependinfo.files = {} - local depvalues = {compinst:program(), compflags} - - if opt.build then - local headerunit_mapper = _generate_headerunit_modulemapper_file({name = path.normalize(headerunit.path), bmifile = bmifile}) - progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s", - target:fullname(), headerunit.name) - if option.get("diagnosis") then - print("mapper file:\n%s", io.readfile(headerunit_mapper)) - end - local headerfile = headerunit.unique and headerunit.name or headerunit.path - _compile(target, - _make_headerunitflags(target, headerunit, headerunit_mapper, opt), - path.translate(headerfile), bmifile) - os.tryrm(headerunit_mapper) - end - - table.insert(dependinfo.files, headerunit.path) - dependinfo.values = depvalues - depend.save(dependinfo, dependfile) - end) +-- build headerunit file for batchjobs / jobgraph +function make_headerunit_job(target, headerunit, opt) + local build = should_build(target, headerunit) + if build then + local headerunit_mapper = _generate_headerunit_modulemapper_file(target, headerunit) + local name = headerunit.unique and path.filename(headerunit.sourcefile) or headerunit.name + if option.get("diagnosis") then + print("mapper file for %s (%s) --------\n%s--------", name, headerunit_mapper, io.readfile(headerunit_mapper)) + end + progress.show(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s", target:fullname(), name) + _compile(target, + _make_headerunitflags(target, headerunit_mapper, headerunit), + path.filename(headerunit.sourcefile), headerunit.bmifile) + os.tryrm(headerunit_mapper) end end - - -- build headerunit file for batchcmds -function make_headerunit_buildcmds(target, batchcmds, headerunit, bmifile, outputdir, opt) - local headerunit_mapper = _generate_headerunit_modulemapper_file({name = path.normalize(headerunit.path), bmifile = bmifile}) - batchcmds:mkdir(outputdir) - - local _headerunit = headerunit - _headerunit.path = headerunit.type == ":quote" and "./" .. path.relative(headerunit.path) or headerunit.path - add_headerunit_to_target_mapper(target, _headerunit, bmifile) +function make_headerunit_buildcmds(target, batchcmds, headerunit, opt) + local compinst = compiler.load("cxx", {target = target}) + local compflags = compinst:compflags({sourcefile = headerunit.sourcefile, target = target, sourcekind = "cxx"}) + local depvalues = {compinst:program(), compflags} - if opt.build then - local headerfile = headerunit.unique and headerunit.name or headerunit.path - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s", - target:fullname(), headerfile) + local build = should_build(target, headerunit) + if build then + local headerunit_mapper = _generate_headerunit_modulemapper_file(target, headerunit) + local name = headerunit.unique and path.filename(headerunit.name) or headerunit.name if option.get("diagnosis") then - batchcmds:print("mapper file:\n%s", io.readfile(headerunit_mapper)) + batchcmds:show("mapper file for %s (%s) --------\n%s--------", name, headerunit_mapper, io.readfile(headerunit_mapper)) end - _batchcmds_compile(batchcmds, target, _make_headerunitflags(target, headerunit, headerunit_mapper), bmifile) + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s", target:fullname(), name) + _batchcmds_compile(batchcmds, target, + _make_headerunitflags(target, headerunit_mapper, headerunit), + path.filename(headerunit.sourcefile), headerunit.bmifile) + batchcmds:add_depfiles(headerunit.sourcefile) + batchcmds:rm(headerunit_mapper) end - - batchcmds:rm(headerunit_mapper) - batchcmds:add_depfiles(headerunit.path) - return os.mtime(bmifile) + batchcmds:add_depvalues(depvalues) end |
