Initial MeshPort SDK and cross-platform client
This commit is contained in:
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
# Optional: install build tools inside work/, leaving the user's shell unchanged.
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
mkdir -p work/toolchain
|
||||
curl --fail --location https://sh.rustup.rs -o work/toolchain/rustup-init.sh
|
||||
export CARGO_HOME="$PWD/work/toolchain/cargo"
|
||||
export RUSTUP_HOME="$PWD/work/toolchain/rustup"
|
||||
sh work/toolchain/rustup-init.sh -y --profile minimal --no-modify-path
|
||||
"$CARGO_HOME/bin/rustup" component add rustfmt clippy
|
||||
case "$(uname -s)-$(uname -m)" in
|
||||
Darwin-*) archive="protoc-31.1-osx-universal_binary.zip" ;;
|
||||
Linux-x86_64) archive="protoc-31.1-linux-x86_64.zip" ;;
|
||||
Linux-aarch64) archive="protoc-31.1-linux-aarch_64.zip" ;;
|
||||
*) printf '%s\n' 'Install protoc for this platform manually.'; exit 1 ;;
|
||||
esac
|
||||
curl --fail --location "https://github.com/protocolbuffers/protobuf/releases/download/v31.1/$archive" -o work/toolchain/protoc.zip
|
||||
unzip -q -o work/toolchain/protoc.zip -d work/toolchain/protoc
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
mode="${1:---release}"
|
||||
case "$mode" in --debug|--release) ;; *) printf '%s\n' 'usage: build-lab-android.sh [--debug|--release]' >&2; exit 2;; esac
|
||||
sdk="${ANDROID_SDK_ROOT:-$HOME/Library/Android/sdk}"
|
||||
ndk="$sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin"
|
||||
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$ndk/aarch64-linux-android26-clang"
|
||||
export CC_aarch64_linux_android="$CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER"
|
||||
export AR_aarch64_linux_android="$ndk/llvm-ar"
|
||||
export CARGO_TARGET_AARCH64_LINUX_ANDROID_RUSTFLAGS='-C link-arg=-Wl,-z,max-page-size=16384'
|
||||
if [ "$mode" = --release ]; then
|
||||
scripts/cargo-local.sh build -p meshport-ffi --target aarch64-linux-android --features system-vpn --release --locked
|
||||
profile=release
|
||||
else
|
||||
scripts/cargo-local.sh build -p meshport-ffi --target aarch64-linux-android --features system-vpn --locked
|
||||
profile=debug
|
||||
fi
|
||||
mkdir -p apps/meshport_lab/android/app/src/main/jniLibs/arm64-v8a
|
||||
cp "target/aarch64-linux-android/$profile/libmeshport_ffi.so" apps/meshport_lab/android/app/src/main/jniLibs/arm64-v8a/
|
||||
build_number=$(date +%s)
|
||||
cd apps/meshport_lab
|
||||
flutter build apk "$mode" --target-platform android-arm64 --build-number="$build_number"
|
||||
cd ../..
|
||||
mkdir -p outputs/android
|
||||
output="$PWD/outputs/android/MeshPort-0.1.0-$build_number-$profile.apk"
|
||||
cp "apps/meshport_lab/build/app/outputs/flutter-apk/app-$profile.apk" "$output"
|
||||
printf '%s\n' "$output"
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
scripts/cargo-local.sh build -p meshport-ffi -p meshport-vpn-helper --locked
|
||||
root="$PWD"
|
||||
cd apps/meshport_lab
|
||||
build_number=$(TZ=Asia/Tokyo date +%Y%m%d%H%M%S)
|
||||
flutter build macos --debug --build-number="$build_number"
|
||||
app="$PWD/build/macos/Build/Products/Debug/MeshPort.app"
|
||||
cp "$root/target/debug/libmeshport_ffi.dylib" "$app/Contents/Frameworks/"
|
||||
cp "$root/target/debug/meshport-vpn-helper" "$app/Contents/MacOS/"
|
||||
codesign --force --sign - "$app/Contents/MacOS/meshport-vpn-helper"
|
||||
codesign --force --sign - "$app/Contents/Frameworks/libmeshport_ffi.dylib"
|
||||
codesign --force --deep --sign - --entitlements macos/Runner/DebugProfile.entitlements "$app"
|
||||
touch "$app"
|
||||
printf '%s\n' "$app"
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
if [ -x work/toolchain/cargo/bin/cargo ]; then
|
||||
export CARGO_HOME="$PWD/work/toolchain/cargo"
|
||||
export RUSTUP_HOME="$PWD/work/toolchain/rustup"
|
||||
export PATH="$CARGO_HOME/bin:$PATH"
|
||||
fi
|
||||
if [ -x work/toolchain/protoc/bin/protoc ]; then
|
||||
export PROTOC="$PWD/work/toolchain/protoc/bin/protoc"
|
||||
fi
|
||||
exec cargo "$@"
|
||||
@@ -0,0 +1,32 @@
|
||||
"""Resize the approved MeshPort artwork into native platform icon assets.
|
||||
|
||||
Requires Pillow. No generation or creative editing of the source artwork.
|
||||
"""
|
||||
import json
|
||||
from pathlib import Path
|
||||
from PIL import Image
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
APP = ROOT / "apps/meshport_lab"
|
||||
source = Image.open(ROOT / "outputs/branding/meshport-logo-v1.png").convert("RGBA")
|
||||
|
||||
def write_icon(path, size, opaque=False):
|
||||
image = source.resize((size, size), Image.Resampling.LANCZOS)
|
||||
if opaque:
|
||||
background = Image.new("RGBA", image.size, "#087d8e")
|
||||
background.alpha_composite(image)
|
||||
image = background.convert("RGB")
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
image.save(path)
|
||||
|
||||
for platform in ("macos", "ios"):
|
||||
directory = APP / platform / "Runner/Assets.xcassets/AppIcon.appiconset"
|
||||
for item in json.loads((directory / "Contents.json").read_text())["images"]:
|
||||
if "filename" in item:
|
||||
pixels = round(float(item["size"].split("x")[0]) * float(item["scale"].rstrip("x")))
|
||||
write_icon(directory / item["filename"], pixels, opaque=platform == "ios")
|
||||
|
||||
for density, size in {"mdpi": 48, "hdpi": 72, "xhdpi": 96, "xxhdpi": 144, "xxxhdpi": 192}.items():
|
||||
write_icon(APP / f"android/app/src/main/res/mipmap-{density}/ic_launcher.png", size)
|
||||
source.save(APP / "windows/runner/resources/app_icon.ico", sizes=[(16,16), (32,32), (48,48), (64,64), (128,128), (256,256)])
|
||||
write_icon(APP / "assets/branding/meshport.png", 256)
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
scripts/build-lab-macos.sh
|
||||
exec open apps/meshport_lab/build/macos/Build/Products/Debug/MeshPort.app
|
||||
Reference in New Issue
Block a user