forked from cjbassi/gotop
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes cross-compiling, adds a new build script
- Loading branch information
Showing
12 changed files
with
125 additions
and
42 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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// +build arm64 | ||
|
||
package logging | ||
|
||
import ( | ||
|
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,3 +1,4 @@ | ||
// +build linux openbsd freebsd | ||
// +build !arm64 | ||
|
||
package logging | ||
|
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,18 @@ | ||
// +build windows | ||
|
||
package logging | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
) | ||
|
||
var ( | ||
kernel32 = syscall.MustLoadDLL("kernel32.dll") | ||
procSetStdHandle = kernel32.MustFindProc("SetStdHandle") | ||
) | ||
|
||
func stderrToLogfile(logfile *os.File) { | ||
// https://groups.google.com/d/msg/golang-nuts/fG8hEAs7ZXs/tahEOuCEPn0J. | ||
syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(logfile.Fd()), 2, 0) | ||
} |
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,75 @@ | ||
#!/bin/bash | ||
|
||
export VERSION=$(go run ./cmd/gotop -V) | ||
|
||
rm -f build.log | ||
|
||
function candz() { | ||
export GOOS=$1 | ||
export GOARCH=$2 | ||
OUT=build/gotop_${VERSION}_${GOOS}_${GOARCH} | ||
if [[ -n $3 ]]; then | ||
export GOARM=$3 | ||
OUT=${OUT}_v${GOARM} | ||
fi | ||
OUT=${OUT}.zip | ||
if [[ -e $OUT ]]; then | ||
echo SKIP $OUT | ||
return | ||
fi | ||
D=build/gotop | ||
if [[ $GOOS == "windows" ]]; then | ||
D=${D}.exe | ||
fi | ||
go build -o $D ./cmd/gotop >> build.log 2>&1 | ||
unset GOOS GOARCH GOARM CGO_ENABLED | ||
if [[ $? -ne 0 ]]; then | ||
printenv | grep GO >> build.log | ||
echo "############### FAILED ###############" >> build.log | ||
echo >> build.log | ||
echo >> build.log | ||
echo FAILED $OUT | ||
return | ||
fi | ||
cd build | ||
zip $(basename $OUT) $(basename $D) >> ../build.log 2>&1 | ||
cd .. | ||
rm -f $D | ||
if [[ $? -ne 0 ]]; then | ||
echo "############### FAILED ###############" >> build.log | ||
echo >> build.log | ||
echo >> build.log | ||
echo FAILED $OUT | ||
return | ||
fi | ||
echo BUILT $OUT | ||
} | ||
|
||
candz linux arm64 | ||
for x in 5 6 7; do | ||
candz linux arm $x | ||
done | ||
for x in 386 amd64; do | ||
candz linux $x | ||
|
||
sed -i "s/arch: .*/arch: \"${x}\"/" build/nfpm.yml | ||
for y in rpm deb; do | ||
OUT=build/gotop_${VERSION}_linux_${x}.${y} | ||
if [[ -e $OUT ]]; then | ||
echo SKIP $OUT | ||
else | ||
echo Building $OUT | ||
nfpm pkg -t ${OUT} -f build/nfpm.yml | ||
fi | ||
done | ||
|
||
candz windows $x | ||
candz freebsd $x | ||
|
||
export CGO_ENABLED=1 | ||
candz darwin $x | ||
candz openbsd $x | ||
unset CGO_ENABLED | ||
done | ||
|
||
rm -f build/gotop |
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,3 +1,5 @@ | ||
// +build darwin | ||
|
||
package widgets | ||
|
||
// #cgo LDFLAGS: -framework IOKit | ||
|
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,3 +1,5 @@ | ||
// +build freebsd | ||
|
||
package widgets | ||
|
||
import ( | ||
|
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,3 +1,5 @@ | ||
// +build linux | ||
|
||
package widgets | ||
|
||
import ( | ||
|
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// +build windows | ||
|
||
package widgets | ||
|
||
import ( | ||
|