diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 65 | ||||
-rw-r--r-- | src/binder.go (renamed from src/lib.go) | 2 | ||||
-rw-r--r-- | src/main.go (renamed from src/cmd/main.go) | 2 | ||||
-rw-r--r-- | tests/binder.go | 21 | ||||
-rw-r--r-- | tests/lib_test.go | 24 | ||||
-rw-r--r-- | tests/main.go | 7 |
7 files changed, 80 insertions, 44 deletions
@@ -1,2 +1,5 @@ /*.bin +/src/*.a +/src/*.bin +/tests/*.a /tests/*.bin @@ -8,6 +8,7 @@ LANGUAGES = en PREFIX = /usr BINDIR = $(PREFIX)/bin LIBDIR = $(PREFIX)/lib +GOLIBDIR = $(LIBDIR)/go INCLUDEDIR = $(PREFIX)/include SRCDIR = $(PREFIX)/src/$(NAME) SHAREDIR = $(PREFIX)/share @@ -17,12 +18,11 @@ EXEC = ./ ## Where to store the installation. Empty by default. DESTDIR = LDLIBS = -GOFLAGS = .SUFFIXES: -.SUFFIXES: .go .bin +.SUFFIXES: .go .a .bin .bin-check @@ -30,14 +30,22 @@ all: include deps.mk +objects = \ + src/$(NAME).a \ + src/main.a \ + tests/$(NAME).a \ + tests/main.a \ + sources = \ - src/lib.go \ - src/cmd/main.go \ + src/$(NAME).go \ + src/main.go \ derived-assets = \ + $(objects) \ + src/main.bin \ + tests/main.bin \ $(NAME).bin \ - tests/lib_test.bin \ side-assets = \ glaze.socket \ @@ -49,16 +57,37 @@ side-assets = \ all: $(derived-assets) -$(NAME).bin: src/lib.go src/cmd/main.go Makefile - go build $(GOFLAGS) -v -o $@ src/cmd/main.go +$(objects): Makefile + +src/$(NAME).a: src/$(NAME).go + go tool compile $(GOCFLAGS) -o $@ -p $(*F) $*.go + +tests/$(NAME).a: tests/$(NAME).go src/$(NAME).go + go tool compile $(GOCFLAGS) -o $@ -p $(*F) $*.go src/$(NAME).go + +src/main.a: src/main.go src/$(NAME).a +tests/main.a: tests/main.go tests/$(NAME).a +src/main.a tests/main.a: + go tool compile $(GOCFLAGS) -o $@ -I $(@D) $*.go + +src/main.bin: src/main.a +tests/main.bin: tests/main.a +src/main.bin tests/main.bin: + go tool link $(GOLDFLAGS) -o $@ -L $(@D) $*.a + +$(NAME).bin: src/main.bin + ln -fs $? $@ + -tests/lib_test.bin: src/lib.go tests/lib_test.go Makefile - go test $(GOFLAGS) -v -o $@ -c $*.go +tests.bin-check = \ + tests/main.bin-check +$(tests.bin-check): tests/main.bin +$(tests.bin-check): + $(EXEC)$*.bin -check-unit: tests/lib_test.bin - ./tests/lib_test.bin +check-unit: $(tests.bin-check) integration-tests = \ @@ -91,21 +120,21 @@ clean: install: all mkdir -p \ '$(DESTDIR)$(BINDIR)' \ + '$(DESTDIR)$(GOLIBDIR)' \ + '$(DESTDIR)$(SRCDIR)' \ cp $(NAME).bin '$(DESTDIR)$(BINDIR)'/$(NAME) - for f in $(sources); do \ - dir='$(DESTDIR)$(SRCDIR)'/"`dirname "$${f#src/}"`"; \ - mkdir -p "$$dir"; \ - cp -P "$$f" "$$dir"; \ - done + 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)$(BINDIR)'/$(NAME) \ - '$(DESTDIR)$(SRCDIR)' \ + '$(DESTDIR)$(BINDIR)'/$(NAME) \ + '$(DESTDIR)$(GOLIBDIR)'/$(NAME).a \ + '$(DESTDIR)$(SRCDIR)' \ diff --git a/src/lib.go b/src/binder.go index 4ece950..8950c29 100644 --- a/src/lib.go +++ b/src/binder.go @@ -8,7 +8,7 @@ import ( "strconv" "syscall" - g "euandre.org/gobang/src" + g "gobang" ) diff --git a/src/cmd/main.go b/src/main.go index d9c8379..8fb49be 100644 --- a/src/cmd/main.go +++ b/src/main.go @@ -1,6 +1,6 @@ package main -import "euandre.org/binder/src" +import "binder" func main() { binder.Main() diff --git a/tests/binder.go b/tests/binder.go new file mode 100644 index 0000000..0a1c3b7 --- /dev/null +++ b/tests/binder.go @@ -0,0 +1,21 @@ +package binder + +import ( + g "gobang" +) + + + +func test_ParseArgs() { + given := ParseArgs([]string { "a", "b", "c" }) + expected := CLIArgs { + FromAddr: "b", + ToAddr: "c", + } + + g.AssertEqual(given, expected) +} + +func MainTest() { + test_ParseArgs() +} diff --git a/tests/lib_test.go b/tests/lib_test.go deleted file mode 100644 index 4e63d06..0000000 --- a/tests/lib_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package binder_test - -import ( - "testing" - - g "euandre.org/gobang/src" - - "euandre.org/binder/src" -) - - -func TestPlaceholder(t *testing.T) { - g.AssertEqual(t, binder.USER, "nobody") -} - -func TestParseArgs(t *testing.T) { - given := binder.ParseArgs([]string { "a", "b", "c" }) - expected := binder.CLIArgs { - FromAddr: "b", - ToAddr: "c", - } - - g.AssertEqual(t, given, expected) -} diff --git a/tests/main.go b/tests/main.go new file mode 100644 index 0000000..846bc7e --- /dev/null +++ b/tests/main.go @@ -0,0 +1,7 @@ +package main + +import "binder" + +func main() { + binder.MainTest() +} |