summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-02-18 22:35:50 +0800
committerruki <[email protected]>2020-02-18 09:35:01 +0800
commit753309f3eca9445904c2e70d99fcdc49a67e5add (patch)
tree141d7d83ff6cbe8782c9ab85f981d993f573cfb8
parent0835cadcfe5f48870790cce20d6a3968d7b1ccf7 (diff)
move trybuild config
-rw-r--r--xmake/actions/build/main.lua17
-rw-r--r--xmake/actions/build/xmake.lua3
-rw-r--r--xmake/actions/config/main.lua33
-rw-r--r--xmake/actions/config/xmake.lua5
-rw-r--r--xmake/modules/private/action/trybuild/autotools.lua (renamed from xmake/actions/build/trybuild/autotools.lua)0
-rw-r--r--xmake/modules/private/action/trybuild/cmake.lua (renamed from xmake/actions/build/trybuild/cmake.lua)0
-rw-r--r--xmake/modules/private/action/trybuild/make.lua (renamed from xmake/actions/build/trybuild/make.lua)0
-rw-r--r--xmake/modules/private/action/trybuild/msbuild.lua (renamed from xmake/actions/build/trybuild/msbuild.lua)0
-rw-r--r--xmake/modules/private/action/trybuild/xcodebuild.lua (renamed from xmake/actions/build/trybuild/xcodebuild.lua)0
9 files changed, 34 insertions, 24 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua
index 4b14639a2..3e2f71aa2 100644
--- a/xmake/actions/build/main.lua
+++ b/xmake/actions/build/main.lua
@@ -32,30 +32,33 @@ import("statistics")
-- try to build
function _trybuild()
+ -- load config
+ config.load()
+
-- get the buildsystem tool
local configfile = nil
local tool = nil
- local try_tool = option.get("try-tool")
- if try_tool then
- tool = import("trybuild." .. try_tool, {try = true, anonymous = true})
+ local trybuild = config.get("trybuild")
+ if trybuild then
+ tool = import("private.action.trybuild." .. trybuild, {try = true, anonymous = true})
if tool then
configfile = tool.detect()
else
- raise("unknown build tool: %s", try_tool)
+ raise("unknown build tool: %s", trybuild)
end
else
for _, name in ipairs({"msbuild", "xcodebuild", "cmake", "autotools", "make"}) do
- tool = import("trybuild." .. name, {anonymous = true})
+ tool = import("private.action.trybuild." .. name, {anonymous = true})
configfile = tool.detect()
if configfile then
- try_tool = name
+ config.set("trybuild", name, {readonly = true, force = true})
break
end
end
end
-- try building it
- if configfile and tool and utils.confirm({default = true, description = "${bright}" .. path.filename(configfile) .. "${clear} found, try building it"}) then
+ if configfile and tool and (trybuild or utils.confirm({default = true, description = "${bright}" .. path.filename(configfile) .. "${clear} found, try building it"})) then
tool.build()
end
end
diff --git a/xmake/actions/build/xmake.lua b/xmake/actions/build/xmake.lua
index 2d57e554a..eab28b41f 100644
--- a/xmake/actions/build/xmake.lua
+++ b/xmake/actions/build/xmake.lua
@@ -46,9 +46,6 @@ task("build")
, {'j', "jobs", "kv", tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)),
"Specifies the number of jobs to build simultaneously." }
, {'w', "warning", "k", false , "Enable the warnings output." }
- , {nil, "try", "k", false , "Try building project using third-party buildsystem." }
- , {nil, "try-tool", "kv", nil , "Set the third-party buildsystem tool when `--try` is enabled."
- , values = {"make", "cmake", "autotools", "msbuild", "xcodebuild"}}
, {nil, "files", "kv", nil , "Build the given source files.",
"e.g. ",
" - xmake --files=src/main.c",
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index ecb372abb..90f141968 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -147,7 +147,8 @@ function main()
-- scan project and generate it if xmake.lua not exists
local autogen = false
- if not os.isfile(project.file()) then
+ local trybuild = option.get("trybuild")
+ if not os.isfile(project.file()) and not trybuild then
autogen = utils.confirm({default = false, description = "xmake.lua not found, try generating it"})
if autogen then
scangen()
@@ -264,20 +265,24 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
config.set("buildir", path.relative(buildir, project.directory()), {readonly = true, force = true})
end
- -- install and update requires and config header
- local require_enable = option.boolean(option.get("require"))
- if (recheck or require_enable) and require_enable ~= false then
- install_requires()
- end
+ -- only config for building project using third-party buildsystem
+ if not trybuild then
- -- check target and ensure to load all targets, @note we must load targets after installing required packages,
- -- otherwise has_package() will be invalid.
- _check_target(targetname)
+ -- install and update requires and config header
+ local require_enable = option.boolean(option.get("require"))
+ if (recheck or require_enable) and require_enable ~= false then
+ install_requires()
+ end
- -- update the config header
- if recheck then
- generate_configfiles()
- generate_configheader()
+ -- check target and ensure to load all targets, @note we must load targets after installing required packages,
+ -- otherwise has_package() will be invalid.
+ _check_target(targetname)
+
+ -- update the config header
+ if recheck then
+ generate_configfiles()
+ generate_configheader()
+ end
end
-- dump config
@@ -290,7 +295,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
configcache:set("options_" .. targetname, options)
-- save options and configure for each targets if be all
- if targetname == "all" then
+ if not trybuild and targetname == "all" then
for _, target in pairs(project.targets()) do
config.save(target:name())
configcache:set("options_" .. target:name(), options)
diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua
index bf9272c63..571daca36 100644
--- a/xmake/actions/config/xmake.lua
+++ b/xmake/actions/config/xmake.lua
@@ -51,6 +51,11 @@ task("config")
return {"y: force to enable", "n: disable" }
end
end }
+ , {nil, "trybuild", "kv", nil , "Try building and set the third-party buildsystem tool.",
+ "e.g.",
+ " - xmake f --trybuild=auto; xmake",
+ " - xmake f --trybuild=autotools -p android --ndk=xxx; xmake"
+ , values = {"auto", "make", "cmake", "autotools", "msbuild", "xcodebuild"}}
, {category = "."}
, {'p', "plat", "kv", "$(subhost)" , "Compile for the given platform."
diff --git a/xmake/actions/build/trybuild/autotools.lua b/xmake/modules/private/action/trybuild/autotools.lua
index c2bda369e..c2bda369e 100644
--- a/xmake/actions/build/trybuild/autotools.lua
+++ b/xmake/modules/private/action/trybuild/autotools.lua
diff --git a/xmake/actions/build/trybuild/cmake.lua b/xmake/modules/private/action/trybuild/cmake.lua
index 09ad6750c..09ad6750c 100644
--- a/xmake/actions/build/trybuild/cmake.lua
+++ b/xmake/modules/private/action/trybuild/cmake.lua
diff --git a/xmake/actions/build/trybuild/make.lua b/xmake/modules/private/action/trybuild/make.lua
index 4572e4e73..4572e4e73 100644
--- a/xmake/actions/build/trybuild/make.lua
+++ b/xmake/modules/private/action/trybuild/make.lua
diff --git a/xmake/actions/build/trybuild/msbuild.lua b/xmake/modules/private/action/trybuild/msbuild.lua
index 18005c70e..18005c70e 100644
--- a/xmake/actions/build/trybuild/msbuild.lua
+++ b/xmake/modules/private/action/trybuild/msbuild.lua
diff --git a/xmake/actions/build/trybuild/xcodebuild.lua b/xmake/modules/private/action/trybuild/xcodebuild.lua
index 81a15018c..81a15018c 100644
--- a/xmake/actions/build/trybuild/xcodebuild.lua
+++ b/xmake/modules/private/action/trybuild/xcodebuild.lua