Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Tauri beta update #1519

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
131 changes: 72 additions & 59 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,6 @@ angular-release:
rust-base:
FROM ${rust_builder_image}

RUN dpkg --add-architecture armhf
RUN dpkg --add-architecture arm64

RUN apt-get update -qq

# Tools and libraries required for cross-compilation
Expand All @@ -278,9 +275,6 @@ rust-base:
gcc-multilib \
linux-libc-dev \
linux-libc-dev-amd64-cross \
linux-libc-dev-arm64-cross \
linux-libc-dev-armel-cross \
linux-libc-dev-armhf-cross \
build-essential \
curl \
wget \
Expand All @@ -290,45 +284,19 @@ rust-base:

# Install library dependencies for all supported architectures
# required for succesfully linking.
FOR arch IN amd64 arm64 armhf
RUN apt-get install --no-install-recommends -qq \
libsoup-3.0-0:${arch} \
libwebkit2gtk-4.1-0:${arch} \
libssl3:${arch} \
libayatana-appindicator3-1:${arch} \
librsvg2-bin:${arch} \
libgtk-3-0:${arch} \
libjavascriptcoregtk-4.1-0:${arch} \
libssl-dev:${arch} \
libayatana-appindicator3-dev:${arch} \
librsvg2-dev:${arch} \
libgtk-3-dev:${arch} \
libjavascriptcoregtk-4.1-dev:${arch}
END

# Note(ppacher): I've no idea why we need to explicitly create those symlinks:
# Some how all the other libs work but libsoup and libwebkit2gtk do not create the link file
RUN cd /usr/lib/aarch64-linux-gnu && \
ln -s libwebkit2gtk-4.1.so.0 libwebkit2gtk-4.1.so && \
ln -s libsoup-3.0.so.0 libsoup-3.0.so

RUN cd /usr/lib/arm-linux-gnueabihf && \
ln -s libwebkit2gtk-4.1.so.0 libwebkit2gtk-4.1.so && \
ln -s libsoup-3.0.so.0 libsoup-3.0.so

# For what ever reason trying to install the gcc compilers together with the above
# command makes apt fail due to conflicts with gcc-multilib. Installing in a separate
# step seems to work ...
RUN apt-get install --no-install-recommends -qq \
g++-mingw-w64-x86-64 \
gcc-aarch64-linux-gnu \
gcc-arm-none-eabi \
gcc-arm-linux-gnueabi \
gcc-arm-linux-gnueabihf \
libc6-dev-arm64-cross \
libc6-dev-armel-cross \
libc6-dev-armhf-cross \
libc6-dev-amd64-cross
libsoup-3.0-0 \
libwebkit2gtk-4.1-0 \
libssl3 \
libayatana-appindicator3-1 \
librsvg2-bin \
libgtk-3-0 \
libjavascriptcoregtk-4.1-0 \
libssl-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
libgtk-3-dev \
libjavascriptcoregtk-4.1-dev

# Add some required rustup components
RUN rustup component add clippy
Expand All @@ -341,11 +309,8 @@ rust-base:

DO rust+INIT --keep_fingerprints=true

# For now we need tauri-cli 1.5 for bulding
DO rust+CARGO --args="install tauri-cli --version ^1.5.11"

# Required for cross compilation to work.
ENV PKG_CONFIG_ALLOW_CROSS=1
# For now we need tauri-cli 2.0.0 for bulding
DO rust+CARGO --args="install tauri-cli --version ^2.0.0-beta"

# Explicitly cache here.
SAVE IMAGE --cache-hint
Expand All @@ -358,7 +323,7 @@ tauri-src:
# --keep-ts is necessary to ensure that the timestamps of the source files
# are preserved such that Rust's incremental compilation works correctly.
COPY --keep-ts ./desktop/tauri/ .
COPY assets/data ./assets
COPY assets/data ./../../assets/data
COPY packaging/linux ./../../packaging/linux
COPY (+angular-project/output/tauri-builtin --project=tauri-builtin --dist=./dist/tauri-builtin --configuration=production --baseHref="/") ./../angular/dist/tauri-builtin

Expand All @@ -371,13 +336,12 @@ tauri-build:
FROM +tauri-src

ARG --required target
ARG output=".*/release/(([^\./]+|([^\./]+\.(dll|exe)))|bundle/.*\.(deb|msi|AppImage))"
ARG output=".*/release/(([^\./]+|([^\./]+\.(dll|exe)))|bundle/(deb|rpm)/.*\.(deb|rpm))"
ARG bundle="none"


# if we want tauri to create the installer bundles we also need to provide all external binaries
# we need to do some magic here because tauri expects the binaries to include the rust target tripple.
# We already knwo that triple because it's a required argument. From that triple, we use +RUST_TO_GO_ARCH_STRING
# We already know that triple because it's a required argument. From that triple, we use +RUST_TO_GO_ARCH_STRING
# function from below to parse the triple and guess wich GOOS and GOARCH we need.
RUN mkdir /tmp/gobuild
RUN mkdir ./binaries
Expand All @@ -404,7 +368,7 @@ tauri-build:
END

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

# The following is exected to work but doesn't. for whatever reason cargo-sweep errors out on the windows-toolchain.
#
Expand All @@ -413,7 +377,7 @@ tauri-build:
# For, now, we just directly mount the rust target cache and call cargo ourself.

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

# BUG(cross-compilation):
Expand All @@ -429,7 +393,7 @@ tauri-build:
# The following would use the CROSS function from the earthly lib, this
# DO rust+CROSS --target="${target}"

# RUN echo output: $(ls "target/${target}/release")
RUN echo output: $(ls -R "target/${target}/release")
LET outbin="error"
FOR bin IN "portmaster Portmaster.exe WebView2Loader.dll"
# Modify output binary.
Expand All @@ -444,14 +408,63 @@ tauri-build:
SAVE ARTIFACT "target/${target}/release/${bin}" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/${outbin}"
END
END
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-prep-windows:
FROM +angular-base --configuration=production
ARG target="x86_64-pc-windows-msvc"

# if we want tauri to create the installer bundles we also need to provide all external binaries
# we need to do some magic here because tauri expects the binaries to include the rust target tripple.
# We already know that triple because it's a required argument. From that triple, we use +RUST_TO_GO_ARCH_STRING
# function from below to parse the triple and guess wich GOOS and GOARCH we need.
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 try to embed 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

# Copy source
COPY --keep-ts ./desktop/tauri/src-tauri src-tauri
COPY --keep-ts ./assets assets

# Build UI
ENV NODE_ENV="production"
RUN --no-cache ./node_modules/.bin/ng build --configuration production --base-href / "tauri-builtin"

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

SAVE ARTIFACT "./dist/tauri-builtin" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/desktop/angular/dist/"
SAVE ARTIFACT "./src-tauri" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/desktop/tauri/src-tauri"
SAVE ARTIFACT "./binaries" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/desktop/tauri/src-tauri/"
SAVE ARTIFACT "./assets" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/assets"

tauri-release:
FROM ${work_image}

ARG bundle="none"

FOR arch IN ${architectures}
BUILD +tauri-build --target="${arch}" --bundle="${bundle}"
BUILD +tauri-build --target="${arch}"
END

build:
Expand Down
14 changes: 14 additions & 0 deletions assets/data/icons/generate_ico.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

# Traymenu icons. Sometimes to wrong size is selected so remove 256 and 64.
convert pm_dark_green_512.png -colors 256 -define icon:auto-resize=48,32,16 pm_dark_green.ico
convert pm_dark_blue_512.png -colors 256 -define icon:auto-resize=48,32,16 pm_dark_blue.ico
convert pm_dark_red_512.png -colors 256 -define icon:auto-resize=48,32,16 pm_dark_red.ico
convert pm_dark_yellow_512.png -colors 256 -define icon:auto-resize=48,32,16 pm_dark_yellow.ico
convert pm_light_blue_512.png -colors 256 -define icon:auto-resize=48,32,16 pm_light_blue.ico
convert pm_light_green_512.png -colors 256 -define icon:auto-resize=48,32,16 pm_light_green.ico
convert pm_light_red_512.png -colors 256 -define icon:auto-resize=48,32,16 pm_light_red.ico
convert pm_light_yellow_512.png -colors 256 -define icon:auto-resize=48,32,16 pm_light_yellow.ico

convert pm_dark_512.png -colors 256 -define icon:auto-resize=64,48,32,16 pm_dark.ico
convert pm_light_512.png -colors 256 -define icon:auto-resize=64,48,32,16 pm_light.ico
Binary file added assets/data/icons/pm_dark.ico
Binary file not shown.
Binary file removed assets/data/icons/pm_dark_512.ico
Binary file not shown.
Binary file added assets/data/icons/pm_dark_blue.ico
Binary file not shown.
Binary file removed assets/data/icons/pm_dark_blue_512.ico
Binary file not shown.
Binary file added assets/data/icons/pm_dark_green.ico
Binary file not shown.
Binary file removed assets/data/icons/pm_dark_green_512.ico
Binary file not shown.
Binary file added assets/data/icons/pm_dark_red.ico
Binary file not shown.
Binary file removed assets/data/icons/pm_dark_red_512.ico
Binary file not shown.
Binary file added assets/data/icons/pm_dark_yellow.ico
Binary file not shown.
Binary file removed assets/data/icons/pm_dark_yellow_512.ico
Binary file not shown.
Binary file added assets/data/icons/pm_light.ico
Binary file not shown.
Binary file removed assets/data/icons/pm_light_512.ico
Binary file not shown.
Binary file added assets/data/icons/pm_light_blue.ico
Binary file not shown.
Binary file removed assets/data/icons/pm_light_blue_512.ico
Binary file not shown.
Binary file added assets/data/icons/pm_light_green.ico
Binary file not shown.
Binary file removed assets/data/icons/pm_light_green_512.ico
Binary file not shown.
Binary file added assets/data/icons/pm_light_red.ico
Binary file not shown.
Binary file removed assets/data/icons/pm_light_red_512.ico
Binary file not shown.
Binary file added assets/data/icons/pm_light_yellow.ico
Binary file not shown.
Binary file removed assets/data/icons/pm_light_yellow_512.ico
Binary file not shown.