Files
RetroArch/samples/Makefile
T
libretroadmin afbad7a104 samples: shared sources build into each sample's own obj/
Samples compiled shared tree sources in place, so whichever sample ran
next linked those objects with the flags they were built with, as
unity_identity did with mic_handshake's ASan objects. Every sample that
builds a source from outside its directory now includes
sample_objdir.mk and maps those objects under its own obj/; its own
objects stay where they were. The rule for the mapped objects has a
slash in its target, so make 3.81 does not strip the directory.

tools/sample_objdir_check.py dry-runs every sample Makefile and fails
on an object written outside the sample; the Samples-Objdir-Check
workflow runs it.
2026-10-10 19:43:34 +02:00

58 lines
2.1 KiB
Makefile

# Build - and where possible run - every sample harness.
#
# make -C samples build them all
# make -C samples check build and run them all
# make -C samples clean
#
# Worth doing before pushing anything that touches gfx/ or
# libretro-common: the samples stub out large parts of RetroArch, so
# adding a call to a new function in a file a sample compiles will
# break that sample's link without touching the main build. That has
# happened, twice, both times caught by CI rather than here.
#
# Each sample is cleaned first, so a change of SAN= rebuilds it. Shared
# sources are compiled into each sample's own obj/ (sample_objdir.mk).
#
# SAN= is passed through to the samples that honour it, so
# make -C samples check SAN=thread
# runs the suite under TSan instead of ASan/UBSan.
SAMPLES := $(patsubst %/Makefile,%,$(wildcard */*/Makefile))
all:
@rc=0; for d in $(SAMPLES); do \
printf '%-52s ' "$$d"; \
$(MAKE) -s -C $$d clean >/dev/null 2>&1; \
if $(MAKE) -s -C $$d $(if $(SAN),SAN=$(SAN)) >/tmp/.sample.log 2>&1; then \
w=`grep -c 'warning:' /tmp/.sample.log`; \
if [ "$$w" != "0" ]; then echo "ok ($$w warnings)"; else echo "ok"; fi; \
else \
echo "BUILD FAILED"; \
grep -E 'undefined reference|error:' /tmp/.sample.log | head -3 | sed 's/^/ /'; \
rc=1; \
fi; \
done; rm -f /tmp/.sample.log; exit $$rc
check:
@rc=0; for d in $(SAMPLES); do \
printf '%-52s ' "$$d"; \
$(MAKE) -s -C $$d clean >/dev/null 2>&1; \
if $(MAKE) -s -C $$d $(if $(SAN),SAN=$(SAN)) >/tmp/.sample.log 2>&1; then \
if $(MAKE) -s -C $$d check >>/tmp/.sample.log 2>&1; then echo "ok"; \
else \
bin=`ls $$d | grep -E '_test$$|^lifecycle$$|^create$$' | head -1`; \
if [ -n "$$bin" ] && (cd $$d && ./$$bin >/dev/null 2>&1); then echo "ok"; \
else echo "ok (built, no runner)"; fi; \
fi; \
else \
echo "BUILD FAILED"; \
grep -E 'undefined reference|error:' /tmp/.sample.log | head -3 | sed 's/^/ /'; \
rc=1; \
fi; \
done; rm -f /tmp/.sample.log; exit $$rc
clean:
@for d in $(SAMPLES); do $(MAKE) -s -C $$d clean >/dev/null 2>&1 || true; done
.PHONY: all check clean