Skip to content

Commit de40647

Browse files
committed
enable ci, remove all Makefiles
1 parent 15ec911 commit de40647

File tree

89 files changed

+154
-4032
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+154
-4032
lines changed

.github/workflows/ci.yml

Lines changed: 71 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ defaults:
2828
shell: bash
2929

3030
jobs:
31-
# Run test on AMD64 host
32-
test-on-amd64-host:
33-
uses: ./.github/workflows/reuse_test.yml
34-
with:
35-
runs-on: ubuntu-latest
36-
container: ghcr.io/ivila/teaclave-trustzone-sdk-ci-runner:ubuntu-24.04
37-
38-
# Run test on ARM64 host
39-
test-on-arm64-host:
40-
uses: ./.github/workflows/reuse_test.yml
41-
with:
42-
runs-on: ubuntu-24.04-arm
43-
container: ghcr.io/ivila/teaclave-trustzone-sdk-ci-runner:ubuntu-24.04
44-
4531
# Run systest of optee_teec and build systest of optee_utee on ARM64
4632
systest:
4733
runs-on: ubuntu-24.04-arm
@@ -65,40 +51,101 @@ jobs:
6551
(cd optee-teec && cargo run -p systest)
6652
(cd optee-utee && cargo build -p systest)
6753
68-
# Test build no-std examples on dev docker container
69-
test-nostd-build-on-dev-docker:
54+
# Test cargo-optee build no-std examples - aarch64
55+
test-cargo-optee-nostd-aarch64:
56+
runs-on: ubuntu-latest
57+
container:
58+
image: teaclave/teaclave-trustzone-emulator-nostd-expand-memory:latest
59+
steps:
60+
- name: Checkout repository
61+
uses: actions/checkout@v4
62+
- name: Setup environment
63+
run: |
64+
# Run entrypoint.sh to set up the bash profile
65+
/entrypoint.sh true
66+
# Install jq for JSON parsing
67+
apt-get update && apt-get install -y jq
68+
- name: Test cargo-optee no-std build (aarch64)
69+
shell: bash -l {0} # Use login shell to load the profile
70+
run: |
71+
# Build using cargo-optee tool with default aarch64 settings
72+
./ci/build.sh
73+
74+
# Test cargo-optee build no-std examples - arm32
75+
test-cargo-optee-nostd-arm32:
7076
runs-on: ubuntu-latest
7177
container:
72-
image: teaclave/teaclave-trustzone-emulator-nostd-optee-4.7.0-expand-memory:latest
78+
image: teaclave/teaclave-trustzone-emulator-nostd-expand-memory:latest
7379
steps:
7480
- name: Checkout repository
7581
uses: actions/checkout@v4
7682
- name: Setup environment
7783
run: |
7884
# Run entrypoint.sh to set up the bash profile
7985
/entrypoint.sh true
80-
- name: Build no-std and common examples
86+
# Install jq for JSON parsing
87+
apt-get update && apt-get install -y jq
88+
- name: Test cargo-optee no-std build (arm32)
8189
shell: bash -l {0} # Use login shell to load the profile
8290
run: |
83-
make
91+
# Switch to ARM32 configuration and build
92+
switch_config --ta no-std/arm32 && \
93+
switch_config --host arm32 && \
94+
source ${TEACLAVE_TOOLCHAIN_BASE}/environment && \
95+
./ci/build.sh --ta arm --ca arm
96+
97+
# Test cargo-optee build std examples - aarch64
98+
test-cargo-optee-std-aarch64:
99+
runs-on: ubuntu-latest
100+
container:
101+
image: teaclave/teaclave-trustzone-emulator-std-expand-memory:latest
102+
steps:
103+
- name: Checkout repository
104+
uses: actions/checkout@v4
105+
- name: Setup environment
106+
run: |
107+
# Run entrypoint.sh to set up the bash profile
108+
/entrypoint.sh true
109+
# Install jq for JSON parsing
110+
apt-get update && apt-get install -y jq
111+
- name: Test cargo-optee std build (aarch64)
112+
shell: bash -l {0} # Use login shell to load the profile
113+
run: |
114+
# Link rust directory for std support
115+
ln -s $RUST_STD_DIR rust
116+
# Build using cargo-optee tool with default aarch64 std settings
117+
./ci/build.sh --std
84118
85-
# Test build std examples on dev docker container
86-
test-std-build-on-dev-docker:
119+
# Test cargo-optee build std examples - arm32
120+
test-cargo-optee-std-arm32:
87121
runs-on: ubuntu-latest
88122
container:
89-
image: teaclave/teaclave-trustzone-emulator-std-optee-4.7.0-expand-memory:latest
123+
image: teaclave/teaclave-trustzone-emulator-std-expand-memory:latest
90124
steps:
91125
- name: Checkout repository
92126
uses: actions/checkout@v4
93127
- name: Setup environment
94128
run: |
95129
# Run entrypoint.sh to set up the bash profile
96130
/entrypoint.sh true
97-
- name: Build no-std and common examples
131+
# Install jq for JSON parsing
132+
apt-get update && apt-get install -y jq
133+
- name: Test cargo-optee std build (arm32)
98134
shell: bash -l {0} # Use login shell to load the profile
99135
run: |
136+
# Link rust directory for std support
100137
ln -s $RUST_STD_DIR rust
101-
make std-examples
138+
# Debug: Check if switch_config function exists
139+
echo "DEBUG: Checking switch_config function..."
140+
declare -f switch_config >/dev/null && echo "switch_config function EXISTS" || echo "switch_config function MISSING"
141+
type switch_config || echo "switch_config not found"
142+
# Switch to ARM32 std configuration and build
143+
switch_config --ta std/arm32 && \
144+
switch_config --host arm32 && \
145+
source ${TEACLAVE_TOOLCHAIN_BASE}/environment && \
146+
echo "DEBUG: After switch - TA_DEV_KIT_DIR=$TA_DEV_KIT_DIR" && \
147+
echo "DEBUG: After switch - OPTEE_CLIENT_EXPORT=$OPTEE_CLIENT_EXPORT" && \
148+
./ci/build.sh --ta arm --ca arm --std
102149
103150
license:
104151
runs-on: ubuntu-latest

Makefile

Lines changed: 0 additions & 99 deletions
This file was deleted.

cargo-optee/src/main.rs

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,25 +153,60 @@ enum Command {
153153
Build(BuildCommand),
154154
}
155155

156+
/// Source cargo environment from a given path
157+
fn source_cargo_env(env_path: &str) -> bool {
158+
if std::path::Path::new(env_path).exists() {
159+
std::process::Command::new("bash")
160+
.arg("-c")
161+
.arg(format!("source {}", env_path))
162+
.status()
163+
.map(|status| status.success())
164+
.unwrap_or(false)
165+
} else {
166+
false
167+
}
168+
}
169+
170+
/// Setup cargo environment by checking availability and sourcing environment if needed
171+
fn setup_cargo_environment() -> anyhow::Result<()> {
172+
// Check if cargo is available
173+
let cargo_available = std::process::Command::new("which")
174+
.arg("cargo")
175+
.output()
176+
.map(|output| output.status.success())
177+
.unwrap_or(false);
178+
179+
if cargo_available {
180+
return Ok(());
181+
}
182+
183+
// Try to source .cargo/env from ~/.cargo/env or $CARGO_HOME/env
184+
let mut sourced = false;
185+
if let Ok(home) = env::var("HOME") {
186+
sourced = source_cargo_env(&format!("{}/.cargo/env", home));
187+
}
188+
if !sourced {
189+
if let Ok(cargo_home) = env::var("CARGO_HOME") {
190+
sourced = source_cargo_env(&format!("{}/env", cargo_home));
191+
}
192+
}
193+
194+
if !sourced {
195+
anyhow::bail!("cargo command not found. Please install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh");
196+
}
197+
198+
Ok(())
199+
}
200+
156201
fn main() {
157202
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))
158203
.format_timestamp_millis()
159204
.init();
160205

161-
// Setup cargo environment if needed
162-
if let Ok(home) = env::var("HOME") {
163-
let cargo_env = format!("{}/.cargo/env", home);
164-
if std::path::Path::new(&cargo_env).exists() {
165-
// Add cargo bin to PATH
166-
let cargo_bin = format!("{}/.cargo/bin", home);
167-
if let Ok(current_path) = env::var("PATH") {
168-
let new_path = format!("{}:{}", cargo_bin, current_path);
169-
env::set_var("PATH", new_path);
170-
}
171-
} else {
172-
eprintln!("Error: Cargo environment file not found at: {}. Please ensure Rust and Cargo are installed.", cargo_env);
173-
process::exit(1);
174-
}
206+
// Setup cargo environment
207+
if let Err(e) = setup_cargo_environment() {
208+
eprintln!("Error: {}", e);
209+
process::exit(1);
175210
}
176211

177212
let cli = Cli::parse();

0 commit comments

Comments
 (0)