From 96087da46f99e71c52565d3fcd6758968d0f18b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez=20Di=20Antonio?= Date: Sun, 31 Mar 2024 19:43:24 +0200 Subject: [PATCH] fix: Makefile --- .github/workflows/c-build.yml | 25 ++++++++++++++++++++++++- Makefile | 18 ++++++++++-------- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/.github/workflows/c-build.yml b/.github/workflows/c-build.yml index 5f30008..458695d 100644 --- a/.github/workflows/c-build.yml +++ b/.github/workflows/c-build.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: jobs: - build: + test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -38,4 +38,27 @@ jobs: - name: make memcheck run: make memcheck + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt install software-properties-common -y + sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y + sudo apt-get update -y + sudo apt-get install -y gcc-13 valgrind + + - name: Set up gcc-13 + run: | + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 90 + + - name: Check versions + run: | + gcc --version + make --version + + - name: make build + run: make build diff --git a/Makefile b/Makefile index b7d82e1..8ac97cf 100644 --- a/Makefile +++ b/Makefile @@ -4,25 +4,27 @@ TEST_APP = test_linkedlist TARGET_LIB = linkedlistlib.so -CC_MACOS = "/opt/homebrew/bin/gcc-13" -CC_LINUX = "/usr/bin/gcc" +CC_MACOS ?= /opt/homebrew/bin/gcc-13 +CC_LINUX ?= /usr/bin/gcc -AR_MACOS = "/opt/homebrew/bin/gcc-ar-13" -AR_LINUX = "/usr/bin/ar" +AR_MACOS ?= /opt/homebrew/bin/gcc-ar-13 +AR_LINUX ?= /usr/bin/ar -MEMCHECK_MACOS = "/usr/bin/leaks" -MEMCHECK_LINUX = "/usr/bin/valgrind" +MEMCHECK_MACOS ?= /usr/bin/leaks +MEMCHECK_LINUX ?= /usr/bin/valgrind # Determine OS UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) MEMCHECK = $(MEMCHECK_MACOS) + MEMCHECK_ARGS = --atExit -- CC = $(CC_MACOS) AR = $(AR_MACOS) endif ifeq ($(UNAME_S),Linux) MEMCHECK = $(MEMCHECK_LINUX) + MEMCHECK_ARGS = CC = $(CC_LINUX) AR = $(AR_LINUX) endif @@ -97,8 +99,8 @@ test: clean build $(TEST_APP) ## Run tests .PHONY: memcheck memcheck: test ## Run tests and check for memory leaks - @echo "Running tests with valgrind..." - leaks --atExit -- ./$(BUILD_DIR)/$(TEST_APP) + @echo "Running tests with memory check..." + $(MEMCHECK) $(MEMCHECK_ARGS) ./$(BUILD_DIR)/$(TEST_APP) ##@ Clean commands .PHONY: clean