Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Acme Downloader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Geant DevOps
Acme Downloader
Commits
75af031c
Unverified
Commit
75af031c
authored
4 years ago
by
Massimiliano Adamo
Browse files
Options
Downloads
Patches
Plain Diff
allow to compile on every platform
parent
964e3248
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
build.sh
+95
-0
95 additions, 0 deletions
build.sh
with
95 additions
and
0 deletions
build
-binary-for-win-64
.sh
→
build.sh
+
95
−
0
View file @
75af031c
...
...
@@ -17,25 +17,67 @@ ln -sf "$REPO_DIR" "${GOPATH}/src/"
REPO_NAME
=
$(
basename
"
$REPO_DIR
"
)
cd
"
${
GOPATH
}
/src/
$REPO_NAME
"
usage
()
{
echo
"Usage:
$(
basename
$0
)
"
echo
" -h | --help [Print this help and exit]"
echo
" --os (Create binary for this OS)"
echo
" --arch (Compile for this architecture)"
echo
""
echo
" Below is a list of supported combinations (1st column: OS / 2nd column: Arch):"
go tool dist list|awk
-F
'/'
'{printf "OS: "$1"\011=> Arch: "$2"\n"}'
exit
}
OPTS
=
$(
getopt
-o
"h"
--longoptions
"help,platform:,arch:"
--
"
$@
"
)
eval set
--
"
$OPTS
"
while
true
;
do
case
"
$1
"
in
-h
|
--help
)
usage
;;
--platform
)
shift
PLATFORM
=
"
$1
"
;;
--arch
)
shift
ARCH
=
"
$1
"
;;
--
)
shift
break
;;
esac
shift
done
if
[
-z
$PLATFORM
-o
-z
$ARCH
]
;
then
echo
-e
"
\n
You need to supply platform and architecture
\n
"
usage
fi
EXECUTABLE_PATH
=
"
${
GOPATH
}
/bin/
${
PLATFORM
}
_
${
ARCH
}
/
${
BIN_NAME
}
"
run_upx
()
{
if
!
which upx &>/dev/null
;
then
echo
"please download upx here https://github.com/upx/upx/releases"
echo
"and store the executable within your
\$
PATH"
exit
fi
upx
--brute
${
GOPATH
}
/bin/windows_amd64/
${
BIN_NAME
}
upx
--brute
"
$EXECUTABLE_PATH
"
}
# env GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X main.appVersion=${PROG_VERSION} -X main.buildTime=${BUILDTIME}" .
env
GOOS
=
windows
GOARCH
=
amd64
go get
-ldflags
"-s -w -X main.appVersion=
${
PROG_VERSION
}
-X main.buildTime=
${
BUILDTIME
}
"
.
env
GOOS
=
$PLATFORM
GOARCH
=
$ARCH
go get
-ldflags
"-s -w -X main.appVersion=
${
PROG_VERSION
}
-X main.buildTime=
${
BUILDTIME
}
"
.
if
[
$?
-gt
0
]
;
then
echo
-e
"
\n
there was an error while compiling the code
\n
"
exit
fi
while
true
;
do
echo
-e
"
\n
UPX degrades performances but in the case of acme-downloader it is not noticeable
\n
"
echo
-e
"
\n
UPX degrades performances but in the case of acme-downloader it is not noticeable"
echo
-e
"UPX may or may not work for a specific platform (I haven't tried them)
\n
"
read
-p
"Do you wish to run upx against
${
BIN_NAME
}
? (y/n) "
yn
case
$yn
in
[
Yy]
*
)
...
...
@@ -50,4 +92,4 @@ while true; do
esac
done
echo
-e
"
\n
the binary was compiled and it is avilable as:
\n
-
${
GOPATH
}
/bin/windows_amd64/
${
BIN_NAME
}
\n
"
echo
-e
"
\n
the binary was compiled and it is avilable as:
\n
-
\"
$EXECUTABLE_PATH
\"
\n
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment