summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-02-19 23:22:45 +0800
committerruki <[email protected]>2020-02-19 14:16:31 +0800
commit656314dce0e87308babf2f49a35793a3167e849b (patch)
tree231bdde613bd6e1374607dcd42c281e9f60d3abf
parent9201a7b6b9f0b25312130f8eeae73d546532c013 (diff)
improve reconfigure for trybuild
-rw-r--r--xmake/core/base/global.lua14
-rw-r--r--xmake/core/project/config.lua16
-rw-r--r--xmake/core/sandbox/modules/import/core/base/global.lua12
-rw-r--r--xmake/core/sandbox/modules/import/core/project/config.lua11
-rw-r--r--xmake/modules/private/action/trybuild/autotools.lua3
-rw-r--r--xmake/modules/private/action/trybuild/cmake.lua2
-rw-r--r--xmake/modules/private/action/trybuild/meson.lua5
7 files changed, 36 insertions, 27 deletions
diff --git a/xmake/core/base/global.lua b/xmake/core/base/global.lua
index e86c1517c..d777d1243 100644
--- a/xmake/core/base/global.lua
+++ b/xmake/core/base/global.lua
@@ -28,11 +28,6 @@ local path = require("base/path")
local utils = require("base/utils")
local option = require("base/option")
--- get the configure file
-function global._file()
- return path.join(global.directory(), "xmake.conf")
-end
-
-- get the current given configure
function global.get(name)
local value = nil
@@ -91,6 +86,11 @@ function global.options()
return configs
end
+-- get the configure file
+function global.filepath()
+ return path.join(global.directory(), "xmake.conf")
+end
+
-- get the global configure directory
function global.directory()
if global._DIRECTORY == nil then
@@ -104,7 +104,7 @@ end
function global.load()
-- load configure from the file first
- local filepath = global._file()
+ local filepath = global.filepath()
if os.isfile(filepath) then
-- load configs
@@ -134,7 +134,7 @@ function global.save()
options.__version = xmake._VERSION_SHORT
-- save it
- return io.save(global._file(), options)
+ return io.save(global.filepath(), options)
end
-- clear config
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
index bb92081b3..a7e474338 100644
--- a/xmake/core/project/config.lua
+++ b/xmake/core/project/config.lua
@@ -29,11 +29,6 @@ local table = require("base/table")
local utils = require("base/utils")
local option = require("base/option")
--- get the configure file
-function config._file()
- return path.join(config.directory(), "xmake.conf")
-end
-
-- load the project configure
function config._load(targetname)
@@ -41,7 +36,7 @@ function config._load(targetname)
targetname = targetname or "all"
-- load configure from the file first
- local filepath = config._file()
+ local filepath = config.filepath()
if os.isfile(filepath) then
-- load it
@@ -145,6 +140,11 @@ function config.buildir()
return buildir
end
+-- get the configure file
+function config.filepath()
+ return path.join(config.directory(), "xmake.conf")
+end
+
-- get the configure directory on the current host/arch platform
function config.directory()
if config._DIRECTORY == nil then
@@ -185,7 +185,7 @@ function config.save(targetname)
-- load the previous results from configure
local results = {}
- local filepath = config._file()
+ local filepath = config.filepath()
if os.isfile(filepath) then
results = io.load(filepath) or {}
end
@@ -207,7 +207,7 @@ function config.save(targetname)
results.__version = xmake._VERSION_SHORT
-- save it
- return io.save(config._file(), results)
+ return io.save(config.filepath(), results)
end
-- read value from the configure file directly
diff --git a/xmake/core/sandbox/modules/import/core/base/global.lua b/xmake/core/sandbox/modules/import/core/base/global.lua
index ea08b3f90..4ea5b2745 100644
--- a/xmake/core/sandbox/modules/import/core/base/global.lua
+++ b/xmake/core/sandbox/modules/import/core/base/global.lua
@@ -98,17 +98,19 @@ function sandbox_core_base_global.options()
return global.options()
end
+-- get the configure file path
+function sandbox_core_base_global.filepath()
+ local filepath = global.filepath()
+ assert(filepath)
+ return filepath
+end
+
-- get the configure directory
function sandbox_core_base_global.directory()
-
- -- get it
local dir = global.directory()
assert(dir)
-
- -- ok?
return dir
end
-
-- return module
return sandbox_core_base_global
diff --git a/xmake/core/sandbox/modules/import/core/project/config.lua b/xmake/core/sandbox/modules/import/core/project/config.lua
index 32785a261..449fac71f 100644
--- a/xmake/core/sandbox/modules/import/core/project/config.lua
+++ b/xmake/core/sandbox/modules/import/core/project/config.lua
@@ -51,14 +51,17 @@ function sandbox_core_project_config.host()
return config.get("host")
end
+-- get the configuration file path
+function sandbox_core_project_config.filepath()
+ local filepath = config.filepath()
+ assert(filepath)
+ return filepath
+end
+
-- get the configuration directory
function sandbox_core_project_config.directory()
-
- -- get it
local dir = config.directory()
assert(dir)
-
- -- ok?
return dir
end
diff --git a/xmake/modules/private/action/trybuild/autotools.lua b/xmake/modules/private/action/trybuild/autotools.lua
index cbedd70e6..f22573053 100644
--- a/xmake/modules/private/action/trybuild/autotools.lua
+++ b/xmake/modules/private/action/trybuild/autotools.lua
@@ -179,7 +179,8 @@ function build()
end
-- do configure
- if not find_file("[mM]akefile", os.curdir()) then
+ 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()
diff --git a/xmake/modules/private/action/trybuild/cmake.lua b/xmake/modules/private/action/trybuild/cmake.lua
index 7cef45c37..565f00fa7 100644
--- a/xmake/modules/private/action/trybuild/cmake.lua
+++ b/xmake/modules/private/action/trybuild/cmake.lua
@@ -69,7 +69,7 @@ function build()
-- generate makefile
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 then
+ 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")
diff --git a/xmake/modules/private/action/trybuild/meson.lua b/xmake/modules/private/action/trybuild/meson.lua
index 7268b243a..a728e6063 100644
--- a/xmake/modules/private/action/trybuild/meson.lua
+++ b/xmake/modules/private/action/trybuild/meson.lua
@@ -73,8 +73,11 @@ function build()
local buildir = _get_buildir()
local meson = assert(find_tool("meson"), "meson not found!")
local configfile = find_file("build.ninja", buildir)
- if not configfile then
+ 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)
end