Skip to content

chore: refine building script #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_linux_arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
go env -w GOFLAGS="-buildvcs=false" && \
go1.20.12 download && \
rustup default nightly && \
tgn gen linux arm64 ${{ matrix.build_type }} -- is_clang=${{ matrix.compiler == 'gcc' && 'false' || 'true' }} log_level=1 enable_serialized_actions=true ten_enable_tests=false ten_rust_enable_tests=false ten_package_manager_enable_tests=false ten_enable_libwebsockets=false ten_enable_cargo_clean=true && \
tgn gen linux arm64 ${{ matrix.build_type }} -- is_clang=${{ matrix.compiler == 'gcc' && 'false' || 'true' }} log_level=1 enable_serialized_actions=true ten_enable_serialized_rust_action=true ten_enable_tests=false ten_rust_enable_tests=false ten_package_manager_enable_tests=false ten_enable_libwebsockets=false ten_enable_cargo_clean=true && \
tgn build linux arm64 ${{ matrix.build_type }} && \
tree -I 'gen|obj' out \
"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_linux_ubuntu1804.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
echo $PATH
go env -w GOFLAGS="-buildvcs=false"
rustup default nightly
tgn gen linux x64 ${{ matrix.build_type }} -- is_clang=false log_level=1 enable_serialized_actions=true ten_enable_integration_tests=false ten_enable_package_manager=false ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true
tgn gen linux x64 ${{ matrix.build_type }} -- is_clang=false log_level=1 enable_serialized_actions=true ten_enable_serialized_rust_action=true ten_enable_integration_tests=false ten_enable_ten_manager=false ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true
tgn build linux x64 ${{ matrix.build_type }}
tree -I 'gen|obj' out

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_linux_ubuntu2204.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
go env -w GOFLAGS="-buildvcs=false"
go1.20.12 download
rustup default nightly
tgn gen linux x64 ${{ matrix.build_type }} -- is_clang=${{ matrix.compiler == 'gcc' && 'false' || 'true' }} log_level=1 enable_serialized_actions=true ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true ten_enable_go_lint=true
tgn gen linux x64 ${{ matrix.build_type }} -- is_clang=${{ matrix.compiler == 'gcc' && 'false' || 'true' }} log_level=1 enable_serialized_actions=true ten_enable_serialized_rust_action=true ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true ten_enable_go_lint=true
tgn build linux x64 ${{ matrix.build_type }}
tree -I 'gen|obj' out

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
export PATH=$(pwd)/core/ten_gn:$PATH
echo $PATH

tgn gen mac arm64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true ten_enable_python_binding=false
tgn gen mac arm64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_enable_serialized_rust_action=true ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true ten_enable_python_binding=false

tgn build mac arm64 ${{ matrix.build_type }}
tree -I 'gen|obj' out
Expand Down Expand Up @@ -239,7 +239,7 @@ jobs:
export PATH=$(pwd)/core/ten_gn:$PATH
echo $PATH

tgn gen mac x64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true ten_enable_python_binding=false
tgn gen mac x64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_enable_serialized_rust_action=true ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true ten_enable_python_binding=false

tgn build mac x64 ${{ matrix.build_type }}
tree -I 'gen|obj' out
Expand Down Expand Up @@ -402,7 +402,7 @@ jobs:
export PATH=$(pwd)/core/ten_gn:$PATH
echo $PATH

tgn gen mac arm64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_rust_enable_gen_cargo_config=false ten_enable_ten_rust_apis=false
tgn gen mac arm64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_enable_serialized_rust_action=true ten_rust_enable_gen_cargo_config=false ten_enable_ten_rust_apis=false

tgn build mac arm64 ${{ matrix.build_type }}

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/build_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
group: build-win-x64-${{ github.head_ref }}-${{ matrix.build_type }}
cancel-in-progress: true
runs-on: windows-latest
env:
PYTHONIOENCODING: utf-8
strategy:
matrix:
build_type: [debug, release]
Expand Down Expand Up @@ -65,7 +67,7 @@ jobs:
- name: Build
run: |
$ENV:PATH += ";$PWD/core/ten_gn"
tgn gen win x64 ${{ matrix.build_type }} -- vs_version=2022 log_level=1 enable_serialized_actions=true ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true ten_enable_python_binding=false ten_enable_go_binding=false
tgn gen win x64 ${{ matrix.build_type }} -- vs_version=2022 log_level=1 enable_serialized_actions=true ten_enable_serialized_rust_action=true ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true ten_enable_python_binding=false ten_enable_go_binding=false
tgn build win x64 ${{ matrix.build_type }}

- name: Run Tests (ten_utils_unit_test)
Expand Down
11 changes: 9 additions & 2 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ import("//build/ten_runtime/ten.gni")
import("//build/ten_utils/options.gni")

# When you want to get the output of the console in real time, you can use this
# pool
# pool.
pool("serialized_action_pool") {
depth = 1
}

# Since `cargo build` can consume a significant amount of disk space, it is
# necessary to limit the concurrency of `cargo build` in certain build
# environments (e.g., CI) to manage disk space requirements.
pool("rust_action_pool") {
depth = 1
}

group("ten_framework_all") {
deps = [
"//core/src/ten_runtime",
Expand All @@ -28,7 +35,7 @@ group("ten_framework_all") {
"//third_party",
]

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
deps += [ "//core/src/ten_manager" ]
}

Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 11 additions & 3 deletions build/common/rust/rust.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ template("rust_target") {
target_path = invoker.target_path

action("${_target_name}") {
script = "//build/common/rust/rust.py"
if (ten_enable_serialized_rust_action) {
pool = "//:rust_action_pool"
}

script = "//build/common/rust/cargo_build.py"

args = [
"--project-path",
Expand Down Expand Up @@ -186,7 +190,11 @@ template("rust_test") {
tg_timestamp_proxy_file = "${target_path}/${target_name}_rust_tests"

action("${_target_name}") {
script = "//build/common/rust/rust_build_tests.py"
if (ten_enable_serialized_rust_action) {
pool = "//:rust_action_pool"
}

script = "//build/common/rust/cargo_build_tests.py"

args = [
"--project-path",
Expand Down Expand Up @@ -488,7 +496,7 @@ template("rust_clean") {
_target_name = target_name

action("${_target_name}") {
script = "//build/common/rust/rust_clean.py"
script = "//build/common/rust/cargo_clean.py"
_output = "${target_gen_dir}/${_target_name}_rust_clean"

args = [
Expand Down
23 changes: 22 additions & 1 deletion build/options.gni
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Refer to the "LICENSE" file in the root directory for more information.
#
declare_args() {
# The TEN runtime has its own memory check/track mechanism, which can be used
# in conjunction with ASAN (AddressSanitizer).
ten_enable_memory_check = true

# The 'ten_rust' crate depends on the 'ten_utils' (C codes) static library.
Expand All @@ -15,9 +17,28 @@ declare_args() {
# x86.
ten_enable_ten_rust = !(enable_sanitizer && target_cpu == "x86")

ten_enable_package_manager = true
ten_enable_ten_manager = true

# After building a Rust/Cargo project, clean the project using `cargo clean`.
# This is mainly to reduce disk usage in environments with limited disk space,
# such as CI.
ten_enable_cargo_clean = false

# Since building the integration tests also increases disk space usage, in
# disk space-limited environments (such as CI), the variable below is used to
# defer the integration test build until the testing phase. This prevents it
# from being built together with the core TEN framework components (e.g.,
# `ten_runtime`, `ten_manager`).
ten_enable_integration_tests_prebuilt = false

# Rust's incremental build requires additional disk space, so this option
# allows it to be disabled in CI environments.
ten_enable_rust_incremental_build = true
}

declare_args() {
# Since `cargo build` can consume a significant amount of disk space, it is
# necessary to limit the concurrency of `cargo build` in certain build
# environments (e.g., CI) to manage disk space requirements.
ten_enable_serialized_rust_action = false
}
8 changes: 5 additions & 3 deletions core/src/ten_manager/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ copy("ten_manager_test_data") {
outputs = [ "${root_out_dir}/tests/standalone/ten_manager/tests/test_data" ]
}

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
if (ten_package_manager_enable_tests) {
rust_test("tman_test_cargo_build") {
project_path = "//core/src/ten_manager"
Expand All @@ -38,7 +38,7 @@ if (ten_enable_package_manager) {
# executable will be the normal executable, not the test case executable.
# Therefore, it's necessary to separate the `target-dir` for these two
# `cargo build` commands to avoid interfering with each other.
target_path = "${target_gen_dir}/tman_test"
target_path = "${root_gen_dir}/core/src/ten_manager_test"

test_output_dir = "${root_out_dir}/tests/standalone/ten_manager"

Expand All @@ -51,8 +51,9 @@ if (ten_enable_package_manager) {

rust_clean("tman_test_cargo_clean") {
project_path = "//core/src/ten_manager"
target_path = get_label_info("tman_test", "target_gen_dir")
target_path = "${root_gen_dir}/core/src/ten_manager_test"

# Build tman_test first, then `cargo clean` it.
deps = [ ":tman_test_cargo_build" ]
}

Expand Down Expand Up @@ -160,6 +161,7 @@ if (ten_enable_package_manager) {
tman_target_gen_dir = get_label_info(":tman", "target_gen_dir")
target_path = "${tman_target_gen_dir}/tman"

# Build tman first, then `cargo clean` it.
deps = [ ":ten_manager_package" ]
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/ten_runtime/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ ten_package("ten_runtime_system_package") {
]
}

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
ten_package_publish("upload_ten_runtime_system_package_to_server") {
base_dir = rebase_path("${root_out_dir}/ten_packages/system/ten_runtime")
deps = [
Expand All @@ -132,7 +132,7 @@ if (ten_enable_package_manager) {
group("ten_runtime") {
public_deps = [ ":ten_runtime_library" ]

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
deps = [ ":upload_ten_runtime_system_package_to_server" ]
}
}
4 changes: 2 additions & 2 deletions core/src/ten_runtime/binding/go/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ten_package("ten_go_binding_system_package") {
}
}

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
ten_package_publish("upload_ten_go_binding_system_package_to_server") {
base_dir = rebase_path("${root_out_dir}/ten_packages/system/ten_runtime_go")
deps = [
Expand All @@ -55,7 +55,7 @@ if (ten_enable_package_manager) {
group("go") {
deps = [ "native:ten_runtime_go" ]

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
deps += [ ":upload_ten_go_binding_system_package_to_server" ]
}
}
4 changes: 2 additions & 2 deletions core/src/ten_runtime/binding/nodejs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ten_package("ten_nodejs_binding_system_package") {
deps = [ "native:ten_runtime_nodejs" ]
}

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
ten_package_publish("upload_ten_nodejs_binding_system_package_to_server") {
base_dir =
rebase_path("${root_out_dir}/ten_packages/system/ten_runtime_nodejs")
Expand All @@ -42,7 +42,7 @@ if (ten_enable_package_manager) {
group("nodejs") {
deps = [ "native:ten_runtime_nodejs" ]

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
deps += [ ":upload_ten_nodejs_binding_system_package_to_server" ]
}
}
4 changes: 2 additions & 2 deletions core/src/ten_runtime/binding/python/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ten_package("ten_python_binding_system_package") {
deps = [ "native:ten_runtime_python" ]
}

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
ten_package_publish("upload_ten_python_binding_system_package_to_server") {
base_dir =
rebase_path("${root_out_dir}/ten_packages/system/ten_runtime_python")
Expand All @@ -44,7 +44,7 @@ if (ten_enable_package_manager) {
group("python") {
deps = [ "native:ten_runtime_python" ]

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
deps += [ ":upload_ten_python_binding_system_package_to_server" ]
}
}
18 changes: 17 additions & 1 deletion core/src/ten_rust/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ copy("ten_rust_test_data") {

if (ten_enable_ten_rust) {
if (ten_rust_enable_tests) {
rust_test("ten_rust_test") {
rust_test("ten_rust_test_cargo_build") {
project_path = "//core/src/ten_rust"
integration_test_output_name = "integration_test"

Expand All @@ -36,6 +36,22 @@ if (ten_enable_ten_rust) {
":ten_rust_test_data",
]
}

rust_clean("ten_rust_test_cargo_clean") {
project_path = "//core/src/ten_rust"
target_path = "${root_gen_dir}/core/src/ten_rust_test"

# Build ten_rust_test first, then `cargo clean` it.
deps = [ ":ten_rust_test_cargo_build" ]
}

group("ten_rust_test") {
if (ten_enable_cargo_clean) {
deps = [ ":ten_rust_test_cargo_clean" ]
} else {
deps = [ ":ten_rust_test_cargo_build" ]
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/ten_gn
4 changes: 2 additions & 2 deletions packages/core_apps/default_app_cpp/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ ten_package("default_app_cpp") {
]

deps = []
if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
deps +=
[ "//core/src/ten_runtime:upload_ten_runtime_system_package_to_server" ]
}
}

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
ten_package_publish("upload_default_app_cpp_to_server") {
base_dir = rebase_path("${root_out_dir}/app/default_app_cpp")
deps = [ ":default_app_cpp" ]
Expand Down
4 changes: 2 additions & 2 deletions packages/core_apps/default_app_go/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ ten_package("default_app_go") {
]

deps = [ "//core/src/ten_runtime/binding/go" ]
if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
deps +=
[ "//core/src/ten_runtime:upload_ten_runtime_system_package_to_server" ]
}
}

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
ten_package_publish("upload_default_app_go_to_server") {
base_dir = rebase_path("${root_out_dir}/app/default_app_go")
deps = [ ":default_app_go" ]
Expand Down
4 changes: 2 additions & 2 deletions packages/core_apps/default_app_python/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ ten_package("default_app_python") {
]

deps = [ "//core/src/ten_runtime/binding/python" ]
if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
deps +=
[ "//core/src/ten_runtime:upload_ten_runtime_system_package_to_server" ]
}
}

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
ten_package_publish("upload_default_app_python_to_server") {
base_dir = rebase_path("${root_out_dir}/app/default_app_python")
deps = [ ":default_app_python" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ten_package("default_async_extension_python") {
deps = [ "//core/src/ten_runtime" ]
}

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
ten_package_publish("upload_default_async_extension_python_to_server") {
base_dir = rebase_path(
"${root_out_dir}/ten_packages/extension/default_async_extension_python")
Expand Down
2 changes: 1 addition & 1 deletion packages/core_extensions/default_extension_cpp/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ten_package("default_extension_cpp") {
deps = [ ":copy_nlohmann_headers_for_default_extension_cpp" ]
}

if (ten_enable_package_manager) {
if (ten_enable_ten_manager) {
ten_package_publish("upload_default_extension_cpp_to_server") {
base_dir = rebase_path(
"${root_out_dir}/ten_packages/extension/default_extension_cpp")
Expand Down
Loading
Loading