Skip to content

Commit

Permalink
Add help and debug targets, fuzzy assign WEBR_ROOT (#410)
Browse files Browse the repository at this point in the history
* Set the WEBR_ROOT variable only if it's not set/doesn't have a value.

* Provide a help and debug command for top-level make

* Update Makefile

Co-authored-by: George Stagg <georgestagg@gmail.com>

---------

Co-authored-by: George Stagg <georgestagg@gmail.com>
  • Loading branch information
coatless and georgestagg committed Apr 24, 2024
1 parent 5a81d85 commit 3eef6fc
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
WEBR_ROOT = $(abspath .)
WEBR_ROOT ?= $(abspath .)
WASM = $(WEBR_ROOT)/wasm
HOST = $(WEBR_ROOT)/host
TOOLS = $(WEBR_ROOT)/tools
Expand All @@ -8,53 +8,65 @@ default: webr
# This is created at configure-time
include $(TOOLS)/fortran.mk

# Build webR and install the web app in `./dist`
.PHONY: webr
webr: $(EMFC) $(FORTRAN_WASM_LIB) libs
webr: $(EMFC) $(FORTRAN_WASM_LIB) libs ## Build webR and install the web app in `./dist`
cd R && $(MAKE) && $(MAKE) install
cd src && $(MAKE)

# Supporting libs for webr
.PHONY: libs
libs:
libs: ## Compile supporting libs for webR
cd libs && $(MAKE)

# Build webR in a temporary docker container
.PHONY: docker-webr
docker-webr:
docker-webr: ## Build webR in a temporary Docker container
mkdir -p dist
docker build -t webr-build .
docker run --rm --mount type=bind,source=$(PWD),target=/app webr-build

# Create a permanent docker container for building webR. Call `make`
# from within the container to start the build.
.PHONY: docker-container-%
docker-container-%:
docker-container-%: ## Build webR development Docker container using a supplied name
docker build -t webr-build .
docker run -dit --name $* --mount type=bind,source=$(PWD),target=/app webr-build bash

docs: docs/build
docs/build:
docs: docs/build ## Build documentation and Quarto website
docs/build: ## Build documentation and Quarto website
cd docs && $(MAKE) api && $(MAKE) html

.PHONY: check
check:
check: ## Run unit tests and calculate coverage
cd src && $(MAKE) check

.PHONY: check-pr
check-pr:
check-pr: ## Run additional pull request tests, linter, and calculate coverage
cd src && $(MAKE) lint && $(MAKE) check && $(MAKE) check-packages

.PHONY: clean
clean:
clean: ## Remove Wasm R build
rm -rf $(HOST) $(WASM)/R-*
cd R && $(MAKE) clean

.PHONY: clean-wasm
clean-wasm: clean
clean-wasm: clean ## Remove Wasm R build and supporting libs
rm -rf $(WASM)
cd libs && $(MAKE) clean

.PHONY: distclean
distclean: clean-wasm clean-tools
distclean: clean-wasm clean-tools ## Remove Wasm R build, supporting libs, build tools, and webR distribution
rm -rf dist

.PHONY: help
help: ## Show help messages for make targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-18s\033[0m %s\n", $$1, $$2}'

.PHONY: debug
debug: ## Print all variables for debugging
@printf "\033[32m%-18s\033[0m %s\n" "WEBR_ROOT" "$(WEBR_ROOT)"
@printf "\033[32m%-18s\033[0m %s\n" "WASM" "$(WASM)"
@printf "\033[32m%-18s\033[0m %s\n" "HOST" "$(HOST)"
@printf "\033[32m%-18s\033[0m %s\n" "TOOLS" "$(TOOLS)"
@printf "\033[32m%-18s\033[0m %s\n" "EMFC" "$(EMFC)"
@printf "\033[32m%-18s\033[0m %s\n" "FORTRAN_WASM_LIB" "$(FORTRAN_WASM_LIB)"
@printf "\033[32m%-18s\033[0m %s\n" "PWD" "$(PWD)"
@printf "\033[32m%-18s\033[0m %s\n" "MAKE" "$(MAKE)"

0 comments on commit 3eef6fc

Please sign in to comment.