Rework the makefiles.
clippy Build clippy has failed Details
build-organic Build build-organic has failed Details
format Build format has failed Details

main
Tom Alexander 1 month ago
parent a4e433dab1
commit 9f111fe445
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -22,55 +22,70 @@ ifeq ($(origin .RECIPEPREFIX), undefined)
endif endif
.RECIPEPREFIX = > .RECIPEPREFIX = >
.PHONY: help
help: ## List the available make targets.
> @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1: /'
.PHONY: build .PHONY: build
build: build: ## Make a debug build of the project.
> cargo build > cargo build
.PHONY: release .PHONY: release
release: release: ## Make an optimized build of the project.
> cargo build --release $(RELEASEFLAGS) > cargo build --release $(RELEASEFLAGS)
.PHONY: wasm .PHONY: wasm
wasm: wasm: ## Build the parser as wasm.
> cargo build --target=wasm32-unknown-unknown --profile wasm --bin wasm --features wasm > cargo build --target=wasm32-unknown-unknown --profile wasm --bin wasm --features wasm
> wasm-bindgen --target $(WASMTARGET) --out-dir target/wasm32-unknown-unknown/js target/wasm32-unknown-unknown/wasm/wasm.wasm > wasm-bindgen --target $(WASMTARGET) --out-dir target/wasm32-unknown-unknown/js target/wasm32-unknown-unknown/wasm/wasm.wasm
.PHONY: clean .PHONY: clean
clean: clean: ## Delete the built binaries.
> cargo clean > cargo clean
> $(MAKE) -C docker/organic_development TARGET=builder clean
> $(MAKE) -C docker/organic_development TARGET=format clean
> $(MAKE) -C docker/organic_development TARGET=clippy clean
> $(MAKE) -C docker/organic_development TARGET=wasm clean
> $(MAKE) -C docker/organic_test TARGET=tester build
.PHONY: format .PHONY: format
format: format: ## Format the code.
> $(MAKE) -C docker/cargo_fmt run > cargo fmt
.PHONY: docker_format
docker_format: ## Format the code using docker.
> $(MAKE) -C docker/organic_development TARGET=format build
> docker run --rm -i -t --mount type=tmpfs,destination=/tmp -v "$(shell readlink -f .):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "organic-cargo-registry:/usr/local/cargo/registry" organic-development-format cargo fmt
.PHONY: dockerclippy .PHONY: docker_clippy
dockerclippy: docker_clippy: ## Lint the code using docker.
> $(MAKE) -C docker/organic_clippy run > $(MAKE) -C docker/organic_development TARGET=clippy build
> docker run --rm -i -t --mount type=tmpfs,destination=/tmp -v "$(shell readlink -f .):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "organic-cargo-registry:/usr/local/cargo/registry" organic-development-clippy cargo clippy --no-deps --all-targets --all-features -- -D warnings
.PHONY: clippy .PHONY: clippy
clippy: clippy: ## Lint the code.
> cargo clippy --no-deps --all-targets --all-features -- -D warnings > cargo clippy --no-deps --all-targets --all-features -- -D warnings
.PHONY: test .PHONY: test
test: test: ## Run the test suite.
> cargo test --no-default-features --features compare --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS) > cargo test --no-default-features --features compare --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS)
.PHONY: doc .PHONY: doc
doc: doc: ## Generate documentation.
> cargo doc --no-deps --open --lib --release --all-features > cargo doc --no-deps --open --lib --release --all-features
.PHONY: dockertest .PHONY: docker_test
dockertest: docker_test: ## Run the test suite using docker.
> $(MAKE) -C docker/organic_test > $(MAKE) -C docker/organic_test TARGET=tester build
> docker run --init --rm -i -t --read-only -v "$$(readlink -f ./):/source:ro" --mount type=tmpfs,destination=/tmp --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test --no-default-features --features compare --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS) > docker run --init --rm -i -t --read-only -v "$$(readlink -f ./):/source:ro" --mount type=tmpfs,destination=/tmp --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test --no-default-features --features compare --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS)
.PHONY: dockerwasmtest .PHONY: docker_wasm_test
dockerwasmtest: docker_wasm_test: ## Run the test suite with wasm tests.
> $(MAKE) -C docker/organic_test > $(MAKE) -C docker/organic_test TARGET=tester build
> docker run --init --rm -i -t --read-only -v "$$(readlink -f ./):/source:ro" --mount type=tmpfs,destination=/tmp --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test --no-default-features --features compare,wasm_test --no-fail-fast --lib --test test_loader autogen_wasm_ -- --test-threads $(TESTJOBS) > docker run --init --rm -i -t --read-only -v "$$(readlink -f ./):/source:ro" --mount type=tmpfs,destination=/tmp --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test --no-default-features --features compare,wasm_test --no-fail-fast --lib --test test_loader autogen_wasm_ -- --test-threads $(TESTJOBS)
.PHONY: buildtest .PHONY: build_test
buildtest: build_test:
> cargo build --no-default-features > cargo build --no-default-features
> cargo build --no-default-features --features compare > cargo build --no-default-features --features compare
> cargo build --no-default-features --features tracing > cargo build --no-default-features --features tracing
@ -82,7 +97,8 @@ buildtest:
.PHONY: foreign_document_test .PHONY: foreign_document_test
foreign_document_test: foreign_document_test:
> $(MAKE) -C docker/organic_test run_foreign_document_test > $(MAKE) -C docker/organic_test TARGET=foreign-document build
> docker run --init --rm -i -t --read-only -v "$$(readlink -f ./):/source:ro" --mount type=tmpfs,destination=/tmp --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test-foreign-document
.PHONY: dockerclean .PHONY: dockerclean
dockerclean: dockerclean:

@ -2,9 +2,15 @@ FROM rustlang/rust:nightly-alpine3.19 AS builder
RUN apk add --no-cache musl-dev RUN apk add --no-cache musl-dev
RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache
RUN rustup component add rustc-codegen-cranelift
FROM builder AS format
RUN rustup component add rustfmt RUN rustup component add rustfmt
FROM builder AS clippy
RUN rustup component add clippy RUN rustup component add clippy
RUN rustup component add rustc-codegen-cranelift
FROM builder AS wasm FROM builder AS wasm

@ -10,8 +10,11 @@ ifeq ($(origin .RECIPEPREFIX), undefined)
endif endif
.RECIPEPREFIX = > .RECIPEPREFIX = >
IMAGE_NAME:=organic-development TARGET := builder
TARGET := IMAGE_NAME := organic-development
ifneq ($(TARGET),builder)
IMAGE_NAME := $(IMAGE_NAME)-$(TARGET)
endif
.PHONY: help .PHONY: help
help: help:

@ -29,6 +29,7 @@ FROM rustlang/rust:nightly-alpine3.19 AS tester
ENV LANG=en_US.UTF-8 ENV LANG=en_US.UTF-8
RUN apk add --no-cache musl-dev ncurses gnutls libgccjit RUN apk add --no-cache musl-dev ncurses gnutls libgccjit
RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache
RUN rustup component add rustc-codegen-cranelift
COPY --from=build-emacs /root/dist/ / COPY --from=build-emacs /root/dist/ /
COPY --from=build-org-mode /root/dist/ / COPY --from=build-org-mode /root/dist/ /
@ -100,7 +101,7 @@ RUN mkdir -p $LITERATE_BUILD_EMACS_PATH && git -C $LITERATE_BUILD_EMACS_PATH ini
# unused/aws.org contains invalid paths for setupfile which causes both upstream org-mode and Organic to error out. # unused/aws.org contains invalid paths for setupfile which causes both upstream org-mode and Organic to error out.
RUN rm $LITERATE_BUILD_EMACS_PATH/unused/aws.org RUN rm $LITERATE_BUILD_EMACS_PATH/unused/aws.org
FROM tester as foreign-document-test FROM tester as foreign-document
RUN apk add --no-cache bash coreutils RUN apk add --no-cache bash coreutils
RUN mkdir /foreign_documents RUN mkdir /foreign_documents
COPY --from=foreign-document-gather /foreign_documents/howardabrams /foreign_documents/howardabrams COPY --from=foreign-document-gather /foreign_documents/howardabrams /foreign_documents/howardabrams

@ -1,44 +1,36 @@
IMAGE_NAME:=organic-test SHELL := bash
# REMOTE_REPO:=harbor.fizz.buzz/private .ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.PHONY: all .DELETE_ON_ERROR:
all: build push MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
.PHONY: build
build: ifeq ($(origin .RECIPEPREFIX), undefined)
docker build -t $(IMAGE_NAME) -f Dockerfile --target tester . $(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
.PHONY: build_foreign_document_test
build_foreign_document_test:
docker build -t $(IMAGE_NAME)-foreign-document -f Dockerfile --target foreign-document-test .
.PHONY: push
push:
ifdef REMOTE_REPO
docker tag $(IMAGE_NAME) $(REMOTE_REPO)/$(IMAGE_NAME)
docker push $(REMOTE_REPO)/$(IMAGE_NAME)
else
@echo "REMOTE_REPO not defined, not pushing to a remote repo."
endif endif
.RECIPEPREFIX = >
.PHONY: clean TARGET := tester
clean: IMAGE_NAME := organic-test
docker rmi $(IMAGE_NAME) ifneq ($(TARGET),tester)
ifdef REMOTE_REPO IMAGE_NAME := $(IMAGE_NAME)-$(TARGET)
docker rmi $(REMOTE_REPO)/$(IMAGE_NAME)
else
@echo "REMOTE_REPO not defined, not removing from remote repo."
endif endif
docker volume rm rust-cache cargo-cache
.PHONY: run .PHONY: help
run: build help:
docker run --rm --init --read-only --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME) --no-default-features --features compare --no-fail-fast --lib --test test_loader > @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1: /'
.PHONY: build
build: ## Build the docker image.
> docker build --tag $(IMAGE_NAME) --target=$(TARGET) --file Dockerfile .
> docker volume create organic-cargo-registry
.PHONY: shell .PHONY: shell
shell: ## Launch an interactive shell inside the docker image with the source repository mounted at /source.
shell: build shell: build
docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME) > docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "organic-cargo-registry:/usr/local/cargo/registry" $(IMAGE_NAME)
.PHONY: run_foreign_document_test .PHONY: clean
run_foreign_document_test: build_foreign_document_test clean: ## Remove the docker image and volume.
docker run --rm --init --read-only --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME)-foreign-document > docker rmi $(IMAGE_NAME)
> docker volume rm organic-cargo-registry

@ -71,7 +71,7 @@ pub struct EntityDefinition<'a> {
impl<'g, 's> GlobalSettings<'g, 's> { impl<'g, 's> GlobalSettings<'g, 's> {
fn new() -> GlobalSettings<'g, 's> { fn new() -> GlobalSettings<'g, 's> {
debug_assert!(DEFAULT_ORG_ENTITIES.is_sorted_by(|a, b| a.name.len() <= b.name.len())); debug_assert!(DEFAULT_ORG_ENTITIES.is_sorted_by(|a, b| a.name.len() >= b.name.len()));
GlobalSettings { GlobalSettings {
radio_targets: Vec::new(), radio_targets: Vec::new(),
file_access: &LocalFileAccessInterface { file_access: &LocalFileAccessInterface {

Loading…
Cancel
Save