From d7b79196c956d2f2df681af561d83d1f6a2d980b Mon Sep 17 00:00:00 2001 From: Fletcher Nichol Date: Thu, 5 Jan 2017 11:18:05 -0700 Subject: [PATCH] Unify `make bldr-run` Makefile target to work on native Linux & Mac. This change brings the 2 Procfiles into one version that should work under most circumstances under Linux and Mac. The notable exception is for systems that already have a `redis-server` process running, such as a Homebrew-installed package on macOS or a system-installed package on Ubuntu for example. The 2 remaining Makefile targets are: * `bldr-run` - which launches the Builder services necessary for developing against. By default on the Mac this will run in a devshell using Docker and will be run natively on Linux without Docker. * `bldr-shell` - which launches a devshell (i.e. a Docker container) with forwarded ports but doesn't run any of the services As the `BUILDING.md` instructions describe how to work natively on Mac (i.e. not using Docker but targeting macOS directly), you can set `export IN_DOCKER=false` for `make bldr-run` to compile and run on the Mac. The driving user feature for this change was to be able to run `make bldr-run` on a Linux host without needing to resort to the same bind mount/Docker overhead which slows down the development cycle. Signed-off-by: Fletcher Nichol --- .gitignore | 1 + Makefile | 37 +++++++++++----------------- support/{Procfile.linux => Procfile} | 0 support/Procfile.mac | 7 ------ 4 files changed, 16 insertions(+), 29 deletions(-) rename support/{Procfile.linux => Procfile} (100%) delete mode 100644 support/Procfile.mac diff --git a/.gitignore b/.gitignore index 80664451ed..55b7a33353 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +dump.rdb target terraform.tfstate* .delivery/cli.toml diff --git a/Makefile b/Makefile index 93bfc9c71a..4dab12b6d3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,9 @@ UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Darwin) + forego := support/mac/bin/forego +else + forego := support/linux/bin/forego +endif ifneq (${IN_DOCKER},) IN_DOCKER := ${IN_DOCKER} else ifeq ($(UNAME_S),Darwin) @@ -25,8 +30,10 @@ ifeq ($(IN_DOCKER),true) run := $(common_run) shell bldr_run := $(common_run) -p 9636:9636 -p 8080:8080 shell docs_run := $(common_run) -p 9633:9633 shell + forego := support/linux/bin/forego else run := + bldr_run := docs_run := endif ifneq ($(DOCKER_HOST),) @@ -43,9 +50,6 @@ VERSION := $(shell cat VERSION) .DEFAULT_GOAL := build-bin -bldr-build: $(addprefix bldr-build-,$(SRV)) -.PHONY: bldr-build - build: build-bin build-lib build-srv ## builds all the components build-all: build .PHONY: build build-all @@ -107,6 +111,14 @@ shell: image ## launches a development shell $(run) .PHONY: shell +bldr-shell: build-srv ## launches a development shell with forwarded ports but doesn't run anything + $(bldr_run) +.PHONY: bldr-shell + +bldr-run: build-srv ## launches a development shell running the API + $(bldr_run) sh -c '$(forego) start -f support/Procfile -e support/bldr.env' +.PHONY: bldr-run + serve-docs: docs ## serves the project documentation from an HTTP server @echo "==> View the docs at:\n\n http://`\ echo $(docs_host) | sed -e 's|^tcp://||' -e 's|:[0-9]\{1,\}$$||'`:9633/\n\n" @@ -162,25 +174,6 @@ build-$1: image ## builds the $1 component endef $(foreach component,$(ALL),$(eval $(call BUILD,$(component)))) -define BLDR_BUILD -bldr-build-$1: image ## builds the $1 component - cd components/$1 && cargo build -.PHONY: bldr-build-$1 - -endef -$(foreach component,$(ALL),$(eval $(call BLDR_BUILD,$(component)))) - -bldr-run: bldr-build - support/mac/bin/forego start -f support/Procfile.mac -e support/bldr.env - -bldr-shell: build-srv ## launches a development shell with forwarded ports but doesn't run anything - $(bldr_run) -.PHONY: bldr-shell - -bldr-run-shell: build-srv ## launches a development shell running the API - $(bldr_run) sh -c '/src/support/linux/bin/forego start -f support/Procfile.linux -e support/bldr.env' -.PHONY: bldr-run-shell - define UNIT unit-$1: image ## executes the $1 component's unit test suite $(run) sh -c 'cd components/$1 && cargo test' diff --git a/support/Procfile.linux b/support/Procfile similarity index 100% rename from support/Procfile.linux rename to support/Procfile diff --git a/support/Procfile.mac b/support/Procfile.mac deleted file mode 100644 index 4730851335..0000000000 --- a/support/Procfile.mac +++ /dev/null @@ -1,7 +0,0 @@ -api: target/debug/bldr-api start -admin: target/debug/bldr-admin start -router: target/debug/bldr-router start -jobsrv: target/debug/bldr-job-srv start -sessionsrv: target/debug/bldr-session-srv start -vaultsrv: target/debug/bldr-vault start -worker: target/debug/bldr-worker start