| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Public domain notice for all NCBI EDirect scripts is located at: |
| 4 |
# https://www.ncbi.nlm.nih.gov/books/NBK179288/#chapter6.Public_Domain_Notice |
| 5 |
|
| 6 |
# determine current platform |
| 7 |
platform="" |
| 8 |
osname=`uname -s` |
| 9 |
cputype=`uname -m` |
| 10 |
case "$osname-$cputype" in |
| 11 |
Linux-x86_64 ) platform=Linux ;; |
| 12 |
Darwin-x86_64 ) platform=Darwin ;; |
| 13 |
Darwin-*arm* ) platform=Silicon ;; |
| 14 |
CYGWIN_NT-* | MINGW*-* ) platform=CYGWIN_NT ;; |
| 15 |
Linux-*arm* ) platform=ARM ;; |
| 16 |
Linux-aarch64 ) platform=ARM64 ;; |
| 17 |
* ) platform=UNSUPPORTED ;; |
| 18 |
esac |
| 19 |
|
| 20 |
vendor=false |
| 21 |
|
| 22 |
while [ "$#" -ne 0 ] |
| 23 |
do |
| 24 |
case "$1" in |
| 25 |
-vendor | vendor ) |
| 26 |
vendor=true |
| 27 |
shift |
| 28 |
;; |
| 29 |
* ) |
| 30 |
break |
| 31 |
;; |
| 32 |
esac |
| 33 |
done |
| 34 |
|
| 35 |
if [ ! -f "go.mod" ] |
| 36 |
then |
| 37 |
go mod init extern |
| 38 |
# add explicit location to find local helper package |
| 39 |
echo "replace eutils => ../eutils" >> go.mod |
| 40 |
# build local eutils library |
| 41 |
go get eutils |
| 42 |
fi |
| 43 |
if [ ! -f "go.sum" ] |
| 44 |
then |
| 45 |
go mod tidy |
| 46 |
fi |
| 47 |
|
| 48 |
# cache external dependencies |
| 49 |
if [ "$vendor" = true ] && [ ! -d "vendor" ] |
| 50 |
then |
| 51 |
go mod vendor -e |
| 52 |
fi |
| 53 |
|
| 54 |
# erase any existing executables in current directory |
| 55 |
for plt in Darwin Silicon Linux CYGWIN_NT ARM ARM64 |
| 56 |
do |
| 57 |
rm -f *.$plt |
| 58 |
done |
| 59 |
|
| 60 |
# build all executables for current platform |
| 61 |
for exc in *.go |
| 62 |
do |
| 63 |
base=${exc%.go} |
| 64 |
go build -o "$base.$platform" "$base.go" |
| 65 |
done |
| 66 |
|
| 67 |
# will be using "go run", erase executables after test complication |
| 68 |
for plt in Darwin Silicon Linux CYGWIN_NT ARM ARM64 |
| 69 |
do |
| 70 |
rm -f *.$plt |
| 71 |
done |