summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-03-02 00:37:15 +0800
committerruki <[email protected]>2021-03-02 00:37:15 +0800
commit8793a25af4513c1b4820105023d45e458fedaaf0 (patch)
treee78bab6d08ae0506ffac2c1212ef96756d095610
parent8f0fee2899d3fdbca259f32acb068b3a4a45bec6 (diff)
add .def rule
-rw-r--r--CHANGELOG.md8
-rw-r--r--xmake/rules/platform/windows/def/xmake.lua30
-rw-r--r--xmake/rules/platform/xmake.lua5
3 files changed, 42 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index da1aec6fe..870c1ffc9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
## master (unreleased)
+### New features
+
+* [#1259](https://github.com/xmake-io/xmake/issues/1259): Support `add_files("*.def")` to export symbols for windows/dll
+
## v2.5.2
### New features
@@ -937,6 +941,10 @@
## master (开发中)
+### 新特性
+
+* [#1259](https://github.com/xmake-io/xmake/issues/1259): 支持 `add_files("*.def")` 添加 def 文件去导出 windows/dll 符号
+
## v2.5.2
### 新特性
diff --git a/xmake/rules/platform/windows/def/xmake.lua b/xmake/rules/platform/windows/def/xmake.lua
new file mode 100644
index 000000000..e89050a0f
--- /dev/null
+++ b/xmake/rules/platform/windows/def/xmake.lua
@@ -0,0 +1,30 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file xmake.lua
+--
+
+-- add *.def for windows/dll
+rule("platform.windows.def")
+ set_extensions(".def")
+ 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/xmake.lua b/xmake/rules/platform/xmake.lua
index 3bd9b51eb..3b11a8047 100644
--- a/xmake/rules/platform/xmake.lua
+++ b/xmake/rules/platform/xmake.lua
@@ -19,5 +19,8 @@
--
rule("platform.windows")
- add_deps("platform.windows.manifest")
+ if is_host("windows") then
+ add_deps("platform.windows.def")
+ add_deps("platform.windows.manifest")
+ end