From 905d70809b4c764968ec4ebed57f170b0a122a67 Mon Sep 17 00:00:00 2001 From: jianf <2198972886@qq.com> Date: Wed, 25 Mar 2026 14:53:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=AF=91=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=EF=BC=8C=E4=BF=9D=E8=AF=81bundle=E9=A1=BA=E5=88=A9?= =?UTF-8?q?=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.cj | 22 ++++++++++++---------- cjpm.toml | 5 ++++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/build.cj b/build.cj index 2ab9ad7..b7c52af 100644 --- a/build.cj +++ b/build.cj @@ -4,19 +4,16 @@ import std.process.* import std.fs.* import std.core.* -// 构建前钩子:编译 C 库 -func stagePreBuild(): Int64 { +func buildCLib(): Int64 { let root_dir = Path(".") let lib_dir = root_dir.join("lib") let build_dir = lib_dir.join("build") - // 1. 确保 lib 目录存在 if (!exists(lib_dir)) { println("Error: lib directory not found at ${lib_dir}") return 1 } - // 2. 创建构建目录 - 使用 try 表达式 if (!exists(build_dir)) { try { Directory.create(build_dir, recursive: true) @@ -26,7 +23,6 @@ func stagePreBuild(): Int64 { } } - // 3. 执行 cmake 配置 println("Configuring C library with CMake...") let cmake_exit = execute( "cmake", @@ -44,7 +40,6 @@ func stagePreBuild(): Int64 { return cmake_exit } - // 4. 执行构建 println("Building C library...") let build_exit = execute( "cmake", @@ -64,26 +59,32 @@ func stagePreBuild(): Int64 { println("C library compiled successfully at: ${build_dir}") - // 5. 可选:安装到输出目录 let output_dir = root_dir.join("liboutput") if (!exists(output_dir)) { try { Directory.create(output_dir, recursive: true) } catch (_: Exception) { - // 忽略创建错误 } } 0 } -// 构建后钩子 +func stagePreBuild(): Int64 { + println("Pre-build: compiling C library...") + buildCLib() +} + +func stagePreTest(): Int64 { + println("Pre-test: compiling C library...") + buildCLib() +} + func stagePostBuild(): Int64 { println("Post-build: C library integration complete") 0 } -// 清理前钩子 func stagePreClean(): Int64 { let build_dir = Path(".").join("lib").join("build") if (exists(build_dir)) { @@ -104,6 +105,7 @@ main(args: Array): Int64 { match (args[0]) { case "pre-build" => stagePreBuild() + case "pre-test" => stagePreTest() case "post-build" => stagePostBuild() case "pre-clean" => stagePreClean() case _ => 0 diff --git a/cjpm.toml b/cjpm.toml index da3053c..73a1f10 100644 --- a/cjpm.toml +++ b/cjpm.toml @@ -1,10 +1,13 @@ [package] name = "luarunner" -version = "0.0.1" +version = "0.1.1" description = "Lite and High performance LuaRunner" cjc-version = "1.1.0" license = "LGPL-3.0-or-later" output-type ="dynamic" +repository = "https://gitcode.com/JianFeeeee/LuaCangjia_api.git" +homepage = "https://atomgit.com/JianFeeeee/LuaCangjia_api" +include = ["src","lib","build.cj"] [dependencies]