From 351562bb8928c6100d3db7f918672f0ce36fac8d Mon Sep 17 00:00:00 2001 From: Jean <47366872+jean-voila@users.noreply.github.com> Date: Mon, 26 Jan 2026 18:35:08 +0100 Subject: [PATCH] feat: flemme scripts for building and testing --- README.md | 4 +++- build_flemme.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ check_flemme.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100755 build_flemme.sh create mode 100755 check_flemme.sh diff --git a/README.md b/README.md index be08206..d3686bf 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ then: #### asan run this command: `./configure CFLAGS='-std=c99 -Werror -Wall -Wextra -Wvla -g -fsanitize=address'` +or for MacOS (Jean Here): + `./configure CFLAGS='-std=c99 -Werror -Wall -Wextra -Wvla -I/opt/homebrew/include' LDFLAGS='-L/opt/homebrew/lib'` then: `make check` @@ -26,7 +28,7 @@ then: ## Authors - Matteo Flebus -- Jean Hérail +- Jean Herail - William Valenduc - Guillem George diff --git a/build_flemme.sh b/build_flemme.sh new file mode 100755 index 0000000..e16b9f0 --- /dev/null +++ b/build_flemme.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# build_only.sh - Automates build for 42sh with pretty output (no tests) + +set -e + +# Colors +GREEN="\033[1;32m" +RED="\033[1;31m" +YELLOW="\033[1;33m" +RESET="\033[0m" + +VERBOSE=0 +if [[ "$1" == "--verbose" ]]; then + VERBOSE=1 +fi + +run_cmd() { + local desc="$1" + shift + if [[ $VERBOSE -eq 1 ]]; then + echo -e "${YELLOW}${desc}...${RESET}" + "$@" + else + echo -ne "${YELLOW}${desc}...${RESET}" + "$@" &> /dev/null && echo -e " ${GREEN}done${RESET}" || { echo -e " ${RED}failed${RESET}"; exit 1; } + fi +} + +run_cmd "Running autoreconf" autoreconf --force --verbose --install + +if [[ "$(uname)" == "Darwin" ]]; then + run_cmd "Configuring for MacOS" ./configure CFLAGS='-std=c99 -Werror -Wall -Wextra -Wvla -I/opt/homebrew/include' LDFLAGS='-L/opt/homebrew/lib' +else + run_cmd "Configuring for Linux" ./configure CFLAGS='-std=c99 -Werror -Wall -Wextra -Wvla -g -fsanitize=address' +fi + +run_cmd "Cleaning build" make clean + +if [[ $VERBOSE -eq 1 ]]; then + echo -e "${YELLOW}Building...${RESET}" + make +else + echo -ne "${YELLOW}Building...${RESET}" + echo + make +fi diff --git a/check_flemme.sh b/check_flemme.sh new file mode 100755 index 0000000..0543001 --- /dev/null +++ b/check_flemme.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# build_and_test.sh - Automates build and test for 42sh with pretty output + +set -e + +# Colors +GREEN="\033[1;32m" +RED="\033[1;31m" +YELLOW="\033[1;33m" +RESET="\033[0m" + +VERBOSE=0 +if [[ "$1" == "--verbose" ]]; then + VERBOSE=1 +fi + +run_cmd() { + local desc="$1" + shift + if [[ $VERBOSE -eq 1 ]]; then + echo -e "${YELLOW}${desc}...${RESET}" + "$@" + else + echo -ne "${YELLOW}${desc}...${RESET}" + "$@" &> /dev/null && echo -e " ${GREEN}done${RESET}" || { echo -e " ${RED}failed${RESET}"; exit 1; } + fi +} + +run_cmd "Running autoreconf" autoreconf --force --verbose --install + +if [[ "$(uname)" == "Darwin" ]]; then + run_cmd "Configuring for MacOS" ./configure CFLAGS='-std=c99 -Werror -Wall -Wextra -Wvla -I/opt/homebrew/include' LDFLAGS='-L/opt/homebrew/lib' +else + run_cmd "Configuring for Linux" ./configure CFLAGS='-std=c99 -Werror -Wall -Wextra -Wvla -g -fsanitize=address' +fi + +run_cmd "Cleaning build" make clean +if [[ $VERBOSE -eq 1 ]]; then + echo -e "${YELLOW}Running tests...${RESET}" + make check +else + echo -ne "${YELLOW}Running tests...${RESET}" + echo + make check +fi