Skip to content

Commit

Permalink
Merge branch 'main' into 267-protocols-connect_to-supports-retry-and-…
Browse files Browse the repository at this point in the history
…the-msgpack-protocol-should-have-retry-enabled-by-default
  • Loading branch information
sunxilin authored Nov 15, 2024
2 parents 93c7847 + fbc64eb commit f9710bc
Show file tree
Hide file tree
Showing 20 changed files with 267 additions and 1,358 deletions.
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_enable_libwebsockets=false && \
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_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 @@ -50,7 +50,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_private_tests=false ten_rust_enable_tests=false ten_enable_package_manager=false ten_rust_enable_gen_cargo_config=false
tgn gen linux x64 ${{ matrix.build_type }} -- is_clang=false log_level=1 enable_serialized_actions=true ten_enable_integration_tests=false ten_enable_private_tests=false ten_rust_enable_tests=false ten_enable_package_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 @@ -45,7 +45,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_enable_integration_tests=false ten_enable_private_tests=false ten_rust_enable_tests=false ten_package_manager_enable_tests=false ten_rust_enable_gen_cargo_config=false
tgn gen linux x64 ${{ matrix.build_type }} -- is_clang=${{ matrix.compiler == 'gcc' && 'false' || 'true' }} log_level=1 enable_serialized_actions=true ten_enable_integration_tests=false ten_enable_private_tests=false ten_rust_enable_tests=false ten_package_manager_enable_tests=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_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
fi
export PATH=$(pwd)/core/ten_gn:$PATH
echo $PATH
tgn gen mac arm64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_enable_integration_tests=false ten_enable_private_tests=false ten_rust_enable_tests=false ten_rust_enable_gen_cargo_config=false
tgn gen mac arm64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_enable_integration_tests=false ten_enable_private_tests=false ten_rust_enable_tests=false ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true
tgn build mac arm64 ${{ matrix.build_type }}
tree -I 'gen|obj' out
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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_enable_integration_tests=false ten_enable_private_tests=false ten_rust_enable_tests=false ten_package_manager_enable_tests=false ten_rust_enable_gen_cargo_config=false
tgn gen win x64 ${{ matrix.build_type }} -- vs_version=2022 log_level=1 enable_serialized_actions=true ten_enable_integration_tests=false ten_enable_private_tests=false ten_rust_enable_tests=false ten_package_manager_enable_tests=false ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true
tgn build win x64 ${{ matrix.build_type }}
- name: Run Tests (ten_utils_unit_test)
Expand Down
65 changes: 63 additions & 2 deletions build/common/rust/rust.gni
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import("//build/options.gni")
import("//build/ten_rust/options.gni")

template("rust_target") {
assert(defined(invoker.project_path), "project_file is not defined")
assert(defined(invoker.project_path), "project_path is not defined")
assert(defined(invoker.target_path), "target_path is not defined")
assert(defined(invoker.output_name), "output_name is not defined")

_target_name = target_name
target_path = target_gen_dir
target_path = invoker.target_path

action("${_target_name}") {
script = "//build/common/rust/rust.py"
Expand Down Expand Up @@ -479,3 +480,63 @@ template("rust_gen_cargo_config") {
outputs = [ _output ]
}
}

template("rust_clean") {
_project_path = rebase_path(invoker.project_path)
_target_path = rebase_path(invoker.target_path)

_target_name = target_name

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

args = [
"--project-path",
_project_path,
"--target-path",
_target_path,
"--tg-timestamp-proxy-file",
rebase_path(_output),
"--log-level",
"${log_level}",
]

if (is_win) {
if (target_cpu == "x86") {
target = "i686-pc-windows-msvc"
} else if (target_cpu == "x64") {
target = "x86_64-pc-windows-msvc"
} else if (target_cpu == "arm64") {
target = "aarch64-pc-windows-msvc"
}
} else if (is_linux) {
if (target_cpu == "arm64") {
target = "aarch64-unknown-linux-gnu"
} else if (target_cpu == "arm") {
target = "armv7-unknown-linux-gnueabi"
} else if (target_cpu == "x86") {
target = "i686-unknown-linux-gnu"
} else if (target_cpu == "x64") {
target = "x86_64-unknown-linux-gnu"
}
} else if (is_mac) {
if (target_cpu == "arm64") {
target = "aarch64-apple-darwin"
} else if (target_cpu == "x86") {
target = "i686-apple-darwin"
} else if (target_cpu == "x64") {
target = "x86_64-apple-darwin"
}
}

args += [
"--target",
target,
]

forward_variables_from(invoker, [ "deps" ])

outputs = [ _output ]
}
}
1 change: 0 additions & 1 deletion build/common/rust/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def __init__(self):
origin_wd = os.getcwd()

try:

os.chdir(args.project_path)

cmd = [
Expand Down
73 changes: 73 additions & 0 deletions build/common/rust/rust_clean.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# Copyright © 2024 Agora
# This file is part of TEN Framework, an open source project.
# Licensed under the Apache License, Version 2.0, with certain conditions.
# Refer to the "LICENSE" file in the root directory for more information.
#
import argparse
import sys
import os
from build.scripts import cmd_exec, timestamp_proxy


class ArgumentInfo(argparse.Namespace):
def __init__(self):
super().__init__()
self.project_path: str
self.target_path: str
self.target: str
self.log_level: int
self.tg_timestamp_proxy_file: str | None = None


if __name__ == "__main__":
parser = argparse.ArgumentParser()

parser.add_argument("--project-path", type=str, required=True)
parser.add_argument("--target-path", type=str, required=True)
parser.add_argument("--target", type=str, required=True)
parser.add_argument("--log-level", type=int, required=True)
parser.add_argument(
"--tg-timestamp-proxy-file", type=str, default="", required=False
)

arg_info = ArgumentInfo()
args = parser.parse_args(namespace=arg_info)

origin_wd = os.getcwd()

returncode = 0
try:
os.chdir(args.project_path)

cmd = [
"cargo",
"clean",
"--target-dir",
args.target_path,
"--target",
args.target,
]

returncode, logs = cmd_exec.run_cmd(cmd, args.log_level)
if returncode:
raise Exception(
f"Failed to run `cargo clean` on {args.project_path}: {logs}"
)
else:
print(logs)

# Success to clean the rust project, update the stamp file to represent
# this fact.
timestamp_proxy.touch_timestamp_proxy_file(args.tg_timestamp_proxy_file)

except Exception as exc:
returncode = 1
timestamp_proxy.remove_timestamp_proxy_file(
args.tg_timestamp_proxy_file
)
print(exc)

finally:
os.chdir(origin_wd)
sys.exit(-1 if returncode != 0 else 0)
6 changes: 2 additions & 4 deletions build/options.gni
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
#
declare_args() {
ten_enable_memory_check = true
}

declare_args() {
# The 'ten_rust' crate depends on the 'ten_utils' (C codes) static library.
# The C compiler supports AddressSanitizer on Linux x86, however the rustc
# does not. Therefore, the 'ten_rust' crate is disabled on x86.
#
# TODO(Liu): Add a gn target to compile the 'ten_utils' static without asan on
# x86.
ten_enable_ten_rust = !(enable_sanitizer && target_cpu == "x86")
}

declare_args() {
ten_enable_package_manager = true

ten_enable_cargo_clean = false
}
Loading

0 comments on commit f9710bc

Please sign in to comment.