diff options
| author | ruki <[email protected]> | 2020-10-11 11:13:47 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-10-11 11:13:47 +0800 |
| commit | f674268196d2b5d25178d0209cc5f6f57a21e338 (patch) | |
| tree | 37808cacc4040750c6bdd54f8e4b9ceefc662e2a | |
| parent | 6d6420ebc14c3ec019e5b1c71a10ad24a712511e (diff) | |
improve trybuild/autotools
| -rw-r--r-- | xmake/modules/private/action/trybuild/autotools.lua | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/xmake/modules/private/action/trybuild/autotools.lua b/xmake/modules/private/action/trybuild/autotools.lua index 6c35bdbb0..22bd1120e 100644 --- a/xmake/modules/private/action/trybuild/autotools.lua +++ b/xmake/modules/private/action/trybuild/autotools.lua @@ -25,6 +25,23 @@ import("core.project.config") import("core.platform.platform") import("lib.detect.find_file") +-- translate path +function _translate_path(p) + if p and is_host("windows") and is_plat("mingw") then + p = p:gsub("\\", "/") + end + return p +end + +-- translate windows bin path +function _translate_windows_bin_path(bin_path) + if bin_path then + local argv = os.argv(bin_path) + argv[1] = argv[1]:gsub("\\", "/") .. ".exe" + return os.args(argv) + end +end + -- get build directory function _get_buildir() return config.buildir() or "build" @@ -93,11 +110,20 @@ function _get_buildenvs() local ld = envs.LD if ld then if ld:endswith("x86_64-w64-mingw32-g++") then - envs.LD = path.join(path.directory(ld), "x86_64-w64-mingw32-ld") + envs.LD = path.join(path.directory(ld), is_host("windows") and "ld" or "x86_64-w64-mingw32-ld") elseif ld:endswith("i686-w64-mingw32-g++") then - envs.LD = path.join(path.directory(ld), "i686-w64-mingw32-ld") + envs.LD = path.join(path.directory(ld), is_host("windows") and "ld" or "i686-w64-mingw32-ld") end end + if is_host("windows") then + envs.CC = _translate_windows_bin_path(envs.CC) + envs.AS = _translate_windows_bin_path(envs.AS) + envs.AR = _translate_windows_bin_path(envs.AR) + envs.LD = _translate_windows_bin_path(envs.LD) + envs.LDSHARED = _translate_windows_bin_path(envs.LDSHARED) + envs.CPP = _translate_windows_bin_path(envs.CPP) + envs.RANLIB = _translate_windows_bin_path(envs.RANLIB) + end end end if option.get("verbose") then @@ -111,7 +137,7 @@ function _get_configs(artifacts_dir) -- add prefix local configs = {} - table.insert(configs, "--prefix=" .. artifacts_dir) + table.insert(configs, "--prefix=" .. _translate_path(artifacts_dir)) -- add extra user configs local tryconfigs = config.get("tryconfigs") |
