Changes:
- allows explicit crossbuild targets (eg: `make mgmt-darwin-amd64`)
- adds darwin/amd64 to default crossbuild targets
- gitignore only build artifacts (eg: not all files starting with `mgmt-`)
- `build` and `crossbuild` target now utilize the same build function (`build` still generates only a `mgmt` binary for the current os/arch)
- test crossbuilding
- allow specifying custom GOOSARCHES envvar to override defaults
- crossbuild artifacts go into `build/` now
- add `build-debug` which includes symbol tables and debug info
- the build function now has `-s -w` linker arguments which discards some debug info afaict, to build a debug release use `make build-debug`
On my mac crossbuilding won't work unless I disable augeas and libvirt:
```
~/.g/s/g/p/mgmt (build|●1✚8…3) $ make build
Generating: bindata...
Generating: lang...
/Applications/Xcode.app/Contents/Developer/usr/bin/make --quiet -C lang
Building: mgmt, os/arch: darwin-amd64, version: 0.0.14-12-g94c8bc1-dirty...
env GOOS=darwin GOARCH=amd64 time go build -ldflags "-X main.program=mgmt -X main.version=0.0.14-12-g94c8bc1-dirty -s -w" -o mgmt-darwin-amd64 ;
7.14 real 10.36 user 1.73 sys
mv mgmt-darwin-amd64 mgmt
```
```
~/.g/s/g/p/mgmt (build|●1✚8…3) $ time env GOTAGS='noaugeas novirt' make crossbuild
Generating: bindata...
Generating: lang...
/Applications/Xcode.app/Contents/Developer/usr/bin/make --quiet -C lang
Building: mgmt, os/arch: linux-amd64, version: 0.0.14-12-g94c8bc1-dirty...
env GOOS=linux GOARCH=amd64 time go build -ldflags "-X main.program=mgmt -X main.version=0.0.14-12-g94c8bc1-dirty -s -w" -o mgmt-linux-amd64 -tags 'noaugeas novirt';
18.48 real 50.02 user 5.83 sys
Building: mgmt, os/arch: linux-ppc64, version: 0.0.14-12-g94c8bc1-dirty...
env GOOS=linux GOARCH=ppc64 time go build -ldflags "-X main.program=mgmt -X main.version=0.0.14-12-g94c8bc1-dirty -s -w" -o mgmt-linux-ppc64 -tags 'noaugeas novirt';
29.83 real 85.09 user 11.54 sys
Building: mgmt, os/arch: linux-ppc64le, version: 0.0.14-12-g94c8bc1-dirty...
env GOOS=linux GOARCH=ppc64le time go build -ldflags "-X main.program=mgmt -X main.version=0.0.14-12-g94c8bc1-dirty -s -w" -o mgmt-linux-ppc64le -tags 'noaugeas novirt';
29.74 real 85.84 user 11.76 sys
Building: mgmt, os/arch: linux-arm64, version: 0.0.14-12-g94c8bc1-dirty...
env GOOS=linux GOARCH=arm64 time go build -ldflags "-X main.program=mgmt -X main.version=0.0.14-12-g94c8bc1-dirty -s -w" -o mgmt-linux-arm64 -tags 'noaugeas novirt';
28.33 real 83.24 user 11.40 sys
Building: mgmt, os/arch: darwin-amd64, version: 0.0.14-12-g94c8bc1-dirty...
env GOOS=darwin GOARCH=amd64 time go build -ldflags "-X main.program=mgmt -X main.version=0.0.14-12-g94c8bc1-dirty -s -w" -o mgmt-darwin-amd64 -tags 'noaugeas novirt';
7.16 real 10.15 user 1.74 sys
114.71 real 315.26 user 42.44 sys
```
55 lines
1.6 KiB
Bash
Executable File
55 lines
1.6 KiB
Bash
Executable File
#!/bin/bash -e
|
|
# test suite...
|
|
echo running test.sh
|
|
echo "ENV:"
|
|
env
|
|
|
|
failures=''
|
|
function run-test()
|
|
{
|
|
$@ || failures=$( [ -n "$failures" ] && echo "$failures\\n$@" || echo "$@" )
|
|
}
|
|
|
|
# ensure there is no trailing whitespace or other whitespace errors
|
|
run-test git diff-tree --check $(git hash-object -t tree /dev/null) HEAD
|
|
|
|
# ensure entries to authors file are sorted
|
|
start=$(($(grep -n '^[[:space:]]*$' AUTHORS | awk -F ':' '{print $1}' | head -1) + 1))
|
|
run-test diff <(tail -n +$start AUTHORS | sort) <(tail -n +$start AUTHORS)
|
|
|
|
run-test ./test/test-gofmt.sh
|
|
run-test ./test/test-yamlfmt.sh
|
|
run-test ./test/test-bashfmt.sh
|
|
run-test ./test/test-headerfmt.sh
|
|
run-test ./test/test-commit-message.sh
|
|
run-test ./test/test-govet.sh
|
|
run-test ./test/test-examples.sh
|
|
run-test ./test/test-gotest.sh
|
|
|
|
# skipping: https://github.com/purpleidea/mgmt/issues/327
|
|
# run-test ./test/test-crossbuild.sh
|
|
|
|
# do these longer tests only when running on ci
|
|
if env | grep -q -e '^TRAVIS=true$' -e '^JENKINS_URL=' -e '^BUILD_TAG=jenkins'; then
|
|
run-test ./test/test-shell.sh
|
|
#run-test ./test/test-gotest.sh --race # XXX: temporarily disabled...
|
|
fi
|
|
|
|
run-test ./test/test-gometalinter.sh
|
|
# FIXME: this now fails everywhere :(
|
|
#run-test ./test/test-reproducible.sh
|
|
|
|
# run omv tests on jenkins physical hosts only
|
|
if env | grep -q -e '^JENKINS_URL=' -e '^BUILD_TAG=jenkins'; then
|
|
run-test ./test/test-omv.sh
|
|
fi
|
|
run-test ./test/test-golint.sh # test last, because this test is somewhat arbitrary
|
|
|
|
if [[ -n "$failures" ]]; then
|
|
echo 'FAIL'
|
|
echo 'The following tests have failed:'
|
|
echo -e "$failures"
|
|
exit 1
|
|
fi
|
|
echo 'ALL PASSED'
|