Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and gvatsal60 committed Nov 14, 2024
1 parent 0dbeea8 commit e55324e
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 29 deletions.
4 changes: 4 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
Language: Cpp
BasedOnStyle: Google
...
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ else
include Makefiles/out.mk
endif

.PHONY: all test clean
.PHONY: all test clean
4 changes: 2 additions & 2 deletions Makefiles/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DOCKER_IMG_NAME := $(DOCKER_BASE_IMG_NAME):$(DOCKER_IMG_TAG)
DOCKER_DEPS_IMAGE_BUILD_FLAGS ?= --no-cache=true

# Volume mount configuration for Docker container.
DOCKER_VOL ?= --volume $(shell pwd)/$(PROJECT_NAME):/$(PROJECT_NAME)
DOCKER_VOL ?= --volume $(shell pwd):/$(PROJECT_NAME)

# Directory to work within the Docker container.
DOCKER_WORK_DIR ?= -w /$(PROJECT_NAME)
Expand Down Expand Up @@ -58,4 +58,4 @@ ifeq ($(strip $(DOCKER_GID)),)
$(error DOCKER_GID is not set)
endif

.PHONY: all test clean
.PHONY: all test clean
24 changes: 11 additions & 13 deletions Makefiles/out.mk
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
include Makefiles/docker.mk

BUILD_CMD := bazel build //$(TOP_DIR):all
TEST_CMD := bazel test //$(TOP_DIR):test
RUN_CMD := bazel run //$(TOP_DIR):prog
CLEAN_CMD := bazel clean
SONAR_CMD := bazel run @hedron_compile_commands//:refresh_all -- --compilation_mode=dbg
include Makefiles/rules.mk

# Define the path to the Dockerfile
DOCKER_FILE_PATH := dockerfiles/Dockerfile

DOCKER_BUILD_CMD := $(DOCKER_HOST) image build -t $(DOCKER_IMG_NAME) -f $(DOCKER_FILE_PATH) $(DOCKER_BUILD_CONTEXT)
DOCKER_RUN_CMD := $(DOCKER_HOST) container run $(DOCKER_ARG) $(DOCKER_IMG_NAME)

# Define the default target
.PHONY: all test clean

# Targets
all: build run
all: clean build

# Target: build_img
# Description: Builds the Docker image using the specified Dockerfile
.PHONY: build_img
build_img:
@$(DOCKER_HOST) image build -t $(DOCKER_IMG_NAME) -f $(DOCKER_FILE_PATH) $(DOCKER_BUILD_CONTEXT)
@$(DOCKER_BUILD_CMD)

# Code Build
build: build_img
@$(DOCKER_HOST) container run $(DOCKER_ARG) $(DOCKER_IMG_NAME) "$(BUILD_CMD)"
@$(DOCKER_RUN_CMD) $(BUILD_CMD)

# Test code
test: build_img
@$(DOCKER_HOST) container run $(DOCKER_ARG) $(DOCKER_IMG_NAME) "$(TEST_CMD)"
@$(DOCKER_RUN_CMD) $(TEST_CMD)

# Run code
run: build_img
@$(DOCKER_HOST) container run $(DOCKER_ARG) $(DOCKER_IMG_NAME) "$(RUN_CMD)"
@$(DOCKER_RUN_CMD) $(RUN_CMD)

# Clean
clean: build_img
@$(DOCKER_HOST) container run $(DOCKER_ARG) $(DOCKER_IMG_NAME) "$(CLEAN_CMD)"
@$(DOCKER_RUN_CMD) $(CLEAN_CMD)

# Sonar
sonar: clean build
@$(DOCKER_HOST) container run $(DOCKER_ARG) $(DOCKER_IMG_NAME) "$(SONAR_CMD)"
@$(DOCKER_RUN_CMD) $(SONAR_CMD)
10 changes: 10 additions & 0 deletions Makefiles/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

# Targets
.PHONY: all test clean

BUILD_TOOL := bazel
BUILD_CMD := build //$(TOP_DIR):all
TEST_CMD := test //$(TOP_DIR):test
RUN_CMD := run //$(TOP_DIR):main
CLEAN_CMD := clean --async
SONAR_CMD := run @hedron_compile_commands//:refresh_all -- --compilation_mode=dbg
19 changes: 8 additions & 11 deletions Makefiles/vsc.mk
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
include cfg/.env
include Makefiles/rules.mk

# Targets
.PHONY: all test clean

all:
@bazel build //$(TOP_DIR):all
all: clean build

build:
@bazel build //$(TOP_DIR):all
@$(BUILD_TOOL) $(BUILD_CMD)

test:
@bazel test //$(TOP_DIR):test
@$(BUILD_TOOL) $(TEST_CMD)

run:
@bazel run //$(TOP_DIR):main
@$(BUILD_TOOL) $(RUN_CMD)

clean_json:
@rm -rf compile_commands.json

clean: clean_json
@bazel clean --async
clean:
@$(BUILD_TOOL) $(CLEAN_CMD)

sonar: clean build
@bazel run @hedron_compile_commands//:refresh_all -- --compilation_mode=dbg
@$(BUILD_TOOL) $(SONAR_CMD)
2 changes: 1 addition & 1 deletion cfg/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
PROJECT_NAME := $(shell basename `git rev-parse --show-toplevel` | tr '[:upper:]' '[:lower:]')

# Top directory where all code resides
TOP_DIR := "project"
TOP_DIR := project
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ USER ubuntu
# ##########################################################################
# Command to Run
# ##########################################################################
CMD ["/bin/bash"]
CMD [ "version" ]

0 comments on commit e55324e

Please sign in to comment.