mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-11 10:43:31 +02:00
Compare commits
157 Commits
api-v1.0.2
...
api-v1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ceed62686 | ||
|
|
83a6dab7b2 | ||
|
|
9190206387 | ||
|
|
fbdd0a7ca9 | ||
|
|
3c62dbc902 | ||
|
|
255ebcb7ef | ||
|
|
447370fa50 | ||
|
|
9b793eeb68 | ||
|
|
5e74aefd4a | ||
|
|
6b737315b0 | ||
|
|
1c98751da4 | ||
|
|
b779e52ba7 | ||
|
|
3fdd287704 | ||
|
|
f4121c128e | ||
|
|
5b0b8ef83f | ||
|
|
e9412fb983 | ||
|
|
83eefccefd | ||
|
|
cdb5c8e068 | ||
|
|
824aec9e40 | ||
|
|
1d55a5fe1f | ||
|
|
bf5a9ab9e6 | ||
|
|
12e9d811e6 | ||
|
|
0837454b00 | ||
|
|
e6d9b670b0 | ||
|
|
8183153a86 | ||
|
|
5790218fb6 | ||
|
|
a9381f3b40 | ||
|
|
8fd79b8fc0 | ||
|
|
14f337d8ad | ||
|
|
4cd8507ea0 | ||
|
|
89af335156 | ||
|
|
bca796be2f | ||
|
|
0668dd4220 | ||
|
|
b9fb53ed73 | ||
|
|
ef8ca7b363 | ||
|
|
d88de30076 | ||
|
|
1629c5ad27 | ||
|
|
8a380fc4e3 | ||
|
|
2901145c49 | ||
|
|
38449bc57d | ||
|
|
8f6ab87fb4 | ||
|
|
cf6f0c511b | ||
|
|
bd51cddd6f | ||
|
|
4fa968dc0e | ||
|
|
e9f1e627f8 | ||
|
|
ab5a307bc1 | ||
|
|
238fdc9563 | ||
|
|
d35cc77831 | ||
|
|
169682219a | ||
|
|
4ac8006efd | ||
|
|
02a2ec52f1 | ||
|
|
28a1ec34a4 | ||
|
|
436f3d8d66 | ||
|
|
fa44c44379 | ||
|
|
fea70effad | ||
|
|
e16b366174 | ||
|
|
9ac6135c2a | ||
|
|
8bf0f66c06 | ||
|
|
9bbc30590b | ||
|
|
c53d9ea1b3 | ||
|
|
e4d5022077 | ||
|
|
725236cea0 | ||
|
|
d2572050be | ||
|
|
20a7036ba5 | ||
|
|
6ba99689aa | ||
|
|
8958e9fdb5 | ||
|
|
6119f4582e | ||
|
|
ff8fd7619a | ||
|
|
0e925fd8f0 | ||
|
|
64546cb9cc | ||
|
|
96885b6e5a | ||
|
|
9e48da502f | ||
|
|
3951aac930 | ||
|
|
e86c9df9f0 | ||
|
|
4d063ae9ee | ||
|
|
fd992c547e | ||
|
|
e602432ef6 | ||
|
|
698a31aa79 | ||
|
|
57ab9847eb | ||
|
|
4c24d10ff3 | ||
|
|
5813f08386 | ||
|
|
08584fc657 | ||
|
|
4e8b122df6 | ||
|
|
ed581950ea | ||
|
|
f957cbb56c | ||
|
|
5109c27501 | ||
|
|
d88b9de7aa | ||
|
|
1caf485fce | ||
|
|
3b44b01412 | ||
|
|
49f9334e19 | ||
|
|
3be8c238cc | ||
|
|
e59407f2bd | ||
|
|
58fc1f2150 | ||
|
|
f7d2dfc7a6 | ||
|
|
964926ff85 | ||
|
|
52f0c8bb83 | ||
|
|
fa23310f23 | ||
|
|
dcd506676c | ||
|
|
d6f7d3cfe8 | ||
|
|
90d5929fea | ||
|
|
f21cbecdeb | ||
|
|
331f346002 | ||
|
|
e6012b88af | ||
|
|
9f1d34c288 | ||
|
|
5c5c42edb6 | ||
|
|
75d3d677ae | ||
|
|
ae83d008f9 | ||
|
|
c04d0340e2 | ||
|
|
5cc1fd0f7b | ||
|
|
d576e8ae72 | ||
|
|
ba5560b2a1 | ||
|
|
0ad9531d79 | ||
|
|
0983d7ce7f | ||
|
|
024620529e | ||
|
|
596fa08d48 | ||
|
|
77e48ab7db | ||
|
|
d8cf9f9fcd | ||
|
|
433dafa01a | ||
|
|
810b3be080 | ||
|
|
77f4a7173b | ||
|
|
08deda5f99 | ||
|
|
aa9f1243e6 | ||
|
|
f7ea867d31 | ||
|
|
816f474c3e | ||
|
|
47fab6809a | ||
|
|
e903dfe762 | ||
|
|
b47d8c88c5 | ||
|
|
9b7caab672 | ||
|
|
2adef93faf | ||
|
|
c7fec3e1ff | ||
|
|
fd4c851ee9 | ||
|
|
d2b6351157 | ||
|
|
c2c1e6f081 | ||
|
|
38604a111e | ||
|
|
5785aeb806 | ||
|
|
6218c31e17 | ||
|
|
6d4945c9f0 | ||
|
|
b2a8930b3c | ||
|
|
b48962ed15 | ||
|
|
accbc5e880 | ||
|
|
679abc6a9a | ||
|
|
9a8f8fc815 | ||
|
|
f116ee6a12 | ||
|
|
9af43134e1 | ||
|
|
635f23b88a | ||
|
|
b1d53426d1 | ||
|
|
89cb252640 | ||
|
|
597c98203c | ||
|
|
261d1bc9d4 | ||
|
|
ac72800fb6 | ||
|
|
c635a0dad4 | ||
|
|
3b4ed970e6 | ||
|
|
d5e6f7fa5c | ||
|
|
bc370e3268 | ||
|
|
d3e19e3420 | ||
|
|
47666c4a0b | ||
|
|
95abf48e21 |
@@ -17,12 +17,7 @@
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "echo \"# Cargo Audit\"",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "echo '```'",
|
||||
"command": "echo '<details>\n<summary><em><h4>Cargo Audit</h4></em></summary>\n\n```'",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
},
|
||||
@@ -33,7 +28,7 @@
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "echo '```'",
|
||||
"command": "echo '```\n\n</details>\n'",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
}
|
||||
@@ -45,12 +40,7 @@
|
||||
"dryRunCommand": true
|
||||
},
|
||||
{
|
||||
"command": "echo \"# Cargo Publish\"",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "echo '```'",
|
||||
"command": "echo '<details>\n<summary><em><h4>Cargo Publish</h4></em></summary>\n\n```'",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
},
|
||||
@@ -60,7 +50,7 @@
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "echo '```'",
|
||||
"command": "echo '```\n\n</details>\n'",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
}
|
||||
@@ -87,12 +77,7 @@
|
||||
"dryRunCommand": true
|
||||
},
|
||||
{
|
||||
"command": "echo \"# Yarn Audit\n\"",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "echo '<details>\n<summary>click to view</summary>\n\n```'",
|
||||
"command": "echo '<details>\n<summary><em><h4>Yarn Audit</h4></em></summary>\n\n```'",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
},
|
||||
@@ -115,12 +100,7 @@
|
||||
"publish": [
|
||||
"sleep 15s",
|
||||
{
|
||||
"command": "echo \"# Yarn Package Publish\"",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "echo '```'",
|
||||
"command": "echo '<details>\n<summary><em><h4>Yarn Publish</h4></em></summary>\n\n```'",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
},
|
||||
@@ -130,7 +110,7 @@
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "echo '```'",
|
||||
"command": "echo '```\n\n</details>\n'",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
}
|
||||
@@ -158,12 +138,7 @@
|
||||
"dryRunCommand": true
|
||||
},
|
||||
{
|
||||
"command": "echo \"# Yarn Audit\n\"",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "echo '<details>\n<summary>click to view</summary>\n\n```'",
|
||||
"command": "echo '<details>\n<summary><em><h4>Yarn Audit</h4></em></summary>\n\n```'",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
},
|
||||
@@ -185,12 +160,7 @@
|
||||
],
|
||||
"publish": [
|
||||
{
|
||||
"command": "echo \"# Yarn Package Publish\"",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "echo '```'",
|
||||
"command": "echo '<details>\n<summary><em><h4>Yarn Publish</h4></em></summary>\n\n```'",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
},
|
||||
@@ -200,7 +170,7 @@
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "echo '```'",
|
||||
"command": "echo '```\n\n</details>\n'",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
}
|
||||
@@ -239,7 +209,13 @@
|
||||
"path": "./core/tauri-build",
|
||||
"manager": "rust",
|
||||
"dependencies": ["tauri-codegen", "tauri-utils"],
|
||||
"postversion": "node ../../.scripts/covector/sync-cli-metadata.js ${ pkg.pkg } ${ release.type }"
|
||||
"postversion": "node ../../.scripts/covector/sync-cli-metadata.js ${ pkg.pkg } ${ release.type }",
|
||||
"assets": [
|
||||
{
|
||||
"path": "./tooling/cli/schema.json",
|
||||
"name": "schema.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"tauri": {
|
||||
"path": "./core/tauri",
|
||||
|
||||
@@ -5,7 +5,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
|
||||
|
||||
# Derived from Tauri contribution and setup guides:
|
||||
# See: https://github.com/tauri-apps/tauri/blob/dev/.github/CONTRIBUTING.md#development-guide
|
||||
# See: https://tauri.studio/v1/guides/getting-started/prerequisites/#setting-up-linux
|
||||
# See: https://tauri.app/v1/guides/getting-started/prerequisites/#setting-up-linux
|
||||
ARG TAURI_BUILD_DEPS="build-essential curl libappindicator3-dev libgtk-3-dev librsvg2-dev libssl-dev libwebkit2gtk-4.0-dev wget"
|
||||
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
|
||||
@@ -24,7 +24,7 @@ Prerequisites are mainly derived from VS Code's instructions for usage of develo
|
||||
|
||||
### A note on filesystem performance
|
||||
|
||||
Due to limititations in how Docker shares files between the Docker host and a container, it's also recommended that developers [clone Tauri source code into a container volume](https://code.visualstudio.com/remote/advancedcontainers/improve-performance#_use-clone-repository-in-container-volume). This is optional, but highly advised as many filesystem/IO heavy opearations (`cargo build`, `yarn install`, etc) will be very slow if they operate on directories shared with a Docker container from the Docker host.
|
||||
Due to limitations in how Docker shares files between the Docker host and a container, it's also recommended that developers [clone Tauri source code into a container volume](https://code.visualstudio.com/remote/advancedcontainers/improve-performance#_use-clone-repository-in-container-volume). This is optional, but highly advised as many filesystem/IO heavy operations (`cargo build`, `yarn install`, etc) will be very slow if they operate on directories shared with a Docker container from the Docker host.
|
||||
|
||||
To do this, open your project with VS Code and run **Remote-Containers: Clone Repository in Container Volume...** from the Command Palette (<kbd>F1</kbd>).
|
||||
|
||||
|
||||
44
.docker/cross/aarch64.Dockerfile
Normal file
44
.docker/cross/aarch64.Dockerfile
Normal file
@@ -0,0 +1,44 @@
|
||||
FROM ubuntu:18.04
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
COPY common.sh lib.sh /
|
||||
RUN /common.sh
|
||||
|
||||
COPY cmake.sh /
|
||||
RUN /cmake.sh
|
||||
|
||||
COPY xargo.sh /
|
||||
RUN /xargo.sh
|
||||
|
||||
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
|
||||
g++-aarch64-linux-gnu \
|
||||
libc6-dev-arm64-cross
|
||||
|
||||
COPY deny-debian-packages.sh /
|
||||
RUN TARGET_ARCH=arm64 /deny-debian-packages.sh \
|
||||
binutils \
|
||||
binutils-aarch64-linux-gnu
|
||||
|
||||
COPY qemu.sh /
|
||||
RUN /qemu.sh aarch64 softmmu
|
||||
|
||||
COPY dropbear.sh /
|
||||
RUN /dropbear.sh
|
||||
|
||||
COPY linux-image.sh /
|
||||
RUN /linux-image.sh aarch64
|
||||
|
||||
COPY linux-runner /
|
||||
|
||||
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
|
||||
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="/linux-runner aarch64" \
|
||||
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \
|
||||
CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ \
|
||||
BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu="--sysroot=/usr/aarch64-linux-gnu" \
|
||||
QEMU_LD_PREFIX=/usr/aarch64-linux-gnu \
|
||||
RUST_TEST_THREADS=1 \
|
||||
PKG_CONFIG_PATH="/usr/lib/aarch64-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}"
|
||||
|
||||
RUN dpkg --add-architecture arm64
|
||||
RUN apt-get update
|
||||
RUN apt-get install --assume-yes --no-install-recommends libssl-dev:arm64 libdbus-1-dev:arm64 libsoup2.4-dev:arm64 libssl-dev:arm64 libgtk-3-dev:arm64 webkit2gtk-4.0-dev:arm64 libappindicator3-1:arm64 librsvg2-dev:arm64 patchelf:arm64
|
||||
31
.docker/cross/cmake.sh
Executable file
31
.docker/cross/cmake.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -x
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. lib.sh
|
||||
|
||||
main() {
|
||||
local version=3.23.1
|
||||
|
||||
install_packages curl
|
||||
|
||||
local td
|
||||
td="$(mktemp -d)"
|
||||
|
||||
pushd "${td}"
|
||||
|
||||
curl --retry 3 -sSfL "https://github.com/Kitware/CMake/releases/download/v${version}/cmake-${version}-linux-x86_64.sh" -o cmake.sh
|
||||
sh cmake.sh --skip-license --prefix=/usr/local
|
||||
|
||||
popd
|
||||
|
||||
purge_packages
|
||||
|
||||
rm -rf "${td}"
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
rm "${0}"
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
40
.docker/cross/common.sh
Executable file
40
.docker/cross/common.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -x
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. lib.sh
|
||||
|
||||
# For architectures except amd64 and i386, look for packages on ports.ubuntu.com instead.
|
||||
# This is important if you enable additional architectures so you can install libraries to cross-compile against.
|
||||
# Look for 'dpkg --add-architecture' in the README for more details.
|
||||
if grep -i ubuntu /etc/os-release >/dev/null; then
|
||||
sed 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch-=amd64,i386] http:\/\/ports.ubuntu.com\/ubuntu-ports\//g' /etc/apt/sources.list > /etc/apt/sources.list.d/ports.list
|
||||
sed -i 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch=amd64,i386] http:\/\/\1.archive.ubuntu.com\/ubuntu\//g' /etc/apt/sources.list
|
||||
fi
|
||||
|
||||
install_packages \
|
||||
autoconf \
|
||||
automake \
|
||||
binutils \
|
||||
ca-certificates \
|
||||
curl \
|
||||
file \
|
||||
gcc \
|
||||
git \
|
||||
libtool \
|
||||
m4 \
|
||||
make
|
||||
|
||||
if_centos install_packages \
|
||||
clang-devel \
|
||||
gcc-c++ \
|
||||
glibc-devel \
|
||||
pkgconfig
|
||||
|
||||
if_ubuntu install_packages \
|
||||
g++ \
|
||||
libc6-dev \
|
||||
libclang-dev \
|
||||
pkg-config
|
||||
19
.docker/cross/deny-debian-packages.sh
Executable file
19
.docker/cross/deny-debian-packages.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -x
|
||||
set -euo pipefail
|
||||
|
||||
main() {
|
||||
local package
|
||||
|
||||
for package in "${@}"; do
|
||||
echo "Package: ${package}:${TARGET_ARCH}
|
||||
Pin: release *
|
||||
Pin-Priority: -1" > "/etc/apt/preferences.d/${package}"
|
||||
echo "${package}"
|
||||
done
|
||||
|
||||
rm "${0}"
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
56
.docker/cross/dropbear.sh
Executable file
56
.docker/cross/dropbear.sh
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -x
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. lib.sh
|
||||
|
||||
main() {
|
||||
local version=2022.82
|
||||
|
||||
install_packages \
|
||||
autoconf \
|
||||
automake \
|
||||
bzip2 \
|
||||
curl \
|
||||
make
|
||||
|
||||
if_centos install_packages zlib-devel
|
||||
if_ubuntu install_packages zlib1g-dev
|
||||
|
||||
local td
|
||||
td="$(mktemp -d)"
|
||||
|
||||
pushd "${td}"
|
||||
|
||||
curl --retry 3 -sSfL "https://matt.ucc.asn.au/dropbear/releases/dropbear-${version}.tar.bz2" -O
|
||||
tar --strip-components=1 -xjf "dropbear-${version}.tar.bz2"
|
||||
|
||||
# Remove some unwanted message
|
||||
sed -i '/skipping hostkey/d' cli-kex.c
|
||||
sed -i '/failed to identify current user/d' cli-runopts.c
|
||||
|
||||
./configure \
|
||||
--disable-syslog \
|
||||
--disable-shadow \
|
||||
--disable-lastlog \
|
||||
--disable-utmp \
|
||||
--disable-utmpx \
|
||||
--disable-wtmp \
|
||||
--disable-wtmpx \
|
||||
--disable-pututline \
|
||||
--disable-pututxline
|
||||
|
||||
make "-j$(nproc)" PROGRAMS=dbclient
|
||||
cp dbclient /usr/local/bin/
|
||||
|
||||
purge_packages
|
||||
|
||||
popd
|
||||
|
||||
rm -rf "${td}"
|
||||
rm "${0}"
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
45
.docker/cross/lib.sh
Normal file
45
.docker/cross/lib.sh
Normal file
@@ -0,0 +1,45 @@
|
||||
purge_list=()
|
||||
|
||||
install_packages() {
|
||||
if grep -i ubuntu /etc/os-release; then
|
||||
apt-get update
|
||||
|
||||
for pkg in "${@}"; do
|
||||
if ! dpkg -L "${pkg}" >/dev/null 2>/dev/null; then
|
||||
apt-get install --assume-yes --no-install-recommends "${pkg}"
|
||||
|
||||
purge_list+=( "${pkg}" )
|
||||
fi
|
||||
done
|
||||
else
|
||||
for pkg in "${@}"; do
|
||||
if ! yum list installed "${pkg}" >/dev/null 2>/dev/null; then
|
||||
yum install -y "${pkg}"
|
||||
|
||||
purge_list+=( "${pkg}" )
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
purge_packages() {
|
||||
if (( ${#purge_list[@]} )); then
|
||||
if grep -i ubuntu /etc/os-release; then
|
||||
apt-get purge --assume-yes --auto-remove "${purge_list[@]}"
|
||||
else
|
||||
yum remove -y "${purge_list[@]}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if_centos() {
|
||||
if grep -q -i centos /etc/os-release; then
|
||||
eval "${@}"
|
||||
fi
|
||||
}
|
||||
|
||||
if_ubuntu() {
|
||||
if grep -q -i ubuntu /etc/os-release; then
|
||||
eval "${@}"
|
||||
fi
|
||||
}
|
||||
274
.docker/cross/linux-image.sh
Executable file
274
.docker/cross/linux-image.sh
Executable file
@@ -0,0 +1,274 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -x
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. lib.sh
|
||||
|
||||
main() {
|
||||
# arch in the rust target
|
||||
local arch="${1}" \
|
||||
kversion=4.19.0-20
|
||||
|
||||
local debsource="deb http://http.debian.net/debian/ buster main"
|
||||
debsource="${debsource}\ndeb http://security.debian.org/ buster/updates main"
|
||||
|
||||
local dropbear="dropbear-bin"
|
||||
|
||||
local -a deps
|
||||
local kernel=
|
||||
local libgcc="libgcc1"
|
||||
|
||||
# select debian arch and kernel version
|
||||
case "${arch}" in
|
||||
aarch64)
|
||||
arch=arm64
|
||||
kernel="${kversion}-arm64"
|
||||
;;
|
||||
armv7)
|
||||
arch=armhf
|
||||
kernel="${kversion}-armmp"
|
||||
;;
|
||||
i686)
|
||||
arch=i386
|
||||
kernel="${kversion}-686"
|
||||
;;
|
||||
mips|mipsel)
|
||||
kernel="${kversion}-4kc-malta"
|
||||
;;
|
||||
mips64el)
|
||||
kernel="${kversion}-5kc-malta"
|
||||
;;
|
||||
powerpc)
|
||||
# there is no buster powerpc port, so we use jessie
|
||||
# use a more recent kernel from backports
|
||||
kversion='4.9.0-0.bpo.6'
|
||||
kernel="${kversion}-powerpc"
|
||||
debsource="deb http://archive.debian.org/debian jessie main"
|
||||
debsource="${debsource}\ndeb http://archive.debian.org/debian jessie-backports main"
|
||||
debsource="${debsource}\ndeb http://ftp.ports.debian.org/debian-ports unstable main"
|
||||
debsource="${debsource}\ndeb http://ftp.ports.debian.org/debian-ports unreleased main"
|
||||
|
||||
# archive.debian.org Release files are expired.
|
||||
echo "Acquire::Check-Valid-Until false;" | tee -a /etc/apt/apt.conf.d/10-nocheckvalid
|
||||
echo "APT::Get::AllowUnauthenticated true;" | tee -a /etc/apt/apt.conf.d/10-nocheckvalid
|
||||
|
||||
dropbear="dropbear"
|
||||
deps=(libcrypt1:"${arch}")
|
||||
;;
|
||||
powerpc64)
|
||||
# there is no stable port
|
||||
arch=ppc64
|
||||
# https://packages.debian.org/en/sid/linux-image-powerpc64
|
||||
kversion='5.*'
|
||||
kernel="${kversion}-powerpc64"
|
||||
libgcc="libgcc-s1"
|
||||
debsource="deb http://ftp.ports.debian.org/debian-ports unstable main"
|
||||
debsource="${debsource}\ndeb http://ftp.ports.debian.org/debian-ports unreleased main"
|
||||
# sid version of dropbear requires these dependencies
|
||||
deps=(libcrypt1:"${arch}")
|
||||
;;
|
||||
powerpc64le)
|
||||
arch=ppc64el
|
||||
kernel="${kversion}-powerpc64le"
|
||||
;;
|
||||
s390x)
|
||||
arch=s390x
|
||||
kernel="${kversion}-s390x"
|
||||
;;
|
||||
sparc64)
|
||||
# there is no stable port
|
||||
# https://packages.debian.org/en/sid/linux-image-sparc64
|
||||
kernel='*-sparc64'
|
||||
libgcc="libgcc-s1"
|
||||
debsource="deb http://ftp.ports.debian.org/debian-ports unstable main"
|
||||
debsource="${debsource}\ndeb http://ftp.ports.debian.org/debian-ports unreleased main"
|
||||
# sid version of dropbear requires these dependencies
|
||||
deps=(libcrypt1:"${arch}")
|
||||
;;
|
||||
x86_64)
|
||||
arch=amd64
|
||||
kernel="${kversion}-amd64"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid arch: ${arch}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
install_packages ca-certificates \
|
||||
curl \
|
||||
cpio \
|
||||
sharutils \
|
||||
gnupg
|
||||
|
||||
# Download packages
|
||||
mv /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
echo -e "${debsource}" > /etc/apt/sources.list
|
||||
|
||||
# Old ubuntu does not support --add-architecture, so we directly change multiarch file
|
||||
if [ -f /etc/dpkg/dpkg.cfg.d/multiarch ]; then
|
||||
cp /etc/dpkg/dpkg.cfg.d/multiarch /etc/dpkg/dpkg.cfg.d/multiarch.bak
|
||||
fi
|
||||
dpkg --add-architecture "${arch}" || echo "foreign-architecture ${arch}" > /etc/dpkg/dpkg.cfg.d/multiarch
|
||||
|
||||
# Add Debian keys.
|
||||
curl --retry 3 -sSfL 'https://ftp-master.debian.org/keys/archive-key-{7.0,8,9,10}.asc' -O
|
||||
curl --retry 3 -sSfL 'https://ftp-master.debian.org/keys/archive-key-{8,9,10}-security.asc' -O
|
||||
curl --retry 3 -sSfL 'https://ftp-master.debian.org/keys/release-{7,8,9,10}.asc' -O
|
||||
curl --retry 3 -sSfL 'https://www.ports.debian.org/archive_{2020,2021,2022}.key' -O
|
||||
|
||||
for key in *.asc *.key; do
|
||||
apt-key add "${key}"
|
||||
rm "${key}"
|
||||
done
|
||||
|
||||
# allow apt-get to retry downloads
|
||||
echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries
|
||||
|
||||
apt-get update
|
||||
|
||||
mkdir -p "/qemu/${arch}"
|
||||
chmod 777 /qemu "/qemu/${arch}"
|
||||
|
||||
cd "/qemu/${arch}"
|
||||
apt-get -d --no-install-recommends download \
|
||||
${deps[@]+"${deps[@]}"} \
|
||||
"busybox:${arch}" \
|
||||
"${dropbear}:${arch}" \
|
||||
"libtommath1:${arch}" \
|
||||
"libtomcrypt1:${arch}" \
|
||||
"libgmp10:${arch}" \
|
||||
"libc6:${arch}" \
|
||||
"${libgcc}:${arch}" \
|
||||
"libstdc++6:${arch}" \
|
||||
"linux-image-${kernel}:${arch}" \
|
||||
ncurses-base \
|
||||
"zlib1g:${arch}"
|
||||
cd /qemu
|
||||
|
||||
# Install packages
|
||||
root="root-${arch}"
|
||||
mkdir -p "${root}"/{bin,etc/dropbear,root,sys,dev,proc,sbin,tmp,usr/{bin,sbin},var/log}
|
||||
for deb in "${arch}"/*deb; do
|
||||
dpkg -x "${deb}" "${root}"/
|
||||
done
|
||||
|
||||
cp "${root}/boot/vmlinu"* kernel
|
||||
|
||||
# initrd
|
||||
mkdir -p "${root}/modules"
|
||||
cp -v \
|
||||
"${root}/lib/modules"/*/kernel/drivers/net/net_failover.ko \
|
||||
"${root}/lib/modules"/*/kernel/drivers/net/virtio_net.ko \
|
||||
"${root}/lib/modules"/*/kernel/drivers/virtio/* \
|
||||
"${root}/lib/modules"/*/kernel/fs/netfs/netfs.ko \
|
||||
"${root}/lib/modules"/*/kernel/fs/9p/9p.ko \
|
||||
"${root}/lib/modules"/*/kernel/fs/fscache/fscache.ko \
|
||||
"${root}/lib/modules"/*/kernel/net/9p/9pnet.ko \
|
||||
"${root}/lib/modules"/*/kernel/net/9p/9pnet_virtio.ko \
|
||||
"${root}/lib/modules"/*/kernel/net/core/failover.ko \
|
||||
"${root}/modules" || true # some file may not exist
|
||||
rm -rf "${root:?}/boot"
|
||||
rm -rf "${root:?}/lib/modules"
|
||||
|
||||
cat << 'EOF' > "${root}/etc/hosts"
|
||||
127.0.0.1 localhost qemu
|
||||
EOF
|
||||
|
||||
cat << 'EOF' > $root/etc/hostname
|
||||
qemu
|
||||
EOF
|
||||
|
||||
cat << 'EOF' > $root/etc/passwd
|
||||
root::0:0:root:/root:/bin/sh
|
||||
EOF
|
||||
|
||||
cat << 'EOF' | uudecode -o $root/etc/dropbear/dropbear_rsa_host_key
|
||||
begin 600 dropbear_rsa_host_key
|
||||
M````!W-S:"UR<V$````#`0`!```!`0"N!-<%K,3Z.!Z,OEMB2.N\O.$IWQ*F
|
||||
M#5%(_;(^2YKY_J_.RQW/7U@_MK&J#!Z0_\;EH#98ZW*E1\.<FF%P/*Y.W56-
|
||||
M31.'EJE`TN@=T5EC(8"Y%3'ZBYH)^WIVJ]S*G/_;#RH\_?S"U^1L_<<.F`O+
|
||||
MZVI?*]\KTDOT&QV0#B-M;"%_7:\>+3[X=QMH,B<HM$+0E[\B6*^!XKLR@V,K
|
||||
M)<V80HHK:_#;D]26XKN&CB./EZAC%4)78R!G""4HT@UK<5I4B^$/""`,?*\T
|
||||
M>*4$RYULV,V3X6]K:7@Q?80"#WXGGQZNFN6CZ7LTDX(F6J[\]F5<0`HEOF:Z
|
||||
MX;^53`L'4I/A```!``$L:$Z*#6<^3@+O%.[-#/5H+.C'3\#QQZN[1;J>L`8I
|
||||
MZ_&T'!"J'/Y+?R?55G:M^=]R*-&I3TOJYZA8@&H51ZOAF59'1_>>Z@?E4#)$
|
||||
MQU)X/RWH51ZB5KSDWJS:D'7GD(!?NAY`C'7\)I:_4)J")QBV/P"RJQGHG'%B
|
||||
M1BT2LE6676>`1K,0\NIMZTKQNB(IC+88<7#8%_-=P<&6<"9LH>60TSS?3?-C
|
||||
MN`T36YB/3^<(Q;`N1NT>I9EZS`BAC^-?.:,R\7EL"<4>7E=]^1]B\K9])AQU
|
||||
MBM\]M;4V(S(6KH-I.4[6>9E+@\UEM.J6:[2LUEEJDG:G:+:/EVF^Y75@(S$`
|
||||
M``"!`.O+KW=&*CBCHL"11&SVO4/K]$R-]7MV7,3RR)Q[X'0;6.?4JHW!3VR6
|
||||
M*FGBY--37ZD-+UV.8_+"$<?B"#&K$.[V)F7V2\UY!7(0FZ@A2`0ADDY*J-_B
|
||||
M4AU&.*GP#F/!I([:?E],.>6PH9)(/E.\G19#G0K`LRM?JWS!58&;D0C1````
|
||||
M@0"\[@NYWSTW(?Q@:_A*1Y3/AKYO5?S=0"<2>#V-AH6W-NCSDTSRP=2D79FS
|
||||
M"D?[;.)V>8'#9&I3"MU@+:2\Z%$0-MG0+J'(0>T1_C6?*C=4U0I$DI<=@D]1
|
||||
H_&DE8Y(OT%%EPG]!$H&5HX*),_D1A2\P=R.7G'`0L%YM-79Y"T">$0``
|
||||
`
|
||||
end
|
||||
EOF
|
||||
|
||||
# dropbear complains when this file is missing
|
||||
touch "${root}/var/log/lastlog"
|
||||
|
||||
cat << 'EOF' > $root/init
|
||||
#!/bin/busybox sh
|
||||
|
||||
set -e
|
||||
|
||||
/bin/busybox --install
|
||||
|
||||
mount -t devtmpfs devtmpfs /dev
|
||||
mount -t proc none /proc
|
||||
mount -t sysfs none /sys
|
||||
mkdir /dev/pts
|
||||
mount -t devpts none /dev/pts/
|
||||
|
||||
# some archs does not have virtio modules
|
||||
insmod /modules/failover.ko || true
|
||||
insmod /modules/net_failover.ko || true
|
||||
insmod /modules/virtio.ko || true
|
||||
insmod /modules/virtio_ring.ko || true
|
||||
insmod /modules/virtio_mmio.ko || true
|
||||
insmod /modules/virtio_pci_legacy_dev.ko || true
|
||||
insmod /modules/virtio_pci_modern_dev.ko || true
|
||||
insmod /modules/virtio_pci.ko || true
|
||||
insmod /modules/virtio_net.ko || true
|
||||
insmod /modules/netfs.ko || true
|
||||
insmod /modules/fscache.ko
|
||||
insmod /modules/9pnet.ko
|
||||
insmod /modules/9pnet_virtio.ko || true
|
||||
insmod /modules/9p.ko
|
||||
|
||||
ifconfig lo 127.0.0.1
|
||||
ifconfig eth0 10.0.2.15
|
||||
route add default gw 10.0.2.2 eth0
|
||||
|
||||
mkdir /target
|
||||
mount -t 9p -o trans=virtio target /target -oversion=9p2000.u || true
|
||||
|
||||
exec dropbear -F -E -B
|
||||
EOF
|
||||
|
||||
chmod +x "${root}/init"
|
||||
cd "${root}"
|
||||
find . | cpio --create --format='newc' --quiet | gzip > ../initrd.gz
|
||||
cd -
|
||||
|
||||
# Clean up
|
||||
rm -rf "/qemu/${root}" "/qemu/${arch}"
|
||||
mv -f /etc/apt/sources.list.bak /etc/apt/sources.list
|
||||
if [ -f /etc/dpkg/dpkg.cfg.d/multiarch.bak ]; then
|
||||
mv /etc/dpkg/dpkg.cfg.d/multiarch.bak /etc/dpkg/dpkg.cfg.d/multiarch
|
||||
fi
|
||||
# can fail if arch is used (amd64 and/or i386)
|
||||
dpkg --remove-architecture "${arch}" || true
|
||||
apt-get update
|
||||
|
||||
purge_packages
|
||||
|
||||
ls -lh /qemu
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
173
.docker/cross/linux-runner
Executable file
173
.docker/cross/linux-runner
Executable file
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
LOG=/tmp/qemu.log
|
||||
LOCK=/tmp/qemu.lock
|
||||
|
||||
if [ -n "${CROSS_DEBUG}" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
# arch in the rust target
|
||||
arch="${1}"
|
||||
shift
|
||||
|
||||
if [ "${CROSS_RUNNER}" = "" ]; then
|
||||
if [[ "${arch}" == i?86 ]] || [[ "${arch}" == x86_64 ]]; then
|
||||
CROSS_RUNNER=native
|
||||
else
|
||||
CROSS_RUNNER=qemu-user
|
||||
fi
|
||||
fi
|
||||
|
||||
# select qemu arch
|
||||
qarch="${arch}"
|
||||
case "${arch}" in
|
||||
armv7)
|
||||
qarch="arm"
|
||||
;;
|
||||
i686)
|
||||
qarch="i386"
|
||||
;;
|
||||
powerpc)
|
||||
qarch="ppc"
|
||||
;;
|
||||
powerpc64)
|
||||
qarch="ppc64"
|
||||
;;
|
||||
powerpc64le)
|
||||
if [ "${CROSS_RUNNER}" = "qemu-user" ]; then
|
||||
qarch="ppc64le"
|
||||
else
|
||||
qarch="ppc64"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
case "${CROSS_RUNNER}" in
|
||||
native)
|
||||
exec "${@}"
|
||||
;;
|
||||
qemu-user)
|
||||
exec "qemu-${qarch}" "${@}"
|
||||
;;
|
||||
qemu-system)
|
||||
true
|
||||
;;
|
||||
*)
|
||||
echo "Invalid runner: \"${CROSS_RUNNER}\"";
|
||||
echo "Valid runners are: native, qemu-user and qemu-system"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
n="$(nproc)"
|
||||
memory=1G
|
||||
driver9p="virtio-9p-pci"
|
||||
drivernet="virtio-net-pci"
|
||||
|
||||
# select qemu parameters
|
||||
case "${arch}" in
|
||||
aarch64)
|
||||
# 8 is the max number of cpu supported by qemu-aarch64
|
||||
n=$(( n > 8 ? 8 : n ))
|
||||
opt="-machine virt -cpu cortex-a57"
|
||||
;;
|
||||
armv7)
|
||||
opt="-machine virt"
|
||||
driver9p="virtio-9p-device"
|
||||
drivernet="virtio-net-device"
|
||||
;;
|
||||
i686)
|
||||
opt="-append console=ttyS0"
|
||||
;;
|
||||
mips|mipsel)
|
||||
# avoid kernel error
|
||||
# https://blahcat.github.io/2017/07/14/building-a-debian-stretch-qemu-image-for-mipsel/
|
||||
opt="-append nokaslr"
|
||||
n=1
|
||||
;;
|
||||
mips64el)
|
||||
# avoid kernel error
|
||||
# https://blahcat.github.io/2017/07/14/building-a-debian-stretch-qemu-image-for-mipsel/
|
||||
opt="-append nokaslr -cpu MIPS64R2-generic"
|
||||
n=1
|
||||
;;
|
||||
powerpc)
|
||||
opt="-append console=ttyPZ0"
|
||||
n=1
|
||||
;;
|
||||
powerpc64|powerpc64le)
|
||||
opt="-append console=hvc0 --nodefaults -serial stdio"
|
||||
;;
|
||||
s390x)
|
||||
n=1
|
||||
driver9p="virtio-9p-ccw"
|
||||
drivernet="virtio-net-ccw"
|
||||
;;
|
||||
sparc64)
|
||||
n=1
|
||||
driver9p+=",bus=pciB"
|
||||
drivernet+=",bus=pciB"
|
||||
;;
|
||||
x86_64)
|
||||
opt="-append console=ttyS0"
|
||||
;;
|
||||
esac
|
||||
|
||||
(
|
||||
flock -n 200 || exit 0
|
||||
|
||||
echo Booting QEMU virtual machine with $n cpus...
|
||||
|
||||
QEMU_CMD="qemu-system-${qarch} \
|
||||
-m ${memory} \
|
||||
-smp ${n} \
|
||||
-nographic \
|
||||
-monitor none \
|
||||
-netdev user,id=net0,hostfwd=tcp::10022-:22 \
|
||||
-device ${drivernet},netdev=net0 \
|
||||
-kernel /qemu/kernel \
|
||||
-initrd /qemu/initrd.gz \
|
||||
${opt} \
|
||||
-fsdev local,id=fs0,path=/target,security_model=mapped \
|
||||
-device ${driver9p},fsdev=fs0,mount_tag=target"
|
||||
|
||||
touch "${LOG}"
|
||||
if [[ -n "${CROSS_DEBUG}" ]]; then
|
||||
(${QEMU_CMD} 2>&1 | tee -a "${LOG}") &
|
||||
else
|
||||
${QEMU_CMD} >> "${LOG}" 2>&1 &
|
||||
fi
|
||||
|
||||
# wait for dropbear
|
||||
for _ in $(seq 240); do
|
||||
if grep -q "Not backgrounding" "${LOG}"; then
|
||||
READY=1
|
||||
break
|
||||
fi
|
||||
sleep 0.5s
|
||||
done
|
||||
|
||||
if [ -z "${READY}" ]; then
|
||||
if [ -n "${CROSS_DEBUG}" ]; then
|
||||
echo "Not ready but continuing because CROSS_DEBUG is set"
|
||||
else
|
||||
echo "Qemu is not ready after ${SECONDS} seconds..."
|
||||
echo "Set the environment variable CROSS_DEBUG=1 to debug"
|
||||
echo "Last 100 lines of qemu output:"
|
||||
tail -n 100 "${LOG}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Booted in ${SECONDS} seconds"
|
||||
|
||||
) 200>"${LOCK}"
|
||||
|
||||
if [[ -t 1 ]] && [[ -t 2 ]]; then
|
||||
tty_flag='-t'
|
||||
fi
|
||||
|
||||
exec dbclient ${tty_flag} -p 10022 -y -y root@localhost "${@}"
|
||||
233
.docker/cross/qemu.sh
Executable file
233
.docker/cross/qemu.sh
Executable file
@@ -0,0 +1,233 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -x
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. lib.sh
|
||||
|
||||
build_static_libffi () {
|
||||
local version=3.0.13
|
||||
|
||||
local td
|
||||
td="$(mktemp -d)"
|
||||
|
||||
pushd "${td}"
|
||||
|
||||
|
||||
curl --retry 3 -sSfL "https://github.com/libffi/libffi/archive/refs/tags/v${version}.tar.gz" -O -L
|
||||
tar --strip-components=1 -xzf "v${version}.tar.gz"
|
||||
./configure --prefix="$td"/lib --disable-builddir --disable-shared --enable-static
|
||||
make "-j$(nproc)"
|
||||
install -m 644 ./.libs/libffi.a /usr/lib64/
|
||||
|
||||
popd
|
||||
|
||||
rm -rf "${td}"
|
||||
}
|
||||
|
||||
build_static_libmount () {
|
||||
local version_spec=2.23.2
|
||||
local version=2.23
|
||||
local td
|
||||
td="$(mktemp -d)"
|
||||
|
||||
pushd "${td}"
|
||||
|
||||
curl --retry 3 -sSfL "https://kernel.org/pub/linux/utils/util-linux/v${version}/util-linux-${version_spec}.tar.xz" -O -L
|
||||
tar --strip-components=1 -xJf "util-linux-${version_spec}.tar.xz"
|
||||
./configure --disable-shared --enable-static --without-ncurses
|
||||
make "-j$(nproc)" mount blkid
|
||||
install -m 644 ./.libs/*.a /usr/lib64/
|
||||
|
||||
popd
|
||||
|
||||
rm -rf "${td}"
|
||||
}
|
||||
|
||||
|
||||
build_static_libattr() {
|
||||
local version=2.4.46
|
||||
|
||||
local td
|
||||
td="$(mktemp -d)"
|
||||
|
||||
pushd "${td}"
|
||||
|
||||
yum install -y gettext
|
||||
|
||||
curl --retry 3 -sSfL "https://download.savannah.nongnu.org/releases/attr/attr-${version}.src.tar.gz" -O
|
||||
tar --strip-components=1 -xzf "attr-${version}.src.tar.gz"
|
||||
cp /usr/share/automake*/config.* .
|
||||
|
||||
./configure
|
||||
make "-j$(nproc)"
|
||||
install -m 644 ./libattr/.libs/libattr.a /usr/lib64/
|
||||
|
||||
yum remove -y gettext
|
||||
|
||||
popd
|
||||
|
||||
rm -rf "${td}"
|
||||
}
|
||||
|
||||
build_static_libcap() {
|
||||
local version=2.22
|
||||
|
||||
local td
|
||||
td="$(mktemp -d)"
|
||||
|
||||
pushd "${td}"
|
||||
|
||||
curl --retry 3 -sSfL "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-${version}.tar.xz" -O
|
||||
tar --strip-components=1 -xJf "libcap-${version}.tar.xz"
|
||||
make "-j$(nproc)"
|
||||
install -m 644 libcap/libcap.a /usr/lib64/
|
||||
|
||||
popd
|
||||
|
||||
rm -rf "${td}"
|
||||
}
|
||||
|
||||
build_static_pixman() {
|
||||
local version=0.34.0
|
||||
|
||||
local td
|
||||
td="$(mktemp -d)"
|
||||
|
||||
pushd "${td}"
|
||||
|
||||
curl --retry 3 -sSfL "https://www.cairographics.org/releases/pixman-${version}.tar.gz" -O
|
||||
tar --strip-components=1 -xzf "pixman-${version}.tar.gz"
|
||||
./configure
|
||||
make "-j$(nproc)"
|
||||
install -m 644 ./pixman/.libs/libpixman-1.a /usr/lib64/
|
||||
|
||||
popd
|
||||
|
||||
rm -rf "${td}"
|
||||
}
|
||||
|
||||
main() {
|
||||
local version=5.1.0
|
||||
|
||||
if_centos version=4.2.1
|
||||
|
||||
local arch="${1}" \
|
||||
softmmu="${2:-}"
|
||||
|
||||
install_packages \
|
||||
autoconf \
|
||||
automake \
|
||||
bison \
|
||||
bzip2 \
|
||||
curl \
|
||||
flex \
|
||||
libtool \
|
||||
make \
|
||||
patch \
|
||||
python3 \
|
||||
|
||||
if_centos install_packages \
|
||||
gcc-c++ \
|
||||
pkgconfig \
|
||||
xz \
|
||||
glib2-devel \
|
||||
glib2-static \
|
||||
glibc-static \
|
||||
libattr-devel \
|
||||
libcap-devel \
|
||||
libfdt-devel \
|
||||
pcre-static \
|
||||
pixman-devel \
|
||||
libselinux-devel \
|
||||
libselinux-static \
|
||||
libffi \
|
||||
libuuid-devel \
|
||||
libblkid-devel \
|
||||
libmount-devel \
|
||||
zlib-devel \
|
||||
zlib-static
|
||||
|
||||
if_centos 'curl --retry 3 -sSfL "https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD" -o /usr/share/automake*/config.guess'
|
||||
if_centos 'curl --retry 3 -sSfL "https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD" -o /usr/share/automake*/config.sub'
|
||||
|
||||
# these are not packaged as static libraries in centos; build them manually
|
||||
if_centos build_static_libffi
|
||||
if_centos build_static_libmount
|
||||
if_centos build_static_libattr
|
||||
if_centos build_static_libcap
|
||||
if_centos build_static_pixman
|
||||
|
||||
if_ubuntu install_packages \
|
||||
g++ \
|
||||
pkg-config \
|
||||
xz-utils \
|
||||
libattr1-dev \
|
||||
libcap-ng-dev \
|
||||
libffi-dev \
|
||||
libglib2.0-dev \
|
||||
libpixman-1-dev \
|
||||
libselinux1-dev \
|
||||
zlib1g-dev
|
||||
|
||||
# if we have python3.6+, we can install qemu 6.1.0, which needs ninja-build
|
||||
# ubuntu 16.04 only provides python3.5, so remove when we have a newer qemu.
|
||||
is_ge_python36=$(python3 -c "import sys; print(int(sys.version_info >= (3, 6)))")
|
||||
if [[ "${is_ge_python36}" == "1" ]]; then
|
||||
if_ubuntu version=6.1.0
|
||||
if_ubuntu install_packages ninja-build
|
||||
fi
|
||||
|
||||
local td
|
||||
td="$(mktemp -d)"
|
||||
|
||||
pushd "${td}"
|
||||
|
||||
curl --retry 3 -sSfL "https://download.qemu.org/qemu-${version}.tar.xz" -O
|
||||
tar --strip-components=1 -xJf "qemu-${version}.tar.xz"
|
||||
|
||||
local targets="${arch}-linux-user"
|
||||
local virtfs=""
|
||||
case "${softmmu}" in
|
||||
softmmu)
|
||||
if [ "${arch}" = "ppc64le" ]; then
|
||||
targets="${targets},ppc64-softmmu"
|
||||
else
|
||||
targets="${targets},${arch}-softmmu"
|
||||
fi
|
||||
virtfs="--enable-virtfs"
|
||||
;;
|
||||
"")
|
||||
true
|
||||
;;
|
||||
*)
|
||||
echo "Invalid softmmu option: ${softmmu}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
./configure \
|
||||
--disable-kvm \
|
||||
--disable-vnc \
|
||||
--disable-guest-agent \
|
||||
--enable-linux-user \
|
||||
--static \
|
||||
${virtfs} \
|
||||
--target-list="${targets}"
|
||||
make "-j$(nproc)"
|
||||
make install
|
||||
|
||||
# HACK the binfmt_misc interpreter we'll use expects the QEMU binary to be
|
||||
# in /usr/bin. Create an appropriate symlink
|
||||
ln -s "/usr/local/bin/qemu-${arch}" "/usr/bin/qemu-${arch}-static"
|
||||
|
||||
purge_packages
|
||||
|
||||
popd
|
||||
|
||||
rm -rf "${td}"
|
||||
rm "${0}"
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
28
.docker/cross/xargo.sh
Executable file
28
.docker/cross/xargo.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -x
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. lib.sh
|
||||
|
||||
main() {
|
||||
install_packages ca-certificates curl
|
||||
|
||||
export RUSTUP_HOME=/tmp/rustup
|
||||
export CARGO_HOME=/tmp/cargo
|
||||
|
||||
curl --retry 3 -sSfL https://sh.rustup.rs -o rustup-init.sh
|
||||
sh rustup-init.sh -y --no-modify-path --profile minimal
|
||||
rm rustup-init.sh
|
||||
|
||||
PATH="${CARGO_HOME}/bin:${PATH}" cargo install xargo --root /usr/local
|
||||
|
||||
rm -r "${RUSTUP_HOME}" "${CARGO_HOME}"
|
||||
|
||||
purge_packages
|
||||
|
||||
rm "${0}"
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
2
.github/CODE_OF_CONDUCT.md
vendored
2
.github/CODE_OF_CONDUCT.md
vendored
@@ -61,7 +61,7 @@ representative at an online or offline event.
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
[contact@tauri.studio](mailto:contact@tauri.studio).
|
||||
[contact@tauri.app](mailto:contact@tauri.app).
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
|
||||
6
.github/CONTRIBUTING.md
vendored
6
.github/CONTRIBUTING.md
vendored
@@ -48,9 +48,9 @@ Hi! We, the maintainers, are really excited that you are interested in contribut
|
||||
|
||||
First, [join our Discord server](https://discord.gg/SpmNs4S) and let us know that you want to contribute. This way we can point you in the right direction and help ensure your contribution will be as helpful as possible.
|
||||
|
||||
To set up your machine for development, follow the [Tauri setup guide](https://tauri.studio/guides/getting-started/prerequisites/) to get all the tools you need to develop Tauri apps. The only additional tool you may need is [Yarn](https://yarnpkg.com/), it is only required if you are developing the Node CLI or API packages (`tooling/cli/node` and `tooling/api`). Next, fork and clone this repo. It is structured as a monorepo, which means that all the various Tauri packages are under the same repository. The development process varies depending on what part of Tauri you are contributing to, see the guides below for per-package instructions.
|
||||
To set up your machine for development, follow the [Tauri setup guide](https://tauri.app/v1/guides/getting-started/prerequisites/) to get all the tools you need to develop Tauri apps. The only additional tool you may need is [Yarn](https://yarnpkg.com/), it is only required if you are developing the Node CLI or API packages (`tooling/cli/node` and `tooling/api`). Next, fork and clone this repo. It is structured as a monorepo, which means that all the various Tauri packages are under the same repository. The development process varies depending on what part of Tauri you are contributing to, see the guides below for per-package instructions.
|
||||
|
||||
Some Tauri packages will be automatically built when running one of the examples. Others, however, will need to be built beforehand. To build these automatically, run the `.scripts/setup.sh` (Linux and macOS) or `.scripts/setup.ps1` (Windows) script. This will install the Rust and Node.js CLI and build the JS API. After that, you should be able to run all the examples. Note that the setup script should be executed from the root folder of the respository in order to run correctly.
|
||||
Some Tauri packages will be automatically built when running one of the examples. Others, however, will need to be built beforehand. To build these automatically, run the `.scripts/setup.sh` (Linux and macOS) or `.scripts/setup.ps1` (Windows) script. This will install the Rust and Node.js CLI and build the JS API. After that, you should be able to run all the examples. Note that the setup script should be executed from the root folder of the repository in order to run correctly.
|
||||
|
||||
### Packages Overview
|
||||
|
||||
@@ -87,4 +87,4 @@ The JS API provides bindings between the developer's JS in the Webview and the b
|
||||
|
||||
## Financial Contribution
|
||||
|
||||
Tauri is an MIT-licensed open source project. Its ongoing development can be supported via [Github Sponsors](https://github.com/sponsors/nothingismagick) or [Open Collective](https://opencollective.com/tauri). We prefer Github Sponsors as donations made are doubled through the matching fund program.
|
||||
Tauri is an MIT-licensed open source project. Its ongoing development can be supported via [GitHub Sponsors](https://github.com/sponsors/nothingismagick) or [Open Collective](https://opencollective.com/tauri). We prefer GitHub Sponsors as donations made are doubled through the matching fund program.
|
||||
|
||||
1
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
1
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -43,7 +43,6 @@ body:
|
||||
attributes:
|
||||
label: Platform and versions
|
||||
description: "Output of `npm run tauri info` or `cargo tauri info`"
|
||||
render: shell
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
8
.github/workflows/artifacts-updater.yml
vendored
8
.github/workflows/artifacts-updater.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -11,10 +11,8 @@ on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/artifacts-updater.yml'
|
||||
- 'core/tauri/**'
|
||||
- 'tooling/cli/**'
|
||||
- 'tooling/bundler/**'
|
||||
- 'examples/updater/**'
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
@@ -26,7 +24,7 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-artifacs:
|
||||
build-artifacts:
|
||||
runs-on: ${{ matrix.platform }}
|
||||
|
||||
strategy:
|
||||
|
||||
2
.github/workflows/audit.yml
vendored
2
.github/workflows/audit.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
2
.github/workflows/bench.yml
vendored
2
.github/workflows/bench.yml
vendored
@@ -43,7 +43,7 @@ jobs:
|
||||
python-version: '3.x'
|
||||
architecture: x64
|
||||
|
||||
- name: install depedencies
|
||||
- name: install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
sudo apt-get update
|
||||
|
||||
2
.github/workflows/change-status-on-PR.yml
vendored
2
.github/workflows/change-status-on-PR.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -171,3 +171,14 @@ jobs:
|
||||
token: ${{ secrets.TAURI_BOT_PAT }}
|
||||
repository: tauri-apps/tauri
|
||||
event-type: publish-clijs
|
||||
client-payload: '{"releaseId": "${{ steps.covector.outputs.cli.js-releaseId }}" }'
|
||||
|
||||
- name: Trigger cli.rs publishing workflow
|
||||
if: |
|
||||
steps.covector.outputs.successfulPublish == 'true' &&
|
||||
contains(steps.covector.outputs.packagesPublished, 'cli.rs')
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
with:
|
||||
token: ${{ secrets.TAURI_BOT_PAT }}
|
||||
repository: tauri-apps/tauri
|
||||
event-type: publish-clirs
|
||||
|
||||
132
.github/workflows/docker.yml
vendored
Normal file
132
.github/workflows/docker.yml
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
name: docker
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
#pull_request:
|
||||
# paths:
|
||||
# - '.docker/**'
|
||||
# - '.github/workflows/docker.yml'
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: install Linux dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev
|
||||
|
||||
- name: install cross
|
||||
run: cargo install cross --git https://github.com/cross-rs/cross
|
||||
|
||||
- name: Upload cross
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: cross
|
||||
path: '~/.cargo/bin/cross'
|
||||
if-no-files-found: error
|
||||
|
||||
- name: build CLI
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --manifest-path ./tooling/cli/Cargo.toml
|
||||
|
||||
- name: Upload CLI
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: cargo-tauri
|
||||
path: tooling/cli/target/debug/cargo-tauri
|
||||
if-no-files-found: error
|
||||
|
||||
docker:
|
||||
needs: setup
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- { name: 'aarch64-unknown-linux-gnu', filename: 'aarch64' }
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
target: ${{ matrix.target.name }}
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- name: Download cross
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: cross
|
||||
path: '~/.cargo/bin'
|
||||
|
||||
- name: Download CLI
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: cargo-tauri
|
||||
path: 'examples/api'
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and export to Docker
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .docker/cross
|
||||
file: .docker/cross/${{ matrix.target.filename }}.Dockerfile
|
||||
load: true
|
||||
tags: ${{ matrix.target.name }}:latest
|
||||
|
||||
- name: install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd tooling/api
|
||||
yarn && yarn build
|
||||
cd ../../examples/api
|
||||
yarn
|
||||
. .setup-cross.sh
|
||||
chmod +x cargo-tauri
|
||||
chmod +x $HOME/.cargo/bin/cross
|
||||
./cargo-tauri build --runner cross --bundles deb --target ${{ matrix.target.name }} --verbose
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .docker/cross
|
||||
file: .docker/cross/${{ matrix.target.filename }}.Dockerfile
|
||||
push: true
|
||||
tags: ghcr.io/${{ github.repository }}/${{ matrix.target.name }}:latest
|
||||
2
.github/workflows/lint-fmt-cli.yml
vendored
2
.github/workflows/lint-fmt-cli.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
2
.github/workflows/lint-fmt-core.yml
vendored
2
.github/workflows/lint-fmt-core.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
2
.github/workflows/lint-js.yml
vendored
2
.github/workflows/lint-js.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -397,3 +397,4 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
RELEASE_ID: ${{ github.event.client_payload.releaseId }}
|
||||
82
.github/workflows/publish-cli-rs.yml
vendored
Normal file
82
.github/workflows/publish-cli-rs.yml
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
name: publish cli.rs
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
||||
on:
|
||||
workflow_dispatch:
|
||||
repository_dispatch:
|
||||
types: [publish-clirs]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.target.platform }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- {
|
||||
name: 'x86_64-unknown-linux-gnu',
|
||||
platform: 'ubuntu-18.04',
|
||||
ext: ''
|
||||
}
|
||||
- { name: 'x86_64-apple-darwin', platform: 'macos-latest', ext: '' }
|
||||
- {
|
||||
name: 'x86_64-pc-windows-msvc',
|
||||
platform: 'windows-latest',
|
||||
ext: '.exe'
|
||||
}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: install Linux dependencies
|
||||
if: matrix.target.platform == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev
|
||||
|
||||
- name: build CLI
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --manifest-path ./tooling/cli/Cargo.toml --release
|
||||
|
||||
- name: Upload CLI
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: cargo-tauri-${{ matrix.target.name }}${{ matrix.target.ext }}
|
||||
path: tooling/cli/target/release/cargo-tauri${{ matrix.target.ext }}
|
||||
if-no-files-found: error
|
||||
|
||||
upload:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Download built CLIs
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: outputs
|
||||
|
||||
- name: Pack archives
|
||||
run: ./.scripts/ci/pack-cli.sh
|
||||
|
||||
- name: Get CLI version
|
||||
run: echo "CLI_VERSION=$(cat tooling/cli/metadata.json | jq '."cli.js".version' -r)" >> $GITHUB_ENV
|
||||
|
||||
- name: Publish release
|
||||
uses: softprops/action-gh-release@50195ba7f6f93d1ac97ba8332a178e008ad176aa
|
||||
with:
|
||||
tag_name: cli.rs-v${{ env.CLI_VERSION }}
|
||||
files: |
|
||||
outputs/cargo-tauri-*.zip
|
||||
outputs/cargo-tauri-*.tgz
|
||||
2
.github/workflows/test-bundler.yml
vendored
2
.github/workflows/test-bundler.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
2
.github/workflows/test-cli-js.yml
vendored
2
.github/workflows/test-cli-js.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
2
.github/workflows/test-cli-rs.yml
vendored
2
.github/workflows/test-cli-rs.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
63
.github/workflows/test-core.yml
vendored
63
.github/workflows/test-core.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -13,8 +13,6 @@ on:
|
||||
paths:
|
||||
- '.github/workflows/test-core.yml'
|
||||
- 'core/**'
|
||||
- 'examples/**'
|
||||
- 'tooling/cli/**'
|
||||
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
@@ -27,31 +25,48 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
test-tauri-core:
|
||||
runs-on: ${{ matrix.platform }}
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [ubuntu-latest, macos-latest, windows-latest]
|
||||
platform:
|
||||
- {
|
||||
target: x86_64-pc-windows-msvc,
|
||||
os: windows-latest,
|
||||
toolchain: '1.61.0'
|
||||
}
|
||||
- {
|
||||
target: x86_64-unknown-linux-gnu,
|
||||
os: ubuntu-latest,
|
||||
toolchain: '1.57.0'
|
||||
}
|
||||
- {
|
||||
target: x86_64-apple-darwin,
|
||||
os: macos-latest,
|
||||
toolchain: '1.57.0'
|
||||
}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
toolchain: ${{ matrix.platform.toolchain }}
|
||||
target: ${{ matrix.platform.target }}
|
||||
override: true
|
||||
- name: install Linux dependencies
|
||||
if: matrix.platform == 'ubuntu-latest'
|
||||
if: contains(matrix.platform.target, 'unknown-linux')
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
if: matrix.platform == 'macos-latest' || matrix.platform == 'ubuntu-latest'
|
||||
if: matrix.platform.os == 'macos-latest' || matrix.platform.os == 'ubuntu-latest'
|
||||
|
||||
- name: Get current date
|
||||
if: matrix.platform == 'windows-latest'
|
||||
if: matrix.platform.os == 'windows-latest'
|
||||
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Cache cargo state
|
||||
@@ -63,12 +78,12 @@ jobs:
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
~/.cargo/bin
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
key: ${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
|
||||
${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-${{ env.cache-name }}-
|
||||
${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-
|
||||
${{ matrix.platform.os }}-
|
||||
|
||||
- name: Cache core cargo target
|
||||
uses: actions/cache@v2
|
||||
@@ -77,16 +92,20 @@ jobs:
|
||||
with:
|
||||
path: target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
key: ${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
|
||||
${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-${{ env.cache-name }}-
|
||||
${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-
|
||||
${{ matrix.platform.os }}-
|
||||
|
||||
- name: pin time
|
||||
run: |
|
||||
cargo update -p time --precise 0.3.13
|
||||
|
||||
- name: test
|
||||
run: |
|
||||
cargo test
|
||||
cargo test --features api-all
|
||||
cargo test --features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray,windows7-compat,http-multipart
|
||||
cargo test --target ${{ matrix.platform.target }}
|
||||
cargo test --target ${{ matrix.platform.target }} --features api-all
|
||||
cargo test --target ${{ matrix.platform.target }} --features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray,windows7-compat,http-multipart
|
||||
|
||||
140
.github/workflows/udeps.yml
vendored
140
.github/workflows/udeps.yml
vendored
@@ -1,16 +1,14 @@
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: Udeps
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/udeps.yml'
|
||||
- 'core/**'
|
||||
- 'tooling/bundler/**'
|
||||
- 'tooling/cli/**'
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- next
|
||||
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
@@ -22,26 +20,111 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
tauri: ${{ steps.filter.outputs.tauri }}
|
||||
build: ${{ steps.filter.outputs.build }}
|
||||
codegen: ${{ steps.filter.outputs.codegen }}
|
||||
macros: ${{ steps.filter.outputs.macros }}
|
||||
runtime: ${{ steps.filter.outputs.runtime }}
|
||||
wry: ${{ steps.filter.outputs.wry }}
|
||||
utils: ${{ steps.filter.outputs.utils }}
|
||||
bundler: ${{ steps.filter.outputs.bundler }}
|
||||
cli: ${{ steps.filter.outputs.cli }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: dorny/paths-filter@v2
|
||||
id: filter
|
||||
with:
|
||||
filters: |
|
||||
tauri:
|
||||
- 'core/tauri/**'
|
||||
build:
|
||||
- 'core/tauri-build/**'
|
||||
codegen:
|
||||
- 'core/tauri-codegen/**'
|
||||
macros:
|
||||
- 'core/tauri-macros/**'
|
||||
runtime:
|
||||
- 'core/tauri-runtime/**'
|
||||
wry:
|
||||
- 'core/tauri-runtime-wry/**'
|
||||
utils:
|
||||
- 'core/tauri-utils/**'
|
||||
bundler:
|
||||
- 'tooling/bundler/**'
|
||||
cli:
|
||||
- 'tooling/cli/**'
|
||||
|
||||
setup:
|
||||
runs-on: ubuntu-latest
|
||||
needs: changes
|
||||
if: |
|
||||
needs.changes.outputs.tauri == 'true' ||
|
||||
needs.changes.outputs.build == 'true' ||
|
||||
needs.changes.outputs.codegen == 'true' ||
|
||||
needs.changes.outputs.macros == 'true' ||
|
||||
needs.changes.outputs.runtime == 'true' ||
|
||||
needs.changes.outputs.wry == 'true' ||
|
||||
needs.changes.outputs.utils == 'true' ||
|
||||
needs.changes.outputs.bundler == 'true' ||
|
||||
needs.changes.outputs.cli == 'true'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
override: true
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: install
|
||||
args: cargo-udeps --locked --force
|
||||
|
||||
- name: Upload udeps
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: udeps
|
||||
path: '~/.cargo/bin/cargo-udeps'
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Create udeps matrix
|
||||
id: create-matrix
|
||||
env:
|
||||
TAURI: ${{ needs.changes.outputs.tauri == 'true' }}
|
||||
BUILD: ${{ needs.changes.outputs.build == 'true' }}
|
||||
CODEGEN: ${{ needs.changes.outputs.codegen == 'true' }}
|
||||
MACROS: ${{ needs.changes.outputs.macros == 'true' }}
|
||||
RUNTIME: ${{ needs.changes.outputs.runtime == 'true' }}
|
||||
WRY: ${{ needs.changes.outputs.wry == 'true' }}
|
||||
UTILS: ${{ needs.changes.outputs.utils == 'true' }}
|
||||
BUNDLER: ${{ needs.changes.outputs.bundler == 'true' }}
|
||||
CLI: ${{ needs.changes.outputs.cli == 'true' }}
|
||||
run: |
|
||||
crates=()
|
||||
if [ "${TAURI}" == "true" ]; then crates[${#crates[@]}]="\"./core/tauri\""; fi
|
||||
if [ "${BUILD}" == "true" ]; then crates[${#crates[@]}]="\"./core/tauri-build\""; fi
|
||||
if [ "${CODEGEN}" == "true" ]; then crates[${#crates[@]}]="\"./core/tauri-codegen\""; fi
|
||||
if [ "${MACROS}" == "true" ]; then crates[${#crates[@]}]="\"./core/tauri-macros\""; fi
|
||||
if [ "${RUNTIME}" == "true" ]; then crates[${#crates[@]}]="\"./core/tauri-runtime\""; fi
|
||||
if [ "${WRY}" == "true" ]; then crates[${#crates[@]}]="\"./core/tauri-runtime-wry\""; fi
|
||||
if [ "${UTILS}" == "true" ]; then crates[${#crates[@]}]="\"./core/tauri-utils\""; fi
|
||||
if [ "${BUNDLER}" == "true" ]; then crates[${#crates[@]}]="\"./tooling/bundler\""; fi
|
||||
if [ "${CLI}" == "true" ]; then crates[${#crates[@]}]="\"./tooling/cli\""; fi
|
||||
echo ::set-output name=matrix::[$crates]
|
||||
outputs:
|
||||
matrix: ${{ steps.create-matrix.outputs.matrix }}
|
||||
|
||||
udeps:
|
||||
runs-on: ubuntu-latest
|
||||
needs: setup
|
||||
strategy:
|
||||
matrix:
|
||||
clippy:
|
||||
- {
|
||||
path: './core/tauri/Cargo.toml',
|
||||
args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray,windows7-compat,http-multipart'
|
||||
}
|
||||
- { path: './core/tauri-build/Cargo.toml', args: '--all-features' }
|
||||
- { path: './core/tauri-codegen/Cargo.toml', args: '--all-features' }
|
||||
- { path: './core/tauri-macros/Cargo.toml', args: '--all-features' }
|
||||
- { path: './core/tauri-runtime/Cargo.toml', args: '--all-features' }
|
||||
- {
|
||||
path: './core/tauri-runtime-wry/Cargo.toml',
|
||||
args: '--features devtools,system-tray,macos-private-api,objc-exception'
|
||||
}
|
||||
- { path: './core/tauri-utils/Cargo.toml', args: '--all-features' }
|
||||
- { path: './tooling/bundler/Cargo.toml', args: '--all-features' }
|
||||
- { path: './tooling/cli/Cargo.toml', args: '--all-features' }
|
||||
path: ${{ fromJson(needs.setup.outputs.matrix) }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
@@ -120,10 +203,13 @@ jobs:
|
||||
ubuntu-latest-nightly-
|
||||
ubuntu-latest-
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
- name: Download udeps
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
command: install
|
||||
args: cargo-udeps --locked --force
|
||||
name: udeps
|
||||
path: '~/.cargo/bin'
|
||||
|
||||
- run: chmod +x $HOME/.cargo/bin/cargo-udeps
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
@@ -133,4 +219,4 @@ jobs:
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: udeps
|
||||
args: --manifest-path ${{ matrix.clippy.path }} --all-targets ${{ matrix.clippy.args }}
|
||||
args: --manifest-path ${{ matrix.path }}/Cargo.toml --all-targets --all-features
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env pwsh
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
18
.scripts/ci/pack-cli.sh
Executable file
18
.scripts/ci/pack-cli.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
set -euxo pipefail
|
||||
|
||||
for o in outputs/*; do
|
||||
pushd "$o"
|
||||
|
||||
chmod +x cargo-tauri*
|
||||
cp ../../tooling/cli/LICENSE* ../../tooling/cli/README.md .
|
||||
|
||||
target=$(basename "$o" | cut -d. -f1)
|
||||
if grep -qE '(apple|windows)' <<< "$target"; then
|
||||
zip "../${target}.zip" *
|
||||
else
|
||||
tar cv * | gzip -9 > "../${target}.tgz"
|
||||
fi
|
||||
|
||||
popd
|
||||
done
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
3
.scripts/docker/build.sh
Executable file
3
.scripts/docker/build.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
docker build -t aarch64-unknown-linux-gnu:latest --file .docker/cross/aarch64.Dockerfile .docker/cross
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env pwsh
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@ECHO OFF
|
||||
|
||||
REM Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
REM Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
REM SPDX-License-Identifier: Apache-2.0
|
||||
REM SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -59,4 +59,4 @@ IF EXIST %SourceFiles% DEL %SourceFiles%
|
||||
IF EXIST %Config% DEL %Config%
|
||||
IF EXIST %Source7ZFile% DEL %Source7ZFile%
|
||||
|
||||
ENDLOCAL
|
||||
ENDLOCAL
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# The Tauri Architecture
|
||||
https://tauri.studio
|
||||
https://tauri.app
|
||||
|
||||
https://github.com/tauri-apps/tauri
|
||||
|
||||
## Introduction
|
||||
@@ -39,7 +40,7 @@ This is common code that is reused in many places and offers useful utilities li
|
||||
|
||||
### Tauri Tooling
|
||||
#### [api](https://github.com/tauri-apps/tauri/tree/dev/tooling/api) [TS -> JS]
|
||||
A typescript library that creates `cjs` and `esm` Javascript endpoints for you to import into your Frontend framework so that the Webview can call and listen to backend activity. We also ship the pure typescript, because for some frameworks this is more optimal. It uses the message passing of webviews to their hosts.
|
||||
A TypeScript library that creates `cjs` and `esm` JavaScript endpoints for you to import into your Frontend framework so that the Webview can call and listen to backend activity. We also ship the pure TypeScript, because for some frameworks this is more optimal. It uses the message passing of webviews to their hosts.
|
||||
|
||||
#### [bundler](https://github.com/tauri-apps/tauri/tree/dev/tooling/bundler) [RUST / SHELL]
|
||||
The bundler is a library that builds a Tauri App for the platform triple it detects / is told. At the moment it currently supports macOS, Windows and Linux - but in the near future will support mobile platforms as well. May be used outside of Tauri projects.
|
||||
@@ -81,7 +82,7 @@ This plugin allows you to very quickly install tauri in a vue-cli project.
|
||||
## [tauri-vscode](https://github.com/tauri-apps/tauri-vscode)
|
||||
This project enhances the VS Code interface with several nice-to-have features.
|
||||
|
||||
# Tauri Plugins [documentation](https://tauri.studio/en/docs/guides/plugin)
|
||||
# Tauri Plugins [documentation](https://tauri.app/v1/guides/features/plugin/)
|
||||
|
||||
Generally speaking, plugins are authored by third parties (even though there may be official, supported plugins). A plugin generally does 3 things:
|
||||
1. It provides rust code to do "something".
|
||||
|
||||
@@ -8,7 +8,7 @@ members = [
|
||||
"core/tauri-utils",
|
||||
"core/tauri-build",
|
||||
"core/tauri-codegen",
|
||||
|
||||
|
||||
# integration tests
|
||||
"core/tests/restart",
|
||||
"core/tests/app-updater"
|
||||
@@ -24,7 +24,6 @@ exclude = [
|
||||
|
||||
# default to small, optimized workspace release binaries
|
||||
[profile.release]
|
||||
strip = true
|
||||
panic = "abort"
|
||||
codegen-units = 1
|
||||
lto = true
|
||||
|
||||
@@ -6,7 +6,7 @@ PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy
|
||||
PackageHomePage: https://tauri.app
|
||||
PackageLicenseDeclared: Apache-2.0
|
||||
PackageLicenseDeclared: MIT
|
||||
PackageCopyrightText: 2019-2021, The Tauri Programme in the Commons Conservancy
|
||||
PackageCopyrightText: 2019-2022, The Tauri Programme in the Commons Conservancy
|
||||
PackageSummary: <text>Tauri is a rust project that enables developers to make secure
|
||||
and small desktop applications using a web frontend.
|
||||
</text>
|
||||
@@ -17,4 +17,4 @@ Created: 2019-05-20T09:00:00Z
|
||||
PackageDownloadLocation: git://github.com/tauri-apps/tauri
|
||||
PackageDownloadLocation: git+https://github.com/tauri-apps/tauri.git
|
||||
PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git
|
||||
Creator: Person: Daniel Thompson-Yvetot
|
||||
Creator: Person: Daniel Thompson-Yvetot
|
||||
|
||||
12
README.md
12
README.md
@@ -1,15 +1,13 @@
|
||||
<img src=".github/splash.png" alt="Tauri" />
|
||||
|
||||
[](https://github.com/tauri-apps/tauri/tree/dev)
|
||||
[](https://github.com/tauri-apps/tauri/tree/dev)
|
||||
[](https://opencollective.com/tauri)
|
||||
[](https://github.com/tauri-apps/tauri/actions?query=workflow%3A%22test+library%22)
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Ftauri-apps%2Ftauri?ref=badge_shield)
|
||||
|
||||
[](https://discord.gg/SpmNs4S)
|
||||
[](https://dev.to/tauri)
|
||||
[](https://tauri.app)
|
||||
[](https://discord.gg/SpmNs4S)
|
||||
[](https://tauri.app)
|
||||
[](https://good-labs.github.io/greater-good-affirmation)
|
||||
[](https://opencollective.com/tauri)
|
||||
[](https://opencollective.com/tauri)
|
||||
|
||||
## Current Releases
|
||||
|
||||
@@ -51,7 +49,7 @@ To learn more about the details of how all of these pieces fit together, please
|
||||
|
||||
## Get Started
|
||||
|
||||
If you are interested in making a tauri app, please visit the [documentation website](https://tauri.studio). This README is directed towards those who are interested in contributing to the core library. But if you just want a quick overview about where `tauri` is at in its development, here's a quick burndown:
|
||||
If you are interested in making a tauri app, please visit the [documentation website](https://tauri.app). This README is directed towards those who are interested in contributing to the core library. But if you just want a quick overview about where `tauri` is at in its development, here's a quick burndown:
|
||||
|
||||
### Platforms
|
||||
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
# Changelog
|
||||
|
||||
## \[1.1.0]
|
||||
|
||||
- Rerun codegen if assets or icons change.
|
||||
- [ff8fd761](https://www.github.com/tauri-apps/tauri/commit/ff8fd7619ae894b70f149b192d8635d842827141) fix(tauri-build): rerun if assets or icons change ([#4910](https://www.github.com/tauri-apps/tauri/pull/4910)) on 2022-08-10
|
||||
- Create the `desktop` and `mobile` cfg aliases.
|
||||
- [c04d0340](https://www.github.com/tauri-apps/tauri/commit/c04d0340e2f163483f3556c7aabe35322ee71e6a) feat(core): prepare build for mobile targets ([#4830](https://www.github.com/tauri-apps/tauri/pull/4830)) on 2022-08-02
|
||||
- Added support to configuration files in TOML format (Tauri.toml file).
|
||||
- [ae83d008](https://www.github.com/tauri-apps/tauri/commit/ae83d008f9e1b89bfc8dddaca42aa5c1fbc36f6d) feat: add support to TOML config file `Tauri.toml`, closes [#4806](https://www.github.com/tauri-apps/tauri/pull/4806) ([#4813](https://www.github.com/tauri-apps/tauri/pull/4813)) on 2022-08-02
|
||||
- Enhance the dialog style on Windows via the manifest dependency `Microsoft.Windows.Common-Controls v6.0.0.0`.
|
||||
- [5c5c42ed](https://www.github.com/tauri-apps/tauri/commit/5c5c42edb64adf4250af6891d7d226fda7d4d783) feat(build): use modern dialog styles on Windows, closes [#4709](https://www.github.com/tauri-apps/tauri/pull/4709) ([#4840](https://www.github.com/tauri-apps/tauri/pull/4840)) on 2022-08-02
|
||||
- Fix root of codegen output when using the `CodegenContext` API.
|
||||
- [ed581950](https://www.github.com/tauri-apps/tauri/commit/ed581950ea6fd0afee47aa73fb63083d2483429f) fix(tauri-build): use `::tauri` as root for the CodegenContext ([#4894](https://www.github.com/tauri-apps/tauri/pull/4894)) on 2022-08-08
|
||||
- Return an error if a sidecar is configured with the same file name as the application.
|
||||
- [5cc1fd0f](https://www.github.com/tauri-apps/tauri/commit/5cc1fd0f7b01b257a461d4e867ddc8cd5072ff15) feat(tauri-build): validate sidecar name, closes [#4780](https://www.github.com/tauri-apps/tauri/pull/4780) closes [#4823](https://www.github.com/tauri-apps/tauri/pull/4823) ([#4814](https://www.github.com/tauri-apps/tauri/pull/4814)) on 2022-08-02
|
||||
- Only rewrite temporary icon files when the content change, avoid needless rebuilds.
|
||||
- [f957cbb5](https://www.github.com/tauri-apps/tauri/commit/f957cbb56ccbd8d1c047a978b4579946252a6fd2) fix(codegen): write output file when contents change ([#4889](https://www.github.com/tauri-apps/tauri/pull/4889)) on 2022-08-09
|
||||
|
||||
## \[1.0.4]
|
||||
|
||||
- Reduce the amount of allocations when converting cases.
|
||||
- [bc370e32](https://www.github.com/tauri-apps/tauri/commit/bc370e326810446e15b1f50fb962b980114ba16b) feat: reduce the amount of `heck`-related allocations ([#4634](https://www.github.com/tauri-apps/tauri/pull/4634)) on 2022-07-11
|
||||
|
||||
## \[1.0.3]
|
||||
|
||||
- Improve configuration deserialization error messages.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-build"
|
||||
version = "1.0.3"
|
||||
version = "1.1.0"
|
||||
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
||||
categories = [ "gui", "web-programming" ]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
@@ -9,7 +9,7 @@ repository = "https://github.com/tauri-apps/tauri/tree/dev/core/tauri-build"
|
||||
description = "build time code to pair with https://crates.io/crates/tauri"
|
||||
edition = "2021"
|
||||
rust-version = "1.57"
|
||||
exclude = [ ".license_template", "CHANGELOG.md", "/target" ]
|
||||
exclude = [ "CHANGELOG.md", "/target" ]
|
||||
readme = "README.md"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
@@ -19,8 +19,8 @@ rustdoc-args = [ "--cfg", "doc_cfg" ]
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
quote = { version = "1", optional = true }
|
||||
tauri-codegen = { version = "1.0.3", path = "../tauri-codegen", optional = true }
|
||||
tauri-utils = { version = "1.0.3", path = "../tauri-utils", features = [ "build", "resources" ] }
|
||||
tauri-codegen = { version = "1.1.0", path = "../tauri-codegen", optional = true }
|
||||
tauri-utils = { version = "1.1.0", path = "../tauri-utils", features = [ "build", "resources" ] }
|
||||
cargo_toml = "0.11"
|
||||
serde_json = "1"
|
||||
heck = "0.4"
|
||||
@@ -34,3 +34,4 @@ semver = "1"
|
||||
codegen = [ "tauri-codegen", "quote" ]
|
||||
isolation = [ "tauri-codegen/isolation", "tauri-utils/isolation" ]
|
||||
config-json5 = [ "tauri-utils/config-json5" ]
|
||||
config-toml = [ "tauri-utils/config-toml" ]
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
<img align="right" src="https://github.com/tauri-apps/tauri/raw/dev/app-icon.png" height="128" width="128">
|
||||
|
||||
[](https://github.com/tauri-apps/tauri)
|
||||
[](https://discord.gg/SpmNs4S)
|
||||
[](https://dev.to/tauri)
|
||||
|
||||

|
||||
[](https://tauri.app)
|
||||
|
||||
[](https://github.com/tauri-apps/tauri/tree/dev)
|
||||
[](https://opencollective.com/tauri)
|
||||
[](https://github.com/tauri-apps/tauri/actions?query=workflow%3A%22test+library%22)
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Ftauri-apps%2Ftauri?ref=badge_shield)
|
||||
[](https://discord.gg/SpmNs4S)
|
||||
[](https://tauri.app)
|
||||
[](https://good-labs.github.io/greater-good-affirmation)
|
||||
[](https://opencollective.com/tauri)
|
||||
[](https://opencollective.com/tauri)
|
||||
|
||||
| Component | Version |
|
||||
| ----------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -10,6 +10,7 @@ use std::{
|
||||
path::PathBuf,
|
||||
};
|
||||
use tauri_codegen::{context_codegen, ContextData};
|
||||
use tauri_utils::config::{AppUrl, WindowUrl};
|
||||
|
||||
// TODO docs
|
||||
/// A builder for generating a Tauri application context during compile time.
|
||||
@@ -52,13 +53,13 @@ impl CodegenContext {
|
||||
///
|
||||
/// **Note:** This path should be relative to the `OUT_DIR`.
|
||||
///
|
||||
/// Don't set this if you are using [`tauri::include_codegen_context!`] as that helper macro
|
||||
/// Don't set this if you are using [`tauri::tauri_build_context!`] as that helper macro
|
||||
/// expects the default value. This option can be useful if you are not using the helper and
|
||||
/// instead using [`std::include!`] on the generated code yourself.
|
||||
///
|
||||
/// Defaults to `tauri-build-context.rs`.
|
||||
///
|
||||
/// [`tauri::include_codegen_context!`]: https://docs.rs/tauri/0.12/tauri/macro.include_codegen_context.html
|
||||
/// [`tauri::tauri_build_context!`]: https://docs.rs/tauri/latest/tauri/macro.tauri_build_context.html
|
||||
#[must_use]
|
||||
pub fn out_file(mut self, filename: PathBuf) -> Self {
|
||||
self.out_file = filename;
|
||||
@@ -92,13 +93,53 @@ impl CodegenContext {
|
||||
/// Non-panicking [`Self::build`]
|
||||
pub fn try_build(self) -> Result<PathBuf> {
|
||||
let (config, config_parent) = tauri_codegen::get_config(&self.config_path)?;
|
||||
|
||||
// rerun if changed
|
||||
let app_url = if self.dev {
|
||||
&config.build.dev_path
|
||||
} else {
|
||||
&config.build.dist_dir
|
||||
};
|
||||
match app_url {
|
||||
AppUrl::Url(WindowUrl::App(p)) => {
|
||||
println!("cargo:rerun-if-changed={}", config_parent.join(p).display());
|
||||
}
|
||||
AppUrl::Files(files) => {
|
||||
for path in files {
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
config_parent.join(path).display()
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
for icon in &config.tauri.bundle.icon {
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
config_parent.join(icon).display()
|
||||
);
|
||||
}
|
||||
if let Some(tray_icon) = config.tauri.system_tray.as_ref().map(|t| &t.icon_path) {
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
config_parent.join(tray_icon).display()
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
config_parent.join("Info.plist").display()
|
||||
);
|
||||
|
||||
let code = context_codegen(ContextData {
|
||||
dev: self.dev,
|
||||
config,
|
||||
config_parent,
|
||||
// it's very hard to have a build script for unit tests, so assume this is always called from
|
||||
// outside the tauri crate, making the ::tauri root valid.
|
||||
root: quote::quote!(::tauri::Context),
|
||||
root: quote::quote!(::tauri),
|
||||
})?;
|
||||
|
||||
// get the full output file path
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#![cfg_attr(doc_cfg, feature(doc_cfg))]
|
||||
|
||||
pub use anyhow::Result;
|
||||
use heck::ToSnakeCase;
|
||||
use heck::AsShoutySnakeCase;
|
||||
|
||||
use tauri_utils::resources::{external_binaries, resource_relpath, ResourcePaths};
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -34,17 +35,29 @@ fn copy_file(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn copy_binaries<'a>(binaries: ResourcePaths<'a>, target_triple: &str, path: &Path) -> Result<()> {
|
||||
fn copy_binaries<'a>(
|
||||
binaries: ResourcePaths<'a>,
|
||||
target_triple: &str,
|
||||
path: &Path,
|
||||
package_name: Option<&String>,
|
||||
) -> Result<()> {
|
||||
for src in binaries {
|
||||
let src = src?;
|
||||
println!("cargo:rerun-if-changed={}", src.display());
|
||||
let dest = path.join(
|
||||
src
|
||||
.file_name()
|
||||
.expect("failed to extract external binary filename")
|
||||
.to_string_lossy()
|
||||
.replace(&format!("-{}", target_triple), ""),
|
||||
);
|
||||
let file_name = src
|
||||
.file_name()
|
||||
.expect("failed to extract external binary filename")
|
||||
.to_string_lossy()
|
||||
.replace(&format!("-{}", target_triple), "");
|
||||
|
||||
if package_name.map_or(false, |n| n == &file_name) {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Cannot define a sidecar with the same name as the Cargo package name `{}`. Please change the sidecar name in the filesystem and the Tauri configuration.",
|
||||
file_name
|
||||
));
|
||||
}
|
||||
|
||||
let dest = path.join(file_name);
|
||||
if dest.exists() {
|
||||
std::fs::remove_file(&dest).unwrap();
|
||||
}
|
||||
@@ -68,12 +81,9 @@ fn copy_resources(resources: ResourcePaths<'_>, path: &Path) -> Result<()> {
|
||||
fn has_feature(feature: &str) -> bool {
|
||||
// when a feature is enabled, Cargo sets the `CARGO_FEATURE_<name` env var to 1
|
||||
// https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts
|
||||
std::env::var(format!(
|
||||
"CARGO_FEATURE_{}",
|
||||
feature.to_snake_case().to_uppercase()
|
||||
))
|
||||
.map(|x| x == "1")
|
||||
.unwrap_or(false)
|
||||
std::env::var(format!("CARGO_FEATURE_{}", AsShoutySnakeCase(feature)))
|
||||
.map(|x| x == "1")
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
// creates a cfg alias if `has_feature` is true.
|
||||
@@ -96,7 +106,7 @@ pub struct WindowsAttributes {
|
||||
///
|
||||
/// For MSVC the Windows SDK has to be installed. It comes with the resource compiler rc.exe.
|
||||
/// This should be set to the root directory of the Windows SDK, e.g., "C:\Program Files (x86)\Windows Kits\10" or,
|
||||
/// if multiple 10 versions are installed, set it directly to the corret bin directory "C:\Program Files (x86)\Windows Kits\10\bin\10.0.14393.0\x64"
|
||||
/// if multiple 10 versions are installed, set it directly to the correct bin directory "C:\Program Files (x86)\Windows Kits\10\bin\10.0.14393.0\x64"
|
||||
///
|
||||
/// If it is left unset, it will look up a path in the registry, i.e. HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots
|
||||
sdk_dir: Option<PathBuf>,
|
||||
@@ -192,6 +202,13 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
println!("cargo:rerun-if-changed=tauri.conf.json");
|
||||
#[cfg(feature = "config-json5")]
|
||||
println!("cargo:rerun-if-changed=tauri.conf.json5");
|
||||
#[cfg(feature = "config-toml")]
|
||||
println!("cargo:rerun-if-changed=Tauri.toml");
|
||||
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||
let mobile = target_os == "ios" || target_os == "android";
|
||||
cfg_alias("desktop", !mobile);
|
||||
cfg_alias("mobile", mobile);
|
||||
|
||||
let mut config = serde_json::from_value(tauri_utils::config::parse::read_from(
|
||||
std::env::current_dir().unwrap(),
|
||||
@@ -272,6 +289,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
ResourcePaths::new(external_binaries(paths, &target_triple).as_slice(), true),
|
||||
&target_triple,
|
||||
target_dir,
|
||||
manifest.package.as_ref().map(|p| &p.name),
|
||||
)?;
|
||||
}
|
||||
|
||||
@@ -316,6 +334,26 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
|
||||
if window_icon_path.exists() {
|
||||
let mut res = WindowsResource::new();
|
||||
|
||||
res.set_manifest(
|
||||
r#"
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
||||
"#,
|
||||
);
|
||||
|
||||
if let Some(sdk_dir) = &attributes.windows_attributes.sdk_dir {
|
||||
if let Some(sdk_dir_str) = sdk_dir.to_str() {
|
||||
res.set_toolkit_path(sdk_dir_str);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::{env, fs, io::Write, path::Path};
|
||||
pub fn build() {
|
||||
override_msvcrt_lib();
|
||||
|
||||
// Disable conflicting libraries that aren't hard coded by Rust.
|
||||
// Disable conflicting libraries that aren't hard coded by Rust
|
||||
println!("cargo:rustc-link-arg=/NODEFAULTLIB:libvcruntimed.lib");
|
||||
println!("cargo:rustc-link-arg=/NODEFAULTLIB:vcruntime.lib");
|
||||
println!("cargo:rustc-link-arg=/NODEFAULTLIB:vcruntimed.lib");
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
# Changelog
|
||||
|
||||
## \[1.1.0]
|
||||
|
||||
- Use `TARGET` environment variable for code generation inside build scripts.
|
||||
- [6ba99689](https://www.github.com/tauri-apps/tauri/commit/6ba99689aa7ed0ffa9072a1c8ab5db12c9bf95af) feat(codegen): use TARGET environment variable if set ([#4921](https://www.github.com/tauri-apps/tauri/pull/4921)) on 2022-08-12
|
||||
- Added support to configuration files in TOML format (Tauri.toml file).
|
||||
- [ae83d008](https://www.github.com/tauri-apps/tauri/commit/ae83d008f9e1b89bfc8dddaca42aa5c1fbc36f6d) feat: add support to TOML config file `Tauri.toml`, closes [#4806](https://www.github.com/tauri-apps/tauri/pull/4806) ([#4813](https://www.github.com/tauri-apps/tauri/pull/4813)) on 2022-08-02
|
||||
- Improve tray icon read error message.
|
||||
- [52f0c8bb](https://www.github.com/tauri-apps/tauri/commit/52f0c8bb836c6d50b7ce2393161394f4ce78f5ae) feat(core): improve tray icon read error messages ([#4850](https://www.github.com/tauri-apps/tauri/pull/4850)) on 2022-08-03
|
||||
- Fix relative paths in `version` field of `tauri.config.json` not being correctly parsed by `generate_context!()`.
|
||||
- [accbc5e8](https://www.github.com/tauri-apps/tauri/commit/accbc5e8806a32efc555d019634fc2fa14d17f0a) fix(codegen): fix relative paths in `version` field of `tauri.config.json`, closes [#4723](https://www.github.com/tauri-apps/tauri/pull/4723) ([#4725](https://www.github.com/tauri-apps/tauri/pull/4725)) on 2022-07-24
|
||||
- Only rewrite temporary icon files when the content change, avoid needless rebuilds.
|
||||
- [f957cbb5](https://www.github.com/tauri-apps/tauri/commit/f957cbb56ccbd8d1c047a978b4579946252a6fd2) fix(codegen): write output file when contents change ([#4889](https://www.github.com/tauri-apps/tauri/pull/4889)) on 2022-08-09
|
||||
|
||||
## \[1.0.4]
|
||||
|
||||
- Validate `__TAURI_ISOLATION_HOOK__` being set by a file in the isolation application.
|
||||
- [3b4ed970](https://www.github.com/tauri-apps/tauri/commit/3b4ed970e663f5bffbfe0358610f9c3f157c513f) feat(codegen): validate `__TAURI_ISOLATION_HOOK__` is referenced ([#4631](https://www.github.com/tauri-apps/tauri/pull/4631)) on 2022-07-11
|
||||
|
||||
## \[1.0.3]
|
||||
|
||||
- The `TAURI_CONFIG` environment variable now represents the configuration to be merged instead of the entire JSON.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-codegen"
|
||||
version = "1.0.3"
|
||||
version = "1.1.0"
|
||||
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
||||
categories = [ "gui", "web-programming" ]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
@@ -9,7 +9,7 @@ repository = "https://github.com/tauri-apps/tauri/tree/dev/core/tauri-codegen"
|
||||
description = "code generation meant to be consumed inside of `tauri` through `tauri-build` or `tauri-macros`"
|
||||
edition = "2021"
|
||||
rust-version = "1.57"
|
||||
exclude = [ ".license_template", "CHANGELOG.md", "/target" ]
|
||||
exclude = [ "CHANGELOG.md", "/target" ]
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
@@ -19,7 +19,7 @@ proc-macro2 = "1"
|
||||
quote = "1"
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
serde_json = "1"
|
||||
tauri-utils = { version = "1.0.3", path = "../tauri-utils", features = [ "build" ] }
|
||||
tauri-utils = { version = "1.1.0", path = "../tauri-utils", features = [ "build" ] }
|
||||
thiserror = "1"
|
||||
walkdir = "2"
|
||||
brotli = { version = "3", optional = true, default-features = false, features = [ "std" ] }
|
||||
@@ -40,3 +40,4 @@ compression = [ "brotli", "tauri-utils/compression" ]
|
||||
isolation = [ "tauri-utils/isolation" ]
|
||||
shell-scope = [ "regex" ]
|
||||
config-json5 = [ "tauri-utils/config-json5" ]
|
||||
config-toml = [ "tauri-utils/config-toml" ]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -28,6 +28,7 @@ pub struct ContextData {
|
||||
|
||||
fn map_core_assets(
|
||||
options: &AssetOptions,
|
||||
target: Target,
|
||||
) -> impl Fn(&AssetKey, &Path, &mut Vec<u8>, &mut CspHashes) -> Result<(), EmbeddedAssetsError> {
|
||||
#[cfg(feature = "isolation")]
|
||||
let pattern = tauri_utils::html::PatternObject::from(&options.pattern);
|
||||
@@ -40,8 +41,9 @@ fn map_core_assets(
|
||||
|
||||
#[allow(clippy::collapsible_if)]
|
||||
if csp {
|
||||
#[cfg(target_os = "linux")]
|
||||
::tauri_utils::html::inject_csp_token(&mut document);
|
||||
if target == Target::Linux {
|
||||
::tauri_utils::html::inject_csp_token(&mut document);
|
||||
}
|
||||
|
||||
inject_nonce_token(&mut document, &dangerous_disable_asset_csp_modification);
|
||||
|
||||
@@ -106,6 +108,16 @@ fn map_isolation(
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||
enum Target {
|
||||
Linux,
|
||||
Windows,
|
||||
Darwin,
|
||||
Android,
|
||||
// iOS.
|
||||
Ios,
|
||||
}
|
||||
|
||||
/// Build a `tauri::Context` for including in application code.
|
||||
pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsError> {
|
||||
let ContextData {
|
||||
@@ -115,6 +127,34 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
root,
|
||||
} = data;
|
||||
|
||||
let target = if let Ok(target) = std::env::var("TARGET") {
|
||||
if target.contains("unknown-linux") {
|
||||
Target::Linux
|
||||
} else if target.contains("pc-windows") {
|
||||
Target::Windows
|
||||
} else if target.contains("apple-darwin") {
|
||||
Target::Darwin
|
||||
} else if target.contains("android") {
|
||||
Target::Android
|
||||
} else if target.contains("apple-ios") {
|
||||
Target::Ios
|
||||
} else {
|
||||
panic!("unknown codegen target {}", target);
|
||||
}
|
||||
} else if cfg!(target_os = "linux") {
|
||||
Target::Linux
|
||||
} else if cfg!(windows) {
|
||||
Target::Windows
|
||||
} else if cfg!(target_os = "macos") {
|
||||
Target::Darwin
|
||||
} else if cfg!(target_os = "android") {
|
||||
Target::Android
|
||||
} else if cfg!(target_os = "ios") {
|
||||
Target::Ios
|
||||
} else {
|
||||
panic!("unknown codegen target");
|
||||
};
|
||||
|
||||
let mut options = AssetOptions::new(config.tauri.pattern.clone())
|
||||
.freeze_prototype(config.tauri.security.freeze_prototype)
|
||||
.dangerous_disable_asset_csp_modification(
|
||||
@@ -162,7 +202,7 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
path
|
||||
)
|
||||
}
|
||||
EmbeddedAssets::new(assets_path, &options, map_core_assets(&options))?
|
||||
EmbeddedAssets::new(assets_path, &options, map_core_assets(&options, target))?
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
},
|
||||
@@ -172,7 +212,7 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
.map(|p| config_parent.join(p))
|
||||
.collect::<Vec<_>>(),
|
||||
&options,
|
||||
map_core_assets(&options),
|
||||
map_core_assets(&options, target),
|
||||
)?,
|
||||
_ => unimplemented!(),
|
||||
};
|
||||
@@ -189,18 +229,28 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
out_dir
|
||||
};
|
||||
|
||||
// handle default window icons for Windows targets
|
||||
#[cfg(windows)]
|
||||
let default_window_icon = {
|
||||
let icon_path = find_icon(
|
||||
&config,
|
||||
&config_parent,
|
||||
|i| i.ends_with(".ico"),
|
||||
"icons/icon.ico",
|
||||
);
|
||||
if icon_path.exists() {
|
||||
ico_icon(&root, &out_dir, icon_path)?
|
||||
} else {
|
||||
if target == Target::Windows {
|
||||
// handle default window icons for Windows targets
|
||||
let icon_path = find_icon(
|
||||
&config,
|
||||
&config_parent,
|
||||
|i| i.ends_with(".ico"),
|
||||
"icons/icon.ico",
|
||||
);
|
||||
if icon_path.exists() {
|
||||
ico_icon(&root, &out_dir, icon_path)?
|
||||
} else {
|
||||
let icon_path = find_icon(
|
||||
&config,
|
||||
&config_parent,
|
||||
|i| i.ends_with(".png"),
|
||||
"icons/icon.png",
|
||||
);
|
||||
png_icon(&root, &out_dir, icon_path)?
|
||||
}
|
||||
} else if target == Target::Linux {
|
||||
// handle default window icons for Linux targets
|
||||
let icon_path = find_icon(
|
||||
&config,
|
||||
&config_parent,
|
||||
@@ -208,23 +258,12 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
"icons/icon.png",
|
||||
);
|
||||
png_icon(&root, &out_dir, icon_path)?
|
||||
} else {
|
||||
quote!(None)
|
||||
}
|
||||
};
|
||||
#[cfg(target_os = "linux")]
|
||||
let default_window_icon = {
|
||||
let icon_path = find_icon(
|
||||
&config,
|
||||
&config_parent,
|
||||
|i| i.ends_with(".png"),
|
||||
"icons/icon.png",
|
||||
);
|
||||
png_icon(&root, &out_dir, icon_path)?
|
||||
};
|
||||
#[cfg(not(any(windows, target_os = "linux")))]
|
||||
let default_window_icon = quote!(None);
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
let app_icon = if dev {
|
||||
let app_icon = if target == Target::Darwin && dev {
|
||||
let mut icon_path = find_icon(
|
||||
&config,
|
||||
&config_parent,
|
||||
@@ -243,8 +282,6 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
} else {
|
||||
quote!(None)
|
||||
};
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let app_icon = quote!(None);
|
||||
|
||||
let package_name = if let Some(product_name) = &config.package.product_name {
|
||||
quote!(#product_name.to_string())
|
||||
@@ -283,42 +320,40 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
let info_plist = {
|
||||
if dev {
|
||||
let info_plist_path = config_parent.join("Info.plist");
|
||||
let mut info_plist = if info_plist_path.exists() {
|
||||
plist::Value::from_file(&info_plist_path)
|
||||
.unwrap_or_else(|e| panic!("failed to read plist {}: {}", info_plist_path.display(), e))
|
||||
} else {
|
||||
plist::Value::Dictionary(Default::default())
|
||||
};
|
||||
|
||||
if let Some(plist) = info_plist.as_dictionary_mut() {
|
||||
if let Some(product_name) = &config.package.product_name {
|
||||
plist.insert("CFBundleName".into(), product_name.clone().into());
|
||||
}
|
||||
if let Some(version) = &config.package.version {
|
||||
plist.insert("CFBundleShortVersionString".into(), version.clone().into());
|
||||
}
|
||||
let format =
|
||||
time::format_description::parse("[year][month][day].[hour][minute][second]").unwrap();
|
||||
if let Ok(build_number) = time::OffsetDateTime::now_utc().format(&format) {
|
||||
plist.insert("CFBundleVersion".into(), build_number.into());
|
||||
}
|
||||
}
|
||||
|
||||
let out_path = out_dir.join("Info.plist");
|
||||
info_plist
|
||||
.to_file_xml(&out_path)
|
||||
.expect("failed to write Info.plist");
|
||||
|
||||
let info_plist_path = out_path.display().to_string();
|
||||
quote!({
|
||||
tauri::embed_plist::embed_info_plist!(#info_plist_path);
|
||||
})
|
||||
let info_plist = if target == Target::Darwin && dev {
|
||||
let info_plist_path = config_parent.join("Info.plist");
|
||||
let mut info_plist = if info_plist_path.exists() {
|
||||
plist::Value::from_file(&info_plist_path)
|
||||
.unwrap_or_else(|e| panic!("failed to read plist {}: {}", info_plist_path.display(), e))
|
||||
} else {
|
||||
quote!(())
|
||||
plist::Value::Dictionary(Default::default())
|
||||
};
|
||||
|
||||
if let Some(plist) = info_plist.as_dictionary_mut() {
|
||||
if let Some(product_name) = &config.package.product_name {
|
||||
plist.insert("CFBundleName".into(), product_name.clone().into());
|
||||
}
|
||||
if let Some(version) = &config.package.version {
|
||||
plist.insert("CFBundleShortVersionString".into(), version.clone().into());
|
||||
}
|
||||
let format =
|
||||
time::format_description::parse("[year][month][day].[hour][minute][second]").unwrap();
|
||||
if let Ok(build_number) = time::OffsetDateTime::now_utc().format(&format) {
|
||||
plist.insert("CFBundleVersion".into(), build_number.into());
|
||||
}
|
||||
}
|
||||
|
||||
let out_path = out_dir.join("Info.plist");
|
||||
info_plist
|
||||
.to_file_xml(&out_path)
|
||||
.expect("failed to write Info.plist");
|
||||
|
||||
let info_plist_path = out_path.display().to_string();
|
||||
quote!({
|
||||
tauri::embed_plist::embed_info_plist!(#info_plist_path);
|
||||
})
|
||||
} else {
|
||||
quote!(())
|
||||
};
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let info_plist = quote!(());
|
||||
@@ -330,13 +365,28 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
let dir = config_parent.join(dir);
|
||||
if !dir.exists() {
|
||||
panic!(
|
||||
"The isolation dir configuration is set to `{:?}` but this path doesn't exist",
|
||||
"The isolation application path is set to `{:?}` but it does not exist",
|
||||
dir
|
||||
)
|
||||
}
|
||||
|
||||
let mut sets_isolation_hook = false;
|
||||
|
||||
let key = uuid::Uuid::new_v4().to_string();
|
||||
let assets = EmbeddedAssets::new(dir.clone(), &options, map_isolation(&options, dir))?;
|
||||
let map_isolation = map_isolation(&options, dir.clone());
|
||||
let assets = EmbeddedAssets::new(dir, &options, |key, path, input, csp_hashes| {
|
||||
// we check if `__TAURI_ISOLATION_HOOK__` exists in the isolation code
|
||||
// before modifying the files since we inject our own `__TAURI_ISOLATION_HOOK__` reference in HTML files
|
||||
if String::from_utf8_lossy(input).contains("__TAURI_ISOLATION_HOOK__") {
|
||||
sets_isolation_hook = true;
|
||||
}
|
||||
map_isolation(key, path, input, csp_hashes)
|
||||
})?;
|
||||
|
||||
if !sets_isolation_hook {
|
||||
panic!("The isolation application does not contain a file setting the `window.__TAURI_ISOLATION_HOOK__` value.");
|
||||
}
|
||||
|
||||
let schema = options.isolation_schema;
|
||||
|
||||
quote!(#root::Pattern::Isolation {
|
||||
@@ -400,66 +450,45 @@ fn ico_icon<P: AsRef<Path>>(
|
||||
out_dir: &Path,
|
||||
path: P,
|
||||
) -> Result<TokenStream, EmbeddedAssetsError> {
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
|
||||
let path = path.as_ref();
|
||||
let bytes = std::fs::read(&path)
|
||||
.unwrap_or_else(|_| panic!("failed to read icon {}", path.display()))
|
||||
.unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e))
|
||||
.to_vec();
|
||||
let icon_dir = ico::IconDir::read(std::io::Cursor::new(bytes))
|
||||
.unwrap_or_else(|_| panic!("failed to parse icon {}", path.display()));
|
||||
.unwrap_or_else(|e| panic!("failed to parse icon {}: {}", path.display(), e));
|
||||
let entry = &icon_dir.entries()[0];
|
||||
let rgba = entry
|
||||
.decode()
|
||||
.unwrap_or_else(|_| panic!("failed to decode icon {}", path.display()))
|
||||
.unwrap_or_else(|e| panic!("failed to decode icon {}: {}", path.display(), e))
|
||||
.rgba_data()
|
||||
.to_vec();
|
||||
let width = entry.width();
|
||||
let height = entry.height();
|
||||
|
||||
let out_path = out_dir.join(path.file_name().unwrap());
|
||||
let mut out_file = File::create(&out_path).map_err(|error| EmbeddedAssetsError::AssetWrite {
|
||||
path: out_path.clone(),
|
||||
write_if_changed(&out_path, &rgba).map_err(|error| EmbeddedAssetsError::AssetWrite {
|
||||
path: path.to_owned(),
|
||||
error,
|
||||
})?;
|
||||
|
||||
out_file
|
||||
.write_all(&rgba)
|
||||
.map_err(|error| EmbeddedAssetsError::AssetWrite {
|
||||
path: path.to_owned(),
|
||||
error,
|
||||
})?;
|
||||
|
||||
let out_path = out_path.display().to_string();
|
||||
|
||||
let icon = quote!(Some(#root::Icon::Rgba { rgba: include_bytes!(#out_path).to_vec(), width: #width, height: #height }));
|
||||
Ok(icon)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn raw_icon<P: AsRef<Path>>(out_dir: &Path, path: P) -> Result<TokenStream, EmbeddedAssetsError> {
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
|
||||
let path = path.as_ref();
|
||||
let bytes = std::fs::read(&path)
|
||||
.unwrap_or_else(|_| panic!("failed to read icon {}", path.display()))
|
||||
.unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e))
|
||||
.to_vec();
|
||||
|
||||
let out_path = out_dir.join(path.file_name().unwrap());
|
||||
let mut out_file = File::create(&out_path).map_err(|error| EmbeddedAssetsError::AssetWrite {
|
||||
path: out_path.clone(),
|
||||
write_if_changed(&out_path, &bytes).map_err(|error| EmbeddedAssetsError::AssetWrite {
|
||||
path: path.to_owned(),
|
||||
error,
|
||||
})?;
|
||||
|
||||
out_file
|
||||
.write_all(&bytes)
|
||||
.map_err(|error| EmbeddedAssetsError::AssetWrite {
|
||||
path: path.to_owned(),
|
||||
error,
|
||||
})?;
|
||||
|
||||
let out_path = out_path.display().to_string();
|
||||
|
||||
let icon = quote!(Some(include_bytes!(#out_path).to_vec()));
|
||||
@@ -471,17 +500,14 @@ fn png_icon<P: AsRef<Path>>(
|
||||
out_dir: &Path,
|
||||
path: P,
|
||||
) -> Result<TokenStream, EmbeddedAssetsError> {
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
|
||||
let path = path.as_ref();
|
||||
let bytes = std::fs::read(&path)
|
||||
.unwrap_or_else(|_| panic!("failed to read icon {}", path.display()))
|
||||
.unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e))
|
||||
.to_vec();
|
||||
let decoder = png::Decoder::new(std::io::Cursor::new(bytes));
|
||||
let mut reader = decoder
|
||||
.read_info()
|
||||
.unwrap_or_else(|_| panic!("failed to read icon {}", path.display()));
|
||||
.unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e));
|
||||
let mut buffer: Vec<u8> = Vec::new();
|
||||
while let Ok(Some(row)) = reader.next_row() {
|
||||
buffer.extend(row.data());
|
||||
@@ -490,24 +516,31 @@ fn png_icon<P: AsRef<Path>>(
|
||||
let height = reader.info().height;
|
||||
|
||||
let out_path = out_dir.join(path.file_name().unwrap());
|
||||
let mut out_file = File::create(&out_path).map_err(|error| EmbeddedAssetsError::AssetWrite {
|
||||
path: out_path.clone(),
|
||||
write_if_changed(&out_path, &buffer).map_err(|error| EmbeddedAssetsError::AssetWrite {
|
||||
path: path.to_owned(),
|
||||
error,
|
||||
})?;
|
||||
|
||||
out_file
|
||||
.write_all(&buffer)
|
||||
.map_err(|error| EmbeddedAssetsError::AssetWrite {
|
||||
path: path.to_owned(),
|
||||
error,
|
||||
})?;
|
||||
|
||||
let out_path = out_path.display().to_string();
|
||||
|
||||
let icon = quote!(Some(#root::Icon::Rgba { rgba: include_bytes!(#out_path).to_vec(), width: #width, height: #height }));
|
||||
Ok(icon)
|
||||
}
|
||||
|
||||
fn write_if_changed(out_path: &Path, data: &[u8]) -> std::io::Result<()> {
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
|
||||
if let Ok(curr) = std::fs::read(&out_path) {
|
||||
if curr == data {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
let mut out_file = File::create(&out_path)?;
|
||||
out_file.write_all(data)
|
||||
}
|
||||
|
||||
fn find_icon<F: Fn(&&String) -> bool>(
|
||||
config: &Config,
|
||||
config_parent: &Path,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -246,7 +246,12 @@ impl EmbeddedAssets {
|
||||
pub fn new(
|
||||
input: impl Into<EmbeddedAssetsInput>,
|
||||
options: &AssetOptions,
|
||||
map: impl Fn(&AssetKey, &Path, &mut Vec<u8>, &mut CspHashes) -> Result<(), EmbeddedAssetsError>,
|
||||
mut map: impl FnMut(
|
||||
&AssetKey,
|
||||
&Path,
|
||||
&mut Vec<u8>,
|
||||
&mut CspHashes,
|
||||
) -> Result<(), EmbeddedAssetsError>,
|
||||
) -> Result<Self, EmbeddedAssetsError> {
|
||||
// we need to pre-compute all files now, so that we can inject data from all files into a few
|
||||
let RawEmbeddedAssets { paths, csp_hashes } = RawEmbeddedAssets::new(input.into(), options)?;
|
||||
@@ -262,7 +267,8 @@ impl EmbeddedAssets {
|
||||
assets: HashMap::new(),
|
||||
},
|
||||
move |mut state, (prefix, entry)| {
|
||||
let (key, asset) = Self::compress_file(&prefix, entry.path(), &map, &mut state.csp_hashes)?;
|
||||
let (key, asset) =
|
||||
Self::compress_file(&prefix, entry.path(), &mut map, &mut state.csp_hashes)?;
|
||||
state.assets.insert(key, asset);
|
||||
Result::<_, EmbeddedAssetsError>::Ok(state)
|
||||
},
|
||||
@@ -292,7 +298,12 @@ impl EmbeddedAssets {
|
||||
fn compress_file(
|
||||
prefix: &Path,
|
||||
path: &Path,
|
||||
map: &impl Fn(&AssetKey, &Path, &mut Vec<u8>, &mut CspHashes) -> Result<(), EmbeddedAssetsError>,
|
||||
map: &mut impl FnMut(
|
||||
&AssetKey,
|
||||
&Path,
|
||||
&mut Vec<u8>,
|
||||
&mut CspHashes,
|
||||
) -> Result<(), EmbeddedAssetsError>,
|
||||
csp_hashes: &mut CspHashes,
|
||||
) -> Result<Asset, EmbeddedAssetsError> {
|
||||
let mut input = std::fs::read(path).map_err(|error| EmbeddedAssetsError::AssetRead {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -64,5 +64,14 @@ pub fn get_config(path: &Path) -> Result<(Config, PathBuf), CodegenConfigError>
|
||||
json_patch::merge(&mut config, &merge_config);
|
||||
}
|
||||
|
||||
Ok((serde_json::from_value(config)?, parent))
|
||||
let old_cwd = std::env::current_dir().map_err(CodegenConfigError::CurrentDir)?;
|
||||
// Set working directory to where `tauri.config.json` is, so that relative paths in it are parsed correctly.
|
||||
std::env::set_current_dir(parent.clone()).map_err(CodegenConfigError::CurrentDir)?;
|
||||
|
||||
let config = serde_json::from_value(config)?;
|
||||
|
||||
// Reset working directory.
|
||||
std::env::set_current_dir(old_cwd).map_err(CodegenConfigError::CurrentDir)?;
|
||||
|
||||
Ok((config, parent))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
2
core/tauri-codegen/src/vendor/mod.rs
vendored
2
core/tauri-codegen/src/vendor/mod.rs
vendored
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# Changelog
|
||||
|
||||
## \[1.1.0]
|
||||
|
||||
- Added support to configuration files in TOML format (Tauri.toml file).
|
||||
- [ae83d008](https://www.github.com/tauri-apps/tauri/commit/ae83d008f9e1b89bfc8dddaca42aa5c1fbc36f6d) feat: add support to TOML config file `Tauri.toml`, closes [#4806](https://www.github.com/tauri-apps/tauri/pull/4806) ([#4813](https://www.github.com/tauri-apps/tauri/pull/4813)) on 2022-08-02
|
||||
|
||||
## \[1.0.4]
|
||||
|
||||
- Adjust command imports to fix `items_after_statements` Clippy warning.
|
||||
- [d3e19e34](https://www.github.com/tauri-apps/tauri/commit/d3e19e3420a023cddc46173a2d1f1e6c5a390a1b) fix(macros): `items_after_statements` Clippy warning, closes [#4639](https://www.github.com/tauri-apps/tauri/pull/4639) on 2022-07-11
|
||||
- Remove raw identifier (`r#`) prefix from command arguments.
|
||||
- [ac72800f](https://www.github.com/tauri-apps/tauri/commit/ac72800fb630738e2502569935ecdc83e3e78055) fix(macros): strip `r#` from command arguments, closes [#4654](https://www.github.com/tauri-apps/tauri/pull/4654) ([#4657](https://www.github.com/tauri-apps/tauri/pull/4657)) on 2022-07-12
|
||||
|
||||
## \[1.0.3]
|
||||
|
||||
- Add `#[doc(hidden)]` attribute to the `#[command]` generated macro.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-macros"
|
||||
version = "1.0.3"
|
||||
version = "1.1.0"
|
||||
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
||||
categories = [ "gui", "os", "filesystem", "web-programming" ]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
@@ -9,7 +9,7 @@ repository = "https://github.com/tauri-apps/tauri"
|
||||
description = "Macros for the tauri crate."
|
||||
edition = "2021"
|
||||
rust-version = "1.57"
|
||||
exclude = [ ".license_template", "CHANGELOG.md", "/target" ]
|
||||
exclude = [ "CHANGELOG.md", "/target" ]
|
||||
readme = "README.md"
|
||||
|
||||
[lib]
|
||||
@@ -20,8 +20,8 @@ proc-macro2 = "1"
|
||||
quote = "1"
|
||||
syn = { version = "1", features = [ "full" ] }
|
||||
heck = "0.4"
|
||||
tauri-codegen = { version = "1.0.3", default-features = false, path = "../tauri-codegen" }
|
||||
tauri-utils = { version = "1.0.3", path = "../tauri-utils" }
|
||||
tauri-codegen = { version = "1.1.0", default-features = false, path = "../tauri-codegen" }
|
||||
tauri-utils = { version = "1.1.0", path = "../tauri-utils" }
|
||||
|
||||
[features]
|
||||
custom-protocol = [ ]
|
||||
@@ -29,3 +29,4 @@ compression = [ "tauri-codegen/compression" ]
|
||||
isolation = [ "tauri-codegen/isolation" ]
|
||||
shell-scope = [ "tauri-codegen/shell-scope" ]
|
||||
config-json5 = [ "tauri-codegen/config-json5", "tauri-utils/config-json5" ]
|
||||
config-toml = [ "tauri-codegen/config-toml", "tauri-utils/config-toml" ]
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
<img align="right" src="https://github.com/tauri-apps/tauri/raw/dev/app-icon.png" height="128" width="128">
|
||||
|
||||
[](https://github.com/tauri-apps/tauri)
|
||||
[](https://discord.gg/SpmNs4S)
|
||||
[](https://dev.to/tauri)
|
||||
|
||||

|
||||
[](https://tauri.app)
|
||||
|
||||
[](https://github.com/tauri-apps/tauri/tree/dev)
|
||||
[](https://opencollective.com/tauri)
|
||||
[](https://github.com/tauri-apps/tauri/actions?query=workflow%3A%22test+library%22)
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Ftauri-apps%2Ftauri?ref=badge_shield)
|
||||
[](https://discord.gg/SpmNs4S)
|
||||
[](https://tauri.app)
|
||||
[](https://good-labs.github.io/greater-good-affirmation)
|
||||
[](https://opencollective.com/tauri)
|
||||
[](https://opencollective.com/tauri)
|
||||
|
||||
| Component | Version |
|
||||
| ------------ | ------------------------------------------------------------------------------------------------------------ |
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -6,6 +6,7 @@ use proc_macro::TokenStream;
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::{format_ident, quote};
|
||||
use syn::{
|
||||
ext::IdentExt,
|
||||
parse::{Parse, ParseBuffer},
|
||||
parse_macro_input,
|
||||
spanned::Spanned,
|
||||
@@ -82,6 +83,8 @@ pub fn wrapper(attributes: TokenStream, item: TokenStream) -> TokenStream {
|
||||
macro_rules! #wrapper {
|
||||
// double braces because the item is expected to be a block expression
|
||||
($path:path, $invoke:ident) => {{
|
||||
#[allow(unused_imports)]
|
||||
use ::tauri::command::private::*;
|
||||
// prevent warnings when the body is a `compile_error!` or if the command has no arguments
|
||||
#[allow(unused_variables)]
|
||||
let ::tauri::Invoke { message: #message, resolver: #resolver } = $invoke;
|
||||
@@ -106,9 +109,6 @@ fn body_async(function: &ItemFn, invoke: &Invoke) -> syn::Result<TokenStream2> {
|
||||
let Invoke { message, resolver } = invoke;
|
||||
parse_args(function, message).map(|args| {
|
||||
quote! {
|
||||
#[allow(unused_imports)]
|
||||
use ::tauri::command::private::*;
|
||||
|
||||
#resolver.respond_async_serialized(async move {
|
||||
let result = $path(#(#args?),*);
|
||||
let kind = (&result).async_kind();
|
||||
@@ -134,9 +134,6 @@ fn body_blocking(function: &ItemFn, invoke: &Invoke) -> syn::Result<TokenStream2
|
||||
});
|
||||
|
||||
Ok(quote! {
|
||||
#[allow(unused_imports)]
|
||||
use ::tauri::command::private::*;
|
||||
|
||||
let result = $path(#(match #args #match_body),*);
|
||||
let kind = (&result).blocking_kind();
|
||||
kind.block(result, #resolver);
|
||||
@@ -168,7 +165,7 @@ fn parse_arg(command: &Ident, arg: &FnArg, message: &Ident) -> syn::Result<Token
|
||||
|
||||
// we only support patterns that allow us to extract some sort of keyed identifier
|
||||
let mut key = match &mut arg {
|
||||
Pat::Ident(arg) => arg.ident.to_string(),
|
||||
Pat::Ident(arg) => arg.ident.unraw().to_string(),
|
||||
Pat::Wild(_) => "".into(), // we always convert to camelCase, so "_" will end up empty anyways
|
||||
Pat::Struct(s) => super::path_to_command(&mut s.path).ident.to_string(),
|
||||
Pat::TupleStruct(s) => super::path_to_command(&mut s.path).ident.to_string(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -11,7 +11,7 @@ use syn::{
|
||||
LitStr, PathArguments, PathSegment, Token,
|
||||
};
|
||||
use tauri_codegen::{context_codegen, get_config, ContextData};
|
||||
use tauri_utils::config::parse::does_supported_extension_exist;
|
||||
use tauri_utils::config::parse::does_supported_file_name_exist;
|
||||
|
||||
pub(crate) struct ContextItems {
|
||||
config_file: PathBuf,
|
||||
@@ -36,7 +36,7 @@ impl Parse for ContextItems {
|
||||
VarError::NotUnicode(_) => "CARGO_MANIFEST_DIR env var contained invalid utf8".into(),
|
||||
})
|
||||
.and_then(|path| {
|
||||
if does_supported_extension_exist(&path) {
|
||||
if does_supported_file_name_exist(&path) {
|
||||
Ok(path)
|
||||
} else {
|
||||
Err(format!(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -88,7 +88,7 @@ pub fn derive_command_module(input: TokenStream) -> TokenStream {
|
||||
/// The `run` method takes a `tauri::endpoints::InvokeContext`
|
||||
/// and returns a `tauri::Result<tauri::endpoints::InvokeResponse>`.
|
||||
/// It matches on each enum variant and call a method with name equal to the variant name, lowercased and snake_cased,
|
||||
/// passing the the context and the variant's fields as arguments.
|
||||
/// passing the context and the variant's fields as arguments.
|
||||
/// That function must also return the same `Result<InvokeResponse>`.
|
||||
#[doc(hidden)]
|
||||
#[proc_macro_attribute]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# Changelog
|
||||
|
||||
## \[0.11.0]
|
||||
|
||||
- Ignore window events with unknown IDs.
|
||||
- [0668dd42](https://www.github.com/tauri-apps/tauri/commit/0668dd42204b163f11aaf31f45106c8551f15942) fix(tauri-runtime-wry): ignore events on unknown windows on 2022-08-29
|
||||
- Implement theme APIs for Linux.
|
||||
- [f21cbecd](https://www.github.com/tauri-apps/tauri/commit/f21cbecdeb3571ac4ad971b9a865ff62a131a176) feat(core): implement theme APIs for Linux ([#4808](https://www.github.com/tauri-apps/tauri/pull/4808)) on 2022-08-02
|
||||
- Changed `windows` map to be stored in a `RefCell` instead of a `Mutex`.
|
||||
- [64546cb9](https://www.github.com/tauri-apps/tauri/commit/64546cb9cca2fe56cf81cfc4aaf85c4e1d58877c) refactor: use RefCell instead of Mutex for windows map, closes [#4870](https://www.github.com/tauri-apps/tauri/pull/4870) ([#4909](https://www.github.com/tauri-apps/tauri/pull/4909)) on 2022-08-10
|
||||
- Added APIs to create a system tray at runtime.
|
||||
- [4d063ae9](https://www.github.com/tauri-apps/tauri/commit/4d063ae9ee9538cd6fa5e01b80070c6edf8eaeb9) feat(core): create system tray at runtime, closes [#2278](https://www.github.com/tauri-apps/tauri/pull/2278) ([#4862](https://www.github.com/tauri-apps/tauri/pull/4862)) on 2022-08-09
|
||||
- Update windows to 0.39.0 and webview2-com to 0.19.1.
|
||||
- [e6d9b670](https://www.github.com/tauri-apps/tauri/commit/e6d9b670b0b314ed667b0e164f2c8d27048e678f) refactor: remove unneeded focus code ([#5065](https://www.github.com/tauri-apps/tauri/pull/5065)) on 2022-09-03
|
||||
|
||||
## \[0.10.2]
|
||||
|
||||
- Disable drag-n-drop of tao based on `fileDropEnabled` value.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-runtime-wry"
|
||||
version = "0.10.2"
|
||||
version = "0.11.0"
|
||||
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
||||
categories = [ "gui", "web-programming" ]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
@@ -9,22 +9,22 @@ repository = "https://github.com/tauri-apps/tauri"
|
||||
description = "Wry bindings to the Tauri runtime"
|
||||
edition = "2021"
|
||||
rust-version = "1.57"
|
||||
exclude = [ ".license_template", "CHANGELOG.md", "/target" ]
|
||||
exclude = [ "CHANGELOG.md", "/target" ]
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
wry = { version = "0.19", default-features = false, features = [ "file-drop", "protocol" ] }
|
||||
tauri-runtime = { version = "0.10.2", path = "../tauri-runtime" }
|
||||
tauri-utils = { version = "1.0.3", path = "../tauri-utils" }
|
||||
wry = { version = "0.21", default-features = false, features = [ "file-drop", "protocol" ] }
|
||||
tauri-runtime = { version = "0.11.0", path = "../tauri-runtime" }
|
||||
tauri-utils = { version = "1.1.0", path = "../tauri-utils" }
|
||||
uuid = { version = "1", features = [ "v4" ] }
|
||||
rand = "0.8"
|
||||
raw-window-handle = "0.4.3"
|
||||
raw-window-handle = "0.5"
|
||||
|
||||
[target."cfg(windows)".dependencies]
|
||||
webview2-com = "0.16.0"
|
||||
webview2-com = "0.19.1"
|
||||
|
||||
[target."cfg(windows)".dependencies.windows]
|
||||
version = "0.37.0"
|
||||
version = "0.39.0"
|
||||
features = [ "Win32_Foundation" ]
|
||||
|
||||
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
|
||||
|
||||
18
core/tauri-runtime-wry/build.rs
Normal file
18
core/tauri-runtime-wry/build.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// creates a cfg alias if `has_feature` is true.
|
||||
// `alias` must be a snake case string.
|
||||
fn alias(alias: &str, has_feature: bool) {
|
||||
if has_feature {
|
||||
println!("cargo:rustc-cfg={}", alias);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||
let mobile = target_os == "ios" || target_os == "android";
|
||||
alias("desktop", !mobile);
|
||||
alias("mobile", mobile);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -16,10 +16,10 @@ use std::{
|
||||
use crate::{getter, Context, Message};
|
||||
|
||||
use tauri_runtime::{Error, GlobalShortcutManager, Result, UserEvent};
|
||||
pub use wry::application::global_shortcut::ShortcutManager as WryShortcutManager;
|
||||
use wry::application::{
|
||||
#[cfg(desktop)]
|
||||
pub use wry::application::{
|
||||
accelerator::{Accelerator, AcceleratorId},
|
||||
global_shortcut::GlobalShortcut,
|
||||
global_shortcut::{GlobalShortcut, ShortcutManager as WryShortcutManager},
|
||||
};
|
||||
|
||||
pub type GlobalShortcutListeners = Arc<Mutex<HashMap<AcceleratorId, Box<dyn Fn() + Send>>>>;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -9,6 +9,7 @@ pub use tauri_runtime::{
|
||||
},
|
||||
Icon, SystemTrayEvent,
|
||||
};
|
||||
use wry::application::event_loop::EventLoopWindowTarget;
|
||||
pub use wry::application::{
|
||||
event::TrayEvent,
|
||||
event_loop::EventLoopProxy,
|
||||
@@ -16,26 +17,62 @@ pub use wry::application::{
|
||||
ContextMenu as WryContextMenu, CustomMenuItem as WryCustomMenuItem, MenuItem as WryMenuItem,
|
||||
},
|
||||
system_tray::Icon as WryTrayIcon,
|
||||
TrayId as WryTrayId,
|
||||
};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub use wry::application::platform::macos::CustomMenuItemExtMacOS;
|
||||
pub use wry::application::platform::macos::{
|
||||
CustomMenuItemExtMacOS, SystemTrayBuilderExtMacOS, SystemTrayExtMacOS,
|
||||
};
|
||||
|
||||
use crate::{Error, Message, Result, TrayMessage};
|
||||
use wry::application::system_tray::{SystemTray as WrySystemTray, SystemTrayBuilder};
|
||||
|
||||
use tauri_runtime::{menu::MenuHash, UserEvent};
|
||||
use crate::{Error, Message, Result, TrayId, TrayMessage};
|
||||
|
||||
use uuid::Uuid;
|
||||
use tauri_runtime::{menu::MenuHash, SystemTray, UserEvent};
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
pub type GlobalSystemTrayEventHandler = Box<dyn Fn(TrayId, &SystemTrayEvent) + Send>;
|
||||
pub type GlobalSystemTrayEventListeners = Arc<Mutex<Vec<Arc<GlobalSystemTrayEventHandler>>>>;
|
||||
|
||||
pub type SystemTrayEventHandler = Box<dyn Fn(&SystemTrayEvent) + Send>;
|
||||
pub type SystemTrayEventListeners = Arc<Mutex<HashMap<Uuid, Arc<SystemTrayEventHandler>>>>;
|
||||
pub type SystemTrayEventListeners = Arc<Mutex<Vec<Arc<SystemTrayEventHandler>>>>;
|
||||
pub type SystemTrayItems = Arc<Mutex<HashMap<u16, WryCustomMenuItem>>>;
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct TrayContext {
|
||||
pub tray: Arc<Mutex<Option<WrySystemTray>>>,
|
||||
pub listeners: SystemTrayEventListeners,
|
||||
pub items: SystemTrayItems,
|
||||
}
|
||||
|
||||
impl fmt::Debug for TrayContext {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("TrayContext")
|
||||
.field("items", &self.items)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct SystemTrayManager {
|
||||
pub trays: Arc<Mutex<HashMap<TrayId, TrayContext>>>,
|
||||
pub global_listeners: GlobalSystemTrayEventListeners,
|
||||
}
|
||||
|
||||
impl fmt::Debug for SystemTrayManager {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("SystemTrayManager")
|
||||
.field("trays", &self.trays)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// Wrapper around a [`wry::application::system_tray::Icon`] that can be created from an [`WindowIcon`].
|
||||
pub struct TrayIcon(pub(crate) WryTrayIcon);
|
||||
|
||||
@@ -48,8 +85,39 @@ impl TryFrom<Icon> for TrayIcon {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_tray<T>(
|
||||
id: WryTrayId,
|
||||
system_tray: SystemTray,
|
||||
event_loop: &EventLoopWindowTarget<T>,
|
||||
) -> crate::Result<(WrySystemTray, HashMap<u16, WryCustomMenuItem>)> {
|
||||
let icon = TrayIcon::try_from(system_tray.icon.expect("tray icon not set"))?;
|
||||
|
||||
let mut items = HashMap::new();
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut builder = SystemTrayBuilder::new(
|
||||
icon.0,
|
||||
system_tray
|
||||
.menu
|
||||
.map(|menu| to_wry_context_menu(&mut items, menu)),
|
||||
)
|
||||
.with_id(id);
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
builder = builder.with_icon_as_template(system_tray.icon_as_template)
|
||||
}
|
||||
|
||||
let tray = builder
|
||||
.build(event_loop)
|
||||
.map_err(|e| Error::SystemTray(Box::new(e)))?;
|
||||
|
||||
Ok((tray, items))
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SystemTrayHandle<T: UserEvent> {
|
||||
pub(crate) id: TrayId,
|
||||
pub(crate) proxy: EventLoopProxy<super::Message<T>>,
|
||||
}
|
||||
|
||||
@@ -57,28 +125,39 @@ impl<T: UserEvent> TrayHandle for SystemTrayHandle<T> {
|
||||
fn set_icon(&self, icon: Icon) -> Result<()> {
|
||||
self
|
||||
.proxy
|
||||
.send_event(Message::Tray(TrayMessage::UpdateIcon(icon)))
|
||||
.send_event(Message::Tray(self.id, TrayMessage::UpdateIcon(icon)))
|
||||
.map_err(|_| Error::FailedToSendMessage)
|
||||
}
|
||||
|
||||
fn set_menu(&self, menu: SystemTrayMenu) -> Result<()> {
|
||||
self
|
||||
.proxy
|
||||
.send_event(Message::Tray(TrayMessage::UpdateMenu(menu)))
|
||||
.send_event(Message::Tray(self.id, TrayMessage::UpdateMenu(menu)))
|
||||
.map_err(|_| Error::FailedToSendMessage)
|
||||
}
|
||||
|
||||
fn update_item(&self, id: u16, update: MenuUpdate) -> Result<()> {
|
||||
self
|
||||
.proxy
|
||||
.send_event(Message::Tray(TrayMessage::UpdateItem(id, update)))
|
||||
.send_event(Message::Tray(self.id, TrayMessage::UpdateItem(id, update)))
|
||||
.map_err(|_| Error::FailedToSendMessage)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn set_icon_as_template(&self, is_template: bool) -> tauri_runtime::Result<()> {
|
||||
self
|
||||
.proxy
|
||||
.send_event(Message::Tray(TrayMessage::UpdateIconAsTemplate(
|
||||
is_template,
|
||||
)))
|
||||
.send_event(Message::Tray(
|
||||
self.id,
|
||||
TrayMessage::UpdateIconAsTemplate(is_template),
|
||||
))
|
||||
.map_err(|_| Error::FailedToSendMessage)
|
||||
}
|
||||
|
||||
fn destroy(&self) -> Result<()> {
|
||||
self
|
||||
.proxy
|
||||
.send_event(Message::Tray(self.id, TrayMessage::Destroy))
|
||||
.map_err(|_| Error::FailedToSendMessage)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## \[0.11.0]
|
||||
|
||||
- Added APIs to create a system tray at runtime.
|
||||
- [4d063ae9](https://www.github.com/tauri-apps/tauri/commit/4d063ae9ee9538cd6fa5e01b80070c6edf8eaeb9) feat(core): create system tray at runtime, closes [#2278](https://www.github.com/tauri-apps/tauri/pull/2278) ([#4862](https://www.github.com/tauri-apps/tauri/pull/4862)) on 2022-08-09
|
||||
- Update windows to 0.39.0 and webview2-com to 0.19.1.
|
||||
- [e6d9b670](https://www.github.com/tauri-apps/tauri/commit/e6d9b670b0b314ed667b0e164f2c8d27048e678f) refactor: remove unneeded focus code ([#5065](https://www.github.com/tauri-apps/tauri/pull/5065)) on 2022-09-03
|
||||
|
||||
## \[0.10.2]
|
||||
|
||||
- Added option to disable tray menu on left click on macOS.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-runtime"
|
||||
version = "0.10.2"
|
||||
version = "0.11.0"
|
||||
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
||||
categories = [ "gui", "web-programming" ]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
@@ -9,7 +9,7 @@ repository = "https://github.com/tauri-apps/tauri"
|
||||
description = "Runtime for Tauri applications"
|
||||
edition = "2021"
|
||||
rust-version = "1.57"
|
||||
exclude = [ ".license_template", "CHANGELOG.md", "/target" ]
|
||||
exclude = [ "CHANGELOG.md", "/target" ]
|
||||
readme = "README.md"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
@@ -26,18 +26,19 @@ targets = [
|
||||
serde = { version = "1.0", features = [ "derive" ] }
|
||||
serde_json = "1.0"
|
||||
thiserror = "1.0"
|
||||
tauri-utils = { version = "1.0.3", path = "../tauri-utils" }
|
||||
tauri-utils = { version = "1.1.0", path = "../tauri-utils" }
|
||||
uuid = { version = "1", features = [ "v4" ] }
|
||||
http = "0.2.4"
|
||||
http-range = "0.1.4"
|
||||
infer = "0.7"
|
||||
raw-window-handle = "0.4.3"
|
||||
raw-window-handle = "0.5"
|
||||
rand = "0.8"
|
||||
|
||||
[target."cfg(windows)".dependencies]
|
||||
webview2-com = "0.16.0"
|
||||
webview2-com = "0.19.1"
|
||||
|
||||
[target."cfg(windows)".dependencies.windows]
|
||||
version = "0.37.0"
|
||||
version = "0.39.0"
|
||||
features = [ "Win32_Foundation" ]
|
||||
|
||||
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
|
||||
|
||||
18
core/tauri-runtime/build.rs
Normal file
18
core/tauri-runtime/build.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// creates a cfg alias if `has_feature` is true.
|
||||
// `alias` must be a snake case string.
|
||||
fn alias(alias: &str, has_feature: bool) {
|
||||
if has_feature {
|
||||
println!("cargo:rustc-cfg={}", alias);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||
let mobile = target_os == "ios" || target_os == "android";
|
||||
alias("desktop", !mobile);
|
||||
alias("mobile", mobile);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#![cfg_attr(doc_cfg, feature(doc_cfg))]
|
||||
|
||||
use raw_window_handle::RawDisplayHandle;
|
||||
use serde::Deserialize;
|
||||
use std::{fmt::Debug, sync::mpsc::Sender};
|
||||
use tauri_utils::Theme;
|
||||
@@ -33,19 +34,74 @@ use crate::http::{
|
||||
InvalidUri,
|
||||
};
|
||||
|
||||
#[cfg(feature = "system-tray")]
|
||||
#[cfg(all(desktop, feature = "system-tray"))]
|
||||
use std::fmt;
|
||||
|
||||
pub type TrayId = u16;
|
||||
pub type TrayEventHandler = dyn Fn(&SystemTrayEvent) + Send + 'static;
|
||||
|
||||
#[cfg(all(desktop, feature = "system-tray"))]
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct SystemTray {
|
||||
pub id: TrayId,
|
||||
pub icon: Option<Icon>,
|
||||
pub menu: Option<menu::SystemTrayMenu>,
|
||||
#[cfg(target_os = "macos")]
|
||||
pub icon_as_template: bool,
|
||||
#[cfg(target_os = "macos")]
|
||||
pub menu_on_left_click: bool,
|
||||
pub on_event: Option<Box<TrayEventHandler>>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "system-tray")]
|
||||
#[cfg(all(desktop, feature = "system-tray"))]
|
||||
impl fmt::Debug for SystemTray {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let mut d = f.debug_struct("SystemTray");
|
||||
d.field("id", &self.id)
|
||||
.field("icon", &self.icon)
|
||||
.field("menu", &self.menu);
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
d.field("icon_as_template", &self.icon_as_template)
|
||||
.field("menu_on_left_click", &self.menu_on_left_click);
|
||||
}
|
||||
d.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(desktop, feature = "system-tray"))]
|
||||
impl Clone for SystemTray {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
id: self.id,
|
||||
icon: self.icon.clone(),
|
||||
menu: self.menu.clone(),
|
||||
on_event: None,
|
||||
#[cfg(target_os = "macos")]
|
||||
icon_as_template: self.icon_as_template,
|
||||
#[cfg(target_os = "macos")]
|
||||
menu_on_left_click: self.menu_on_left_click,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(desktop, feature = "system-tray"))]
|
||||
impl Default for SystemTray {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
id: rand::random(),
|
||||
icon: None,
|
||||
menu: None,
|
||||
#[cfg(target_os = "macos")]
|
||||
icon_as_template: false,
|
||||
#[cfg(target_os = "macos")]
|
||||
menu_on_left_click: false,
|
||||
on_event: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(desktop, feature = "system-tray"))]
|
||||
impl SystemTray {
|
||||
/// Creates a new system tray that only renders an icon.
|
||||
pub fn new() -> Self {
|
||||
@@ -56,6 +112,13 @@ impl SystemTray {
|
||||
self.menu.as_ref()
|
||||
}
|
||||
|
||||
/// Sets the tray id.
|
||||
#[must_use]
|
||||
pub fn with_id(mut self, id: TrayId) -> Self {
|
||||
self.id = id;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the tray icon.
|
||||
#[must_use]
|
||||
pub fn with_icon(mut self, icon: Icon) -> Self {
|
||||
@@ -85,6 +148,12 @@ impl SystemTray {
|
||||
self.menu.replace(menu);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn on_event<F: Fn(&SystemTrayEvent) + Send + 'static>(mut self, f: F) -> Self {
|
||||
self.on_event.replace(Box::new(f));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Type of user attention requested on a window.
|
||||
@@ -123,7 +192,7 @@ pub enum Error {
|
||||
#[error("JSON error: {0}")]
|
||||
Json(#[from] serde_json::Error),
|
||||
/// Encountered an error creating the app system tray.
|
||||
#[cfg(feature = "system-tray")]
|
||||
#[cfg(all(desktop, feature = "system-tray"))]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "system-tray")))]
|
||||
#[error("error encountered during tray setup: {0}")]
|
||||
SystemTray(Box<dyn std::error::Error + Send + Sync>),
|
||||
@@ -134,7 +203,7 @@ pub enum Error {
|
||||
#[error("failed to get monitor")]
|
||||
FailedToGetMonitor,
|
||||
/// Global shortcut error.
|
||||
#[cfg(feature = "global-shortcut")]
|
||||
#[cfg(all(desktop, feature = "global-shortcut"))]
|
||||
#[error(transparent)]
|
||||
GlobalShortcut(Box<dyn std::error::Error + Send + Sync>),
|
||||
#[error("Invalid header name: {0}")]
|
||||
@@ -260,13 +329,19 @@ pub trait RuntimeHandle<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'st
|
||||
/// Run a task on the main thread.
|
||||
fn run_on_main_thread<F: FnOnce() + Send + 'static>(&self, f: F) -> Result<()>;
|
||||
|
||||
#[cfg(all(windows, feature = "system-tray"))]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(all(windows, feature = "system-tray"))))]
|
||||
fn remove_system_tray(&self) -> Result<()>;
|
||||
/// Adds an icon to the system tray with the specified menu items.
|
||||
#[cfg(all(desktop, feature = "system-tray"))]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(all(desktop, feature = "system-tray"))))]
|
||||
fn system_tray(
|
||||
&self,
|
||||
system_tray: SystemTray,
|
||||
) -> Result<<Self::Runtime as Runtime<T>>::TrayHandler>;
|
||||
|
||||
fn raw_display_handle(&self) -> RawDisplayHandle;
|
||||
}
|
||||
|
||||
/// A global shortcut manager.
|
||||
#[cfg(feature = "global-shortcut")]
|
||||
#[cfg(all(desktop, feature = "global-shortcut"))]
|
||||
pub trait GlobalShortcutManager: Debug + Clone + Send + Sync {
|
||||
/// Whether the application has registered the given `accelerator`.
|
||||
fn is_registered(&self, accelerator: &str) -> Result<bool>;
|
||||
@@ -301,13 +376,13 @@ pub trait Runtime<T: UserEvent>: Debug + Sized + 'static {
|
||||
/// The runtime handle type.
|
||||
type Handle: RuntimeHandle<T, Runtime = Self>;
|
||||
/// The global shortcut manager type.
|
||||
#[cfg(feature = "global-shortcut")]
|
||||
#[cfg(all(desktop, feature = "global-shortcut"))]
|
||||
type GlobalShortcutManager: GlobalShortcutManager;
|
||||
/// The clipboard manager type.
|
||||
#[cfg(feature = "clipboard")]
|
||||
type ClipboardManager: ClipboardManager;
|
||||
/// The tray handler type.
|
||||
#[cfg(feature = "system-tray")]
|
||||
#[cfg(all(desktop, feature = "system-tray"))]
|
||||
type TrayHandler: menu::TrayHandle;
|
||||
/// The proxy type.
|
||||
type EventLoopProxy: EventLoopProxy<T>;
|
||||
@@ -327,7 +402,7 @@ pub trait Runtime<T: UserEvent>: Debug + Sized + 'static {
|
||||
fn handle(&self) -> Self::Handle;
|
||||
|
||||
/// Gets the global shortcut manager.
|
||||
#[cfg(feature = "global-shortcut")]
|
||||
#[cfg(all(desktop, feature = "global-shortcut"))]
|
||||
fn global_shortcut_manager(&self) -> Self::GlobalShortcutManager;
|
||||
|
||||
/// Gets the clipboard manager.
|
||||
@@ -338,14 +413,14 @@ pub trait Runtime<T: UserEvent>: Debug + Sized + 'static {
|
||||
fn create_window(&self, pending: PendingWindow<T, Self>) -> Result<DetachedWindow<T, Self>>;
|
||||
|
||||
/// Adds the icon to the system tray with the specified menu items.
|
||||
#[cfg(feature = "system-tray")]
|
||||
#[cfg(all(desktop, feature = "system-tray"))]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "system-tray")))]
|
||||
fn system_tray(&self, system_tray: SystemTray) -> Result<Self::TrayHandler>;
|
||||
|
||||
/// Registers a system tray event handler.
|
||||
#[cfg(feature = "system-tray")]
|
||||
#[cfg(all(desktop, feature = "system-tray"))]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "system-tray")))]
|
||||
fn on_system_tray_event<F: Fn(&SystemTrayEvent) + Send + 'static>(&mut self, f: F) -> Uuid;
|
||||
fn on_system_tray_event<F: Fn(TrayId, &SystemTrayEvent) + Send + 'static>(&mut self, f: F);
|
||||
|
||||
/// Sets the activation policy for the application. It is set to `NSApplicationActivationPolicyRegular` by default.
|
||||
#[cfg(target_os = "macos")]
|
||||
@@ -353,6 +428,7 @@ pub trait Runtime<T: UserEvent>: Debug + Sized + 'static {
|
||||
fn set_activation_policy(&mut self, activation_policy: ActivationPolicy);
|
||||
|
||||
/// Runs the one step of the webview runtime event loop and returns control flow to the caller.
|
||||
#[cfg(desktop)]
|
||||
fn run_iteration<F: Fn(RunEvent<T>) + 'static>(&mut self, callback: F) -> RunIteration;
|
||||
|
||||
/// Run the webview runtime.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -152,6 +152,7 @@ pub trait TrayHandle: fmt::Debug + Clone + Send + Sync {
|
||||
fn update_item(&self, id: u16, update: MenuUpdate) -> crate::Result<()>;
|
||||
#[cfg(target_os = "macos")]
|
||||
fn set_icon_as_template(&self, is_template: bool) -> crate::Result<()>;
|
||||
fn destroy(&self) -> crate::Result<()>;
|
||||
}
|
||||
|
||||
/// A window menu.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -134,7 +134,7 @@ pub trait WindowBuilder: WindowBuilderBase {
|
||||
#[must_use]
|
||||
fn visible(self, visible: bool) -> Self;
|
||||
|
||||
/// Whether the the window should be transparent. If this is true, writing colors
|
||||
/// Whether the window should be transparent. If this is true, writing colors
|
||||
/// with alpha values different than `1.0` will produce a transparent window.
|
||||
#[cfg(any(not(target_os = "macos"), feature = "macos-private-api"))]
|
||||
#[cfg_attr(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -62,8 +62,6 @@ pub enum WindowEvent {
|
||||
/// The system window theme has changed.
|
||||
///
|
||||
/// Applications might wish to react to this to change the theme of the content of the window when the system changes the window theme.
|
||||
///
|
||||
/// At the moment this is only supported on Windows.
|
||||
ThemeChanged(Theme),
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# Changelog
|
||||
|
||||
## \[1.1.0]
|
||||
|
||||
- Allow adding `build > beforeBundleCommand` in tauri.conf.json to run a shell command before the bundling phase.
|
||||
- [57ab9847](https://www.github.com/tauri-apps/tauri/commit/57ab9847eb2d8c9a5da584b873b7c072e9ee26bf) feat(cli): add `beforeBundleCommand`, closes [#4879](https://www.github.com/tauri-apps/tauri/pull/4879) ([#4893](https://www.github.com/tauri-apps/tauri/pull/4893)) on 2022-08-09
|
||||
- Change `before_dev_command` and `before_build_command` config value to allow configuring the current working directory.
|
||||
- [d6f7d3cf](https://www.github.com/tauri-apps/tauri/commit/d6f7d3cfe8a7ec8d68c8341016c4e0a3103da587) Add cwd option to `before` commands, add wait option to dev [#4740](https://www.github.com/tauri-apps/tauri/pull/4740) [#3551](https://www.github.com/tauri-apps/tauri/pull/3551) ([#4834](https://www.github.com/tauri-apps/tauri/pull/4834)) on 2022-08-02
|
||||
- Allow configuring the `before_dev_command` to force the CLI to wait for the command to finish before proceeding.
|
||||
- [d6f7d3cf](https://www.github.com/tauri-apps/tauri/commit/d6f7d3cfe8a7ec8d68c8341016c4e0a3103da587) Add cwd option to `before` commands, add wait option to dev [#4740](https://www.github.com/tauri-apps/tauri/pull/4740) [#3551](https://www.github.com/tauri-apps/tauri/pull/3551) ([#4834](https://www.github.com/tauri-apps/tauri/pull/4834)) on 2022-08-02
|
||||
- Added support to configuration files in TOML format (Tauri.toml file).
|
||||
- [ae83d008](https://www.github.com/tauri-apps/tauri/commit/ae83d008f9e1b89bfc8dddaca42aa5c1fbc36f6d) feat: add support to TOML config file `Tauri.toml`, closes [#4806](https://www.github.com/tauri-apps/tauri/pull/4806) ([#4813](https://www.github.com/tauri-apps/tauri/pull/4813)) on 2022-08-02
|
||||
- Refactored the `config::parse` module.
|
||||
- [ae83d008](https://www.github.com/tauri-apps/tauri/commit/ae83d008f9e1b89bfc8dddaca42aa5c1fbc36f6d) feat: add support to TOML config file `Tauri.toml`, closes [#4806](https://www.github.com/tauri-apps/tauri/pull/4806) ([#4813](https://www.github.com/tauri-apps/tauri/pull/4813)) on 2022-08-02
|
||||
- Update windows to 0.39.0 and webview2-com to 0.19.1.
|
||||
- [e6d9b670](https://www.github.com/tauri-apps/tauri/commit/e6d9b670b0b314ed667b0e164f2c8d27048e678f) refactor: remove unneeded focus code ([#5065](https://www.github.com/tauri-apps/tauri/pull/5065)) on 2022-09-03
|
||||
|
||||
## \[1.0.3]
|
||||
|
||||
- Added `menu_on_left_click: bool` to the `SystemTrayConfig`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-utils"
|
||||
version = "1.0.3"
|
||||
version = "1.1.0"
|
||||
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
homepage = "https://tauri.app"
|
||||
@@ -8,7 +8,7 @@ repository = "https://github.com/tauri-apps/tauri"
|
||||
description = "Utilities for Tauri"
|
||||
edition = "2021"
|
||||
rust-version = "1.57"
|
||||
exclude = [ ".license_template", "CHANGELOG.md", "/target" ]
|
||||
exclude = [ "CHANGELOG.md", "/target" ]
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
@@ -29,6 +29,7 @@ getrandom = { version = "0.2", optional = true, features = [ "std" ] }
|
||||
serialize-to-javascript = { version = "=0.1.1", optional = true }
|
||||
ctor = "0.1"
|
||||
json5 = { version = "0.4", optional = true }
|
||||
toml = { version = "0.5", optional = true }
|
||||
json-patch = "0.2"
|
||||
glob = { version = "0.3.0", optional = true }
|
||||
walkdir = { version = "2", optional = true }
|
||||
@@ -39,9 +40,8 @@ semver = "1"
|
||||
heck = "0.4"
|
||||
|
||||
[target."cfg(windows)".dependencies.windows]
|
||||
version = "0.37.0"
|
||||
version = "0.39.0"
|
||||
features = [
|
||||
"alloc",
|
||||
"implement",
|
||||
"Win32_Foundation",
|
||||
"Win32_System_Com",
|
||||
@@ -56,4 +56,5 @@ schema = [ "schemars" ]
|
||||
isolation = [ "aes-gcm", "getrandom", "serialize-to-javascript" ]
|
||||
process-relaunch-dangerous-allow-symlink-macos = [ ]
|
||||
config-json5 = [ "json5" ]
|
||||
config-toml = [ "toml" ]
|
||||
resources = [ "glob", "walkdir" ]
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
<img align="right" src="https://github.com/tauri-apps/tauri/raw/dev/app-icon.png" height="128" width="128">
|
||||
|
||||
[](https://github.com/tauri-apps/tauri)
|
||||
[](https://discord.gg/SpmNs4S)
|
||||
[](https://dev.to/tauri)
|
||||
|
||||

|
||||
[](https://tauri.app)
|
||||
|
||||
[](https://github.com/tauri-apps/tauri/tree/dev)
|
||||
[](https://opencollective.com/tauri)
|
||||
[](https://github.com/tauri-apps/tauri/actions?query=workflow%3A%22test+library%22)
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Ftauri-apps%2Ftauri?ref=badge_shield)
|
||||
[](https://discord.gg/SpmNs4S)
|
||||
[](https://tauri.app)
|
||||
[](https://good-labs.github.io/greater-good-affirmation)
|
||||
[](https://opencollective.com/tauri)
|
||||
[](https://opencollective.com/tauri)
|
||||
|
||||
| Component | Version |
|
||||
| ----------- | ---------------------------------------------------------------------------------------------------- |
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -247,7 +247,7 @@ impl BundleTarget {
|
||||
pub struct AppImageConfig {
|
||||
/// Include additional gstreamer dependencies needed for audio and video playback.
|
||||
/// This increases the bundle size by ~15-35MB depending on your build system.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "bundle-media-framework")]
|
||||
pub bundle_media_framework: bool,
|
||||
}
|
||||
|
||||
@@ -293,17 +293,21 @@ pub struct MacConfig {
|
||||
/// An empty string is considered an invalid value so the default value is used.
|
||||
#[serde(
|
||||
deserialize_with = "de_minimum_system_version",
|
||||
default = "minimum_system_version"
|
||||
default = "minimum_system_version",
|
||||
alias = "minimum-system-version"
|
||||
)]
|
||||
pub minimum_system_version: Option<String>,
|
||||
/// Allows your application to communicate with the outside world.
|
||||
/// It should be a lowercase, without port and protocol domain name.
|
||||
#[serde(alias = "exception-domain")]
|
||||
pub exception_domain: Option<String>,
|
||||
/// The path to the license file to add to the DMG bundle.
|
||||
pub license: Option<String>,
|
||||
/// Identity to use for code signing.
|
||||
#[serde(alias = "signing-identity")]
|
||||
pub signing_identity: Option<String>,
|
||||
/// Provider short name for notarization.
|
||||
#[serde(alias = "provider-short-name")]
|
||||
pub provider_short_name: Option<String>,
|
||||
/// Path to the entitlements file.
|
||||
pub entitlements: Option<String>,
|
||||
@@ -333,6 +337,7 @@ fn minimum_system_version() -> Option<String> {
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct WixLanguageConfig {
|
||||
/// The path to a locale (`.wxl`) file. See <https://wixtoolset.org/documentation/manual/v3/howtos/ui_and_localization/build_a_localized_version.html>.
|
||||
#[serde(alias = "locale-path")]
|
||||
pub locale_path: Option<String>,
|
||||
}
|
||||
|
||||
@@ -366,44 +371,46 @@ pub struct WixConfig {
|
||||
/// A custom .wxs template to use.
|
||||
pub template: Option<PathBuf>,
|
||||
/// A list of paths to .wxs files with WiX fragments to use.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "fragment-paths")]
|
||||
pub fragment_paths: Vec<PathBuf>,
|
||||
/// The ComponentGroup element ids you want to reference from the fragments.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "component-group-refs")]
|
||||
pub component_group_refs: Vec<String>,
|
||||
/// The Component element ids you want to reference from the fragments.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "component-refs")]
|
||||
pub component_refs: Vec<String>,
|
||||
/// The FeatureGroup element ids you want to reference from the fragments.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "feature-group-refs")]
|
||||
pub feature_group_refs: Vec<String>,
|
||||
/// The Feature element ids you want to reference from the fragments.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "feature-refs")]
|
||||
pub feature_refs: Vec<String>,
|
||||
/// The Merge element ids you want to reference from the fragments.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "merge-refs")]
|
||||
pub merge_refs: Vec<String>,
|
||||
/// Disables the Webview2 runtime installation after app install.
|
||||
///
|
||||
/// Will be removed in v2, prefer the [`WindowsConfig::webview_install_mode`] option.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "skip-webview-install")]
|
||||
pub skip_webview_install: bool,
|
||||
/// The path to the license file to render on the installer.
|
||||
///
|
||||
/// Must be an RTF file, so if a different extension is provided, we convert it to the RTF format.
|
||||
pub license: Option<PathBuf>,
|
||||
/// Create an elevated update task within Windows Task Scheduler.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "enable-elevated-update-task")]
|
||||
pub enable_elevated_update_task: bool,
|
||||
/// Path to a bitmap file to use as the installation user interface banner.
|
||||
/// This bitmap will appear at the top of all but the first page of the installer.
|
||||
///
|
||||
/// The required dimensions are 493px × 58px.
|
||||
#[serde(alias = "banner-path")]
|
||||
pub banner_path: Option<PathBuf>,
|
||||
/// Path to a bitmap file to use on the installation user interface dialogs.
|
||||
/// It is used on the welcome and completion dialogs.
|
||||
|
||||
/// The required dimensions are 493px × 312px.
|
||||
#[serde(alias = "dialog-image-path")]
|
||||
pub dialog_image_path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
@@ -471,17 +478,20 @@ impl Default for WebviewInstallMode {
|
||||
pub struct WindowsConfig {
|
||||
/// Specifies the file digest algorithm to use for creating file signatures.
|
||||
/// Required for code signing. SHA-256 is recommended.
|
||||
#[serde(alias = "digest-algorithm")]
|
||||
pub digest_algorithm: Option<String>,
|
||||
/// Specifies the SHA1 hash of the signing certificate.
|
||||
#[serde(alias = "certificate-thumbprint")]
|
||||
pub certificate_thumbprint: Option<String>,
|
||||
/// Server to use during timestamping.
|
||||
#[serde(alias = "timestamp-url")]
|
||||
pub timestamp_url: Option<String>,
|
||||
/// Whether to use Time-Stamp Protocol (TSP, a.k.a. RFC 3161) for the timestamp server. Your code signing provider may
|
||||
/// use a TSP timestamp server, like e.g. SSL.com does. If so, enable TSP by setting to true.
|
||||
#[serde(default)]
|
||||
pub tsp: bool,
|
||||
/// The installation mode for the Webview2 runtime.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "webview-install-mode")]
|
||||
pub webview_install_mode: WebviewInstallMode,
|
||||
/// Path to the webview fixed runtime to use. Overwrites [`Self::webview_install_mode`] if set.
|
||||
///
|
||||
@@ -489,13 +499,14 @@ pub struct WindowsConfig {
|
||||
///
|
||||
/// The fixed version can be downloaded [on the official website](https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section).
|
||||
/// The `.cab` file must be extracted to a folder and this folder path must be defined on this field.
|
||||
#[serde(alias = "webview-fixed-runtime-path")]
|
||||
pub webview_fixed_runtime_path: Option<PathBuf>,
|
||||
/// Validates a second app installation, blocking the user from installing an older version if set to `false`.
|
||||
///
|
||||
/// For instance, if `1.2.1` is installed, the user won't be able to install app version `1.2.0` or `1.1.5`.
|
||||
///
|
||||
/// The default value of this flag is `true`.
|
||||
#[serde(default = "default_allow_downgrades")]
|
||||
#[serde(default = "default_allow_downgrades", alias = "allow-downgrades")]
|
||||
pub allow_downgrades: bool,
|
||||
/// Configuration for the MSI generated with WiX.
|
||||
pub wix: Option<WixConfig>,
|
||||
@@ -553,8 +564,10 @@ pub struct BundleConfig {
|
||||
/// Business, DeveloperTool, Education, Entertainment, Finance, Game, ActionGame, AdventureGame, ArcadeGame, BoardGame, CardGame, CasinoGame, DiceGame, EducationalGame, FamilyGame, KidsGame, MusicGame, PuzzleGame, RacingGame, RolePlayingGame, SimulationGame, SportsGame, StrategyGame, TriviaGame, WordGame, GraphicsAndDesign, HealthcareAndFitness, Lifestyle, Medical, Music, News, Photography, Productivity, Reference, SocialNetworking, Sports, Travel, Utility, Video, Weather.
|
||||
pub category: Option<String>,
|
||||
/// A short description of your application.
|
||||
#[serde(alias = "short-description")]
|
||||
pub short_description: Option<String>,
|
||||
/// A longer, multi-line description of the application.
|
||||
#[serde(alias = "long-description")]
|
||||
pub long_description: Option<String>,
|
||||
/// Configuration for the AppImage bundle.
|
||||
#[serde(default)]
|
||||
@@ -576,6 +589,7 @@ pub struct BundleConfig {
|
||||
/// - "my-binary-x86_64-unknown-linux-gnu" for Linux
|
||||
///
|
||||
/// so don't forget to provide binaries for all targeted platforms.
|
||||
#[serde(alias = "external-bin")]
|
||||
pub external_bin: Option<Vec<String>>,
|
||||
/// Configuration for the Windows bundle.
|
||||
#[serde(default)]
|
||||
@@ -599,6 +613,7 @@ pub struct CliArg {
|
||||
pub description: Option<String>,
|
||||
/// The argument long description which will be shown on the help information.
|
||||
/// Typically this a more detailed (multi-line) message that describes the argument.
|
||||
#[serde(alias = "long-description")]
|
||||
pub long_description: Option<String>,
|
||||
/// Specifies that the argument takes a value at run time.
|
||||
///
|
||||
@@ -606,7 +621,7 @@ pub struct CliArg {
|
||||
/// - Using a space such as -o value or --option value
|
||||
/// - Using an equals and no space such as -o=value or --option=value
|
||||
/// - Use a short and no space such as -ovalue
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "takes-value")]
|
||||
pub takes_value: bool,
|
||||
/// Specifies that the argument may have an unknown number of multiple values. Without any other settings, this argument may appear only once.
|
||||
///
|
||||
@@ -620,7 +635,7 @@ pub struct CliArg {
|
||||
/// For options or arguments that take a value, this does not affect how many values they can accept. (i.e. only one at a time is allowed)
|
||||
///
|
||||
/// For example, --opt val1 --opt val2 is allowed, but --opt val1 val2 is not.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "multiple-occurrences")]
|
||||
pub multiple_occurrences: bool,
|
||||
/// Specifies how many values are required to satisfy this argument. For example, if you had a
|
||||
/// `-f <file>` argument where you wanted exactly 3 'files' you would set
|
||||
@@ -632,17 +647,21 @@ pub struct CliArg {
|
||||
/// as *not* setting it would only allow one occurrence of this argument.
|
||||
///
|
||||
/// **NOTE:** implicitly sets `takes_value = true` and `multiple_values = true`.
|
||||
#[serde(alias = "number-of-values")]
|
||||
pub number_of_values: Option<usize>,
|
||||
/// Specifies a list of possible values for this argument.
|
||||
/// At runtime, the CLI verifies that only one of the specified values was used, or fails with an error message.
|
||||
#[serde(alias = "possible-values")]
|
||||
pub possible_values: Option<Vec<String>>,
|
||||
/// Specifies the minimum number of values for this argument.
|
||||
/// For example, if you had a -f `<file>` argument where you wanted at least 2 'files',
|
||||
/// you would set `minValues: 2`, and this argument would be satisfied if the user provided, 2 or more values.
|
||||
#[serde(alias = "min-values")]
|
||||
pub min_values: Option<usize>,
|
||||
/// Specifies the maximum number of values are for this argument.
|
||||
/// For example, if you had a -f `<file>` argument where you wanted up to 3 'files',
|
||||
/// you would set .max_values(3), and this argument would be satisfied if the user provided, 1, 2, or 3 values.
|
||||
#[serde(alias = "max-values")]
|
||||
pub max_values: Option<usize>,
|
||||
/// Sets whether or not the argument is required by default.
|
||||
///
|
||||
@@ -652,32 +671,41 @@ pub struct CliArg {
|
||||
pub required: bool,
|
||||
/// Sets an arg that override this arg's required setting
|
||||
/// i.e. this arg will be required unless this other argument is present.
|
||||
#[serde(alias = "required-unless-present")]
|
||||
pub required_unless_present: Option<String>,
|
||||
/// Sets args that override this arg's required setting
|
||||
/// i.e. this arg will be required unless all these other arguments are present.
|
||||
#[serde(alias = "required-unless-present-all")]
|
||||
pub required_unless_present_all: Option<Vec<String>>,
|
||||
/// Sets args that override this arg's required setting
|
||||
/// i.e. this arg will be required unless at least one of these other arguments are present.
|
||||
#[serde(alias = "required-unless-present-any")]
|
||||
pub required_unless_present_any: Option<Vec<String>>,
|
||||
/// Sets a conflicting argument by name
|
||||
/// i.e. when using this argument, the following argument can't be present and vice versa.
|
||||
#[serde(alias = "conflicts-with")]
|
||||
pub conflicts_with: Option<String>,
|
||||
/// The same as conflictsWith but allows specifying multiple two-way conflicts per argument.
|
||||
#[serde(alias = "conflicts-with-all")]
|
||||
pub conflicts_with_all: Option<Vec<String>>,
|
||||
/// Tets an argument by name that is required when this one is present
|
||||
/// i.e. when using this argument, the following argument must be present.
|
||||
pub requires: Option<String>,
|
||||
/// Sts multiple arguments by names that are required when this one is present
|
||||
/// i.e. when using this argument, the following arguments must be present.
|
||||
#[serde(alias = "requires-all")]
|
||||
pub requires_all: Option<Vec<String>>,
|
||||
/// Allows a conditional requirement with the signature [arg, value]
|
||||
/// the requirement will only become valid if `arg`'s value equals `${value}`.
|
||||
#[serde(alias = "requires-if")]
|
||||
pub requires_if: Option<Vec<String>>,
|
||||
/// Allows specifying that an argument is required conditionally with the signature [arg, value]
|
||||
/// the requirement will only become valid if the `arg`'s value equals `${value}`.
|
||||
#[serde(alias = "requires-if-eq")]
|
||||
pub required_if_eq: Option<Vec<String>>,
|
||||
/// Requires that options use the --option=val syntax
|
||||
/// i.e. an equals between the option and associated value.
|
||||
#[serde(alias = "requires-equals")]
|
||||
pub require_equals: Option<bool>,
|
||||
/// The positional argument index, starting at 1.
|
||||
///
|
||||
@@ -697,14 +725,17 @@ pub struct CliConfig {
|
||||
/// Command description which will be shown on the help information.
|
||||
pub description: Option<String>,
|
||||
/// Command long description which will be shown on the help information.
|
||||
#[serde(alias = "long-description")]
|
||||
pub long_description: Option<String>,
|
||||
/// Adds additional help information to be displayed in addition to auto-generated help.
|
||||
/// This information is displayed before the auto-generated help information.
|
||||
/// This is often used for header information.
|
||||
#[serde(alias = "before-help")]
|
||||
pub before_help: Option<String>,
|
||||
/// Adds additional help information to be displayed in addition to auto-generated help.
|
||||
/// This information is displayed after the auto-generated help information.
|
||||
/// This is often used to describe how to use the arguments, or caveats to be noted.
|
||||
#[serde(alias = "after-help")]
|
||||
pub after_help: Option<String>,
|
||||
/// List of arguments for the command
|
||||
pub args: Option<Vec<CliArg>>,
|
||||
@@ -763,7 +794,7 @@ pub struct WindowConfig {
|
||||
/// Whether the file drop is enabled or not on the webview. By default it is enabled.
|
||||
///
|
||||
/// Disabling it is required to use drag and drop on the frontend on Windows.
|
||||
#[serde(default = "default_file_drop_enabled")]
|
||||
#[serde(default = "default_file_drop_enabled", alias = "file-drop-enabled")]
|
||||
pub file_drop_enabled: bool,
|
||||
/// Whether or not the window starts centered or not.
|
||||
#[serde(default)]
|
||||
@@ -779,12 +810,16 @@ pub struct WindowConfig {
|
||||
#[serde(default = "default_height")]
|
||||
pub height: f64,
|
||||
/// The min window width.
|
||||
#[serde(alias = "min-width")]
|
||||
pub min_width: Option<f64>,
|
||||
/// The min window height.
|
||||
#[serde(alias = "min-height")]
|
||||
pub min_height: Option<f64>,
|
||||
/// The max window width.
|
||||
#[serde(alias = "max-width")]
|
||||
pub max_width: Option<f64>,
|
||||
/// The max window height.
|
||||
#[serde(alias = "max-height")]
|
||||
pub max_height: Option<f64>,
|
||||
/// Whether the window is resizable or not.
|
||||
#[serde(default = "default_resizable")]
|
||||
@@ -800,7 +835,7 @@ pub struct WindowConfig {
|
||||
pub focus: bool,
|
||||
/// Whether the window is transparent or not.
|
||||
///
|
||||
/// Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri.conf.json > tauri > macOSPrivateApi`.
|
||||
/// Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri > macOSPrivateApi`.
|
||||
/// WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`.
|
||||
#[serde(default)]
|
||||
pub transparent: bool,
|
||||
@@ -814,10 +849,10 @@ pub struct WindowConfig {
|
||||
#[serde(default = "default_decorations")]
|
||||
pub decorations: bool,
|
||||
/// Whether the window should always be on top of other windows.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "always-on-top")]
|
||||
pub always_on_top: bool,
|
||||
/// Whether or not the window icon should be added to the taskbar.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "skip-taskbar")]
|
||||
pub skip_taskbar: bool,
|
||||
/// The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.
|
||||
pub theme: Option<crate::Theme>,
|
||||
@@ -1048,9 +1083,10 @@ pub struct SecurityConfig {
|
||||
///
|
||||
/// This is a really important part of the configuration since it helps you ensure your WebView is secured.
|
||||
/// See <https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP>.
|
||||
#[serde(alias = "dev-csp")]
|
||||
pub dev_csp: Option<Csp>,
|
||||
/// Freeze the `Object.prototype` when using the custom protocol.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "freeze-prototype")]
|
||||
pub freeze_prototype: bool,
|
||||
/// Disables the Tauri-injected CSP sources.
|
||||
///
|
||||
@@ -1064,7 +1100,7 @@ pub struct SecurityConfig {
|
||||
///
|
||||
/// **WARNING:** Only disable this if you know what you are doing and have properly configured the CSP.
|
||||
/// Your application might be vulnerable to XSS attacks without this Tauri protection.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "dangerous-disable-asset-csp-modification")]
|
||||
pub dangerous_disable_asset_csp_modification: DisabledCspModificationKind,
|
||||
}
|
||||
|
||||
@@ -1145,29 +1181,32 @@ pub struct FsAllowlistConfig {
|
||||
#[serde(default)]
|
||||
pub all: bool,
|
||||
/// Read file from local filesystem.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "read-file")]
|
||||
pub read_file: bool,
|
||||
/// Write file to local filesystem.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "write-file")]
|
||||
pub write_file: bool,
|
||||
/// Read directory from local filesystem.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "read-dir")]
|
||||
pub read_dir: bool,
|
||||
/// Copy file from local filesystem.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "copy-file")]
|
||||
pub copy_file: bool,
|
||||
/// Create directory from local filesystem.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "create-dir")]
|
||||
pub create_dir: bool,
|
||||
/// Remove directory from local filesystem.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "remove-dir")]
|
||||
pub remove_dir: bool,
|
||||
/// Remove file from local filesystem.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "remove-file")]
|
||||
pub remove_file: bool,
|
||||
/// Rename file from local filesystem.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "rename-file")]
|
||||
pub rename_file: bool,
|
||||
/// Check if path exists on the local filesystem.
|
||||
#[serde(default)]
|
||||
pub exists: bool,
|
||||
}
|
||||
|
||||
impl Allowlist for FsAllowlistConfig {
|
||||
@@ -1183,6 +1222,7 @@ impl Allowlist for FsAllowlistConfig {
|
||||
remove_dir: true,
|
||||
remove_file: true,
|
||||
rename_file: true,
|
||||
exists: true,
|
||||
};
|
||||
let mut features = allowlist.to_features();
|
||||
features.push("fs-all");
|
||||
@@ -1202,6 +1242,7 @@ impl Allowlist for FsAllowlistConfig {
|
||||
check_feature!(self, features, remove_dir, "fs-remove-dir");
|
||||
check_feature!(self, features, remove_file, "fs-remove-file");
|
||||
check_feature!(self, features, rename_file, "fs-rename-file");
|
||||
check_feature!(self, features, exists, "fs-exists");
|
||||
features
|
||||
}
|
||||
}
|
||||
@@ -1222,13 +1263,13 @@ pub struct WindowAllowlistConfig {
|
||||
#[serde(default)]
|
||||
pub center: bool,
|
||||
/// Allows requesting user attention on the window.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "request-user-attention")]
|
||||
pub request_user_attention: bool,
|
||||
/// Allows setting the resizable flag of the window.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "set-resizable")]
|
||||
pub set_resizable: bool,
|
||||
/// Allows changing the window title.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "set-title")]
|
||||
pub set_title: bool,
|
||||
/// Allows maximizing the window.
|
||||
#[serde(default)]
|
||||
@@ -1252,37 +1293,37 @@ pub struct WindowAllowlistConfig {
|
||||
#[serde(default)]
|
||||
pub close: bool,
|
||||
/// Allows setting the decorations flag of the window.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "set-decorations")]
|
||||
pub set_decorations: bool,
|
||||
/// Allows setting the always_on_top flag of the window.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "set-always-on-top")]
|
||||
pub set_always_on_top: bool,
|
||||
/// Allows setting the window size.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "set-size")]
|
||||
pub set_size: bool,
|
||||
/// Allows setting the window minimum size.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "set-min-size")]
|
||||
pub set_min_size: bool,
|
||||
/// Allows setting the window maximum size.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "set-max-size")]
|
||||
pub set_max_size: bool,
|
||||
/// Allows changing the position of the window.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "set-position")]
|
||||
pub set_position: bool,
|
||||
/// Allows setting the fullscreen flag of the window.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "set-fullscreen")]
|
||||
pub set_fullscreen: bool,
|
||||
/// Allows focusing the window.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "set-focus")]
|
||||
pub set_focus: bool,
|
||||
/// Allows changing the window icon.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "set-icon")]
|
||||
pub set_icon: bool,
|
||||
/// Allows setting the skip_taskbar flag of the window.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "set-skip-taskbar")]
|
||||
pub set_skip_taskbar: bool,
|
||||
/// Allows start dragging on the window.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "start-dragging")]
|
||||
pub start_dragging: bool,
|
||||
/// Allows opening the system dialog to print the window content.
|
||||
#[serde(default)]
|
||||
@@ -1779,7 +1820,7 @@ impl Allowlist for PathAllowlistConfig {
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct ProtocolAllowlistConfig {
|
||||
/// The access scope for the asset protocol.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "asset-scope")]
|
||||
pub asset_scope: FsAllowlistScope,
|
||||
/// Use this flag to enable all custom protocols.
|
||||
#[serde(default)]
|
||||
@@ -1827,7 +1868,11 @@ pub struct ProcessAllowlistConfig {
|
||||
///
|
||||
/// This is due to macOS having less symlink protection. Highly recommended to not set this flag
|
||||
/// unless you have a very specific reason too, and understand the implications of it.
|
||||
#[serde(default)]
|
||||
#[serde(
|
||||
default,
|
||||
alias = "relaunchDangerousAllowSymlinkMacOS",
|
||||
alias = "relaunch-dangerous-allow-symlink-macos"
|
||||
)]
|
||||
pub relaunch_dangerous_allow_symlink_macos: bool,
|
||||
/// Enables the exit API.
|
||||
#[serde(default)]
|
||||
@@ -1874,10 +1919,10 @@ pub struct ClipboardAllowlistConfig {
|
||||
#[serde(default)]
|
||||
pub all: bool,
|
||||
/// Enables the clipboard's `writeText` API.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "writeText")]
|
||||
pub write_text: bool,
|
||||
/// Enables the clipboard's `readText` API.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "readText")]
|
||||
pub read_text: bool,
|
||||
}
|
||||
|
||||
@@ -1932,7 +1977,7 @@ pub struct AllowlistConfig {
|
||||
#[serde(default)]
|
||||
pub notification: NotificationAllowlistConfig,
|
||||
/// Global shortcut API allowlist.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "global-shortcut")]
|
||||
pub global_shortcut: GlobalShortcutAllowlistConfig,
|
||||
/// OS allowlist.
|
||||
#[serde(default)]
|
||||
@@ -2040,9 +2085,10 @@ pub struct TauriConfig {
|
||||
#[serde(default)]
|
||||
pub updater: UpdaterConfig,
|
||||
/// Configuration for app system tray.
|
||||
#[serde(alias = "system-tray")]
|
||||
pub system_tray: Option<SystemTrayConfig>,
|
||||
/// MacOS private API configuration. Enables the transparent background API and sets the `fullScreenEnabled` preference to `true`.
|
||||
#[serde(rename = "macOSPrivateApi", default)]
|
||||
#[serde(rename = "macOSPrivateApi", alias = "macos-private-api", default)]
|
||||
pub macos_private_api: bool,
|
||||
}
|
||||
|
||||
@@ -2199,7 +2245,7 @@ impl<'de> Deserialize<'de> for WindowsUpdateInstallMode {
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct UpdaterWindowsConfig {
|
||||
/// The installation mode for the update on Windows. Defaults to `passive`.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "install-mode")]
|
||||
pub install_mode: WindowsUpdateInstallMode,
|
||||
}
|
||||
|
||||
@@ -2288,15 +2334,17 @@ impl Default for UpdaterConfig {
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct SystemTrayConfig {
|
||||
/// Path to the icon to use on the system tray.
|
||||
///
|
||||
/// It is forced to be a `.png` file on Linux and macOS, and a `.ico` file on Windows.
|
||||
/// Path to the default icon to use on the system tray.
|
||||
#[serde(alias = "icon-path")]
|
||||
pub icon_path: PathBuf,
|
||||
/// A Boolean value that determines whether the image represents a [template](https://developer.apple.com/documentation/appkit/nsimage/1520017-template?language=objc) image on macOS.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "icon-as-template")]
|
||||
pub icon_as_template: bool,
|
||||
/// A Boolean value that determines whether the menu should appear when the tray icon receives a left click on macOS.
|
||||
#[serde(default = "default_tray_menu_on_left_click")]
|
||||
#[serde(
|
||||
default = "default_tray_menu_on_left_click",
|
||||
alias = "menu-on-left-click"
|
||||
)]
|
||||
pub menu_on_left_click: bool,
|
||||
}
|
||||
|
||||
@@ -2332,6 +2380,41 @@ impl std::fmt::Display for AppUrl {
|
||||
}
|
||||
}
|
||||
|
||||
/// Describes the shell command to run before `tauri dev`.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", untagged)]
|
||||
pub enum BeforeDevCommand {
|
||||
/// Run the given script with the default options.
|
||||
Script(String),
|
||||
/// Run the given script with custom options.
|
||||
ScriptWithOptions {
|
||||
/// The script to execute.
|
||||
script: String,
|
||||
/// The current working directory.
|
||||
cwd: Option<String>,
|
||||
/// Whether `tauri dev` should wait for the command to finish or not. Defaults to `false`.
|
||||
#[serde(default)]
|
||||
wait: bool,
|
||||
},
|
||||
}
|
||||
|
||||
/// Describes a shell command to be executed when a CLI hook is triggered.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", untagged)]
|
||||
pub enum HookCommand {
|
||||
/// Run the given script with the default options.
|
||||
Script(String),
|
||||
/// Run the given script with custom options.
|
||||
ScriptWithOptions {
|
||||
/// The script to execute.
|
||||
script: String,
|
||||
/// The current working directory.
|
||||
cwd: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
/// The Build configuration object.
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
@@ -2347,7 +2430,7 @@ pub struct BuildConfig {
|
||||
///
|
||||
/// See [vite](https://vitejs.dev/guide/), [Webpack DevServer](https://webpack.js.org/configuration/dev-server/) and [sirv](https://github.com/lukeed/sirv)
|
||||
/// for examples on how to set up a dev server.
|
||||
#[serde(default = "default_dev_path")]
|
||||
#[serde(default = "default_dev_path", alias = "dev-path")]
|
||||
pub dev_path: AppUrl,
|
||||
/// The path to the application assets or URL to load in production.
|
||||
///
|
||||
@@ -2360,20 +2443,27 @@ pub struct BuildConfig {
|
||||
///
|
||||
/// When an URL is provided, the application won't have bundled assets
|
||||
/// and the application will load that URL by default.
|
||||
#[serde(default = "default_dist_dir")]
|
||||
#[serde(default = "default_dist_dir", alias = "dist-dir")]
|
||||
pub dist_dir: AppUrl,
|
||||
/// A shell command to run before `tauri dev` kicks in.
|
||||
///
|
||||
/// The TAURI_PLATFORM, TAURI_ARCH, TAURI_FAMILY, TAURI_PLATFORM_VERSION, TAURI_PLATFORM_TYPE and TAURI_DEBUG environment variables are set if you perform conditional compilation.
|
||||
pub before_dev_command: Option<String>,
|
||||
#[serde(alias = "before-dev-command")]
|
||||
pub before_dev_command: Option<BeforeDevCommand>,
|
||||
/// A shell command to run before `tauri build` kicks in.
|
||||
///
|
||||
/// The TAURI_PLATFORM, TAURI_ARCH, TAURI_FAMILY, TAURI_PLATFORM_VERSION, TAURI_PLATFORM_TYPE and TAURI_DEBUG environment variables are set if you perform conditional compilation.
|
||||
pub before_build_command: Option<String>,
|
||||
#[serde(alias = "before-build-command")]
|
||||
pub before_build_command: Option<HookCommand>,
|
||||
/// A shell command to run before the bundling phase in `tauri build` kicks in.
|
||||
///
|
||||
/// The TAURI_PLATFORM, TAURI_ARCH, TAURI_FAMILY, TAURI_PLATFORM_VERSION, TAURI_PLATFORM_TYPE and TAURI_DEBUG environment variables are set if you perform conditional compilation.
|
||||
#[serde(alias = "before-bundle-command")]
|
||||
pub before_bundle_command: Option<HookCommand>,
|
||||
/// Features passed to `cargo` commands.
|
||||
pub features: Option<Vec<String>>,
|
||||
/// Whether we should inject the Tauri API on `window.__TAURI__` or not.
|
||||
#[serde(default)]
|
||||
#[serde(default, alias = "with-global-tauri")]
|
||||
pub with_global_tauri: bool,
|
||||
}
|
||||
|
||||
@@ -2385,6 +2475,7 @@ impl Default for BuildConfig {
|
||||
dist_dir: default_dist_dir(),
|
||||
before_dev_command: None,
|
||||
before_build_command: None,
|
||||
before_bundle_command: None,
|
||||
features: None,
|
||||
with_global_tauri: false,
|
||||
}
|
||||
@@ -2463,8 +2554,9 @@ impl<'d> serde::Deserialize<'d> for PackageVersion {
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct PackageConfig {
|
||||
/// App name.
|
||||
#[serde(alias = "product-name")]
|
||||
pub product_name: Option<String>,
|
||||
/// App version. It is a semver version number or a path to a `package.json` file contaning the `version` field.
|
||||
/// App version. It is a semver version number or a path to a `package.json` file containing the `version` field.
|
||||
#[serde(deserialize_with = "version_deserializer", default)]
|
||||
pub version: Option<String>,
|
||||
}
|
||||
@@ -2491,22 +2583,36 @@ impl PackageConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/// The tauri.conf.json is a file generated by the
|
||||
/// The Tauri configuration object.
|
||||
/// It is read from a file where you can define your frontend assets,
|
||||
/// configure the bundler, enable the app updater, define a system tray,
|
||||
/// enable APIs via the allowlist and more.
|
||||
///
|
||||
/// The configuration file is generated by the
|
||||
/// [`tauri init`](https://tauri.app/v1/api/cli#init) command that lives in
|
||||
/// your Tauri application source directory (src-tauri).
|
||||
///
|
||||
/// Once generated, you may modify it at will to customize your Tauri application.
|
||||
///
|
||||
/// ## File Formats
|
||||
///
|
||||
/// By default, the configuration is defined as a JSON file named `tauri.conf.json`.
|
||||
///
|
||||
/// Tauri also supports JSON5 and TOML files via the `config-json5` and `config-toml` Cargo features, respectively.
|
||||
/// The JSON5 file name must be either `tauri.conf.json` or `tauri.conf.json5`.
|
||||
/// The TOML file name is `Tauri.toml`.
|
||||
///
|
||||
/// ## Platform-Specific Configuration
|
||||
///
|
||||
/// In addition to the JSON defined on the `tauri.conf.json` file, Tauri can
|
||||
/// In addition to the default configuration file, Tauri can
|
||||
/// read a platform-specific configuration from `tauri.linux.conf.json`,
|
||||
/// `tauri.windows.conf.json`, and `tauri.macos.conf.json` and merges it with
|
||||
/// the main `tauri.conf.json` configuration.
|
||||
/// `tauri.windows.conf.json`, and `tauri.macos.conf.json`
|
||||
/// (or `Tauri.linux.toml`, `Tauri.windows.toml` and `Tauri.macos.toml` if the `Tauri.toml` format is used),
|
||||
/// which gets merged with the main configuration object.
|
||||
///
|
||||
/// ## Configuration Structure
|
||||
///
|
||||
/// `tauri.conf.json` is composed of the following objects:
|
||||
/// The configuration is composed of the following objects:
|
||||
///
|
||||
/// - [`package`](#packageconfig): Package settings
|
||||
/// - [`tauri`](#tauriconfig): The Tauri config
|
||||
@@ -2582,6 +2688,7 @@ fn default_build() -> BuildConfig {
|
||||
dist_dir: default_dist_dir(),
|
||||
before_dev_command: None,
|
||||
before_build_command: None,
|
||||
before_bundle_command: None,
|
||||
features: None,
|
||||
with_global_tauri: false,
|
||||
}
|
||||
@@ -3049,6 +3156,7 @@ mod build {
|
||||
let runner = quote!(None);
|
||||
let before_dev_command = quote!(None);
|
||||
let before_build_command = quote!(None);
|
||||
let before_bundle_command = quote!(None);
|
||||
let features = quote!(None);
|
||||
|
||||
literal_struct!(
|
||||
@@ -3060,6 +3168,7 @@ mod build {
|
||||
with_global_tauri,
|
||||
before_dev_command,
|
||||
before_build_command,
|
||||
before_bundle_command,
|
||||
features
|
||||
);
|
||||
}
|
||||
@@ -3460,6 +3569,7 @@ mod test {
|
||||
dist_dir: AppUrl::Url(WindowUrl::App("../dist".into())),
|
||||
before_dev_command: None,
|
||||
before_build_command: None,
|
||||
before_bundle_command: None,
|
||||
features: None,
|
||||
with_global_tauri: false,
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -11,15 +11,75 @@ use std::path::{Path, PathBuf};
|
||||
use thiserror::Error;
|
||||
|
||||
/// All extensions that are possibly supported, but perhaps not enabled.
|
||||
pub const EXTENSIONS_SUPPORTED: &[&str] = &["json", "json5"];
|
||||
pub const EXTENSIONS_SUPPORTED: &[&str] = &["json", "json5", "toml"];
|
||||
|
||||
/// All extensions that are currently enabled.
|
||||
pub const EXTENSIONS_ENABLED: &[&str] = &[
|
||||
"json",
|
||||
/// All configuration formats that are possibly supported, but perhaps not enabled.
|
||||
pub const SUPPORTED_FORMATS: &[ConfigFormat] =
|
||||
&[ConfigFormat::Json, ConfigFormat::Json5, ConfigFormat::Toml];
|
||||
|
||||
/// All configuration formats that are currently enabled.
|
||||
pub const ENABLED_FORMATS: &[ConfigFormat] = &[
|
||||
ConfigFormat::Json,
|
||||
#[cfg(feature = "config-json5")]
|
||||
"json5",
|
||||
ConfigFormat::Json5,
|
||||
#[cfg(feature = "config-toml")]
|
||||
ConfigFormat::Toml,
|
||||
];
|
||||
|
||||
/// The available configuration formats.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum ConfigFormat {
|
||||
/// The default JSON (tauri.conf.json) format.
|
||||
Json,
|
||||
/// The JSON5 (tauri.conf.json5) format.
|
||||
Json5,
|
||||
/// The TOML (Tauri.toml file) format.
|
||||
Toml,
|
||||
}
|
||||
|
||||
impl ConfigFormat {
|
||||
/// Maps the config format to its file name.
|
||||
pub fn into_file_name(self) -> &'static str {
|
||||
match self {
|
||||
Self::Json => "tauri.conf.json",
|
||||
Self::Json5 => "tauri.conf.json5",
|
||||
Self::Toml => "Tauri.toml",
|
||||
}
|
||||
}
|
||||
|
||||
fn into_platform_file_name(self) -> &'static str {
|
||||
match self {
|
||||
Self::Json => {
|
||||
if cfg!(target_os = "macos") {
|
||||
"tauri.macos.conf.json"
|
||||
} else if cfg!(windows) {
|
||||
"tauri.windows.conf.json"
|
||||
} else {
|
||||
"tauri.linux.conf.json"
|
||||
}
|
||||
}
|
||||
Self::Json5 => {
|
||||
if cfg!(target_os = "macos") {
|
||||
"tauri.macos.conf.json5"
|
||||
} else if cfg!(windows) {
|
||||
"tauri.windows.conf.json5"
|
||||
} else {
|
||||
"tauri.linux.conf.json5"
|
||||
}
|
||||
}
|
||||
Self::Toml => {
|
||||
if cfg!(target_os = "macos") {
|
||||
"Tauri.macos.toml"
|
||||
} else if cfg!(windows) {
|
||||
"Tauri.windows.toml"
|
||||
} else {
|
||||
"Tauri.linux.toml"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents all the errors that can happen while reading the config.
|
||||
#[derive(Debug, Error)]
|
||||
#[non_exhaustive]
|
||||
@@ -45,7 +105,18 @@ pub enum ConfigError {
|
||||
error: ::json5::Error,
|
||||
},
|
||||
|
||||
/// Unknown file extension encountered.
|
||||
/// Failed to parse from TOML.
|
||||
#[cfg(feature = "config-toml")]
|
||||
#[error("unable to parse toml Tauri config file at {path} because {error}")]
|
||||
FormatToml {
|
||||
/// The path that failed to parse into TOML.
|
||||
path: PathBuf,
|
||||
|
||||
/// The parsing [`toml::Error`].
|
||||
error: ::toml::de::Error,
|
||||
},
|
||||
|
||||
/// Unknown config file name encountered.
|
||||
#[error("unsupported format encountered {0}")]
|
||||
UnsupportedFormat(String),
|
||||
|
||||
@@ -81,32 +152,21 @@ pub enum ConfigError {
|
||||
///
|
||||
/// [JSON Merge Patch (RFC 7396)]: https://datatracker.ietf.org/doc/html/rfc7396.
|
||||
pub fn read_from(root_dir: PathBuf) -> Result<Value, ConfigError> {
|
||||
let mut config: Value = parse_value(root_dir.join("tauri.conf.json"))?;
|
||||
if let Some(platform_config) = read_platform(root_dir)? {
|
||||
let mut config: Value = parse_value(root_dir.join("tauri.conf.json"))?.0;
|
||||
if let Some((platform_config, _)) = read_platform(root_dir)? {
|
||||
merge(&mut config, &platform_config);
|
||||
}
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
/// Gets the platform configuration file name.
|
||||
pub fn get_platform_config_filename() -> &'static str {
|
||||
if cfg!(target_os = "macos") {
|
||||
"tauri.macos.conf.json"
|
||||
} else if cfg!(windows) {
|
||||
"tauri.windows.conf.json"
|
||||
} else {
|
||||
"tauri.linux.conf.json"
|
||||
}
|
||||
}
|
||||
|
||||
/// Reads the platform-specific configuration file from the given root directory if it exists.
|
||||
///
|
||||
/// Check [`read_from`] for more information.
|
||||
pub fn read_platform(root_dir: PathBuf) -> Result<Option<Value>, ConfigError> {
|
||||
let platform_config_path = root_dir.join(get_platform_config_filename());
|
||||
if does_supported_extension_exist(&platform_config_path) {
|
||||
let platform_config: Value = parse_value(platform_config_path)?;
|
||||
Ok(Some(platform_config))
|
||||
pub fn read_platform(root_dir: PathBuf) -> Result<Option<(Value, PathBuf)>, ConfigError> {
|
||||
let platform_config_path = root_dir.join(ConfigFormat::Json.into_platform_file_name());
|
||||
if does_supported_file_name_exist(&platform_config_path) {
|
||||
let (platform_config, path): (Value, PathBuf) = parse_value(platform_config_path)?;
|
||||
Ok(Some((platform_config, path)))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
@@ -116,11 +176,21 @@ pub fn read_platform(root_dir: PathBuf) -> Result<Option<Value>, ConfigError> {
|
||||
///
|
||||
/// The passed path is expected to be the path to the "default" configuration format, in this case
|
||||
/// JSON with `.json`.
|
||||
pub fn does_supported_extension_exist(path: impl Into<PathBuf>) -> bool {
|
||||
pub fn does_supported_file_name_exist(path: impl Into<PathBuf>) -> bool {
|
||||
let path = path.into();
|
||||
EXTENSIONS_ENABLED
|
||||
let source_file_name = path.file_name().unwrap().to_str().unwrap();
|
||||
let lookup_platform_config = ENABLED_FORMATS
|
||||
.iter()
|
||||
.any(|ext| path.with_extension(ext).exists())
|
||||
.any(|format| source_file_name == format.into_platform_file_name());
|
||||
ENABLED_FORMATS.iter().any(|format| {
|
||||
path
|
||||
.with_file_name(if lookup_platform_config {
|
||||
format.into_platform_file_name()
|
||||
} else {
|
||||
format.into_file_name()
|
||||
})
|
||||
.exists()
|
||||
})
|
||||
}
|
||||
|
||||
/// Parse the config from path, including alternative formats.
|
||||
@@ -133,18 +203,39 @@ pub fn does_supported_extension_exist(path: impl Into<PathBuf>) -> bool {
|
||||
/// 2. Check if `tauri.conf.json5` exists
|
||||
/// a. Parse it with `json5`
|
||||
/// b. Return error if all above steps failed
|
||||
/// 3. Return error if all above steps failed
|
||||
pub fn parse(path: impl Into<PathBuf>) -> Result<Config, ConfigError> {
|
||||
/// 3. Check if `Tauri.json` exists
|
||||
/// a. Parse it with `toml`
|
||||
/// b. Return error if all above steps failed
|
||||
/// 4. Return error if all above steps failed
|
||||
pub fn parse(path: impl Into<PathBuf>) -> Result<(Config, PathBuf), ConfigError> {
|
||||
do_parse(path.into())
|
||||
}
|
||||
|
||||
/// See [`parse`] for specifics, returns a JSON [`Value`] instead of [`Config`].
|
||||
pub fn parse_value(path: impl Into<PathBuf>) -> Result<Value, ConfigError> {
|
||||
pub fn parse_value(path: impl Into<PathBuf>) -> Result<(Value, PathBuf), ConfigError> {
|
||||
do_parse(path.into())
|
||||
}
|
||||
|
||||
fn do_parse<D: DeserializeOwned>(path: PathBuf) -> Result<D, ConfigError> {
|
||||
let json5 = path.with_extension("json5");
|
||||
fn do_parse<D: DeserializeOwned>(path: PathBuf) -> Result<(D, PathBuf), ConfigError> {
|
||||
let file_name = path
|
||||
.file_name()
|
||||
.map(OsStr::to_string_lossy)
|
||||
.unwrap_or_default();
|
||||
let lookup_platform_config = ENABLED_FORMATS
|
||||
.iter()
|
||||
.any(|format| file_name == format.into_platform_file_name());
|
||||
|
||||
let json5 = path.with_file_name(if lookup_platform_config {
|
||||
ConfigFormat::Json5.into_platform_file_name()
|
||||
} else {
|
||||
ConfigFormat::Json5.into_file_name()
|
||||
});
|
||||
let toml = path.with_file_name(if lookup_platform_config {
|
||||
ConfigFormat::Toml.into_platform_file_name()
|
||||
} else {
|
||||
ConfigFormat::Toml.into_file_name()
|
||||
});
|
||||
|
||||
let path_ext = path
|
||||
.extension()
|
||||
.map(OsStr::to_string_lossy)
|
||||
@@ -171,12 +262,12 @@ fn do_parse<D: DeserializeOwned>(path: PathBuf) -> Result<D, ConfigError> {
|
||||
}
|
||||
};
|
||||
|
||||
json
|
||||
json.map(|j| (j, path))
|
||||
} else if json5.exists() {
|
||||
#[cfg(feature = "config-json5")]
|
||||
{
|
||||
let raw = read_to_string(&json5)?;
|
||||
do_parse_json5(&raw, &path)
|
||||
do_parse_json5(&raw, &path).map(|config| (config, json5))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "config-json5"))]
|
||||
@@ -184,6 +275,18 @@ fn do_parse<D: DeserializeOwned>(path: PathBuf) -> Result<D, ConfigError> {
|
||||
extension: ".json5".into(),
|
||||
feature: "config-json5".into(),
|
||||
})
|
||||
} else if toml.exists() {
|
||||
#[cfg(feature = "config-toml")]
|
||||
{
|
||||
let raw = read_to_string(&toml)?;
|
||||
do_parse_toml(&raw, &path).map(|config| (config, toml))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "config-toml"))]
|
||||
Err(ConfigError::DisabledFormat {
|
||||
extension: ".toml".into(),
|
||||
feature: "config-toml".into(),
|
||||
})
|
||||
} else if !EXTENSIONS_SUPPORTED.contains(&path_ext.as_ref()) {
|
||||
Err(ConfigError::UnsupportedFormat(path_ext.to_string()))
|
||||
} else {
|
||||
@@ -241,6 +344,14 @@ fn do_parse_json5<D: DeserializeOwned>(raw: &str, path: &Path) -> Result<D, Conf
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "config-toml")]
|
||||
fn do_parse_toml<D: DeserializeOwned>(raw: &str, path: &Path) -> Result<D, ConfigError> {
|
||||
::toml::from_str(raw).map_err(|error| ConfigError::FormatToml {
|
||||
path: path.into(),
|
||||
error,
|
||||
})
|
||||
}
|
||||
|
||||
/// Helper function to wrap IO errors from [`std::fs::read_to_string`] into a [`ConfigError`].
|
||||
fn read_to_string(path: &Path) -> Result<String, ConfigError> {
|
||||
std::fs::read_to_string(path).map_err(|error| ConfigError::Io {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -105,11 +105,14 @@ pub struct Env {
|
||||
/// The APPDIR environment variable.
|
||||
#[cfg(target_os = "linux")]
|
||||
pub appdir: Option<std::ffi::OsString>,
|
||||
/// The command line arguments of the current process.
|
||||
pub args: Vec<String>,
|
||||
}
|
||||
|
||||
#[allow(clippy::derivable_impls)]
|
||||
impl Default for Env {
|
||||
fn default() -> Self {
|
||||
let args = std::env::args().skip(1).collect();
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let env = Self {
|
||||
@@ -117,6 +120,7 @@ impl Default for Env {
|
||||
appimage: std::env::var_os("APPIMAGE"),
|
||||
#[cfg(target_os = "linux")]
|
||||
appdir: std::env::var_os("APPDIR"),
|
||||
args,
|
||||
};
|
||||
if env.appimage.is_some() || env.appdir.is_some() {
|
||||
// validate that we're actually running on an AppImage
|
||||
@@ -139,7 +143,7 @@ impl Default for Env {
|
||||
}
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
Self {}
|
||||
Self { args }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user