h48

A prototype for an optimal Rubik's cube solver, work in progress.
git clone https://git.tronto.net/h48
Download | Log | Files | Refs | README | LICENSE

commit b8d17736ce2c85174a47c7200ef6d19a51d0c347
parent 8d3fe446815a1631876e4170747bc6cb03a6bbf8
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Wed,  2 Oct 2024 18:37:36 +0200

Do not run make clean automatically on every build and other Makefile changes

Diffstat:
M.gitignore | 1+
MMakefile | 37++++++++++++++++++++-----------------
Mtest/test.sh | 4+---
Dtools/run_tool.sh | 25-------------------------
Atools/tool.sh | 22++++++++++++++++++++++
5 files changed, 44 insertions(+), 45 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -19,4 +19,5 @@ test/last.* tools/results .vscode *.o +*.so *.s diff --git a/Makefile b/Makefile @@ -1,36 +1,39 @@ include config.mk -all: cube.o debugcube.o +all: nissy.o -cube.s: clean - ${CC} ${MACROS} ${CFLAGS} -c -S -o cube.s src/nissy.c +nissy.s: + ${CC} ${MACROS} ${CFLAGS} -c -S -o nissy.s src/nissy.c -cube.o: clean - ${CC} ${MACROS} ${CFLAGS} -c -o cube.o src/nissy.c +nissy.o: + ${CC} ${MACROS} ${CFLAGS} -c -o nissy.o src/nissy.c -debugcube.o: clean - ${CC} ${MACROS} ${DBGFLAGS} -c -o debugcube.o src/nissy.c +nissy.so: + ${CC} ${MACROS} ${CFLAGS} -c -shared -o nissy.so src/nissy.c + +debugnissy.o: + ${CC} ${MACROS} ${DBGFLAGS} -c -o debugnissy.o src/nissy.c clean: rm -rf *.o run -test: debugcube.o - CC="${CC} ${MACROS} ${DBGFLAGS}" ./test/test.sh +test: debugnissy.o + CC="${CC} ${MACROS} ${DBGFLAGS}" OBJ=debugnissy.o ./test/test.sh -tool: cube.o +tool: nissy.o mkdir -p tools/results - CC="${CC} ${MACROS} ${CFLAGS}" CUBEOBJ=cube.o ./tools/run_tool.sh + CC="${CC} ${MACROS} ${CFLAGS}" OBJ=nissy.o ./tools/tool.sh -debugtool: debugcube.o +debugtool: debugnissy.o mkdir -p tools/results - CC="${CC} ${MACROS} ${DBGFLAGS}" CUBEOBJ=debugcube.o ./tools/run_tool.sh + CC="${CC} ${MACROS} ${DBGFLAGS}" OBJ=debugnissy.o ./tools/tool.sh -shell: cube.o +shell: nissy.o mkdir -p tables - ${CC} ${MACROS} ${CFLAGS} -o run cube.o shell.c + ${CC} ${MACROS} ${CFLAGS} -o run nissy.o shell.c -debugshell: debugcube.o +debugshell: debugnissy.o mkdir -p tables - ${CC} ${MACROS} ${DBGFLAGS} -o run debugcube.o shell.c + ${CC} ${MACROS} ${DBGFLAGS} -o run debugnissy.o shell.c .PHONY: all clean test tool debugtool shell debugshell diff --git a/test/test.sh b/test/test.sh @@ -5,7 +5,6 @@ re="${TEST:-$@}" TESTBIN="test/run" TESTOUT="test/last.out" TESTERR="test/last.err" -CUBEOBJ="debugcube.o" for t in test/*; do if [ -n "$re" ] && !(echo "$t" | grep -q "$re"); then @@ -14,7 +13,7 @@ for t in test/*; do # Verify if $t is a directory and if its name starts with three digits if [ -d "$t" ] && basename "$t" | grep -Eq '^[0-9]{3}'; then - $CC -o $TESTBIN "$t"/*.c $CUBEOBJ || exit 1 + $CC -o $TESTBIN "$t"/*.c $OBJ || exit 1 for cin in "$t"/*.in; do c=$(echo "$cin" | sed 's/\.in//') cout="$c.out" @@ -32,4 +31,3 @@ for t in test/*; do done echo "All tests passed!" -rm -rf $TESTBIN $TESTOUT $TESTERR $CUBEOBJ diff --git a/tools/run_tool.sh b/tools/run_tool.sh @@ -1,25 +0,0 @@ -#!/bin/sh - -if [ -z "$TOOL" ]; then - echo "No tool selected (TOOL variable must be set)" - exit 1 -fi - -CC="$CC -D_POSIX_C_SOURCE=199309L" # For timer - -BIN="tools/run" -d="$(date +'%Y-%m-%d-%H-%M-%S')" - -for t in tools/*; do - if [ ! -d "$t" ] || ! (echo "$t" | grep -q "$TOOL"); then - continue - fi - toolname="$(basename "$t" .c)" - $CC -o $BIN "$t"/*.c "$CUBEOBJ" || exit 1; - $BIN $TOOLARGS \ - | tee "tools/results/$toolname-$d.txt" "tools/results/last.out" - break -done - -# $BIN is kept so it can be run manually for profiling -rm -rf "$CUBEOBJ" diff --git a/tools/tool.sh b/tools/tool.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +if [ -z "$TOOL" ]; then + echo "No tool selected (TOOL variable must be set)" + exit 1 +fi + +CC="$CC -D_POSIX_C_SOURCE=199309L" # For timer + +BIN="tools/run" +d="$(date +'%Y-%m-%d-%H-%M-%S')" + +for t in tools/*; do + if [ ! -d "$t" ] || ! (echo "$t" | grep -q "$TOOL"); then + continue + fi + toolname="$(basename "$t" .c)" + $CC -o $BIN "$t"/*.c "$OBJ" || exit 1; + $BIN $TOOLARGS \ + | tee "tools/results/$toolname-$d.txt" "tools/results/last.out" + break +done