-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from wuqinqiang/feat/build
add build sh
- Loading branch information
Showing
5 changed files
with
75 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
build/.* | ||
.idea | ||
conf/conf.yml | ||
conf/conf.example.yml | ||
conf/conf.example.yml | ||
|
||
release/ | ||
packages/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export PATH := $(GOPATH)/bin:$(PATH) | ||
export GO111MODULE=on | ||
LDFLAGS := -s -w | ||
|
||
os-archs=darwin:amd64 darwin:arm64 linux:amd64 linux:arm64 windows:amd64 windows:arm64 | ||
|
||
all: build | ||
|
||
build: app | ||
|
||
app: | ||
@$(foreach n, $(os-archs),\ | ||
os=$(shell echo "$(n)" | cut -d : -f 1);\ | ||
arch=$(shell echo "$(n)" | cut -d : -f 2);\ | ||
gomips=$(shell echo "$(n)" | cut -d : -f 3);\ | ||
target_suffix=$${os}_$${arch};\ | ||
echo "Build $${os}-$${arch}...";\ | ||
GOOS=$${os} GOARCH=$${arch} GOMIPS=$${gomips} go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/helloword_$${target_suffix} main.go;\ | ||
echo "Build $${os}-$${arch} done";\ | ||
) | ||
@mv ./release/helloword_windows_amd64 ./release/helloword_windows_amd64.exe | ||
@mv ./release/helloword_windows_arm64 ./release/helloword_windows_arm64.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
|
||
# cross_compiles | ||
make -f ./Makefile.cross-compiles | ||
rm -rf ./release/packages | ||
mkdir -p ./release/packages | ||
|
||
os_all='linux windows darwin' | ||
arch_all='amd64 arm64' | ||
|
||
cd ./release | ||
|
||
for os in $os_all; do | ||
for arch in $arch_all; do | ||
hello_dir_name="helloword_${os}_${arch}" | ||
hello_path="./packages/helloword_${os}_${arch}" | ||
|
||
if [ "x${os}" = x"windows" ]; then | ||
if [ ! -f "./helloword_${os}_${arch}.exe" ]; then | ||
continue | ||
fi | ||
mkdir ${hello_path} | ||
mv ./helloword_${os}_${arch}.exe ${hello_path}/helloword.exe | ||
else | ||
if [ ! -f "./helloword_${os}_${arch}" ]; then | ||
continue | ||
fi | ||
mkdir ${hello_path} | ||
mv ./helloword_${os}_${arch} ${hello_path}/helloword | ||
fi | ||
cp ../LICENSE ${hello_path} | ||
cp -rf ../library/* ${hello_path} | ||
|
||
# packages | ||
cd ./packages | ||
if [ "x${os}" = x"windows" ]; then | ||
zip -rq ${hello_dir_name}.zip ${hello_dir_name} | ||
else | ||
tar -zcf ${hello_dir_name}.tar.gz ${hello_dir_name} | ||
fi | ||
cd .. | ||
rm -rf ${hello_path} | ||
done | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters