summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-03-06 00:32:09 +0800
committerruki <[email protected]>2021-03-06 00:32:09 +0800
commit0a3430a9e0a613de7cdac9e8d75335683744ab95 (patch)
treee8ae3f4c8724e312a5c26884fde4292029e670d4
parent6ad24d9abe5b30d3b3c7dbf812afc558a10ecc08 (diff)
switch on_config
-rw-r--r--xmake/actions/config/main.lua3
-rw-r--r--xmake/core/project/project.lua1
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x.lua26
-rw-r--r--xmake/plugins/project/vsxmake/getinfo.lua26
-rw-r--r--xmake/rules/platform/windows/def/xmake.lua9
-rw-r--r--xmake/rules/platform/windows/manifest/xmake.lua9
6 files changed, 58 insertions, 16 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index a061ce2c6..4a8cfc2ed 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -346,6 +346,9 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
end
end
+ -- config targets
+ _config_targets(targetname)
+
-- dump config
if option.get("verbose") and not opt.disable_dump then
config.dump()
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 75cfa106e..86990a2cb 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -935,6 +935,7 @@ function project.ordertargets()
if not ordertargets then
-- ensure ordertargets to be cached
project.targets()
+ ordertargets = project._memcache():get("ordertargets")
end
return ordertargets
end
diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua
index 968cac080..a66761d4d 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x.lua
@@ -220,6 +220,29 @@ function _make_vsinfo_archs()
return vsinfo_archs
end
+-- config target
+function _config_target(target)
+ for _, rule in ipairs(target:orderules()) do
+ local on_config = rule:script("config")
+ if on_config then
+ on_config(target)
+ end
+ end
+ local on_config = target:script("config")
+ if on_config then
+ on_config(target)
+ end
+end
+
+-- config targets
+function _config_targets()
+ for _, target in ipairs(project.ordertargets()) do
+ if target:is_enabled() then
+ _config_target(target)
+ end
+ end
+end
+
-- make vstudio project
function make(outputdir, vsinfo)
@@ -273,6 +296,9 @@ function make(outputdir, vsinfo)
-- install and update requires
install_requires()
+ -- config targets
+ _config_targets()
+
-- update config files
generate_configfiles()
generate_configheader()
diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua
index d1d9895bb..f2d54fdfe 100644
--- a/xmake/plugins/project/vsxmake/getinfo.lua
+++ b/xmake/plugins/project/vsxmake/getinfo.lua
@@ -291,6 +291,29 @@ function _make_vsinfo_groups()
return groups, group_deps
end
+-- config target
+function _config_target(target)
+ for _, rule in ipairs(target:orderules()) do
+ local on_config = rule:script("config")
+ if on_config then
+ on_config(target)
+ end
+ end
+ local on_config = target:script("config")
+ if on_config then
+ on_config(target)
+ end
+end
+
+-- config targets
+function _config_targets()
+ for _, target in ipairs(project.ordertargets()) do
+ if target:is_enabled() then
+ _config_target(target)
+ end
+ end
+end
+
-- make vstudio project
function main(outputdir, vsinfo)
@@ -366,6 +389,9 @@ function main(outputdir, vsinfo)
-- install and update requires
install_requires()
+ -- config targets
+ _config_targets()
+
-- update config files
generate_configfiles()
generate_configheader()
diff --git a/xmake/rules/platform/windows/def/xmake.lua b/xmake/rules/platform/windows/def/xmake.lua
index 97c356c28..06e960380 100644
--- a/xmake/rules/platform/windows/def/xmake.lua
+++ b/xmake/rules/platform/windows/def/xmake.lua
@@ -21,8 +21,7 @@
-- add *.def for windows/dll
rule("platform.windows.def")
set_extensions(".def")
- --[[FIXME
- after_load("windows", function (target)
+ on_config("windows", function (target)
local _, toolname = target:tool("ld")
if toolname == "link" then
for _, sourcebatch in pairs(target:sourcebatches()) do
@@ -33,11 +32,5 @@ rule("platform.windows.def")
end
end
end
- end)]]
- before_build_file("windows", function (target, sourcefile)
- local _, toolname = target:tool("ld")
- if toolname == "link" then
- target:add("shflags", "/def:" .. path.translate(sourcefile), {force = true})
- end
end)
diff --git a/xmake/rules/platform/windows/manifest/xmake.lua b/xmake/rules/platform/windows/manifest/xmake.lua
index 77546e25e..efb750edd 100644
--- a/xmake/rules/platform/windows/manifest/xmake.lua
+++ b/xmake/rules/platform/windows/manifest/xmake.lua
@@ -22,8 +22,7 @@
-- https://github.com/xmake-io/xmake/issues/1241
rule("platform.windows.manifest")
set_extensions(".manifest")
- --[[FIXME
- after_load("windows", function (target)
+ on_config("windows", function (target)
local _, toolname = target:tool("ld")
if toolname == "link" then
local manifest = false
@@ -39,10 +38,4 @@ rule("platform.windows.manifest")
target:add("ldflags", "/manifest", {force = true})
end
end
- end)]]
- before_build_file("windows", function (target, sourcefile)
- local _, toolname = target:tool("ld")
- if toolname == "link" then
- target:add("ldflags", "/manifest", "/ManifestFile:" .. path.translate(sourcefile), {force = true})
- end
end)