mirror of
https://gitcode.com/JianFeeeee/LuaCangjia_api.git
synced 2026-09-20 00:48:47 +00:00
优化编译脚本,保证bundle顺利通过
This commit is contained in:
22
build.cj
22
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<String>): Int64 {
|
||||
|
||||
match (args[0]) {
|
||||
case "pre-build" => stagePreBuild()
|
||||
case "pre-test" => stagePreTest()
|
||||
case "post-build" => stagePostBuild()
|
||||
case "pre-clean" => stagePreClean()
|
||||
case _ => 0
|
||||
|
||||
@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user