diff options
| -rw-r--r-- | CHANGELOG.md | 12 | ||||
| -rw-r--r-- | tests/apis/check_xxx/xmake.lua | 9 | ||||
| -rw-r--r-- | tests/projects/qt/quickapp_static/xmake.lua | 2 | ||||
| -rw-r--r-- | tests/projects/qt/widgetapp_static/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/core/base/interpreter.lua | 45 | ||||
| -rw-r--r-- | xmake/includes/check/check_cflags.lua (renamed from xmake/includes/check_cflags.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/check_cfuncs.lua (renamed from xmake/includes/check_cfuncs.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/check_cincludes.lua (renamed from xmake/includes/check_cincludes.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/check_csnippets.lua (renamed from xmake/includes/check_csnippets.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/check_ctypes.lua (renamed from xmake/includes/check_ctypes.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/check_cxxflags.lua (renamed from xmake/includes/check_cxxflags.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/check_cxxfuncs.lua (renamed from xmake/includes/check_cxxfuncs.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/check_cxxincludes.lua (renamed from xmake/includes/check_cxxincludes.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/check_cxxsnippets.lua (renamed from xmake/includes/check_cxxsnippets.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/check_cxxtypes.lua (renamed from xmake/includes/check_cxxtypes.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/check_features.lua (renamed from xmake/includes/check_features.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/check_links.lua (renamed from xmake/includes/check_links.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/check_macros.lua (renamed from xmake/includes/check_macros.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/check_syslinks.lua (renamed from xmake/includes/check_syslinks.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/check/xmake.lua | 34 | ||||
| -rw-r--r-- | xmake/includes/find_and_add_packages.lua | 47 | ||||
| -rw-r--r-- | xmake/includes/qt/qt_add_static_plugins.lua (renamed from xmake/includes/qt_add_static_plugins.lua) | 0 | ||||
| -rw-r--r-- | xmake/includes/qt/xmake.lua | 21 | ||||
| -rw-r--r-- | xmake/templates/c++/qt.quickapp_static/project/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/templates/c++/qt.widgetapp_static/project/xmake.lua | 2 |
25 files changed, 107 insertions, 69 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index fec885d11..2aeb65b0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,11 @@ * [#3381](https://github.com/xmake-io/xmake/issues/3381): Add `xmake test` support * [#4276](https://github.com/xmake-io/xmake/issues/4276): Support custom scope api -## Bugs fixed +### Changes + +* [#4284](https://github.com/xmake-io/xmake/issues/4284): Improve builtin includes + +### Bugs fixed * [#4256](https://github.com/xmake-io/xmake/issues/4256): Fix intellisense for vsxmake/c++modules @@ -1680,7 +1684,11 @@ * [#3381](https://github.com/xmake-io/xmake/issues/3381): 添加 `xmake test` 支持 * [#4276](https://github.com/xmake-io/xmake/issues/4276): 支持自定义域 API -## Bugs 修复 +### 改进 + +* [#4284](https://github.com/xmake-io/xmake/issues/4284): 改进内置 includes 模块 + +### Bugs 修复 * [#4256](https://github.com/xmake-io/xmake/issues/4256): 为 vsxmake 生成器修复 c++ modules intellisense diff --git a/tests/apis/check_xxx/xmake.lua b/tests/apis/check_xxx/xmake.lua index a5c748414..c68f71b48 100644 --- a/tests/apis/check_xxx/xmake.lua +++ b/tests/apis/check_xxx/xmake.lua @@ -1,11 +1,4 @@ -includes("check_links.lua") -includes("check_ctypes.lua") -includes("check_cflags.lua") -includes("check_cfuncs.lua") -includes("check_macros.lua") -includes("check_features.lua") -includes("check_csnippets.lua") -includes("check_cincludes.lua") +includes("@builtin/check") target("foo") set_kind("static") diff --git a/tests/projects/qt/quickapp_static/xmake.lua b/tests/projects/qt/quickapp_static/xmake.lua index 196749658..b6bc9a8cb 100644 --- a/tests/projects/qt/quickapp_static/xmake.lua +++ b/tests/projects/qt/quickapp_static/xmake.lua @@ -1,6 +1,6 @@ add_rules("mode.debug", "mode.release") -includes("qt_add_static_plugins.lua") +includes("@builtin/qt") target("demo") add_rules("qt.quickapp_static") diff --git a/tests/projects/qt/widgetapp_static/xmake.lua b/tests/projects/qt/widgetapp_static/xmake.lua index 8ae0094bf..5ca10c888 100644 --- a/tests/projects/qt/widgetapp_static/xmake.lua +++ b/tests/projects/qt/widgetapp_static/xmake.lua @@ -1,6 +1,6 @@ add_rules("mode.debug", "mode.release") -includes("qt_add_static_plugins.lua") +includes("@builtin/qt") target("demo") add_rules("qt.widgetapp_static") diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 6060fc319..7ba677a8f 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -1686,20 +1686,49 @@ function interpreter:api_builtin_includes(...) local subpaths = table.join(...) local subpaths_matched = {} for _, subpath in ipairs(subpaths) do - -- find the given files from the project directory local found = false - local files = os.match(subpath, not subpath:endswith(".lua")) - if files and #files > 0 then - table.join2(subpaths_matched, files) - found = true - elseif not path.is_absolute(subpath) then - -- attempt to find files from programdir/includes/*.lua - files = os.files(path.join(os.programdir(), "includes", subpath)) + -- attempt to find files from programdir/includes/*.lua + -- e.g. includes("@builtin/check") + if subpath:startswith("@builtin/") then + local builtin_path = subpath:sub(10) + local files + if builtin_path:endswith(".lua") then + files = os.files(path.join(os.programdir(), "includes", builtin_path)) + else + files = os.files(path.join(os.programdir(), "includes", builtin_path, "xmake.lua")) + end + if files and #files > 0 then + table.join2(subpaths_matched, files) + found = true + end + end + -- find the given files from the project directory + if not found then + local files = os.match(subpath, not subpath:endswith(".lua")) if files and #files > 0 then table.join2(subpaths_matched, files) found = true end end + -- attempt to find files from programdir/includes/*.lua (deprecated) + if not found and not path.is_absolute(subpath) then + -- e.g. includes("check_cflags.lua") + if subpath:startswith("check_") then + local files = os.files(path.join(os.programdir(), "includes", "check", subpath)) + if files and #files > 0 then + table.join2(subpaths_matched, files) + found = true + utils.warning("deprecated: please use includes(\"@builtin/check\") instead of includes(\"%s\")", subpath) + end + elseif subpath:startswith("qt_") then + local files = os.files(path.join(os.programdir(), "includes", "qt", subpath)) + if files and #files > 0 then + table.join2(subpaths_matched, files) + found = true + utils.warning("deprecated: please use includes(\"@builtin/qt\") instead of includes(\"%s\")", subpath) + end + end + end if not found then utils.warning("includes(\"%s\") cannot find any files!", subpath) end diff --git a/xmake/includes/check_cflags.lua b/xmake/includes/check/check_cflags.lua index 5da75b699..5da75b699 100644 --- a/xmake/includes/check_cflags.lua +++ b/xmake/includes/check/check_cflags.lua diff --git a/xmake/includes/check_cfuncs.lua b/xmake/includes/check/check_cfuncs.lua index a7a2cfb22..a7a2cfb22 100644 --- a/xmake/includes/check_cfuncs.lua +++ b/xmake/includes/check/check_cfuncs.lua diff --git a/xmake/includes/check_cincludes.lua b/xmake/includes/check/check_cincludes.lua index 68ace5980..68ace5980 100644 --- a/xmake/includes/check_cincludes.lua +++ b/xmake/includes/check/check_cincludes.lua diff --git a/xmake/includes/check_csnippets.lua b/xmake/includes/check/check_csnippets.lua index 2e22c3220..2e22c3220 100644 --- a/xmake/includes/check_csnippets.lua +++ b/xmake/includes/check/check_csnippets.lua diff --git a/xmake/includes/check_ctypes.lua b/xmake/includes/check/check_ctypes.lua index e89345eea..e89345eea 100644 --- a/xmake/includes/check_ctypes.lua +++ b/xmake/includes/check/check_ctypes.lua diff --git a/xmake/includes/check_cxxflags.lua b/xmake/includes/check/check_cxxflags.lua index 6b6e78d0f..6b6e78d0f 100644 --- a/xmake/includes/check_cxxflags.lua +++ b/xmake/includes/check/check_cxxflags.lua diff --git a/xmake/includes/check_cxxfuncs.lua b/xmake/includes/check/check_cxxfuncs.lua index 2ac98d799..2ac98d799 100644 --- a/xmake/includes/check_cxxfuncs.lua +++ b/xmake/includes/check/check_cxxfuncs.lua diff --git a/xmake/includes/check_cxxincludes.lua b/xmake/includes/check/check_cxxincludes.lua index 4eff5f53e..4eff5f53e 100644 --- a/xmake/includes/check_cxxincludes.lua +++ b/xmake/includes/check/check_cxxincludes.lua diff --git a/xmake/includes/check_cxxsnippets.lua b/xmake/includes/check/check_cxxsnippets.lua index 358818844..358818844 100644 --- a/xmake/includes/check_cxxsnippets.lua +++ b/xmake/includes/check/check_cxxsnippets.lua diff --git a/xmake/includes/check_cxxtypes.lua b/xmake/includes/check/check_cxxtypes.lua index 28964b6f4..28964b6f4 100644 --- a/xmake/includes/check_cxxtypes.lua +++ b/xmake/includes/check/check_cxxtypes.lua diff --git a/xmake/includes/check_features.lua b/xmake/includes/check/check_features.lua index 2dca743fa..2dca743fa 100644 --- a/xmake/includes/check_features.lua +++ b/xmake/includes/check/check_features.lua diff --git a/xmake/includes/check_links.lua b/xmake/includes/check/check_links.lua index 075be25b0..075be25b0 100644 --- a/xmake/includes/check_links.lua +++ b/xmake/includes/check/check_links.lua diff --git a/xmake/includes/check_macros.lua b/xmake/includes/check/check_macros.lua index 2235798ec..2235798ec 100644 --- a/xmake/includes/check_macros.lua +++ b/xmake/includes/check/check_macros.lua diff --git a/xmake/includes/check_syslinks.lua b/xmake/includes/check/check_syslinks.lua index ff44f8098..ff44f8098 100644 --- a/xmake/includes/check_syslinks.lua +++ b/xmake/includes/check/check_syslinks.lua diff --git a/xmake/includes/check/xmake.lua b/xmake/includes/check/xmake.lua new file mode 100644 index 000000000..467d232f6 --- /dev/null +++ b/xmake/includes/check/xmake.lua @@ -0,0 +1,34 @@ +--!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 +-- + +includes("@builtin/check/check_cflags.lua") +includes("@builtin/check/check_cfuncs.lua") +includes("@builtin/check/check_cincludes.lua") +includes("@builtin/check/check_csnippets.lua") +includes("@builtin/check/check_ctypes.lua") +includes("@builtin/check/check_cxxflags.lua") +includes("@builtin/check/check_cxxfuncs.lua") +includes("@builtin/check/check_cxxincludes.lua") +includes("@builtin/check/check_cxxsnippets.lua") +includes("@builtin/check/check_cxxtypes.lua") +includes("@builtin/check/check_features.lua") +includes("@builtin/check/check_links.lua") +includes("@builtin/check/check_macros.lua") +includes("@builtin/check/check_syslinks.lua") diff --git a/xmake/includes/find_and_add_packages.lua b/xmake/includes/find_and_add_packages.lua deleted file mode 100644 index d0d98fac7..000000000 --- a/xmake/includes/find_and_add_packages.lua +++ /dev/null @@ -1,47 +0,0 @@ ---!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 find_and_add_packages.lua --- - --- find and add packages to the given target --- --- e.g. --- --- @code --- includes("find_and_add_packages.lua") --- target("test") --- set_kind("binary") --- add_files("src/*.c") --- find_and_add_packages("brew::pcre2/libpcre2-8", "zlib") --- @endcode --- -function find_and_add_packages(...) - for _, name in ipairs({...}) do - local optname = "__" .. name - interp_save_scope() - option(optname) - set_showmenu(false) - before_check(function (option) - option:add(find_packages(name)) - end) - option_end() - interp_restore_scope() - add_options(optname) - end -end - diff --git a/xmake/includes/qt_add_static_plugins.lua b/xmake/includes/qt/qt_add_static_plugins.lua index e65965972..e65965972 100644 --- a/xmake/includes/qt_add_static_plugins.lua +++ b/xmake/includes/qt/qt_add_static_plugins.lua diff --git a/xmake/includes/qt/xmake.lua b/xmake/includes/qt/xmake.lua new file mode 100644 index 000000000..c08485bf6 --- /dev/null +++ b/xmake/includes/qt/xmake.lua @@ -0,0 +1,21 @@ +--!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 +-- + +includes("@builtin/qt/qt_add_static_plugins.lua") diff --git a/xmake/templates/c++/qt.quickapp_static/project/xmake.lua b/xmake/templates/c++/qt.quickapp_static/project/xmake.lua index 860dc513c..0d752b270 100644 --- a/xmake/templates/c++/qt.quickapp_static/project/xmake.lua +++ b/xmake/templates/c++/qt.quickapp_static/project/xmake.lua @@ -1,6 +1,6 @@ add_rules("mode.debug", "mode.release") -includes("qt_add_static_plugins.lua") +includes("@builtin/qt") target("${TARGETNAME}") add_rules("qt.quickapp_static") diff --git a/xmake/templates/c++/qt.widgetapp_static/project/xmake.lua b/xmake/templates/c++/qt.widgetapp_static/project/xmake.lua index ac08f5c2e..b2cc1ac86 100644 --- a/xmake/templates/c++/qt.widgetapp_static/project/xmake.lua +++ b/xmake/templates/c++/qt.widgetapp_static/project/xmake.lua @@ -1,6 +1,6 @@ add_rules("mode.debug", "mode.release") -includes("qt_add_static_plugins.lua") +includes("@builtin/qt") target("${TARGETNAME}") add_rules("qt.widgetapp_static") |
