diff --git a/.cargo/config b/.cargo/config index 757fd081..dbd1a2b4 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,5 +1,7 @@ [alias] xtask = "run --package xtask --" +build-bpfel = "build -Zbuild-std=core --target=bpfel-unknown-none" +build-bpfeb = "build -Zbuild-std=core --target=bpfeb-unknown-none" [target.armv7-unknown-linux-gnueabi] linker = "arm-linux-gnueabi-gcc" diff --git a/.github/workflows/build-aya-bpf.yml b/.github/workflows/build-aya-bpf.yml index e520833d..a29d7c09 100644 --- a/.github/workflows/build-aya-bpf.yml +++ b/.github/workflows/build-aya-bpf.yml @@ -31,59 +31,19 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: nightly + components: rust-src override: true - uses: Swatinem/rust-cache@v1 - name: Prereqs - run: cargo install cross --git https://github.com/cross-rs/cross + run: cargo install bpf-linker - name: Build env: CARGO_CFG_BPF_TARGET_ARCH: ${{ matrix.arch }} run: | - pushd bpf - cargo build --workspace --exclude aya-bpf-macros --verbose - popd - - - name: Run tests - env: - CARGO_CFG_BPF_TARGET_ARCH: ${{ matrix.arch }} - run: | - pushd bpf - cargo test --workspace --exclude aya-bpf-macros --verbose - popd - - build-macros: - strategy: - matrix: - arch: - - x86_64-unknown-linux-gnu - - aarch64-unknown-linux-gnu - - armv7-unknown-linux-gnueabi - - riscv64gc-unknown-none-elf - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - - uses: Swatinem/rust-cache@v1 - - - name: Prereqs - run: cargo install cross --git https://github.com/cross-rs/cross - - - name: Build bpf macros - run: | - pushd bpf - cross build -p aya-bpf-macros --verbose - popd - - - name: Test bpf macros - run: | - pushd bpf - RUST_BACKTRACE=full cross test -p aya-bpf-macros --verbose - popd + cargo build-bpfel -p aya-bpf --verbose + cargo build-bpfeb -p aya-bpf --verbose + cargo build-bpfel -p aya-log-ebpf --verbose + cargo build-bpfeb -p aya-log-ebpf --verbose diff --git a/.github/workflows/build-aya.yml b/.github/workflows/build-aya.yml index 9d523875..c16373a7 100644 --- a/.github/workflows/build-aya.yml +++ b/.github/workflows/build-aya.yml @@ -21,19 +21,38 @@ jobs: - x86_64-unknown-linux-gnu - aarch64-unknown-linux-gnu - armv7-unknown-linux-gnueabi - - riscv64gc-unknown-none-elf + - riscv64gc-unknown-linux-gnu runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + override: false + - uses: Swatinem/rust-cache@v1 - name: Prereqs run: cargo install cross --git https://github.com/cross-rs/cross - name: Build - run: cross build --verbose + run: cross build --verbose --target ${{matrix.arch}} - name: Run test - run: RUST_BACKTRACE=full cross test --verbose + env: + RUST_BACKTRACE: full + run: | + cross test --verbose -p aya --target ${{matrix.arch}} + cross test --verbose -p aya-gen --target ${{matrix.arch}} + cross test --verbose -p aya-log --target ${{matrix.arch}} + cross test --verbose -p aya-log-ebpf-macros --target ${{matrix.arch}} + # aya-bpf-macros can only be tested on nightly since its tests depend on aya-bpf, which requires the never type + cross +nightly test --verbose -p aya-bpf-macros --target ${{matrix.arch}} test: runs-on: ubuntu-20.04 @@ -60,12 +79,10 @@ jobs: sudo apt-get -qy install linux-tools-common qemu-system-x86 cloud-image-utils openssh-client libelf-dev gcc-multilib cargo install bpf-linker - - name: Lint integration tests run: | cargo xtask build-integration-test-ebpf --libbpf-dir ./libbpf cargo clippy -p integration-test -- --deny warnings - cargo clippy -p integration-test-macros -- --deny warnings - name: Run integration tests run: | diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ffb10c76..afe47cf0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,22 +30,11 @@ jobs: - name: Check formatting run: | cargo fmt --all -- --check - (cd bpf && cargo fmt --all -- --check) - (cd test/integration-ebpf && cargo fmt --all -- --check) - name: Run clippy run: | - cargo clippy -p aya -- --deny warnings - cargo clippy -p aya-gen -- --deny warnings - cargo clippy -p xtask -- --deny warnings - (cd bpf && cargo clippy -p aya-bpf -- --deny warnings) - (cd test/integration-ebpf && cargo clippy -- --deny warnings) + cargo clippy --workspace --exclude integration-test -- --deny warnings - name: Run miri - env: - MIRIFLAGS: -Zmiri-disable-stacked-borrows run: | - cargo miri test --all-targets - pushd bpf - cargo miri test - popd + cargo miri test --all-targets \ No newline at end of file diff --git a/.vim/coc-settings.json b/.vim/coc-settings.json index 4b796ccb..07c919f9 100644 --- a/.vim/coc-settings.json +++ b/.vim/coc-settings.json @@ -1,4 +1,4 @@ { - "rust-analyzer.linkedProjects": ["Cargo.toml", "bpf/Cargo.toml", "test/integration-ebpf/Cargo.toml"], - "rust-analyzer.checkOnSave.allTargets": false + "rust-analyzer.checkOnSave.allTargets": false, + "rust-analyzer.checkOnSave.command": "clippy" } diff --git a/.vscode/settings.json b/.vscode/settings.json index 4b796ccb..07c919f9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ { - "rust-analyzer.linkedProjects": ["Cargo.toml", "bpf/Cargo.toml", "test/integration-ebpf/Cargo.toml"], - "rust-analyzer.checkOnSave.allTargets": false + "rust-analyzer.checkOnSave.allTargets": false, + "rust-analyzer.checkOnSave.command": "clippy" } diff --git a/Cargo.toml b/Cargo.toml index c5a9a2e0..61c3b7df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,22 @@ [workspace] -members = ["aya", "aya-gen", "test/integration-test", "test/integration-test-macros", "xtask"] -default-members = ["aya", "aya-gen"] +members = [ + "aya", "aya-gen", "aya-log", "aya-log-common", "test/integration-test", "test/integration-test-macros", "xtask", + # macros + "aya-bpf-macros", "aya-log-ebpf-macros", + # ebpf crates + "bpf/aya-bpf", "bpf/aya-bpf-bindings", "bpf/aya-log-ebpf", "test/integration-ebpf" +] +default-members = ["aya", "aya-gen", "aya-log", "aya-bpf-macros", "aya-log-ebpf-macros"] + +[profile.dev] +panic = "abort" + +[profile.release] +panic = "abort" + +[profile.dev.package.integration-ebpf] +opt-level = 2 +overflow-checks = false + +[profile.release.package.integration-ebpf] +debug = 2 \ No newline at end of file diff --git a/bpf/aya-bpf-macros/Cargo.toml b/aya-bpf-macros/Cargo.toml similarity index 87% rename from bpf/aya-bpf-macros/Cargo.toml rename to aya-bpf-macros/Cargo.toml index 9c43f7bd..929098ee 100644 --- a/bpf/aya-bpf-macros/Cargo.toml +++ b/aya-bpf-macros/Cargo.toml @@ -13,4 +13,4 @@ quote = "1.0" syn = {version = "1.0", features = ["full"]} [dev-dependencies] -aya-bpf = { path = "../aya-bpf" } +aya-bpf = { path = "../bpf/aya-bpf" } diff --git a/bpf/aya-bpf-macros/src/expand.rs b/aya-bpf-macros/src/expand.rs similarity index 100% rename from bpf/aya-bpf-macros/src/expand.rs rename to aya-bpf-macros/src/expand.rs diff --git a/bpf/aya-bpf-macros/src/lib.rs b/aya-bpf-macros/src/lib.rs similarity index 100% rename from bpf/aya-bpf-macros/src/lib.rs rename to aya-bpf-macros/src/lib.rs diff --git a/aya-log/aya-log-common/Cargo.toml b/aya-log-common/Cargo.toml similarity index 87% rename from aya-log/aya-log-common/Cargo.toml rename to aya-log-common/Cargo.toml index a3a54d8c..4b50e2a1 100644 --- a/aya-log/aya-log-common/Cargo.toml +++ b/aya-log-common/Cargo.toml @@ -14,7 +14,7 @@ default = [] userspace = [ "aya" ] [dependencies] -aya = { version = "0.11.0", optional=true } +aya = { path = "../aya", version = "0.11.0", optional=true } [lib] path = "src/lib.rs" diff --git a/aya-log-common/release.toml b/aya-log-common/release.toml new file mode 100644 index 00000000..bf6eaefc --- /dev/null +++ b/aya-log-common/release.toml @@ -0,0 +1 @@ +shared-version = true diff --git a/aya-log/aya-log-common/src/lib.rs b/aya-log-common/src/lib.rs similarity index 100% rename from aya-log/aya-log-common/src/lib.rs rename to aya-log-common/src/lib.rs diff --git a/aya-log/ebpf/aya-log-ebpf-macros/Cargo.toml b/aya-log-ebpf-macros/Cargo.toml similarity index 100% rename from aya-log/ebpf/aya-log-ebpf-macros/Cargo.toml rename to aya-log-ebpf-macros/Cargo.toml diff --git a/aya-log/ebpf/aya-log-ebpf-macros/src/expand.rs b/aya-log-ebpf-macros/src/expand.rs similarity index 100% rename from aya-log/ebpf/aya-log-ebpf-macros/src/expand.rs rename to aya-log-ebpf-macros/src/expand.rs diff --git a/aya-log/ebpf/aya-log-ebpf-macros/src/lib.rs b/aya-log-ebpf-macros/src/lib.rs similarity index 100% rename from aya-log/ebpf/aya-log-ebpf-macros/src/lib.rs rename to aya-log-ebpf-macros/src/lib.rs diff --git a/aya-log/.cargo/config.toml b/aya-log/.cargo/config.toml deleted file mode 100644 index f0ccbc9a..00000000 --- a/aya-log/.cargo/config.toml +++ /dev/null @@ -1,2 +0,0 @@ -[alias] -xtask = "run --package xtask --" \ No newline at end of file diff --git a/aya-log/.github/dependabot.yml b/aya-log/.github/dependabot.yml deleted file mode 100644 index 08c94a23..00000000 --- a/aya-log/.github/dependabot.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Please see the documentation for all configuration options: -# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - -version: 2 -updates: - - package-ecosystem: "cargo" - directory: "/" - schedule: - interval: "weekly" diff --git a/aya-log/.github/workflows/build-bpf.yml b/aya-log/.github/workflows/build-bpf.yml deleted file mode 100644 index 002e965d..00000000 --- a/aya-log/.github/workflows/build-bpf.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: build-bpf - -on: - push: - branches: - - main - - pull_request: - branches: - - main - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - components: rust-src - override: true - - - uses: Swatinem/rust-cache@v1 - - - name: Pre-requisites - run: cargo install bpf-linker - - - name: Build - run: | - pushd ebpf - cargo build --verbose - popd diff --git a/aya-log/.github/workflows/build.yml b/aya-log/.github/workflows/build.yml deleted file mode 100644 index dd031044..00000000 --- a/aya-log/.github/workflows/build.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: build - -on: - push: - branches: - - main - - pull_request: - branches: - - main - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: Swatinem/rust-cache@v1 - - - name: Build - run: cargo build --verbose - - - name: Run tests - run: RUST_BACKTRACE=full cargo test --verbose diff --git a/aya-log/.github/workflows/lint.yml b/aya-log/.github/workflows/lint.yml deleted file mode 100644 index 169b536e..00000000 --- a/aya-log/.github/workflows/lint.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: lint - -on: - push: - branches: - - main - - pull_request: - branches: - - main - -env: - CARGO_TERM_COLOR: always - -jobs: - lint: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - components: rustfmt, clippy, rust-src - override: true - - - name: Check formatting - run: | - cargo fmt --all -- --check - pushd ebpf - cargo fmt --all -- --check - popd - - - name: Run clippy - run: | - cargo clippy -- --deny warnings - pushd ebpf - cargo clippy -- --deny warnings - popd diff --git a/aya-log/.gitignore b/aya-log/.gitignore deleted file mode 100644 index 54f741e1..00000000 --- a/aya-log/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -### https://raw.github.com/github/gitignore/master/Rust.gitignore - -# Generated by Cargo -# will have compiled files and executables -debug/ -target/ - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - -# These are backup files generated by rustfmt -**/*.rs.bk diff --git a/aya-log/.vim/coc-settings.json b/aya-log/.vim/coc-settings.json deleted file mode 100644 index f8d723bb..00000000 --- a/aya-log/.vim/coc-settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "rust-analyzer.linkedProjects": ["Cargo.toml", "ebpf/Cargo.toml"] -} diff --git a/aya-log/.vscode/settings.json b/aya-log/.vscode/settings.json deleted file mode 100644 index f8d723bb..00000000 --- a/aya-log/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "rust-analyzer.linkedProjects": ["Cargo.toml", "ebpf/Cargo.toml"] -} diff --git a/aya-log/Cargo.toml b/aya-log/Cargo.toml index a8e5e117..701f3adb 100644 --- a/aya-log/Cargo.toml +++ b/aya-log/Cargo.toml @@ -1,2 +1,27 @@ -[workspace] -members = ["aya-log", "aya-log-common", "xtask"] +[package] +name = "aya-log" +version = "0.1.11-dev.0" +description = "A logging library for eBPF programs." +keywords = ["ebpf", "bpf", "log", "logging"] +license = "MIT OR Apache-2.0" +authors = ["The Aya Contributors"] +repository = "https://github.com/aya-rs/aya-log" +readme = "README.md" +documentation = "https://docs.rs/aya-log" +edition = "2018" + +[dependencies] +aya = { path = "../aya", version = "0.11.0", features=["async_tokio"] } +aya-log-common = { path = "../aya-log-common", version = "0.1.11-dev.0", features=["userspace"] } +dyn-fmt = "0.3.0" +thiserror = "1" +log = "0.4" +bytes = "1.1" +tokio = { version = "1.2.0" } + +[dev-dependencies] +simplelog = "0.12" +testing_logger = "0.1.1" + +[lib] +path = "src/lib.rs" diff --git a/aya-log/aya-log/Cargo.toml b/aya-log/aya-log/Cargo.toml deleted file mode 100644 index 605386d4..00000000 --- a/aya-log/aya-log/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "aya-log" -version = "0.1.11-dev.0" -description = "A logging library for eBPF programs." -keywords = ["ebpf", "bpf", "log", "logging"] -license = "MIT OR Apache-2.0" -authors = ["The Aya Contributors"] -repository = "https://github.com/aya-rs/aya-log" -readme = "README.md" -documentation = "https://docs.rs/aya-log" -edition = "2018" - -[dependencies] -aya = { version = "0.11.0", features=["async_tokio"] } -aya-log-common = { version = "0.1.11-dev.0", path = "../aya-log-common", features=["userspace"] } -dyn-fmt = "0.3.0" -thiserror = "1" -log = "0.4" -bytes = "1.1" -tokio = { version = "1.2.0" } - -[dev-dependencies] -simplelog = "0.12" -testing_logger = "0.1.1" - -[lib] -path = "src/lib.rs" diff --git a/aya-log/aya-log/README.md b/aya-log/aya-log/README.md deleted file mode 100644 index 5e1245ca..00000000 --- a/aya-log/aya-log/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# aya-log - a logging library for eBPF programs - -## Overview - -`aya-log` is a logging library for eBPF programs written using [aya]. Think of -it as the [log] crate for eBPF. - -## Installation - -### User space - -Add `aya-log` to `Cargo.toml`: - -```toml -[dependencies] -aya-log = { git = "https://github.com/aya-rs/aya-log", branch = "main" } -``` - -### eBPF side - -Add `aya-log-ebpf` to `Cargo.toml`: - -```toml -[dependencies] -aya-log-ebpf = { git = "https://github.com/aya-rs/aya-log", branch = "main" } -``` - -## Example - -Here's an example that uses `aya-log` in conjunction with the [simplelog] crate -to log eBPF messages to the terminal. - -### User space code - -```rust -use simplelog::{ColorChoice, ConfigBuilder, LevelFilter, TermLogger, TerminalMode}; -use aya_log::BpfLogger; - -TermLogger::init( - LevelFilter::Debug, - ConfigBuilder::new() - .set_target_level(LevelFilter::Error) - .set_location_level(LevelFilter::Error) - .build(), - TerminalMode::Mixed, - ColorChoice::Auto, -) -.unwrap(); - -// Will log using the default logger, which is TermLogger in this case -BpfLogger::init(&mut bpf).unwrap(); -``` - -### eBPF code - -```rust -use aya_log_ebpf::info; - -fn try_xdp_firewall(ctx: XdpContext) -> Result { - if let Some(port) = tcp_dest_port(&ctx)? { - if block_port(port) { - info!(&ctx, "❌ blocked incoming connection on port: {}", port); - return Ok(XDP_DROP); - } - } - - Ok(XDP_PASS) -} -``` - -[aya]: https://github.com/aya-rs/aya -[log]: https://docs.rs/log -[simplelog]: https://docs.rs/simplelog diff --git a/aya-log/ebpf/Cargo.toml b/aya-log/ebpf/Cargo.toml deleted file mode 100644 index d29c15e0..00000000 --- a/aya-log/ebpf/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[workspace] -members = ["aya-log-ebpf", "aya-log-ebpf-macros", "example"] - - -[profile.dev] -panic = "abort" -debug = 1 -opt-level = 2 -overflow-checks = false - -[profile.release] -panic = "abort" diff --git a/aya-log/ebpf/example/Cargo.toml b/aya-log/ebpf/example/Cargo.toml deleted file mode 100644 index e78d7049..00000000 --- a/aya-log/ebpf/example/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "example" -version = "0.1.0" -edition = "2018" -publish = false - -[dependencies] -aya-bpf = { git = "https://github.com/aya-rs/aya", branch = "main" } -aya-log-ebpf = { path = "../aya-log-ebpf" } - -[[bin]] -name = "example" -path = "src/main.rs" diff --git a/aya-log/ebpf/example/src/main.rs b/aya-log/ebpf/example/src/main.rs deleted file mode 100644 index b43b5364..00000000 --- a/aya-log/ebpf/example/src/main.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![no_std] -#![no_main] - -use aya_bpf::{macros::tracepoint, programs::TracePointContext, BpfContext}; -use aya_log_ebpf::{debug, error, info, trace, warn}; - -#[tracepoint] -pub fn example(ctx: TracePointContext) -> u32 { - error!(&ctx, "this is an error message 🚨"); - warn!(&ctx, "this is a warning message ⚠ī¸"); - info!(&ctx, "this is an info message ℹī¸"); - debug!(&ctx, "this is a debug message ī¸đŸ"); - trace!(&ctx, "this is a trace message 🔍"); - let pid = ctx.pid(); - info!(&ctx, "a message with args PID: {}", pid); - 0 -} - -#[panic_handler] -fn panic(_info: &core::panic::PanicInfo) -> ! { - unsafe { core::hint::unreachable_unchecked() } -} diff --git a/aya-log/ebpf/rustfmt.toml b/aya-log/ebpf/rustfmt.toml deleted file mode 100644 index 0c3bc0ee..00000000 --- a/aya-log/ebpf/rustfmt.toml +++ /dev/null @@ -1,4 +0,0 @@ -unstable_features = true -reorder_imports = true -imports_granularity = "Crate" - diff --git a/aya-log/release.toml b/aya-log/release.toml index b2239c1f..bf6eaefc 100644 --- a/aya-log/release.toml +++ b/aya-log/release.toml @@ -1,7 +1 @@ -pre-release-commit-message = "aya-log, aya-log-common: release version {{version}}" -post-release-commit-message = "aya-log, aya-log-common: start next development iteration {{next_version}}" -consolidate-pushes = true -consolidate-commits = true shared-version = true -dev-version = true -dev-version-ext = "dev.0" diff --git a/aya-log/rustfmt.toml b/aya-log/rustfmt.toml deleted file mode 100644 index 0c3bc0ee..00000000 --- a/aya-log/rustfmt.toml +++ /dev/null @@ -1,4 +0,0 @@ -unstable_features = true -reorder_imports = true -imports_granularity = "Crate" - diff --git a/aya-log/aya-log/src/lib.rs b/aya-log/src/lib.rs similarity index 100% rename from aya-log/aya-log/src/lib.rs rename to aya-log/src/lib.rs diff --git a/aya-log/xtask/Cargo.toml b/aya-log/xtask/Cargo.toml deleted file mode 100644 index 32cde2ab..00000000 --- a/aya-log/xtask/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "xtask" -publish = false -version = "0.1.0" -edition = "2018" - -[dependencies] -structopt = {version = "0.3", default-features = false } -anyhow = "1" - -[package.metadata.release] -release = false diff --git a/aya-log/xtask/src/build_ebpf.rs b/aya-log/xtask/src/build_ebpf.rs deleted file mode 100644 index 517a8a1d..00000000 --- a/aya-log/xtask/src/build_ebpf.rs +++ /dev/null @@ -1,61 +0,0 @@ -use std::{path::PathBuf, process::Command}; - -use structopt::StructOpt; - -#[derive(Debug, Copy, Clone)] -pub enum Architecture { - BpfEl, - BpfEb, -} - -impl std::str::FromStr for Architecture { - type Err = String; - - fn from_str(s: &str) -> Result { - Ok(match s { - "bpfel-unknown-none" => Architecture::BpfEl, - "bpfeb-unknown-none" => Architecture::BpfEb, - _ => return Err("invalid target".to_owned()), - }) - } -} - -impl std::fmt::Display for Architecture { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(match self { - Architecture::BpfEl => "bpfel-unknown-none", - Architecture::BpfEb => "bpfeb-unknown-none", - }) - } -} - -#[derive(StructOpt)] -pub struct Options { - #[structopt(default_value = "bpfel-unknown-none", long)] - target: Architecture, - #[structopt(long)] - release: bool, -} - -pub fn build(opts: Options) -> Result<(), anyhow::Error> { - let dir = PathBuf::from("aya-log-ebpf"); - let target = format!("--target={}", opts.target); - let mut args = vec![ - "+nightly", - "build", - "--verbose", - target.as_str(), - "-Z", - "build-std=core", - ]; - if opts.release { - args.push("--release") - } - let status = Command::new("cargo") - .current_dir(&dir) - .args(&args) - .status() - .expect("failed to build bpf examples"); - assert!(status.success()); - Ok(()) -} diff --git a/aya-log/xtask/src/main.rs b/aya-log/xtask/src/main.rs deleted file mode 100644 index 96308fd3..00000000 --- a/aya-log/xtask/src/main.rs +++ /dev/null @@ -1,29 +0,0 @@ -mod build_ebpf; - -use std::process::exit; - -use structopt::StructOpt; -#[derive(StructOpt)] -pub struct Options { - #[structopt(subcommand)] - command: Command, -} - -#[derive(StructOpt)] -enum Command { - BuildEbpf(build_ebpf::Options), -} - -fn main() { - let opts = Options::from_args(); - - use Command::*; - let ret = match opts.command { - BuildEbpf(opts) => build_ebpf::build(opts), - }; - - if let Err(e) = ret { - eprintln!("{:#}", e); - exit(1); - } -} diff --git a/aya-log/ebpf/.cargo/config.toml b/bpf/.cargo/config.toml similarity index 100% rename from aya-log/ebpf/.cargo/config.toml rename to bpf/.cargo/config.toml diff --git a/bpf/Cargo.toml b/bpf/Cargo.toml deleted file mode 100644 index b7cf3e2c..00000000 --- a/bpf/Cargo.toml +++ /dev/null @@ -1,2 +0,0 @@ -[workspace] -members = ["aya-bpf", "aya-bpf-macros", "aya-bpf-bindings"] diff --git a/bpf/aya-bpf/Cargo.toml b/bpf/aya-bpf/Cargo.toml index c28551c2..e8822cb4 100644 --- a/bpf/aya-bpf/Cargo.toml +++ b/bpf/aya-bpf/Cargo.toml @@ -6,5 +6,5 @@ edition = "2018" [dependencies] aya-bpf-cty = { path = "../aya-bpf-cty" } -aya-bpf-macros = { path = "../aya-bpf-macros" } +aya-bpf-macros = { path = "../../aya-bpf-macros" } aya-bpf-bindings = { path = "../aya-bpf-bindings" } diff --git a/aya-log/ebpf/aya-log-ebpf/Cargo.toml b/bpf/aya-log-ebpf/Cargo.toml similarity index 55% rename from aya-log/ebpf/aya-log-ebpf/Cargo.toml rename to bpf/aya-log-ebpf/Cargo.toml index 5b716747..ffbd9dca 100644 --- a/aya-log/ebpf/aya-log-ebpf/Cargo.toml +++ b/bpf/aya-log-ebpf/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.0" edition = "2018" [dependencies] -aya-bpf = { git = "https://github.com/aya-rs/aya", branch = "main" } +aya-bpf = { path = "../aya-bpf" } aya-log-common = { path = "../../aya-log-common" } -aya-log-ebpf-macros = { path = "../aya-log-ebpf-macros" } +aya-log-ebpf-macros = { path = "../../aya-log-ebpf-macros" } [lib] path = "src/lib.rs" diff --git a/aya-log/ebpf/aya-log-ebpf/src/lib.rs b/bpf/aya-log-ebpf/src/lib.rs similarity index 100% rename from aya-log/ebpf/aya-log-ebpf/src/lib.rs rename to bpf/aya-log-ebpf/src/lib.rs diff --git a/aya-log/ebpf/rust-toolchain.toml b/bpf/rust-toolchain.toml similarity index 100% rename from aya-log/ebpf/rust-toolchain.toml rename to bpf/rust-toolchain.toml diff --git a/bpf/rustfmt.toml b/bpf/rustfmt.toml deleted file mode 120000 index 39f97b04..00000000 --- a/bpf/rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -../rustfmt.toml \ No newline at end of file diff --git a/netlify.toml b/netlify.toml index 0b8e1991..3ad62912 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,3 +1,3 @@ [build] publish = "site" - command = "rustup toolchain install nightly && cargo xtask docs" + command = "rustup toolchain install nightly -c rust-src && cargo xtask docs" diff --git a/release.toml b/release.toml new file mode 100644 index 00000000..e5351ffa --- /dev/null +++ b/release.toml @@ -0,0 +1,6 @@ +pre-release-commit-message = "{crate_name}: release version {{version}}" +post-release-commit-message = "{crate_name}: start next development iteration {{next_version}}" +consolidate-pushes = true +consolidate-commits = true +dev-version = true +dev-version-ext = "dev.0" diff --git a/test/integration-ebpf/Cargo.toml b/test/integration-ebpf/Cargo.toml index b2a526fa..8688d790 100644 --- a/test/integration-ebpf/Cargo.toml +++ b/test/integration-ebpf/Cargo.toml @@ -21,16 +21,4 @@ path = "src/pass.rs" [[bin]] name = "test" -path = "src/test.rs" - -[profile.dev] -panic = "abort" -opt-level = 2 -overflow-checks = false - -[profile.release] -panic = "abort" -debug = 2 - -[workspace] -members = [] +path = "src/test.rs" \ No newline at end of file diff --git a/xtask/src/docs/mod.rs b/xtask/src/docs/mod.rs index 0496ef63..8705cae7 100644 --- a/xtask/src/docs/mod.rs +++ b/xtask/src/docs/mod.rs @@ -8,67 +8,19 @@ use std::{fs, io, io::Write}; use indoc::indoc; pub fn docs() -> Result<(), anyhow::Error> { - let mut working_dir = PathBuf::from("."); - - let replace = Command::new("sed") - .current_dir(&working_dir) - .args(vec![ - "-i.bak", - "s/crabby.svg/crabby_dev.svg/", - "aya/src/lib.rs", - ]) - .status() - .expect("failed to replace logo"); - assert!(replace.success()); - - let mut header_path = PathBuf::from("."); - header_path.push("header.html"); + let current_dir = PathBuf::from("."); + let header_path = current_dir.join("header.html"); let mut header = fs::File::create(&header_path).expect("can't create header.html"); header .write_all(r#""#.as_bytes()) .expect("can't write header.html contents"); header.flush().expect("couldn't flush contents"); - let abs_header_path = fs::canonicalize(&header_path).unwrap(); - let args = vec!["+nightly", "doc", "--no-deps", "--all-features"]; - - let status = Command::new("cargo") - .current_dir(&working_dir) - .env( - "RUSTDOCFLAGS", - format!("--html-in-header {}", abs_header_path.to_str().unwrap()), - ) - .args(&args) - .status() - .expect("failed to build aya docs"); - assert!(status.success()); - - working_dir.push("bpf"); - - let replace = Command::new("sed") - .current_dir(&working_dir) - .args(vec![ - "-i.bak", - "s/crabby.svg/crabby_dev.svg/", - "aya-bpf/src/lib.rs", - ]) - .status() - .expect("failed to replace logo"); - assert!(replace.success()); - - let status = Command::new("cargo") - .current_dir(&working_dir) - .env( - "RUSTDOCFLAGS", - format!("--html-in-header {}", abs_header_path.to_str().unwrap()), - ) - .args(&args) - .status() - .expect("failed to build aya-bpf docs"); - assert!(status.success()); - copy_dir_all("./target/doc", "site/user")?; - copy_dir_all("./bpf/target/doc", "site/bpf")?; + build_docs(¤t_dir.join("aya"), &abs_header_path)?; + build_docs(¤t_dir.join("bpf/aya-bpf"), &abs_header_path)?; + copy_dir_all("./target/doc", "./site/user")?; + copy_dir_all("./target/bpfel-unknown-none/doc", "./site/bpf")?; let mut robots = fs::File::create("site/robots.txt").expect("can't create robots.txt"); robots @@ -98,14 +50,38 @@ pub fn docs() -> Result<(), anyhow::Error> { .as_bytes(), ) .expect("can't write index.html"); + Ok(()) +} + +fn build_docs(working_dir: &PathBuf, abs_header_path: &Path) -> Result<(), anyhow::Error> { + let replace = Command::new("sed") + .current_dir(&working_dir) + .args(vec!["-i.bak", "s/crabby.svg/crabby_dev.svg/", "src/lib.rs"]) + .status() + .expect("failed to replace logo"); + assert!(replace.success()); - fs::rename("aya/src/lib.rs.bak", "aya/src/lib.rs").unwrap(); - fs::rename("bpf/aya-bpf/src/lib.rs.bak", "bpf/aya-bpf/src/lib.rs").unwrap(); + let args = vec!["+nightly", "doc", "--no-deps", "--all-features"]; + let status = Command::new("cargo") + .current_dir(&working_dir) + .env( + "RUSTDOCFLAGS", + format!("--html-in-header {}", abs_header_path.to_str().unwrap()), + ) + .args(&args) + .status() + .expect("failed to build aya docs"); + assert!(status.success()); + fs::rename( + working_dir.join("src/lib.rs.bak"), + working_dir.join("src/lib.rs"), + ) + .unwrap(); Ok(()) } -fn copy_dir_all>(src: P, dst: P) -> io::Result<()> { +fn copy_dir_all, P2: AsRef>(src: P1, dst: P2) -> io::Result<()> { fs::create_dir_all(&dst)?; for entry in fs::read_dir(src)? { let entry = entry?;