From a8c60009ba4b17694e13b45b733819c2fc3dce8b Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 1 Sep 2024 22:25:27 +0800 Subject: improve cosmocc for windows --- tests/projects/c/cosmocc/console/xmake.lua | 6 ++++++ xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/projects/c/cosmocc/console/xmake.lua b/tests/projects/c/cosmocc/console/xmake.lua index babd520a2..1327045c1 100644 --- a/tests/projects/c/cosmocc/console/xmake.lua +++ b/tests/projects/c/cosmocc/console/xmake.lua @@ -2,6 +2,12 @@ add_rules("mode.debug", "mode.release") add_requires("cosmocc") +-- TODO, we should add envs to toolchains/cosmocc +if is_subhost("windoows") then + add_requires("msys2") + add_packages("msys2") +end + target("test") set_kind("binary") add_files("src/*.c") diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index 3923916d9..3b20eb938 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -74,9 +74,10 @@ end -- check program function sandbox_lib_detect_find_program._check(program, opt) + opt = opt or {} local findname = program if os.subhost() == "windows" then - if not program:endswith(".exe") and not program:endswith(".cmd") and not program:endswith(".bat") then + if not opt.shell and not program:endswith(".exe") and not program:endswith(".cmd") and not program:endswith(".bat") then findname = program .. ".exe" end elseif os.subhost() == "msys" and os.isfile(program) and os.filesize(program) < 256 then -- cgit v1.3.1