Skip to content

Commit fa5661b

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

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+
# Note: Explicit environment reload needed for GitHub Actions
93+
# (wrapper function in .bashrc not working for non-interactive shells: docker exec cmd=[...])
94+
# We can fix this by updating entrypoint.sh to make ~/.profile source ~/.bashrc
95+
switch_config --ta no-std/arm32 && \
96+
switch_config --host arm32 && \
97+
source ${TEACLAVE_TOOLCHAIN_BASE}/environment && \
98+
./ci/build.sh --ta arm --ca arm
99+
100+
# Test cargo-optee build std examples - aarch64
101+
test-cargo-optee-std-aarch64:
102+
runs-on: ubuntu-latest
103+
container:
104+
image: teaclave/teaclave-trustzone-emulator-std-expand-memory:latest
105+
steps:
106+
- name: Checkout repository
107+
uses: actions/checkout@v4
108+
- name: Setup environment
109+
run: |
110+
# Run entrypoint.sh to set up the bash profile
111+
/entrypoint.sh true
112+
# Install jq for JSON parsing
113+
apt-get update && apt-get install -y jq
114+
- name: Test cargo-optee std build (aarch64)
115+
shell: bash -l {0} # Use login shell to load the profile
116+
run: |
117+
# Link rust directory for std support
118+
ln -s $RUST_STD_DIR rust
119+
# Build using cargo-optee tool with default aarch64 std settings
120+
./ci/build.sh --std
84121
85-
# Test build std examples on dev docker container
86-
test-std-build-on-dev-docker:
122+
# Test cargo-optee build std examples - arm32
123+
test-cargo-optee-std-arm32:
87124
runs-on: ubuntu-latest
88125
container:
89-
image: teaclave/teaclave-trustzone-emulator-std-optee-4.7.0-expand-memory:latest
126+
image: teaclave/teaclave-trustzone-emulator-std-expand-memory:latest
90127
steps:
91128
- name: Checkout repository
92129
uses: actions/checkout@v4
93130
- name: Setup environment
94131
run: |
95132
# Run entrypoint.sh to set up the bash profile
96133
/entrypoint.sh true
97-
- name: Build no-std and common examples
134+
# Install jq for JSON parsing
135+
apt-get update && apt-get install -y jq
136+
- name: Test cargo-optee std build (arm32)
98137
shell: bash -l {0} # Use login shell to load the profile
99138
run: |
139+
# Link rust directory for std support
100140
ln -s $RUST_STD_DIR rust
101-
make std-examples
141+
# Switch to ARM32 std configuration and build
142+
# Note: Explicit environment reload needed for GitHub Actions
143+
# (wrapper function in .bashrc not working for non-interactive shells: docker exec cmd=[...])
144+
# We can fix this by updating entrypoint.sh to make ~/.profile source ~/.bashrc
145+
switch_config --ta std/arm32 && \
146+
switch_config --host arm32 && \
147+
source ${TEACLAVE_TOOLCHAIN_BASE}/environment && \
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)