diff options
| author | ruki <[email protected]> | 2020-02-20 00:32:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-02-19 21:13:37 +0800 |
| commit | cddd02bfe9ab6d77026134303baf41056862021a (patch) | |
| tree | a179c290b28ab2b2576bff59c407c52a9f9c471c /xmake/modules | |
| parent | d7507f0e845f4066975fce6e357a55d4cbb938d4 (diff) | |
add --tryconfigs= for trybuild
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/private/action/trybuild/autotools.lua | 22 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/cmake.lua | 32 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/meson.lua | 30 |
3 files changed, 59 insertions, 25 deletions
diff --git a/xmake/modules/private/action/trybuild/autotools.lua b/xmake/modules/private/action/trybuild/autotools.lua index f22573053..89b41bc2f 100644 --- a/xmake/modules/private/action/trybuild/autotools.lua +++ b/xmake/modules/private/action/trybuild/autotools.lua @@ -19,6 +19,7 @@ -- -- imports +import("core.base.cli") import("core.base.option") import("core.project.config") import("core.platform.platform") @@ -103,6 +104,14 @@ function _get_configs(artifacts_dir) local configs = {} table.insert(configs, "--prefix=" .. artifacts_dir) + -- add extra user configs + local tryconfigs = config.get("tryconfigs") + if tryconfigs then + for _, opt in ipairs(cli.parse(tryconfigs)) do + table.insert(configs, tostring(opt)) + end + end + -- add host for cross-complation if not is_plat(os.subhost()) then if is_plat("iphoneos") then @@ -181,18 +190,7 @@ function build() -- do configure local configfile = find_file("[mM]akefile", os.curdir()) if not configfile or os.mtime(config.filepath()) > os.mtime(configfile) then - local argv = {} - for name, value in pairs(_get_configs(artifacts_dir)) do - value = tostring(value):trim() - if value ~= "" then - if type(name) == "number" then - table.insert(argv, value) - else - table.insert(argv, "--" .. name .. "=" .. value) - end - end - end - os.vexecv("./configure", argv, {envs = _get_buildenvs()}) + os.vexecv("./configure", _get_configs(artifacts_dir), {envs = _get_buildenvs()}) end -- do build diff --git a/xmake/modules/private/action/trybuild/cmake.lua b/xmake/modules/private/action/trybuild/cmake.lua index 565f00fa7..94cfc9e3e 100644 --- a/xmake/modules/private/action/trybuild/cmake.lua +++ b/xmake/modules/private/action/trybuild/cmake.lua @@ -19,6 +19,7 @@ -- -- imports +import("core.base.cli") import("core.base.option") import("core.project.config") import("lib.detect.find_file") @@ -34,6 +35,29 @@ function _get_artifacts_dir() return path.absolute(path.join(_get_buildir(), "artifacts")) end +-- get configs +function _get_configs(artifacts_dir) + + -- add prefix + local configs = {"-DCMAKE_INSTALL_PREFIX=" .. artifacts_dir, "-DDCMAKE_INSTALL_LIBDIR=" .. path.join(artifacts_dir, "lib")} + if is_plat("windows") and is_arch("x64") then + table.insert(configs, "-A") + table.insert(configs, "x64") + end + + -- add extra user configs + local tryconfigs = config.get("tryconfigs") + if tryconfigs then + for _, opt in ipairs(cli.parse(tryconfigs)) do + table.insert(configs, tostring(opt)) + end + end + + -- add build directory + table.insert(configs, '..') + return configs +end + -- detect build-system and configuration file function detect() return find_file("CMakeLists.txt", os.curdir()) @@ -70,13 +94,7 @@ function build() local cmake = assert(find_tool("cmake"), "cmake not found!") local configfile = find_file("[mM]akefile", os.curdir()) or (is_plat("windows") and find_file("*.sln", os.curdir())) if not configfile or os.mtime(config.filepath()) > os.mtime(configfile) then - local argv = {"-DCMAKE_INSTALL_PREFIX=" .. artifacts_dir, "-DDCMAKE_INSTALL_LIBDIR=" .. path.join(artifacts_dir, "lib")} - if is_plat("windows") and is_arch("x64") then - table.insert(argv, "-A") - table.insert(argv, "x64") - end - table.insert(argv, '..') - os.vexecv(cmake.program, argv) + os.vexecv(cmake.program, _get_configs(artifacts_dir)) end -- do build diff --git a/xmake/modules/private/action/trybuild/meson.lua b/xmake/modules/private/action/trybuild/meson.lua index a728e6063..80d1185bd 100644 --- a/xmake/modules/private/action/trybuild/meson.lua +++ b/xmake/modules/private/action/trybuild/meson.lua @@ -19,6 +19,7 @@ -- -- imports +import("core.base.cli") import("core.base.option") import("core.project.config") import("lib.detect.find_file") @@ -34,6 +35,28 @@ function _get_artifacts_dir() return path.absolute(path.join(_get_buildir(), "artifacts")) end +-- get configs +function _get_configs(artifacts_dir, buildir) + + -- add prefix + local configs = {"--prefix=" .. artifacts_dir} + if configfile then + table.insert(configs, "--reconfigure") + end + + -- add extra user configs + local tryconfigs = config.get("tryconfigs") + if tryconfigs then + for _, opt in ipairs(cli.parse(tryconfigs)) do + table.insert(configs, tostring(opt)) + end + end + + -- add build directory + table.insert(configs, buildir) + return configs +end + -- detect build-system and configuration file function detect() return find_file("meson.build", os.curdir()) @@ -74,12 +97,7 @@ function build() local meson = assert(find_tool("meson"), "meson not found!") local configfile = find_file("build.ninja", buildir) if not configfile or os.mtime(config.filepath()) > os.mtime(configfile) then - local argv = {"--prefix=" .. artifacts_dir} - if configfile then - table.insert(argv, "--reconfigure") - end - table.insert(argv, buildir) - os.vexecv(meson.program, argv) + os.vexecv(meson.program, _get_configs(artifacts_dir, buildir)) end -- do build |
