diff options
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | Makefile | 82 | ||||
-rw-r--r-- | deps.mk | 25 | ||||
-rw-r--r-- | doc/golite.en.0.adoc | 5 | ||||
-rwxr-xr-x | mkdeps.sh | 32 | ||||
-rw-r--r-- | po/doc/de.po | 22 | ||||
-rw-r--r-- | po/doc/doc.pot | 21 | ||||
-rw-r--r-- | po/doc/eo.po | 22 | ||||
-rw-r--r-- | po/doc/es.po | 22 | ||||
-rw-r--r-- | po/doc/fr.po | 22 | ||||
-rw-r--r-- | po/doc/note.txt | 5 | ||||
-rw-r--r-- | po/doc/po4a.cfg | 5 | ||||
-rw-r--r-- | po/doc/pt.po | 22 | ||||
-rw-r--r-- | po/golite/de.po | 9 | ||||
-rw-r--r-- | po/golite/eo.po | 9 | ||||
-rw-r--r-- | po/golite/es.po | 9 | ||||
-rw-r--r-- | po/golite/fr.po | 9 | ||||
-rw-r--r-- | po/golite/golite.pot | 9 | ||||
-rw-r--r-- | po/golite/po4a.cfg | 3 | ||||
-rw-r--r-- | po/golite/pt.po | 9 | ||||
-rw-r--r-- | src/golite.go | 4 |
21 files changed, 315 insertions, 36 deletions
@@ -1,4 +1,7 @@ -/src/version.go +/doc/* +!/doc/*.en.*.adoc +/po/*/*.mo +/src/meta.go /*.bin /src/*.a /src/*.bin @@ -3,7 +3,6 @@ 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 @@ -20,11 +19,12 @@ DESTDIR = LDLIBS = --static -lsqlite3 -lm GOCFLAGS = -I $(GOLIBDIR) GOLDFLAGS = -L $(GOLIBDIR) +N = `nproc` .SUFFIXES: -.SUFFIXES: .go .a .c .o .bin .bin-check +.SUFFIXES: .go .a .c .o .bin .bin-check .adoc .po .mo .c.o: $(CC) $(CFLAGS) -o $@ -c $< @@ -32,23 +32,32 @@ GOLDFLAGS = -L $(GOLIBDIR) .go.a: go tool compile -I $(@D) $(GOCFLAGS) -o $@ -p $(*F) \ `find $< $$(if [ $(*F) != main ]; then \ - echo src/$(NAME).go src/version.go; fi) | uniq` + echo src/$(NAME).go src/meta.go; fi) | uniq` .a.bin: go tool link -L $(@D) $(GOLDFLAGS) -o $@ --extldflags '$(LDLIBS)' $< +.adoc: + asciidoctor -b manpage -o $@ $< + +.po.mo: + msgfmt -cfv -o $@ $< + all: include deps.mk -libs.a = $(libs.go:.go=.a) -mains.a = $(mains.go:.go=.a) -mains.bin = $(mains.go:.go=.bin) -functional-tests/lib.a = $(functional-tests/lib.go:.go=.a) -fuzz-targets/lib.a = $(fuzz-targets/lib.go:.go=.a) -benchmarks/lib.a = $(benchmarks/lib.go:.go=.a) +libs.a = $(libs.go:.go=.a) +mains.a = $(mains.go:.go=.a) +mains.bin = $(mains.go:.go=.bin) +functional/lib.a = $(functional/lib.go:.go=.a) +fuzz/lib.a = $(fuzz/lib.go:.go=.a) +benchmarks/lib.a = $(benchmarks/lib.go:.go=.a) +manpages.N.adoc = $(manpages.en.N.adoc) $(manpages.XX.N.adoc) +manpages.N = $(manpages.N.adoc:.adoc=) +sources.mo = $(sources.po:.po=.mo) cgo.go = \ src/_cgo_import.go \ @@ -69,15 +78,18 @@ objects = \ sources = \ src/$(NAME).go \ - src/version.go \ + src/meta.go \ derived-assets = \ - src/version.go \ + src/meta.go \ $(objects) \ $(libs.a) \ $(mains.a) \ $(mains.bin) \ + $(manpages.XX.N.adoc) \ + $(manpages.N) \ + $(sources.mo) \ side-assets = \ src/_cgo_export.h \ @@ -94,7 +106,7 @@ all: $(derived-assets) $(objects): Makefile deps.mk $(libs.a): Makefile deps.mk -$(libs.a): src/$(NAME).go src/version.go +$(libs.a): src/$(NAME).go src/meta.go $(libs.a): $(cgo.go) $(cgo.o) $(cgo.go) $(cgo.c) $(cgo.o): src/_cgo_.o @@ -106,24 +118,30 @@ src/_cgo_.o: src/$(NAME).go src/_cgo_import.go: src/_cgo_.o go tool cgo --dynpackage $(NAME) --dynimport src/_cgo_.o --dynout $@ -src/$(NAME).a tests/$(NAME).a $(functional-tests/lib.a) $(benchmarks/lib.a): - go tool compile $(GOCFLAGS) -o $@ -p $(*F) $(cgo.go) src/version.go \ +src/$(NAME).a tests/$(NAME).a $(functional/lib.a) $(benchmarks/lib.a): + go tool compile $(GOCFLAGS) -o $@ -p $(*F) $(cgo.go) src/meta.go \ `find $*.go | grep -Ev '^src/$(NAME)\.go$$'` go tool pack r $@ $(cgo.o) -$(fuzz-targets/lib.a): +$(fuzz/lib.a): go tool compile $(GOCFLAGS) -o $@ -p $(NAME) -d=libfuzzer \ - $*.go $(cgo.go) src/version.go + $*.go $(cgo.go) src/meta.go go tool pack r $@ $(cgo.o) -src/version.go: Makefile - echo 'package $(NAME); const Version = "$(VERSION)"' > $@ +src/meta.go: Makefile + echo 'package $(NAME)' > $@ + echo 'const Version = "$(VERSION)"' >> $@ + echo 'const Name = "$(NAME)"' >> $@ + echo 'const LOCALEDIR = "$(LOCALEDIR)"' >> $@ + +$(manpages.XX.N.adoc): po/doc/po4a.cfg + po4a --no-update --translate-only $@ po/doc/po4a.cfg tests.bin-check = \ tests/main.bin-check \ - $(functional-tests/main.go:.go=.bin-check) \ + $(functional/main.go:.go=.bin-check) \ $(tests.bin-check): $(EXEC)$*.bin @@ -150,12 +168,12 @@ check: check-unit check-integration FUZZSEC=1 -fuzz-targets/main.bin-check = $(fuzz-targets/main.go:.go=.bin-check) -$(fuzz-targets/main.bin-check): - $(EXEC)$*.bin --test.fuzztime=$(FUZZSEC)s \ +fuzz/main.bin-check = $(fuzz/main.go:.go=.bin-check) +$(fuzz/main.bin-check): + $(EXEC)$*.bin --test.fuzztime=$(FUZZSEC)s --test.parallel=$N \ --test.fuzz='.*' --test.fuzzcachedir=tests/fuzz/corpus -fuzz: $(fuzz-targets/main.bin-check) +fuzz: $(fuzz/main.bin-check) @@ -169,6 +187,17 @@ bench: $(benchmarks/main.bin-check) +i18n-doc: + po4a po/doc/po4a.cfg + +i18n-code: + gotext src/$(NAME).go > po/$(NAME)/$(NAME).pot + po4a po/$(NAME)/po4a.cfg + +i18n: i18n-doc i18n-code + + + ## Remove *all* derived artifacts produced during the build. ## A dedicated test asserts that this is always true. clean: @@ -183,7 +212,9 @@ install: all '$(DESTDIR)$(SRCDIR)' \ cp src/$(NAME).a '$(DESTDIR)$(GOLIBDIR)' - cp -P $(sources) '$(DESTDIR)$(SRCDIR)' + cp $(sources) '$(DESTDIR)$(SRCDIR)' + instool '$(DESTDIR)$(MANDIR)' install man $(manpages.N) + instool '$(DESTDIR)$(LOCALEDIR)' install mo $(sources.mo) ## Uninstalls from $(DESTDIR)$(PREFIX). This is a perfect mirror ## of the "install" target, and removes *all* that was installed. @@ -193,6 +224,9 @@ uninstall: '$(DESTDIR)$(GOLIBDIR)'/$(NAME).a \ '$(DESTDIR)$(SRCDIR)' \ + instool '$(DESTDIR)$(MANDIR)' uninstall man $(manpages.N) + instool '$(DESTDIR)$(LOCALEDIR)' uninstall mo $(sources.mo) + ALWAYS: @@ -15,18 +15,35 @@ mains.go = \ tests/fuzz/api/main.go \ tests/main.go \ -functional-tests/lib.go = \ +manpages.en.N.adoc = \ + doc/golite.en.0.adoc \ + +manpages.XX.N.adoc = \ + doc/golite.de.0.adoc \ + doc/golite.eo.0.adoc \ + doc/golite.es.0.adoc \ + doc/golite.fr.0.adoc \ + doc/golite.pt.0.adoc \ + +sources.po = \ + po/golite/de.po \ + po/golite/eo.po \ + po/golite/es.po \ + po/golite/fr.po \ + po/golite/pt.po \ + +functional/lib.go = \ tests/functional/json/golite.go \ tests/functional/limit/golite.go \ -functional-tests/main.go = \ +functional/main.go = \ tests/functional/json/main.go \ tests/functional/limit/main.go \ -fuzz-targets/lib.go = \ +fuzz/lib.go = \ tests/fuzz/api/golite.go \ -fuzz-targets/main.go = \ +fuzz/main.go = \ tests/fuzz/api/main.go \ benchmarks/lib.go = \ diff --git a/doc/golite.en.0.adoc b/doc/golite.en.0.adoc new file mode 100644 index 0000000..0ad8895 --- /dev/null +++ b/doc/golite.en.0.adoc @@ -0,0 +1,5 @@ += golite(0) + +== NAME + +golite - . @@ -5,21 +5,41 @@ export LANG=POSIX.UTF-8 libs() { - find src tests -name '*.go' | grep -v '/main\.go$' | - grep -v '/version\.go$' + find src tests -name '*.go' | + grep -Ev '/(main|meta)\.go$' | + grep -Ev '/_cgo_(import|gotypes)\.go$' | + grep -Ev '\.cgo1\.go$' } mains() { find src tests -name '*.go' | grep '/main\.go$' } +docs() { + find doc/*.en.*.adoc +} + +xdocs() { + for l in `find po/doc/*.po | xargs -I% basename % .po`; do + docs | sed 's|/\(.*\)\.en\.\(.*\)$|/\1.'"$l"'.\2|' + done +} + +pos() { + find po/ -name '*.po' | grep -Ev '^po/(doc|tests)/' +} + + libs | varlist 'libs.go' mains | varlist 'mains.go' +docs | varlist 'manpages.en.N.adoc' +xdocs | varlist 'manpages.XX.N.adoc' +pos | varlist 'sources.po' -find tests/functional/*/*.go -not -name main.go | varlist 'functional-tests/lib.go' -find tests/functional/*/main.go | varlist 'functional-tests/main.go' -find tests/fuzz/*/*.go -not -name main.go | varlist 'fuzz-targets/lib.go' -find tests/fuzz/*/main.go | varlist 'fuzz-targets/main.go' +find tests/functional/*/*.go -not -name main.go | varlist 'functional/lib.go' +find tests/functional/*/main.go | varlist 'functional/main.go' +find tests/fuzz/*/*.go -not -name main.go | varlist 'fuzz/lib.go' +find tests/fuzz/*/main.go | varlist 'fuzz/main.go' find tests/benchmarks/*/*.go -not -name main.go | varlist 'benchmarks/lib.go' find tests/benchmarks/*/main.go | varlist 'benchmarks/main.go' diff --git a/po/doc/de.po b/po/doc/de.po new file mode 100644 index 0000000..10ffe8b --- /dev/null +++ b/po/doc/de.po @@ -0,0 +1,22 @@ +msgid "" +msgstr "" +"Language: de\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. type: Title = +#: doc/golite.en.0.adoc:1 +#, no-wrap +msgid "golite(0)" +msgstr "" + +#. type: Title == +#: doc/golite.en.0.adoc:3 +#, no-wrap +msgid "NAME" +msgstr "" + +#. type: Plain text +#: doc/golite.en.0.adoc:5 +msgid "golite - ." +msgstr "" diff --git a/po/doc/doc.pot b/po/doc/doc.pot new file mode 100644 index 0000000..bdc7c36 --- /dev/null +++ b/po/doc/doc.pot @@ -0,0 +1,21 @@ +msgid "" +msgstr "" +"Language: \n" +"Content-Type: text/plain; charset=UTF-8\n" + +#. type: Title = +#: doc/golite.en.0.adoc:1 +#, no-wrap +msgid "golite(0)" +msgstr "" + +#. type: Title == +#: doc/golite.en.0.adoc:3 +#, no-wrap +msgid "NAME" +msgstr "" + +#. type: Plain text +#: doc/golite.en.0.adoc:5 +msgid "golite - ." +msgstr "" diff --git a/po/doc/eo.po b/po/doc/eo.po new file mode 100644 index 0000000..f53cc72 --- /dev/null +++ b/po/doc/eo.po @@ -0,0 +1,22 @@ +msgid "" +msgstr "" +"Language: eo\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. type: Title = +#: doc/golite.en.0.adoc:1 +#, no-wrap +msgid "golite(0)" +msgstr "" + +#. type: Title == +#: doc/golite.en.0.adoc:3 +#, no-wrap +msgid "NAME" +msgstr "" + +#. type: Plain text +#: doc/golite.en.0.adoc:5 +msgid "golite - ." +msgstr "" diff --git a/po/doc/es.po b/po/doc/es.po new file mode 100644 index 0000000..7300bde --- /dev/null +++ b/po/doc/es.po @@ -0,0 +1,22 @@ +msgid "" +msgstr "" +"Language: es\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. type: Title = +#: doc/golite.en.0.adoc:1 +#, no-wrap +msgid "golite(0)" +msgstr "" + +#. type: Title == +#: doc/golite.en.0.adoc:3 +#, no-wrap +msgid "NAME" +msgstr "" + +#. type: Plain text +#: doc/golite.en.0.adoc:5 +msgid "golite - ." +msgstr "" diff --git a/po/doc/fr.po b/po/doc/fr.po new file mode 100644 index 0000000..d6254fe --- /dev/null +++ b/po/doc/fr.po @@ -0,0 +1,22 @@ +msgid "" +msgstr "" +"Language: fr\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. type: Title = +#: doc/golite.en.0.adoc:1 +#, no-wrap +msgid "golite(0)" +msgstr "" + +#. type: Title == +#: doc/golite.en.0.adoc:3 +#, no-wrap +msgid "NAME" +msgstr "" + +#. type: Plain text +#: doc/golite.en.0.adoc:5 +msgid "golite - ." +msgstr "" diff --git a/po/doc/note.txt b/po/doc/note.txt new file mode 100644 index 0000000..45279a4 --- /dev/null +++ b/po/doc/note.txt @@ -0,0 +1,5 @@ +PO4A-HEADER: mode=eof + + + +// Generated from po4a(1). diff --git a/po/doc/po4a.cfg b/po/doc/po4a.cfg new file mode 100644 index 0000000..617db1f --- /dev/null +++ b/po/doc/po4a.cfg @@ -0,0 +1,5 @@ +[options] --keep 0 --master-charset UTF-8 --localized-charset UTF-8 --addendum-charset UTF-8 + +[po_directory] po/doc + +[type: asciidoc] doc/golite.en.0.adoc $lang:doc/golite.$lang.0.adoc diff --git a/po/doc/pt.po b/po/doc/pt.po new file mode 100644 index 0000000..59b7a63 --- /dev/null +++ b/po/doc/pt.po @@ -0,0 +1,22 @@ +msgid "" +msgstr "" +"Language: pt\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. type: Title = +#: doc/golite.en.0.adoc:1 +#, no-wrap +msgid "golite(0)" +msgstr "" + +#. type: Title == +#: doc/golite.en.0.adoc:3 +#, no-wrap +msgid "NAME" +msgstr "" + +#. type: Plain text +#: doc/golite.en.0.adoc:5 +msgid "golite - ." +msgstr "" diff --git a/po/golite/de.po b/po/golite/de.po new file mode 100644 index 0000000..a8380f3 --- /dev/null +++ b/po/golite/de.po @@ -0,0 +1,9 @@ +msgid "" +msgstr "" +"Language: de\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/golite.go:175 +msgid "can't allocate 'cgo-pointer hack index pointer': ptr == nil" +msgstr "" diff --git a/po/golite/eo.po b/po/golite/eo.po new file mode 100644 index 0000000..3118176 --- /dev/null +++ b/po/golite/eo.po @@ -0,0 +1,9 @@ +msgid "" +msgstr "" +"Language: eo\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/golite.go:175 +msgid "can't allocate 'cgo-pointer hack index pointer': ptr == nil" +msgstr "" diff --git a/po/golite/es.po b/po/golite/es.po new file mode 100644 index 0000000..f4ba968 --- /dev/null +++ b/po/golite/es.po @@ -0,0 +1,9 @@ +msgid "" +msgstr "" +"Language: es\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/golite.go:175 +msgid "can't allocate 'cgo-pointer hack index pointer': ptr == nil" +msgstr "" diff --git a/po/golite/fr.po b/po/golite/fr.po new file mode 100644 index 0000000..f58b32f --- /dev/null +++ b/po/golite/fr.po @@ -0,0 +1,9 @@ +msgid "" +msgstr "" +"Language: fr\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: src/golite.go:175 +msgid "can't allocate 'cgo-pointer hack index pointer': ptr == nil" +msgstr "" diff --git a/po/golite/golite.pot b/po/golite/golite.pot new file mode 100644 index 0000000..49fb09f --- /dev/null +++ b/po/golite/golite.pot @@ -0,0 +1,9 @@ +msgid "" +msgstr "" +"Language: \n" +"Content-Type: text/plain; charset=UTF-8\n" + +#: src/golite.go:175 +msgid "can't allocate 'cgo-pointer hack index pointer': ptr == nil" +msgstr "" + diff --git a/po/golite/po4a.cfg b/po/golite/po4a.cfg new file mode 100644 index 0000000..5f7b65b --- /dev/null +++ b/po/golite/po4a.cfg @@ -0,0 +1,3 @@ +[options] --keep 0 --master-charset UTF-8 --localized-charset UTF-8 --addendum-charset UTF-8 + +[po_directory] po/golite diff --git a/po/golite/pt.po b/po/golite/pt.po new file mode 100644 index 0000000..82d361a --- /dev/null +++ b/po/golite/pt.po @@ -0,0 +1,9 @@ +msgid "" +msgstr "" +"Language: pt\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/golite.go:175 +msgid "can't allocate 'cgo-pointer hack index pointer': ptr == nil" +msgstr "" diff --git a/src/golite.go b/src/golite.go index 0229229..5648408 100644 --- a/src/golite.go +++ b/src/golite.go @@ -17,6 +17,8 @@ import ( "time" "unsafe" "syscall" + + gt "gotext" ) @@ -170,7 +172,7 @@ func newHandle(db *SQLiteConn, v any) unsafe.Pointer { val := handleVal{db: db, val: v} p := C.malloc(C.size_t(1)) if p == nil { - panic("can't allocate 'cgo-pointer hack index pointer': ptr == nil") + panic(gt.Gettext("can't allocate 'cgo-pointer hack index pointer': ptr == nil")) } { handleLock.Lock() |