ruki 6 ماه پیش
والد
کامیت
ff253aa29b
4فایلهای تغییر یافته به همراه60 افزوده شده و 2 حذف شده
  1. 4 1
      docs/config.ts
  2. 26 0
      docs/examples/cpp/linux-bpf.md
  3. 4 1
      docs/zh/config.ts
  4. 26 0
      docs/zh/examples/cpp/linux-bpf.md

+ 4 - 1
docs/config.ts

@@ -108,19 +108,22 @@ function examplesGuide(): DefaultTheme.SidebarItem[] {
         { text: 'Protobuf Programs', link: 'cpp/protobuf' },
         { text: 'OpenMP Programs', link: 'cpp/openmp' },
         { text: 'C++ Modules Programs', link: 'cpp/modules' },
+        { text: 'Linux Bpf Programs', link: 'cpp/linux-bpf' },
       ]
     },
     {
       text: 'Other Languages',
       collapsed: false,
       items: [
-        { text: 'iOS/MacOS Programs', link: 'other/objc' },
+        { text: 'ObjC Programs', link: 'other/objc' },
         { text: 'Cuda Programs', link: 'other/cuda' },
         { text: 'Lex/Yacc Programs', link: 'other/lex-yacc' },
         { text: 'Fortran Programs', link: 'other/fortran' },
         { text: 'Golang Programs', link: 'other/golang' },
         { text: 'Dlang Programs', link: 'other/dlang' },
         { text: 'Rust Programs', link: 'other/rust' },
+        { text: 'Swift Programs', link: 'other/swift' },
+        { text: 'Zig Programs', link: 'other/zig' },
       ]
     }
   ]

+ 26 - 0
docs/examples/cpp/linux-bpf.md

@@ -0,0 +1,26 @@
+
+Since 2.5.3, it supports bpf program construction, supports both linux and android platforms, and can automatically pull llvm and android ndk toolchains.
+
+For more details, please see: [#1274](https://github.com/xmake-io/xmake/issues/1274)
+
+```lua
+add_rules("mode.release", "mode.debug")
+add_rules("platform.linux.bpf")
+
+add_requires("linux-tools", {configs = {bpftool = true}})
+add_requires("libbpf")
+if is_plat("android") then
+     add_requires("ndk >=22.x")
+     set_toolchains("@ndk", {sdkver = "23"})
+else
+     add_requires("llvm >=10.x")
+     set_toolchains("@llvm")
+     add_requires("linux-headers")
+end
+
+target("minimal")
+     set_kind("binary")
+     add_files("src/*.c")
+     add_packages("linux-tools", "linux-headers", "libbpf")
+     set_license("GPL-2.0")
+```

+ 4 - 1
docs/zh/config.ts

@@ -145,19 +145,22 @@ function examplesGuide(): DefaultTheme.SidebarItem[] {
         { text: 'Protobuf 程序', link: 'cpp/protobuf' },
         { text: 'OpenMP 程序', link: 'cpp/openmp' },
         { text: 'C++ Modules 程序', link: 'cpp/modules' },
+        { text: 'Linux Bpf 程序', link: 'cpp/linux-bpf' },
       ]
     },
     {
       text: '其他语言',
       collapsed: false,
       items: [
-        { text: 'iOS/MacOS 程序', link: 'other/objc' },
+        { text: 'ObjC 程序', link: 'other/objc' },
         { text: 'Cuda 程序', link: 'other/cuda' },
         { text: 'Lex/Yacc 程序', link: 'other/lex-yacc' },
         { text: 'Fortran 程序', link: 'other/fortran' },
         { text: 'Golang 程序', link: 'other/golang' },
         { text: 'Dlang 程序', link: 'other/dlang' },
         { text: 'Rust 程序', link: 'other/rust' },
+        { text: 'Swift 程序', link: 'other/swift' },
+        { text: 'Zig 程序', link: 'other/zig' },
       ]
     }
   ]

+ 26 - 0
docs/zh/examples/cpp/linux-bpf.md

@@ -0,0 +1,26 @@
+从 2.5.3 之后开始支持 bpf 程序构建,同时支持 linux 以及 android 平台,能够自动拉取 llvm 和 android ndk 工具链。
+
+更多详情见:[#1274](https://github.com/xmake-io/xmake/issues/1274)
+
+```lua
+add_rules("mode.release", "mode.debug")
+add_rules("platform.linux.bpf")
+
+add_requires("linux-tools", {configs = {bpftool = true}})
+add_requires("libbpf")
+if is_plat("android") then
+    add_requires("ndk >=22.x")
+    set_toolchains("@ndk", {sdkver = "23"})
+else
+    add_requires("llvm >=10.x")
+    set_toolchains("@llvm")
+    add_requires("linux-headers")
+end
+
+target("minimal")
+    set_kind("binary")
+    add_files("src/*.c")
+    add_packages("linux-tools", "linux-headers", "libbpf")
+    set_license("GPL-2.0")
+```
+