Skip to content

Commit

Permalink
Merge pull request #746 from jiangliu/macos
Browse files Browse the repository at this point in the history
Clean up fusedev and enhance makefile targets for macos
  • Loading branch information
bergwolf authored Sep 26, 2022
2 parents 0a8dac9 + 0d9000e commit a4a7a0f
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ jobs:
- name: build and check
run: |
rustup component add rustfmt && rustup component add clippy
make macos-ut
make
make ut
deny:
name: Cargo Deny
Expand Down
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@ all: build
TEST_WORKDIR_PREFIX ?= "/tmp"
DOCKER ?= "true"

RUST_TARGET_STATIC ?= $(shell uname -m)-unknown-linux-musl
CARGO ?= $(shell which cargo)
CARGO_BUILD_GEARS = -v ~/.ssh/id_rsa:/root/.ssh/id_rsa -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry
SUDO = $(shell which sudo)

CARGO_COMMON ?=

EXCLUDE_PACKAGES =
STATIC_TARGET = $(UNAME_M)-unknown-linux-musl
UNAME_M := $(shell uname -m)
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CARGO_COMMON += --features=virtiofs
endif
ifeq ($(UNAME_S),Darwin)
EXCLUDE_PACKAGES += --exclude nydus-blobfs
ifeq ($(UNAME_M),arm64)
UNAME_M = aarch64
STATIC_TARGET = aarch64-apple-darwin
endif
endif
RUST_TARGET_STATIC ?= $(STATIC_TARGET)

current_dir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
env_go_path := $(shell go env GOPATH 2> /dev/null)
Expand Down Expand Up @@ -54,7 +64,7 @@ endef
build: .format
${CARGO} build $(CARGO_COMMON) $(CARGO_BUILD_FLAGS)
# Cargo will skip checking if it is already checked
${CARGO} clippy $(CARGO_COMMON) --workspace --bins --tests -- -Dwarnings
${CARGO} clippy $(CARGO_COMMON) --workspace $(EXCLUDE_PACKAGES) --bins --tests -- -Dwarnings

release: .format .release_version build

Expand All @@ -69,21 +79,12 @@ install: release
@sudo install -D -m 755 target/release/nydusctl /usr/local/bin/nydusctl

ut:
TEST_WORKDIR_PREFIX=$(TEST_WORKDIR_PREFIX) RUST_BACKTRACE=1 ${CARGO} test --workspace $(CARGO_COMMON) -- --skip integration --nocapture --test-threads=8
TEST_WORKDIR_PREFIX=$(TEST_WORKDIR_PREFIX) RUST_BACKTRACE=1 ${CARGO} test --workspace $(EXCLUDE_PACKAGES) $(CARGO_COMMON) -- --skip integration --nocapture --test-threads=8

smoke: ut
# TODO: Put each test function into separated rs file.
$(SUDO) TEST_WORKDIR_PREFIX=$(TEST_WORKDIR_PREFIX) $(CARGO) test --test '*' $(CARGO_COMMON) -- --nocapture --test-threads=8

macos-fusedev:
${CARGO} build --target ${RUST_TARGET_STATIC} --release --bin nydusctl --bin nydusd --bin nydus-image

macos-ut:
${CARGO} clippy --bin nydusd --release --workspace -- -Dwarnings
echo "Testing packages: ${PACKAGES}"
$(foreach var,$(PACKAGES),${CARGO} test $(CARGO_COMMON) -p $(var);)
TEST_WORKDIR_PREFIX=$(TEST_WORKDIR_PREFIX) RUST_BACKTRACE=1 ${CARGO} test $(CARGO_COMMON) --bin nydusd -- --nocapture --test-threads=8

docker-static:
docker build -t nydus-rs-static --build-arg RUST_TARGET=${RUST_TARGET_STATIC} misc/musl-static
docker run --rm ${CARGO_BUILD_GEARS} -e RUST_TARGET=${RUST_TARGET_STATIC} --workdir /nydus-rs -v ${current_dir}:/nydus-rs nydus-rs-static
Expand Down
2 changes: 1 addition & 1 deletion contrib/nydus-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Before running nydus-test, please compile nydus components.

```bash
cd /path/to/image-service/repo
make fusedev-release
make release
```

`nydus-backend-proxy`
Expand Down
8 changes: 4 additions & 4 deletions contrib/nydus-test/framework/nydus_anchor.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,18 @@ def __init__(self, path=None):
link_target = kwargs.pop("target")
if link_target == "gnu":
self.binary_release_dir = os.path.join(
self.nydus_project, "target-fusedev/release"
self.nydus_project, "target/release"
)
elif link_target == "musl":
arch = platform.machine()
self.binary_release_dir = os.path.join(
self.nydus_project,
f"target-fusedev/{arch}-unknown-linux-musl",
f"target/{arch}-unknown-linux-musl",
"release",
)

self.build_dir = os.path.join(self.nydus_project, "target-fusedev/debug")
self.binary_debug_dir = os.path.join(self.nydus_project, "target-fusedev/debug")
self.build_dir = os.path.join(self.nydus_project, "target/debug")
self.binary_debug_dir = os.path.join(self.nydus_project, "target/debug")

if profile == "release":
self.binary_dir = self.binary_release_dir
Expand Down
2 changes: 0 additions & 2 deletions docs/containerd-env-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ This document will walk through how to setup a nydus image service to work with

Get `nydus-image`, `nydusd`, `nydusify`, `ctr-remote` and `nydus-overlayfs` binaries from [release](https://github.com/dragonflyoss/image-service/releases/latest) page.

`nydusd` currently has two binaries, `nydusd-fusedev` (for fuse daemon mode) and `nydusd-virtiofs` (for virtiofs daemon mode), choose the one that fits your mode and rename it as `nydusd`.

```bash
sudo cp nydusd nydus-image /usr/local/bin
sudo cp nydusify containerd-nydus-grpc /usr/local/bin
Expand Down
2 changes: 1 addition & 1 deletion docs/nydus-fscache.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ make release
```

4. Copy the "nydus-image" binary file compiled in Step 3 into _$PATH_ e.g. /usr/local/bin with \
``cp target-fusedev/release/nydus-image /usr/local/bin``
``cp target/release/nydus-image /usr/local/bin``

5. Build ctr-remote with

Expand Down
7 changes: 6 additions & 1 deletion docs/nydus_with_macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ Only `fusedev` works on macos, by the way passthrough file system not work(passt

## Build instruction
```shell
cargo build --features=fusedev --release --target-dir target-fusedev --bin=nydusd
cargo build --release --bin=nydusd
```
or
```
make release
make install
```
8 changes: 4 additions & 4 deletions rafs/src/metadata/layout/v5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1919,10 +1919,10 @@ pub mod tests {
inode2.load(&mut reader).unwrap();
assert_eq!(inode2.i_name_size, 4);
assert_eq!(inode2.i_symlink_size, 6);
assert_eq!(inode.i_size, 0x1000);
assert_eq!(inode.i_blocks, 1);
assert_eq!(inode.i_child_count, 10);
assert_eq!(inode.i_child_index, 20);
assert_eq!(inode2.i_size, 0x1000);
assert_eq!(inode2.i_blocks, 1);
assert_eq!(inode2.i_child_count, 10);
assert_eq!(inode2.i_child_index, 20);

let filename = inode2.load_file_name(&mut reader).unwrap();
assert_eq!(filename, OsString::from_str("test").unwrap());
Expand Down
2 changes: 1 addition & 1 deletion tests/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Builder<'a> {

pub fn new<'a>(work_dir: &'a Path, whiteout_spec: &'a str) -> Builder<'a> {
let builder = std::env::var("NYDUS_IMAGE")
.unwrap_or_else(|_| String::from("./target-fusedev/release/nydus-image"));
.unwrap_or_else(|_| String::from("./target/release/nydus-image"));
Builder {
builder,
work_dir,
Expand Down
5 changes: 3 additions & 2 deletions tests/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use serde_json::Value::{self, Null};
use std::{fs::File, io::Read};

pub fn test_image_inspect_cmd(cmd: &str, bootstrap_path: &str) {
let nydus_image = std::env::var("NYDUS_IMAGE")
.unwrap_or_else(|_| String::from("./target-fusedev/release/nydus-image"));
let default_nydus_image = env!("CARGO_BIN_EXE_nydus-image");
let nydus_image =
std::env::var("NYDUS_IMAGE").unwrap_or_else(|_| String::from(default_nydus_image));

let output = exec(
format!("{} inspect -B {} -R {}", nydus_image, bootstrap_path, cmd).as_str(),
Expand Down
2 changes: 1 addition & 1 deletion tests/nydusd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn new(
.unwrap();

let nydusd =
std::env::var("NYDUSD").unwrap_or_else(|_| String::from("./target-fusedev/release/nydusd"));
std::env::var("NYDUSD").unwrap_or_else(|_| String::from("./target/release/nydusd"));

Nydusd {
nydusd,
Expand Down

0 comments on commit a4a7a0f

Please sign in to comment.