commit 6416ac6ab1fd26587a3ec7ba6aef44d28dee51ed
parent 7d8f8098c4feaad498ca7f325a8d43e33b0060c9
Author: Nick Econopouly <wry@mm.st>
Date: Sun, 22 Mar 2020 17:51:50 -0400
Update winbuild.sh to build project with mingw in a Linux container
Diffstat:
3 files changed, 79 insertions(+), 4 deletions(-)
diff --git a/import.go b/import.go
@@ -1,7 +1,6 @@
package main
import (
- "fmt"
"github.com/360EntSecGroup-Skylar/excelize"
"log"
)
diff --git a/main.go b/main.go
@@ -239,8 +239,6 @@ func main() {
log.Fatal("Unable to create grid: ", err)
}
- mainBox.PackStart(newHeadline("Add datasets:"), false, false, 0)
-
// holds the paths to the datasets to be merged; this var is
// passed around when removing and adding datasets
filepaths := &[]string{}
diff --git a/winbuild.sh b/winbuild.sh
@@ -1,2 +1,80 @@
#!/bin/bash
-GOOS=windows GOARCH=amd64 go build
+setup() {
+ # Create a fedora container
+ container=$(buildah from fedora)
+
+ # Install dependencies
+ buildah run $container dnf -y install mingw64-gtk3 go mingw32-binutils mingw32-nsiswrapper # glib2-devel gtk3-devel
+
+ # Fix typo in mingw library
+ buildah run $container bash -c "sed -i -e 's/-Wl,-luuid/-luuid/g' /usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/gdk-3.0.pc"
+
+ # Download gotk3
+ buildah run $container go get -u github.com/gotk3/gotk3/gtk
+
+ # Compile gotk3
+ buildah run $container bash -c "PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go install -v github.com/gotk3/gotk3/gtk"
+
+ # Cache image to avoid re-downloading dependencies every time
+ buildah commit $container my-gotk3-app
+
+ # Clean up
+ buildah rm $container
+}
+
+build () {
+ # Create a new container from the base one we created
+ container=$(buildah from localhost/my-gotk3-app)
+
+ # Folder to hold everything needed for the windows installer:
+ output_folder=windows
+ yes | rm -r $output_folder
+ mkdir $output_folder
+
+ # Directory of your package in the container
+ folder=$(go list)
+ folder=/root/go/src/$folder
+
+ # Copy program into container
+ buildah copy $container . $folder
+
+ # Pull dependencies for your program.
+ buildah run $container bash -c "cd $folder && go get ./... &>/dev/null"&>/dev/null
+
+ # default name the go compiler produces
+ original_name="merge.exe"
+ # Name for the executable file on Windows
+ executable_name="dataset-merge-tool.exe"
+
+ # Compile your program
+ buildah run $container bash -c "cd $folder && PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -ldflags -H=windowsgui -o $folder/$output_folder/$executable_name"
+
+ # Copy data files into installation folder
+ buildah run $container bash -c "cd $folder && mv trash.png style.css $output_folder/"
+
+ # Copy mingw dlls into installation folder
+ # This part may need to be personalized
+ buildah run $container bash -c "yes | cp -r /usr/x86_64-w64-mingw32/sys-root/mingw/{bin/*.dll,share} $folder/$output_folder/"
+
+ # Generate an installer
+ buildah run $container bash -ic "cd $folder/$output_folder && nsiswrapper --run $executable_name ./*"
+
+ # Copy the output from the container
+ cp -ru $(buildah unshare buildah mount $container)$folder/$output_folder .
+
+ # Clean up
+ buildah rm $container
+}
+
+# This just checks whether the container already exists on your drive
+buildah inspect localhost/my-gotk3-app &>/dev/null
+return_value=$?
+
+if [ $return_value -eq 1 ]
+then
+ echo "Initial container setup"
+ setup
+fi
+
+# Build project
+build