diff options
-rw-r--r-- | .gitignore | 17 | ||||
-rw-r--r-- | Makefile | 122 | ||||
-rw-r--r-- | deps.mk | 0 | ||||
-rwxr-xr-x | mkdeps.sh | 10 | ||||
-rw-r--r-- | src/golite.go | 4 | ||||
-rw-r--r-- | tests/golite.go | 8 | ||||
-rw-r--r-- | tests/main.go | 7 |
7 files changed, 154 insertions, 14 deletions
@@ -1,14 +1,3 @@ -*.db -*.exe -*.dll -*.o - -# VSCode -.vscode - -# Exclude from upgrade -upgrade/*.c -upgrade/*.h - -# Exclude upgrade binary -upgrade/upgrade +/src/*.a +/tests/*.a +/tests/*.bin diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bb6e39d --- /dev/null +++ b/Makefile @@ -0,0 +1,122 @@ +.POSIX: +DATE = 1970-01-01 +VERSION = 0.1.0 +NAME = golite +NAME_UC = $(NAME) +LANGUAGES = en +## Installation prefix. Defaults to "/usr". +PREFIX = /usr +BINDIR = $(PREFIX)/bin +LIBDIR = $(PREFIX)/lib +GOLIBDIR = $(LIBDIR)/go +INCLUDEDIR = $(PREFIX)/include +SRCDIR = $(PREFIX)/src/$(NAME) +SHAREDIR = $(PREFIX)/share +LOCALEDIR = $(SHAREDIR)/locale +MANDIR = $(SHAREDIR)/man +EXEC = ./ +## Where to store the installation. Empty by default. +DESTDIR = +LDLIBS = + + + +.SUFFIXES: +.SUFFIXES: .go .a .bin .bin-check + + + +all: +include deps.mk + + +objects = \ + src/$(NAME).a \ + tests/$(NAME).a \ + tests/main.a \ + +sources = \ + src/$(NAME).go \ + + +derived-assets = \ + $(objects) \ + tests/main.bin \ + +side-assets = \ + + + +## Default target. Builds all artifacts required for testing +## and installation. +all: $(derived-assets) + + +$(objects): Makefile + +src/$(NAME).a: src/$(NAME).go +tests/main.a: tests/main.go tests/$(NAME).a +src/$(NAME).a tests/main.a: + go tool compile $(GOCFLAGS) -o $@ -p $(*F) -I $(@D) $*.go + +tests/$(NAME).a: tests/$(NAME).go src/$(NAME).go + go tool compile $(GOCFLAGS) -o $@ -p $(*F) $*.go src/$(*F).go + +tests/main.bin: tests/main.a + go tool link $(GOLDFLAGS) -o $@ -L $(@D) $*.a + + + +tests.bin-check = \ + tests/main.bin-check \ + +tests/main.bin-check: tests/main.bin +$(tests.bin-check): + $(EXEC)$*.bin + +check-unit: $(tests.bin-check) + + +integration-tests = \ + +.PRECIOUS: $(integration-tests) +$(integration-tests): $(NAME).bin +$(integration-tests): ALWAYS + sh $@ + +check-integration: $(integration-tests) + + +## Run all tests. Each test suite is isolated, so that a parallel +## build can run tests at the same time. The required artifacts +## are created if missing. +check: check-unit check-integration + + + +## Remove *all* derived artifacts produced during the build. +## A dedicated test asserts that this is always true. +clean: + rm -rf $(derived-assets) $(side-assets) + + +## Installs into $(DESTDIR)$(PREFIX). Its dependency target +## ensures that all installable artifacts are crafted beforehand. +install: all + mkdir -p \ + '$(DESTDIR)$(GOLIBDIR)' \ + '$(DESTDIR)$(SRCDIR)' \ + + cp src/$(NAME).a '$(DESTDIR)$(GOLIBDIR)' + cp $(sources) '$(DESTDIR)$(SRCDIR)' + +## Uninstalls from $(DESTDIR)$(PREFIX). This is a perfect mirror +## of the "install" target, and removes *all* that was installed. +## A dedicated test asserts that this is always true. +uninstall: + rm -rf \ + '$(DESTDIR)$(GOLIBDIR)'/$(NAME).a \ + '$(DESTDIR)$(SRCDIR)' \ + + +ALWAYS: diff --git a/mkdeps.sh b/mkdeps.sh new file mode 100755 index 0000000..a6b23d5 --- /dev/null +++ b/mkdeps.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -eu + +export LANG=POSIX.UTF-8 + +varlist() { + printf '%s = \\\n' "$1" + sed 's|^\(.*\)$|\t\1 \\|' + printf '\n' +} diff --git a/src/golite.go b/src/golite.go new file mode 100644 index 0000000..2c52764 --- /dev/null +++ b/src/golite.go @@ -0,0 +1,4 @@ +package golite + +import ( +) diff --git a/tests/golite.go b/tests/golite.go new file mode 100644 index 0000000..1988f6e --- /dev/null +++ b/tests/golite.go @@ -0,0 +1,8 @@ +package golite + +import ( +) + + +func MainTest() { +} diff --git a/tests/main.go b/tests/main.go new file mode 100644 index 0000000..f8a5b6f --- /dev/null +++ b/tests/main.go @@ -0,0 +1,7 @@ +package main + +import "golite" + +func main() { + golite.MainTest() +} |