Skip to content

Commit

Permalink
[cmds] Move new UI to a zip for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
vlabo committed Jul 16, 2024
1 parent 090a5e6 commit c868598
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 11 deletions.
53 changes: 52 additions & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ rust-base:
wget \
file \
libsoup-3.0-dev \
libwebkit2gtk-4.1-dev
libwebkit2gtk-4.1-dev \
gcc-mingw-w64-x86-64 \
zip

# Install library dependencies for all supported architectures
# required for succesfully linking.
Expand Down Expand Up @@ -451,6 +453,55 @@ tauri-build:
SAVE ARTIFACT --if-exists "target/${target}/release/bundle/deb/*.deb" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/"
SAVE ARTIFACT --if-exists "target/${target}/release/bundle/rpm/*.rpm" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/"

tauri-build-windows-binary:
FROM +tauri-src

ARG target="x86_64-pc-windows-gnu"
ARG output=".*/release/(([^\./]+|([^\./]+\.(dll|exe))))"
ARG bundle="none"
ARG --required version_suffix

ARG GOOS=windows
ARG GOARCH=amd64
ARG GOARM

# The binaries will not be used but we still need to create them. Tauri will check for them.
RUN mkdir /tmp/gobuild
RUN mkdir ./binaries

DO +RUST_TO_GO_ARCH_STRING --rustTarget="${target}"
RUN echo "GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} GO_ARCH_STRING=${GO_ARCH_STRING}"

# Our tauri app has externalBins configured so tauri will look for them when it finished compiling
# the app. Make sure we copy portmaster-start and portmaster-core in all architectures supported.
# See documentation for externalBins for more information on how tauri searches for the binaries.

COPY (+go-build/output --GOOS="${GOOS}" --CMDS="portmaster-start portmaster-core" --GOARCH="${GOARCH}" --GOARM="${GOARM}") /tmp/gobuild

# Place them in the correct folder with the rust target tripple attached.
FOR bin IN $(ls /tmp/gobuild)
# ${bin$.*} does not work in SET commands unfortunately so we use a shell
# snippet here:
RUN set -e ; \
dest="./binaries/${bin}-${target}" ; \
if [ -z "${bin##*.exe}" ]; then \
dest="./binaries/${bin%.*}-${target}.exe" ; \
fi ; \
cp "/tmp/gobuild/${bin}" "${dest}" ;
END

# Just for debugging ...
# RUN ls -R ./binaries

DO rust+SET_CACHE_MOUNTS_ENV
RUN --mount=$EARTHLY_RUST_TARGET_CACHE cargo tauri build --no-bundle --ci --target="${target}"
DO rust+COPY_OUTPUT --output="${output}"

RUN echo output: $(ls -R "target/${target}/release")
RUN mv "target/${target}/release/app.exe" "target/${target}/release/portmaster-app_${version_suffix}.exe"
RUN zip "target/${target}/release/portmaster-app_${version_suffix}.zip" "target/${target}/release/portmaster-app_${version_suffix}.exe" -j portmaster-app${version_suffix}.exe "target/${target}/release/WebView2Loader.dll" -j WebView2Loader.dll
SAVE ARTIFACT --if-exists "target/${target}/release/portmaster-app_${version_suffix}.zip" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/"

tauri-prep-windows:
FROM +angular-base --configuration=production
ARG target="x86_64-pc-windows-msvc"
Expand Down
30 changes: 22 additions & 8 deletions cmds/portmaster-start/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type Options struct {
// This is a temp value that will be used to test the new UI in beta.
var app2Options = Options{
Name: "Portmaster App2",
Identifier: "app2/portmaster",
Identifier: "app2/portmaster-app",
AllowDownload: false,
AllowHidingWindow: false,
RestartOnFail: true,
Expand All @@ -73,7 +73,7 @@ var app2Options = Options{
func init() {
// Make sure the new UI has a proper extension.
if onWindows {
app2Options.Identifier += ".exe"
app2Options.Identifier += ".zip"
}

registerComponent([]Options{
Expand All @@ -92,12 +92,6 @@ func init() {
AllowHidingWindow: false,
RestartOnFail: true,
},
{
Name: "Portmaster App2",
Identifier: "app2/portmaster",
AllowDownload: false,
AllowHidingWindow: false,
},
{
Name: "Portmaster Notifier",
Identifier: "notifier/portmaster-notifier",
Expand All @@ -116,6 +110,26 @@ func init() {
RestartOnFail: true,
},
})

if onWindows {
registerComponent([]Options{
{
Name: "Portmaster App2",
Identifier: "app2/portmaster-app.zip",
AllowDownload: false,
AllowHidingWindow: false,
},
})
} else {
registerComponent([]Options{
{
Name: "Portmaster App2",
Identifier: "app2/portmaster-app",
AllowDownload: false,
AllowHidingWindow: false,
},
})
}
}

func registerComponent(opts []Options) {
Expand Down
5 changes: 3 additions & 2 deletions service/updates/helper/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ func MandatoryUpdates() (identifiers []string) {
PlatformIdentifier("start/portmaster-start.exe"),
PlatformIdentifier("notifier/portmaster-notifier.exe"),
PlatformIdentifier("notifier/portmaster-wintoast.dll"),
PlatformIdentifier("app2/portmaster.exe"),
PlatformIdentifier("app2/portmaster-app.zip"),
)
} else {
identifiers = append(
identifiers,
PlatformIdentifier("core/portmaster-core"),
PlatformIdentifier("start/portmaster-start"),
PlatformIdentifier("notifier/portmaster-notifier"),
PlatformIdentifier("app2/portmaster"),
PlatformIdentifier("app2/portmaster-app"),
)
}

Expand All @@ -90,5 +90,6 @@ func AutoUnpackUpdates() []string {

return []string{
PlatformIdentifier("app/portmaster-app.zip"),
PlatformIdentifier("app2/portmaster-app.zip"),
}
}

0 comments on commit c868598

Please sign in to comment.