commit
dce871b329
4 changed files with 138 additions and 0 deletions
-
3.gitignore
-
37Makefile
-
58tools.go
-
40version.go.m4
@ -0,0 +1,3 @@ |
|||
# Generated with m4 |
|||
version.go |
|||
.version* |
|||
@ -0,0 +1,37 @@ |
|||
PACKAGE = gitlab.weird-web-workers.org/golang/version |
|||
|
|||
SOURCES = version.go \
|
|||
tools.go |
|||
|
|||
VERSION = 0.0.1 |
|||
REVISION = $(shell git rev-parse HEAD) |
|||
BUILDTIME= "$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')" |
|||
|
|||
GOOS = $(shell go env GOOS) |
|||
GOARCH = $(shell go env GOARCH) |
|||
|
|||
LIBRARY = $(GOPATH)/pkg/$(GOOS)_$(GOARCH)/$(PACKAGE).a |
|||
|
|||
.PHONY: all clean .version |
|||
|
|||
all: $(LIBRARY) |
|||
|
|||
$(LIBRARY): $(SOURCES) |
|||
go install $(PACKAGE) |
|||
|
|||
.version: |
|||
-@printf "%s\n%s\n%s" \
|
|||
"$(VERSION)" "$(REVISION)" "$(BUILDTIME)" >$@.new |
|||
-@diff $@ $@.new >/dev/null 2>&1 && rm $@.new || mv $@.new $@ |
|||
|
|||
version.go: version.go.m4 .version |
|||
-@m4 -Dm4_version=$(VERSION) \
|
|||
-Dm4_revision=$(REVISION) \
|
|||
-Dm4_build_time=$(BUILDTIME) \
|
|||
-Dm4_package=$(PACKAGE) \
|
|||
$< >$@ |
|||
|
|||
clean: |
|||
-@rm -f version.go 2>/dev/null |
|||
-@rm -f .version 2>/dev/null |
|||
-@rm -f $(LIBRARY) 2>/dev/null |
|||
@ -0,0 +1,58 @@ |
|||
/* |
|||
Version management tools. |
|||
|
|||
Authors: |
|||
Georg Hopp <georg@steffers.org> |
|||
|
|||
Changes: |
|||
2018-10-02 [Georg Hopp] File created. |
|||
|
|||
Copyright © 2018 Georg Hopp |
|||
|
|||
This program is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
package version |
|||
|
|||
import ( |
|||
"encoding/json" |
|||
) |
|||
|
|||
type Version struct { |
|||
Package string `json:"Package"` |
|||
Version string `json:"Version"` |
|||
Revision string `json:"Revision"` |
|||
BuildTime string `json:"BuildTime"` |
|||
} |
|||
|
|||
type versionSlice map[string]Version |
|||
|
|||
var ( |
|||
versions = make(versionSlice) |
|||
) |
|||
|
|||
func (v Version) Register() { |
|||
versions[v.Package] = v |
|||
} |
|||
|
|||
func (vs versionSlice)Json() string { |
|||
vSlice := make([]Version, len(vs)) |
|||
for v := range vs { |
|||
vSlice = append(vSlice, v) |
|||
} |
|||
vJson, err := json.Marshal(vSlice) |
|||
logger.Default.FailOnError(err, "Unable to marshal versions") |
|||
return vJson |
|||
) |
|||
|
|||
// vim: ts=4 sts=4 sw=4 noet tw=72:
|
|||
@ -0,0 +1,40 @@ |
|||
/* |
|||
Package version information. |
|||
|
|||
Authors: |
|||
Georg Hopp <georg@steffers.org> |
|||
|
|||
Changes: |
|||
2018-09-30 [Georg Hopp] File created. |
|||
|
|||
Copyright © 2018 Georg Hopp |
|||
|
|||
This program is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
package version |
|||
|
|||
import ( |
|||
"gitlab.weird-web-workers.org/golang/version" |
|||
) |
|||
|
|||
const ( |
|||
VERSION = Version{ |
|||
Package: "m4_package", |
|||
Version: "m4_version", |
|||
Revision: "m4_revision", |
|||
BuildTime: "m4_build_time", |
|||
} |
|||
) |
|||
|
|||
// vim: ts=4 sts=4 sw=4 noet tw=72: |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue