diff options
| author | ruki <[email protected]> | 2020-10-05 23:12:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-10-05 13:17:45 +0800 |
| commit | 5fb2bcc38583f830e064082024212c061f055b99 (patch) | |
| tree | 24198cdd2d4c7a6093584074933a4ae08d651225 | |
| parent | 8e6f673fe1eb57a5f5535d9bac663868a3922caf (diff) | |
improve find_mingw
| -rw-r--r-- | .github/workflows/msys2_mingw.yml | 5 | ||||
| -rw-r--r-- | xmake/modules/detect/sdks/find_mingw.lua | 26 | ||||
| -rw-r--r-- | xmake/platforms/mingw/xmake.lua | 11 |
3 files changed, 36 insertions, 6 deletions
diff --git a/.github/workflows/msys2_mingw.yml b/.github/workflows/msys2_mingw.yml index c7901e80d..135fcd2bd 100644 --- a/.github/workflows/msys2_mingw.yml +++ b/.github/workflows/msys2_mingw.yml @@ -38,4 +38,9 @@ jobs: make build make install PREFIX=${{ matrix.prefix }} xmake --version + + - name: Tests + shell: msys2 {0} + run: | + cd /C/_ xmake lua -v -D tests/run.lua diff --git a/xmake/modules/detect/sdks/find_mingw.lua b/xmake/modules/detect/sdks/find_mingw.lua index cf6cfcc8c..a5bf55932 100644 --- a/xmake/modules/detect/sdks/find_mingw.lua +++ b/xmake/modules/detect/sdks/find_mingw.lua @@ -33,11 +33,27 @@ function _find_mingwdir(sdkdir) if not sdkdir then if is_host("macosx", "linux") and os.isdir("/opt/llvm-mingw") then sdkdir = "/opt/llvm-mingw" - else - if is_host("macosx") then - sdkdir = "/usr/local/opt/mingw-w64" - elseif is_host("linux") then - sdkdir = "/usr" + elseif is_host("macosx") and os.isdir("/usr/local/opt/mingw-w64") then + sdkdir = "/usr/local/opt/mingw-w64" + elseif is_host("linux") then + sdkdir = "/usr" + elseif is_subhost("msys") then + local mingw_prefix = os.getenv("MINGW_PREFIX") + if mingw_prefix and os.isdir(mingw_prefix) then + sdkdir = mingw_prefix + end + end + -- attempt to get it from $PATH + -- @see https://github.com/xmake-io/xmake/issues/977 + if not sdkdir then + local pathenv = os.getenv("PATH") + if pathenv then + for _, p in ipairs(path.splitenv(pathenv)) do + if p:find("mingw[%w%-%_%+]+[\\/]bin") and path.filename(p) == "bin" and os.isdir(p) then + sdkdir = path.directory(p) + break + end + end end end end diff --git a/xmake/platforms/mingw/xmake.lua b/xmake/platforms/mingw/xmake.lua index e0624500a..6fd1eaa58 100644 --- a/xmake/platforms/mingw/xmake.lua +++ b/xmake/platforms/mingw/xmake.lua @@ -42,7 +42,16 @@ platform("mingw") import("core.project.config") local arch = config.get("arch") if not arch then - config.set("arch", "x86_64") + local mingw_chost = nil + if is_subhost("msys") then + mingw_chost = os.getenv("MINGW_CHOST") + end + if mingw_chost == "i686-w64-mingw32" then + arch = "i386" + else + arch = "x86_64" + end + config.set("arch", arch) cprint("checking for architecture ... ${color.success}%s", config.get("arch")) end end) |
