From 757cd035b5c7cc712b359e3b4dbf28a19b6b21f6 Mon Sep 17 00:00:00 2001 From: Ian Meyer Date: Sun, 15 Sep 2024 21:40:28 +0000 Subject: [PATCH] make: Add test and run targets Change-Id: I62b7710cdfdfdba7212b59b61c05363a7a673545 Signed-off-by: Ian Meyer --- Makefile | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 8e9d983..3326ba6 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,21 @@ # Detect OS UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) - PLATFORM := darwin + PLATFORM := darwin else ifeq ($(UNAME_S),Linux) - PLATFORM := linux + PLATFORM := linux else - $(error Unsupported platform: $(UNAME_S)) + $(error Unsupported platform: $(UNAME_S)) endif # Detect architecture UNAME_M := $(shell uname -m) ifeq ($(UNAME_M),arm64) - ARCH := arm64 + ARCH := arm64 else ifeq ($(UNAME_M),x86_64) - ARCH := amd64 + ARCH := amd64 else - $(error Unsupported architecture: $(UNAME_M)) + $(error Unsupported architecture: $(UNAME_M)) endif # Combine platform and architecture @@ -23,7 +23,11 @@ TARGET := tdiscuss-$(PLATFORM)-$(ARCH) # Bazel build command BAZEL := bazelisk -BAZEL_ARGS := build --stamp --workspace_status_command="$${PWD}/status.sh" +BAZEL_BUILD_ARGS := build --config=silent --stamp --workspace_status_command="$${PWD}/status.sh" +BAZEL_TEST_ARGS := test --config=silent --build_tests_only --test_output=errors +BAZEL_RUN_ARGS := run +# Change the hostname to anything you wish to use for testing +BAZEL_RUN_TRAILING_ARGS := -- -hostname discuss-dev .PHONY: all clean @@ -31,7 +35,15 @@ all: build build: @echo "Building for $(PLATFORM)-$(ARCH)" - $(BAZEL) $(BAZEL_ARGS) //:$(TARGET) + $(BAZEL) $(BAZEL_BUILD_ARGS) //:$(TARGET) + +test: + @echo "Testing all targets" + $(BAZEL) $(BAZEL_TEST_ARGS) //... + +run: + @echo "Running for $(PLATFORM)-$(ARCH)" + $(BAZEL) $(BAZEL_RUN_ARGS) //:$(TARGET) $(BAZEL_RUN_TRAILING_ARGS) clean: $(BAZEL) clean