diff options
| author | Arthur LAURENT <[email protected]> | 2023-01-24 12:11:37 +0100 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2023-01-24 12:11:37 +0100 |
| commit | 924403375684235e1f34f3b6b2210cc5cda1feb5 (patch) | |
| tree | 9cf0e1999bcdfcdaa8d133a04569b4b0bb1dbda0 | |
| parent | d7816ecb549f15bed8937a3362856fc6e7ec9129 (diff) | |
fix unsafe table remove
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/clang.lua | 8 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/gcc.lua | 8 |
2 files changed, 4 insertions, 12 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 17ce22659..320061e1a 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -271,12 +271,8 @@ function generate_dependencies(target, sourcebatch, opt) common.fallback_generate_dependencies(target, jsonfile, sourcefile, function(file) local compinst = target:compiler("cxx") local compflags = compinst:compflags({sourcefile = file, target = target}) - for i, flag in ipairs(compflags) do - -- exclude -fmodule* and -std=c++/gnu++* flags because, when they are set clang try to find bmi of imported modules but they don't exists a this point of compilation - if flag:startswith("-fmodule") or flag:startswith("-std=c++") or flag:startswith("-std=gnu++") then - table.remove(compflags, i) - end - end + -- exclude -fmodule* and -std=c++/gnu++* flags because, when they are set clang try to find bmi of imported modules but they don't exists a this point of compilation + compflags = table.remove_if(compflags, function(_, flag) return flag:startswith("-fmodule") or flag:startswith("-std=c++") or flag:startswith("-std=gnu++") end) local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i")) os.vrunv(compinst:program(), table.join(compflags, {"-E", "-x", "c++", file, "-o", ifile})) local content = io.readfile(ifile) diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua index 2864e41a4..eb83ed96d 100644 --- a/xmake/rules/c++/modules/modules_support/gcc.lua +++ b/xmake/rules/c++/modules/modules_support/gcc.lua @@ -200,12 +200,8 @@ function generate_dependencies(target, sourcebatch, opt) common.fallback_generate_dependencies(target, jsonfile, sourcefile, function(file) local compinst = target:compiler("cxx") local compflags = compinst:compflags({sourcefile = file, target = target}) - for i, flag in ipairs(compflags) do - -- exclude -fmodule* flags because, when they are set gcc try to find bmi of imported modules but they don't exists a this point of compilation - if flag:startswith("-fmodule") then - table.remove(compflags, i) - end - end + -- exclude -fmodule* flags because, when they are set gcc try to find bmi of imported modules but they don't exists a this point of compilation + compflags = table.remove_if(compflags, function(_, flag) return flag:startswith("-fmodule") end) local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i")) os.vrunv(compinst:program(), table.join(common_args, compflags, {file, "-o", ifile})) local content = io.readfile(ifile) |
