Skip to content

Commit 4a18fd6

Browse files
committed
Let nbuild set the start address to anything
1 parent 2587e64 commit 4a18fd6

File tree

11 files changed

+249
-487
lines changed

11 files changed

+249
-487
lines changed

.github/workflows/rust.yml

Lines changed: 61 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,78 +3,82 @@ name: Build
33
on: [push, pull_request]
44

55
jobs:
6-
build:
7-
name: Build (and Release)
6+
binaries:
7+
name: Build Binaries
8+
strategy:
9+
matrix:
10+
target: [thumbv6m-none-eabi, thumbv7em-none-eabi, thumbv8m.main-none-eabi]
11+
start_address: [0x0802_0000, 0x1002_0000]
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
submodules: true
17+
- run: |
18+
rustup target add ${{ matrix.target }}
19+
cargo nbuild binaries --target=${{ matrix.target }} --start-address=${{ matrix.start_address }}
20+
- name: Upload Artifacts
21+
uses: actions/upload-artifact@v4
22+
if: ${{success()}}
23+
with:
24+
name: ${{ matrix.target }}-${{ matrix.start_address }}-binaries
25+
if-no-files-found: error
26+
path: |
27+
./target/${{ matrix.target }}/release/neotron-os
28+
linux-libraries:
829
runs-on: ubuntu-latest
930
steps:
1031
- name: Checkout
1132
uses: actions/checkout@v4
1233
with:
1334
submodules: true
14-
15-
- name: Check Syntax
16-
run: |
17-
cargo check
18-
19-
- name: Test
20-
run: |
21-
cargo test --lib
22-
23-
- name: Install Targets and Tools
24-
run: |
25-
rustup toolchain install stable --profile minimal --no-self-update
26-
rustup default stable
27-
rustup target add thumbv7em-none-eabi
28-
rustup target add thumbv7m-none-eabi
29-
rustup target add thumbv6m-none-eabi
30-
rustup component add llvm-tools-preview
31-
echo CARGO_INCREMENTAL=0 >> $GITHUB_ENV
32-
echo CARGO_TERM_COLOR=always >> $GITHUB_ENV
33-
34-
- name: Install tools
35-
uses: taiki-e/install-action@v2
35+
- name: Build
36+
run: cargo nbuild libraries
37+
- name: Upload Artifacts
38+
uses: actions/upload-artifact@v4
39+
if: ${{success()}}
3640
with:
37-
tool: cargo-binutils@0.3.6
38-
39-
- name: Install ROMFS tools
40-
run: |
41-
cargo install neotron-romfs-lsfs
42-
cargo install neotron-romfs-mkfs
43-
41+
name: linux-libraries
42+
if-no-files-found: error
43+
path: |
44+
./target/release/libneotron_os.so
45+
windows-libraries:
46+
runs-on: windows-latest
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
with:
51+
submodules: true
4452
- name: Build
45-
run: |
46-
./build.sh --verbose
47-
53+
run: cargo nbuild libraries
4854
- name: Upload Artifacts
4955
uses: actions/upload-artifact@v4
5056
if: ${{success()}}
5157
with:
52-
name: Artifacts
58+
name: windows-libraries
5359
if-no-files-found: error
5460
path: |
55-
./release/
56-
61+
./target/release/neotron_os.dll
62+
run-tests:
63+
steps:
64+
- uses: actions/checkout@v4
65+
with:
66+
submodules: true
67+
- run: cargo nbuild test
68+
release:
69+
name: Upload Release
70+
needs: [binaries, linux-libraries, windows-libraries]
71+
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
72+
steps:
73+
- name: Make release area
74+
run: |
75+
mkdir ./release
76+
- name: Download Artifacts
77+
uses: actions/download-artifact@v4
78+
with:
79+
path: ./release
5780
- name: Upload files to Release
58-
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
5981
uses: softprops/action-gh-release@v1
6082
with:
6183
files: |
62-
./release/thumbv6m-none-eabi-flash0002-libneotron_os.bin
63-
./release/thumbv6m-none-eabi-flash0002-libneotron_os.elf
64-
./release/thumbv6m-none-eabi-flash0802-libneotron_os.bin
65-
./release/thumbv6m-none-eabi-flash0802-libneotron_os.elf
66-
./release/thumbv6m-none-eabi-flash1002-libneotron_os.bin
67-
./release/thumbv6m-none-eabi-flash1002-libneotron_os.elf
68-
./release/thumbv7em-none-eabi-flash0002-libneotron_os.bin
69-
./release/thumbv7em-none-eabi-flash0002-libneotron_os.elf
70-
./release/thumbv7em-none-eabi-flash0802-libneotron_os.bin
71-
./release/thumbv7em-none-eabi-flash0802-libneotron_os.elf
72-
./release/thumbv7em-none-eabi-flash1002-libneotron_os.bin
73-
./release/thumbv7em-none-eabi-flash1002-libneotron_os.elf
74-
./release/thumbv7m-none-eabi-flash0002-libneotron_os.bin
75-
./release/thumbv7m-none-eabi-flash0002-libneotron_os.elf
76-
./release/thumbv7m-none-eabi-flash0802-libneotron_os.bin
77-
./release/thumbv7m-none-eabi-flash0802-libneotron_os.elf
78-
./release/thumbv7m-none-eabi-flash1002-libneotron_os.bin
79-
./release/thumbv7m-none-eabi-flash1002-libneotron_os.elf
80-
./release/x86_64-unknown-linux-gnu-libneotron_os.so
84+
./release/*

nbuild/src/lib.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@ impl std::fmt::Display for CargoError {
2020
}
2121
}
2222

23+
/// The kinds of package we have
24+
#[derive(Debug, PartialEq, Eq)]
25+
pub enum PackageKind {
26+
Os,
27+
Utility,
28+
NBuild,
29+
}
30+
31+
/// Describes a package in this repository
32+
#[derive(Debug)]
33+
pub struct Package {
34+
pub name: &'static str,
35+
pub path: &'static std::path::Path,
36+
pub output: &'static std::path::Path,
37+
pub kind: PackageKind,
38+
}
39+
2340
/// Parse an integer, with an optional `0x` prefix.
2441
///
2542
/// Underscores are ignored.
@@ -37,12 +54,25 @@ where
3754
if let Some(suffix) = input.strip_prefix("0x") {
3855
u32::from_str_radix(suffix, 16)
3956
} else {
40-
u32::from_str_radix(&input, 10)
57+
input.parse()
4158
}
4259
}
4360

4461
/// Runs cargo
4562
pub fn cargo<P>(commands: &[&str], target: Option<&str>, manifest_path: P) -> Result<(), CargoError>
63+
where
64+
P: AsRef<std::path::Path>,
65+
{
66+
cargo_with_env(commands, target, manifest_path, &[])
67+
}
68+
69+
/// Runs cargo with extra environment variables
70+
pub fn cargo_with_env<P>(
71+
commands: &[&str],
72+
target: Option<&str>,
73+
manifest_path: P,
74+
environment: &[(&'static str, String)],
75+
) -> Result<(), CargoError>
4676
where
4777
P: AsRef<std::path::Path>,
4878
{
@@ -56,6 +86,9 @@ where
5686
}
5787
command_line.arg("--manifest-path");
5888
command_line.arg(manifest_path.as_ref());
89+
for (k, v) in environment.into_iter() {
90+
command_line.env(k, v);
91+
}
5992

6093
println!("Running: {:?}", command_line);
6194

0 commit comments

Comments
 (0)