diff options
| author | ruki <[email protected]> | 2025-10-13 12:57:07 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-10-13 12:57:07 +0800 |
| commit | c651547b697ee25caa754460f14761d60849912e (patch) | |
| tree | 3e5ca1601f50130fa19ec2bea79c60aa68ef9cb9 | |
| parent | 4c4a4df3d5ece5d01b76b0e0a814e561500c521f (diff) | |
| parent | e8c4a4499ca1aaac6db60173f4ee02d0ab9f74f6 (diff) | |
Merge pull request #6921 from xmake-io/vcenvs
improve to find cl and fix force flags
| -rw-r--r-- | xmake/core/tool/builder.lua | 1 | ||||
| -rw-r--r-- | xmake/modules/core/tools/cl/parse_include.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/core/tools/link/has_flags.lua | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua index bc7e995a4..e6c649580 100644 --- a/xmake/core/tool/builder.lua +++ b/xmake/core/tool/builder.lua @@ -168,6 +168,7 @@ function builder:_add_flags_from_flagkind(flags, target, flagkind, opt) flag = target_utils.flag_belong_to_tool(flag, self, extraconf) if flag then if extraconf then + local flagconf = extraconf[flag] -- @note we need join the single flag with shallow mode, aboid expand table values -- e.g. add_cflags({"-I", "/tmp/xxx foo"}, {force = true, expand = false}) if flagconf and flagconf.force then diff --git a/xmake/modules/core/tools/cl/parse_include.lua b/xmake/modules/core/tools/cl/parse_include.lua index e53163e8f..597e033f8 100644 --- a/xmake/modules/core/tools/cl/parse_include.lua +++ b/xmake/modules/core/tools/cl/parse_include.lua @@ -31,14 +31,14 @@ function probe_include_note_from_cl() local key = "cldeps.parse_include.note" local note = detectcache:get(key) if not note then - local cl = find_tool("cl") + local runenvs = toolchain.load("msvc"):runenvs() + local cl = find_tool("cl", {envs = runenvs}) if cl then local projectdir = os.tmpfile() .. ".cldeps" local sourcefile = path.join(projectdir, "main.c") local headerfile = path.join(projectdir, "foo.h") local objectfile = sourcefile .. ".obj" local outdata = try { function() - local runenvs = toolchain.load("msvc"):runenvs() local argv = {"-nologo", "-showIncludes", "-c", "-Fo" .. objectfile, sourcefile} io.writefile(headerfile, "\n") io.writefile(sourcefile, [[ diff --git a/xmake/modules/core/tools/link/has_flags.lua b/xmake/modules/core/tools/link/has_flags.lua index 5fcb15543..9d44b7b1c 100644 --- a/xmake/modules/core/tools/link/has_flags.lua +++ b/xmake/modules/core/tools/link/has_flags.lua @@ -72,7 +72,7 @@ function _check_try_running(flags, opt) -- compile the source file local objectfile = os.tmpfile() .. ".obj" local binaryfile = os.tmpfile() .. ".exe" - local cl = find_tool("cl") + local cl = find_tool("cl", {envs = opt.envs}) if cl then os.runv(cl.program, {"-c", "-nologo", "-Fo" .. objectfile, sourcefile}, {envs = opt.envs}) end |
