Rework the makefiles.
This commit is contained in:
		
							parent
							
								
									a4e433dab1
								
							
						
					
					
						commit
						9f111fe445
					
				
							
								
								
									
										58
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										58
									
								
								Makefile
									
									
									
									
									
								
							| @ -22,55 +22,70 @@ ifeq ($(origin .RECIPEPREFIX), undefined) | ||||
| endif | ||||
| .RECIPEPREFIX = > | ||||
| 
 | ||||
| .PHONY: help | ||||
| help: ## List the available make targets.
 | ||||
| > @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1:  /'
 | ||||
| 
 | ||||
| .PHONY: build | ||||
| build: | ||||
| build: ## Make a debug build of the project.
 | ||||
| > cargo build | ||||
| 
 | ||||
| .PHONY: release | ||||
| release: | ||||
| release: ## Make an optimized build of the project.
 | ||||
| > cargo build --release $(RELEASEFLAGS) | ||||
| 
 | ||||
| .PHONY: wasm | ||||
| wasm: | ||||
| wasm: ## Build the parser as 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 | ||||
| 
 | ||||
| .PHONY: clean | ||||
| clean: | ||||
| clean: ## Delete the built binaries.
 | ||||
| > 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 | ||||
| format: | ||||
| > $(MAKE) -C docker/cargo_fmt run | ||||
| format: ## Format the code.
 | ||||
| > cargo fmt | ||||
| 
 | ||||
| .PHONY: dockerclippy | ||||
| dockerclippy: | ||||
| > $(MAKE) -C docker/organic_clippy run | ||||
| .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: docker_clippy | ||||
| docker_clippy: ## Lint the code using docker.
 | ||||
| > $(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 | ||||
| clippy: | ||||
| clippy: ## Lint the code.
 | ||||
| > cargo clippy --no-deps --all-targets --all-features -- -D warnings | ||||
| 
 | ||||
| .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) | ||||
| 
 | ||||
| .PHONY: doc | ||||
| doc: | ||||
| doc: ## Generate documentation.
 | ||||
| > cargo doc --no-deps --open --lib --release --all-features | ||||
| 
 | ||||
| .PHONY: dockertest | ||||
| dockertest: | ||||
| > $(MAKE) -C docker/organic_test | ||||
| .PHONY: docker_test | ||||
| docker_test: ## Run the test suite using docker.
 | ||||
| > $(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) | ||||
| 
 | ||||
| .PHONY: dockerwasmtest | ||||
| dockerwasmtest: | ||||
| > $(MAKE) -C docker/organic_test | ||||
| .PHONY: docker_wasm_test | ||||
| docker_wasm_test: ## Run the test suite with wasm tests.
 | ||||
| > $(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) | ||||
| 
 | ||||
| .PHONY: buildtest | ||||
| buildtest: | ||||
| .PHONY: build_test | ||||
| build_test: | ||||
| > cargo build --no-default-features | ||||
| > cargo build --no-default-features --features compare | ||||
| > cargo build --no-default-features --features tracing | ||||
| @ -82,7 +97,8 @@ buildtest: | ||||
| 
 | ||||
| .PHONY: 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 | ||||
| dockerclean: | ||||
|  | ||||
| @ -2,10 +2,16 @@ FROM rustlang/rust:nightly-alpine3.19 AS builder | ||||
| 
 | ||||
| RUN apk add --no-cache musl-dev | ||||
| RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache | ||||
| RUN rustup component add rustfmt | ||||
| RUN rustup component add clippy | ||||
| RUN rustup component add rustc-codegen-cranelift | ||||
| 
 | ||||
| FROM builder AS format | ||||
| 
 | ||||
| RUN rustup component add rustfmt | ||||
| 
 | ||||
| FROM builder AS clippy | ||||
| 
 | ||||
| RUN rustup component add clippy | ||||
| 
 | ||||
| FROM builder AS wasm | ||||
| 
 | ||||
| RUN rustup target add wasm32-unknown-unknown | ||||
|  | ||||
| @ -10,8 +10,11 @@ ifeq ($(origin .RECIPEPREFIX), undefined) | ||||
| endif | ||||
| .RECIPEPREFIX = > | ||||
| 
 | ||||
| IMAGE_NAME:=organic-development | ||||
| TARGET := | ||||
| TARGET := builder | ||||
| IMAGE_NAME := organic-development | ||||
| ifneq ($(TARGET),builder) | ||||
|   IMAGE_NAME := $(IMAGE_NAME)-$(TARGET) | ||||
| endif | ||||
| 
 | ||||
| .PHONY: help | ||||
| help: | ||||
|  | ||||
| @ -29,6 +29,7 @@ FROM rustlang/rust:nightly-alpine3.19 AS tester | ||||
| ENV LANG=en_US.UTF-8 | ||||
| RUN apk add --no-cache musl-dev ncurses gnutls libgccjit | ||||
| 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-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. | ||||
| 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 mkdir /foreign_documents | ||||
| COPY --from=foreign-document-gather /foreign_documents/howardabrams /foreign_documents/howardabrams | ||||
|  | ||||
| @ -1,44 +1,36 @@ | ||||
| IMAGE_NAME:=organic-test | ||||
| # REMOTE_REPO:=harbor.fizz.buzz/private
 | ||||
| SHELL := bash | ||||
| .ONESHELL: | ||||
| .SHELLFLAGS := -eu -o pipefail -c | ||||
| .DELETE_ON_ERROR: | ||||
| MAKEFLAGS += --warn-undefined-variables | ||||
| MAKEFLAGS += --no-builtin-rules | ||||
| 
 | ||||
| .PHONY: all | ||||
| all: build push | ||||
| ifeq ($(origin .RECIPEPREFIX), undefined) | ||||
|   $(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later) | ||||
| endif | ||||
| .RECIPEPREFIX = > | ||||
| 
 | ||||
| TARGET := tester | ||||
| IMAGE_NAME := organic-test | ||||
| ifneq ($(TARGET),tester) | ||||
|   IMAGE_NAME := $(IMAGE_NAME)-$(TARGET) | ||||
| endif | ||||
| 
 | ||||
| .PHONY: help | ||||
| help: | ||||
| > @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1:  /'
 | ||||
| 
 | ||||
| .PHONY: build | ||||
| build: | ||||
| 	docker build -t $(IMAGE_NAME) -f Dockerfile --target tester . | ||||
| 
 | ||||
| .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 | ||||
| 
 | ||||
| .PHONY: clean | ||||
| clean: | ||||
| 	docker rmi $(IMAGE_NAME) | ||||
| ifdef REMOTE_REPO | ||||
| 	docker rmi $(REMOTE_REPO)/$(IMAGE_NAME) | ||||
| else | ||||
| 	@echo "REMOTE_REPO not defined, not removing from remote repo." | ||||
| endif | ||||
| 	docker volume rm rust-cache cargo-cache | ||||
| 
 | ||||
| .PHONY: run | ||||
| run: build | ||||
| 	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 | ||||
| build: ## Build the docker image.
 | ||||
| > docker build --tag $(IMAGE_NAME) --target=$(TARGET) --file Dockerfile . | ||||
| > docker volume create organic-cargo-registry | ||||
| 
 | ||||
| .PHONY: shell | ||||
| shell: ## Launch an interactive shell inside the docker image with the source repository mounted at /source.
 | ||||
| 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 | ||||
| run_foreign_document_test: build_foreign_document_test | ||||
| 	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 | ||||
| .PHONY: clean | ||||
| clean: ## Remove the docker image and volume.
 | ||||
| > docker rmi $(IMAGE_NAME) | ||||
| > docker volume rm organic-cargo-registry | ||||
|  | ||||
| @ -71,7 +71,7 @@ pub struct EntityDefinition<'a> { | ||||
| 
 | ||||
| impl<'g, 's> 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 { | ||||
|             radio_targets: Vec::new(), | ||||
|             file_access: &LocalFileAccessInterface { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander