Skip to content

Commit

Permalink
make: Add test and run targets
Browse files Browse the repository at this point in the history
Change-Id: I62b7710cdfdfdba7212b59b61c05363a7a673545
Signed-off-by: Ian Meyer <[email protected]>
  • Loading branch information
imeyer committed Sep 15, 2024
1 parent 05d1b31 commit 757cd03
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
# 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
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

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

0 comments on commit 757cd03

Please sign in to comment.