浏览代码

add more examples

ruki 1 周之前
父节点
当前提交
4f4de89313

+ 5 - 0
docs/codes/examples/configuration/unity_build/src/bar/test.cpp

@@ -0,0 +1,5 @@
+#include <iostream>
+
+void test_bar() {
+    std::cout << "test_bar" << std::endl;
+}

+ 5 - 0
docs/codes/examples/configuration/unity_build/src/foo/test.cpp

@@ -0,0 +1,5 @@
+#include <iostream>
+
+void test_foo() {
+    std::cout << "test_foo" << std::endl;
+}

+ 13 - 0
docs/codes/examples/configuration/unity_build/src/main.cpp

@@ -0,0 +1,13 @@
+#include <iostream>
+
+void test_c();
+void test_foo();
+void test_bar();
+
+int main() {
+    test_c();
+    test_foo();
+    test_bar();
+    std::cout << "hello unity build" << std::endl;
+    return 0;
+}

+ 5 - 0
docs/codes/examples/configuration/unity_build/src/test.c

@@ -0,0 +1,5 @@
+#include <stdio.h>
+
+void test_c() {
+    printf("test_c\n");
+}

+ 7 - 0
docs/codes/examples/configuration/unity_build/xmake.lua

@@ -0,0 +1,7 @@
+target("test")
+    set_kind("binary")
+    add_includedirs("src")
+    add_rules("c++.unity_build", {batchsize = 2, uniqueid = "MY_UNITY_ID"})
+    add_files("src/*.c", "src/*.cpp")
+    add_files("src/foo/*.cpp", {unity_group = "foo"})
+    add_files("src/bar/*.cpp", {unity_group = "bar"})

+ 1 - 0
docs/config.ts

@@ -338,6 +338,7 @@ function examplesSidebar(): DefaultTheme.SidebarItem[] {
         { text: 'Namespace Isolation', link: 'configuration/namespace_isolation' },
         { text: 'Custom Toolchain', link: 'configuration/custom_toolchain' },
         { text: 'Remote Toolchain', link: 'configuration/remote_toolchain' },
+        { text: 'Unity Build', link: 'configuration/unity_build' },
         { text: 'Custom Rule', link: 'configuration/custom_rule' },
         { text: 'Custom Module', link: 'configuration/custom_module' },
         { text: 'Custom Scope API', link: 'configuration/custom_scope_api' },

+ 5 - 0
docs/examples/configuration/unity_build.md

@@ -0,0 +1,5 @@
+# Unity Build
+
+We can use `c.unity_build` and `c++.unity_build` rules to enable unity build acceleration.
+
+<FileExplorer rootFilesDir="examples/configuration/unity_build" />

+ 1 - 0
docs/posts/xmake-update-v3.0.6.md

@@ -226,6 +226,7 @@ In addition, we have improved dependent library resolution, support for extracti
 * [#7145](https://github.com/xmake-io/xmake/pull/7145): Improve Clang/LLVM runtime support
 * [#7136](https://github.com/xmake-io/xmake/pull/7136): Improve clang-cl depfiles generation
 * [#7135](https://github.com/xmake-io/xmake/pull/7135): Improve `xrepo env` to add session ID
+* [#7155](https://github.com/xmake-io/xmake/pull/7155): Refactor Windows ASan for clang-cl (runtime linking, linker flags, PATH/CMAKE_LINKER_TYPE setup, toolchain streamlining)
 * [#7109](https://github.com/xmake-io/xmake/pull/7109): Improve binutils to read symbols from binary file
 * [#7102](https://github.com/xmake-io/xmake/pull/7102): Improve bin2c rule
 * [#7098](https://github.com/xmake-io/xmake/pull/7098): Refactor and improve Golang support

+ 1 - 0
docs/zh/config.ts

@@ -419,6 +419,7 @@ function examplesSidebar(): DefaultTheme.SidebarItem[] {
         { text: '命名空间隔离', link: 'configuration/namespace_isolation' },
         { text: '自定义工具链', link: 'configuration/custom_toolchain' },
         { text: '远程工具链', link: 'configuration/remote_toolchain' },
+        { text: 'Unity 编译加速', link: 'configuration/unity_build' },
         { text: '自定义规则', link: 'configuration/custom_rule' },
         { text: '自定义模块', link: 'configuration/custom_module' },
         { text: '自定义描述域 API', link: 'configuration/custom_scope_api' },

+ 5 - 0
docs/zh/examples/configuration/unity_build.md

@@ -0,0 +1,5 @@
+# Unity Build
+
+我们可以使用 `c.unity_build` 和 `c++.unity_build` 规则来启用 Unity Build 编译加速。
+
+<FileExplorer rootFilesDir="examples/configuration/unity_build" />

+ 1 - 0
docs/zh/posts/xmake-update-v3.0.6.md

@@ -226,6 +226,7 @@ extractlib("/path/to/lib.a", "/path/to/outputdir")
 * [#7145](https://github.com/xmake-io/xmake/pull/7145):改进 Clang/LLVM 运行时支持
 * [#7136](https://github.com/xmake-io/xmake/pull/7136):改进 clang-cl 依赖文件生成
 * [#7135](https://github.com/xmake-io/xmake/pull/7135):`xrepo env` 增加 session ID
+* [#7155](https://github.com/xmake-io/xmake/pull/7155):重构 clang-cl 的 Windows ASan 支持(运行时链接,链接器标志,PATH/CMAKE_LINKER_TYPE 设置,工具链简化)
 * [#7109](https://github.com/xmake-io/xmake/pull/7109):binutils 支持从二进制文件读取符号
 * [#7102](https://github.com/xmake-io/xmake/pull/7102):改进 bin2c 规则
 * [#7098](https://github.com/xmake-io/xmake/pull/7098):重构并改进 Golang 支持