aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rwxr-xr-xconverter/convert_darwin_arm64.sh38
-rwxr-xr-xconverter/convert_darwin_x64.sh38
-rwxr-xr-xconverter/convert_linux_arm64.sh37
-rwxr-xr-xconverter/convert_linux_x64.sh37
-rw-r--r--launcher/.gitignore1
-rw-r--r--launcher/.idea/.gitignore5
-rw-r--r--launcher/.idea/discord.xml12
-rw-r--r--launcher/.idea/launcher.iml11
-rw-r--r--launcher/.idea/modules.xml8
-rw-r--r--launcher/.idea/vcs.xml6
-rw-r--r--launcher/Cargo.lock240
-rw-r--r--launcher/Cargo.toml8
-rw-r--r--launcher/src/main.rs203
14 files changed, 648 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2f1cff0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+work
+launcher/target
+converter/launcher-*
+launcher/release
diff --git a/converter/convert_darwin_arm64.sh b/converter/convert_darwin_arm64.sh
new file mode 100755
index 0000000..2938746
--- /dev/null
+++ b/converter/convert_darwin_arm64.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+me="$(realpath "$(dirname "$0")")"
+
+if [ ! -d "$1" ]; then
+ echo "$0: No such file or directory"
+ exit
+fi
+
+if [ ! -f "$1/Contents/Frameworks/Electron Framework.framework/Electron Framework" ]; then
+ echo "$0: Application is not a valid Atomic application"
+ exit
+fi
+
+original=$(du -hs "$1" | awk '{print $1;}')
+
+executable=""
+for i in "$1/Contents/MacOS/"*; do executable="$i"; done
+
+echo "$0: Executable found at $executable"
+
+echo "$0: Copying launcher"
+rm -f "$executable"
+cp "$me/launcher-darwin-arm64" "$executable"
+
+echo "$0: Removing built-in Electron"
+rm -rf "$1/Contents/Frameworks"
+for i in "$1/Contents/Resources/"*; do
+ if [[ "$i" == */app ]] || [[ "$i" == */electron.icns ]]; then
+ true
+ else
+ rm -rf "$i"
+ fi
+done
+
+new=$(du -hs "$1" | awk '{print $1;}')
+
+echo "$0: Completed. Was $original, is now $new."
diff --git a/converter/convert_darwin_x64.sh b/converter/convert_darwin_x64.sh
new file mode 100755
index 0000000..79ba101
--- /dev/null
+++ b/converter/convert_darwin_x64.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+me="$(realpath "$(dirname "$0")")"
+
+if [ ! -d "$1" ]; then
+ echo "$0: No such file or directory"
+ exit
+fi
+
+if [ ! -f "$1/Contents/Frameworks/Electron Framework.framework/Electron Framework" ]; then
+ echo "$0: Application is not a valid Atomic application"
+ exit
+fi
+
+original=$(du -hs "$1" | awk '{print $1;}')
+
+executable=""
+for i in "$1/Contents/MacOS/"*; do executable="$i"; done
+
+echo "$0: Executable found at $executable"
+
+echo "$0: Copying launcher"
+rm -f "$executable"
+cp "$me/launcher-darwin-x64" "$executable"
+
+echo "$0: Removing built-in Electron"
+rm -rf "$1/Contents/Frameworks"
+for i in "$1/Contents/Resources/"*; do
+ if [[ "$i" == */app ]] || [[ "$i" == */electron.icns ]]; then
+ true
+ else
+ rm -rf "$i"
+ fi
+done
+
+new=$(du -hs "$1" | awk '{print $1;}')
+
+echo "$0: Completed. Was $original, is now $new."
diff --git a/converter/convert_linux_arm64.sh b/converter/convert_linux_arm64.sh
new file mode 100755
index 0000000..a6476a5
--- /dev/null
+++ b/converter/convert_linux_arm64.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+me="$(realpath "$(dirname "$0")")"
+
+if [ ! -d "$1" ]; then
+ echo "$0: No such file or directory"
+ exit
+fi
+
+if [ ! -f "$1/chrome-sandbox" ]; then
+ echo "$0: Application is not a valid Atomic application"
+ exit
+fi
+
+original=$(du -hs "$1" | awk '{print $1;}')
+
+echo "$0: Removing built-in Electron"
+rm -rf "$1/locales" "$1/"*".pak" "$1/chrome_crashpad_handler" "$1/chrome-sandbox" "$1/icudtl.dat" "$1/"*".so" "$1/libvulkan.so.1" "$1/LICENSE" "$1/LICENSES.chromium.html" "$1/"*".bin" "$1/version" "$1/vk_swiftshader_icd.json"
+
+executable=""
+for i in "$1/"*; do
+ if [[ "$(basename "$i")" == *"."* ]] || [ -d "$i" ]; then
+ true
+ else
+ executable="$i"
+ fi
+done
+
+echo "$0: Executable found at $executable"
+
+echo "$0: Copying launcher"
+rm -f "$executable"
+cp "$me/launcher-linux-arm64" "$executable"
+
+new=$(du -hs "$1" | awk '{print $1;}')
+
+echo "$0: Completed. Was $original, is now $new."
diff --git a/converter/convert_linux_x64.sh b/converter/convert_linux_x64.sh
new file mode 100755
index 0000000..462641c
--- /dev/null
+++ b/converter/convert_linux_x64.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+me="$(realpath "$(dirname "$0")")"
+
+if [ ! -d "$1" ]; then
+ echo "$0: No such file or directory"
+ exit
+fi
+
+if [ ! -f "$1/chrome-sandbox" ]; then
+ echo "$0: Application is not a valid Atomic application"
+ exit
+fi
+
+original=$(du -hs "$1" | awk '{print $1;}')
+
+echo "$0: Removing built-in Electron"
+rm -rf "$1/locales" "$1/"*".pak" "$1/chrome_crashpad_handler" "$1/chrome-sandbox" "$1/icudtl.dat" "$1/"*".so" "$1/libvulkan.so.1" "$1/LICENSE" "$1/LICENSES.chromium.html" "$1/"*".bin" "$1/version" "$1/vk_swiftshader_icd.json"
+
+executable=""
+for i in "$1/"*; do
+ if [[ "$(basename "$i")" == *"."* ]] || [ -d "$i" ]; then
+ true
+ else
+ executable="$i"
+ fi
+done
+
+echo "$0: Executable found at $executable"
+
+echo "$0: Copying launcher"
+rm -f "$executable"
+cp "$me/launcher-linux-x64" "$executable"
+
+new=$(du -hs "$1" | awk '{print $1;}')
+
+echo "$0: Completed. Was $original, is now $new."
diff --git a/launcher/.gitignore b/launcher/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/launcher/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/launcher/.idea/.gitignore b/launcher/.idea/.gitignore
new file mode 100644
index 0000000..b58b603
--- /dev/null
+++ b/launcher/.idea/.gitignore
@@ -0,0 +1,5 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/launcher/.idea/discord.xml b/launcher/.idea/discord.xml
new file mode 100644
index 0000000..3aef922
--- /dev/null
+++ b/launcher/.idea/discord.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="DiscordProjectSettings">
+ <option name="show" value="PROJECT_FILES" />
+ <option name="description" value="" />
+ <option name="theme" value="material" />
+ <option name="button1Title" value="" />
+ <option name="button1Url" value="" />
+ <option name="button2Title" value="" />
+ <option name="button2Url" value="" />
+ </component>
+</project> \ No newline at end of file
diff --git a/launcher/.idea/launcher.iml b/launcher/.idea/launcher.iml
new file mode 100644
index 0000000..cf84ae4
--- /dev/null
+++ b/launcher/.idea/launcher.iml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="EMPTY_MODULE" version="4">
+ <component name="NewModuleRootManager">
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
+</module> \ No newline at end of file
diff --git a/launcher/.idea/modules.xml b/launcher/.idea/modules.xml
new file mode 100644
index 0000000..1515be0
--- /dev/null
+++ b/launcher/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/.idea/launcher.iml" filepath="$PROJECT_DIR$/.idea/launcher.iml" />
+ </modules>
+ </component>
+</project> \ No newline at end of file
diff --git a/launcher/.idea/vcs.xml b/launcher/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/launcher/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="" vcs="Git" />
+ </component>
+</project> \ No newline at end of file
diff --git a/launcher/Cargo.lock b/launcher/Cargo.lock
new file mode 100644
index 0000000..d8290e5
--- /dev/null
+++ b/launcher/Cargo.lock
@@ -0,0 +1,240 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "bitflags"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "dirs"
+version = "5.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
+dependencies = [
+ "dirs-sys",
+]
+
+[[package]]
+name = "dirs-sys"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
+dependencies = [
+ "libc",
+ "option-ext",
+ "redox_users",
+ "windows-sys",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi",
+]
+
+[[package]]
+name = "launcher"
+version = "1.1.0"
+dependencies = [
+ "dirs",
+ "rustc_version_runtime",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.154"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
+
+[[package]]
+name = "libredox"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
+dependencies = [
+ "bitflags",
+ "libc",
+]
+
+[[package]]
+name = "option-ext"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.82"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.36"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "redox_users"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891"
+dependencies = [
+ "getrandom",
+ "libredox",
+ "thiserror",
+]
+
+[[package]]
+name = "rustc_version"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
+dependencies = [
+ "semver",
+]
+
+[[package]]
+name = "rustc_version_runtime"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2dd18cd2bae1820af0b6ad5e54f4a51d0f3fcc53b05f845675074efcc7af071d"
+dependencies = [
+ "rustc_version",
+ "semver",
+]
+
+[[package]]
+name = "semver"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
+
+[[package]]
+name = "syn"
+version = "2.0.61"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "thiserror"
+version = "1.0.60"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.60"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
+
+[[package]]
+name = "wasi"
+version = "0.11.0+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
+
+[[package]]
+name = "windows-sys"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
diff --git a/launcher/Cargo.toml b/launcher/Cargo.toml
new file mode 100644
index 0000000..a2cdfee
--- /dev/null
+++ b/launcher/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "launcher"
+version = "1.1.0"
+edition = "2021"
+
+[dependencies]
+dirs = "5.0.1"
+rustc_version_runtime = "0.3.0"
diff --git a/launcher/src/main.rs b/launcher/src/main.rs
new file mode 100644
index 0000000..6f3e21c
--- /dev/null
+++ b/launcher/src/main.rs
@@ -0,0 +1,203 @@
+use std::env::current_exe;
+use std::path::{Path, PathBuf};
+use std::process::{Command, exit};
+use dirs::home_dir;
+use rustc_version_runtime::version;
+
+fn get_home() -> String {
+ let home_buf = home_dir()
+ .unwrap_or(PathBuf::from("/"));
+ let os_string = home_buf
+ .into_os_string();
+ os_string
+ .to_string_lossy()
+ .to_string()
+}
+
+#[cfg(target_os = "macos")]
+fn get_home_search() -> PathBuf {
+ PathBuf::from(format!("{}/Library/Frameworks/AtomicRuntime.framework", get_home()))
+}
+
+#[cfg(target_os = "linux")]
+fn get_home_search() -> PathBuf {
+ PathBuf::from(format!("{}/.local/share/atomic-runtime", get_home()))
+}
+
+#[cfg(target_os = "windows")]
+fn get_home_search() -> PathBuf {
+ PathBuf::from(format!("{}\\AppData\\Local\\Atomic Runtime", get_home()))
+}
+
+#[cfg(target_os = "macos")]
+fn get_search_paths() -> [PathBuf; 5] {
+ [
+ PathBuf::from("/Library/Frameworks/AtomicRuntime.framework"),
+ PathBuf::from("/System/Library/Frameworks/AtomicRuntime.framework"),
+ PathBuf::from("/usr/local/lib/atomic-runtime"),
+ PathBuf::from("/opt/atomic-runtime"),
+ get_home_search()
+ ]
+}
+
+#[cfg(target_os = "linux")]
+fn get_search_paths() -> [PathBuf; 8] {
+ [
+ PathBuf::from("/usr/local/lib/atomic-runtime"),
+ PathBuf::from("/usr/local/lib64/atomic-runtime"),
+ PathBuf::from("/usr/lib/atomic-runtime"),
+ PathBuf::from("/usr/lib64/atomic-runtime"),
+ PathBuf::from("/lib/atomic-runtime"),
+ PathBuf::from("/lib64/atomic-runtime"),
+ PathBuf::from("/opt/atomic-runtime"),
+ get_home_search()
+ ]
+}
+
+#[cfg(target_os = "windows")]
+fn get_search_paths() -> [PathBuf; 29] {
+ [
+ PathBuf::from("C:\\Program Files\\Common Files\\Equestria.dev\\AtomicRuntime"),
+ PathBuf::from("C:\\Program Files\\Common Files\\Equestria.dev\\Atomic Runtime"),
+ PathBuf::from("C:\\Program Files (x86)\\Common Files\\Equestria.dev\\AtomicRuntime"),
+ PathBuf::from("C:\\Program Files (x86)\\Common Files\\Equestria.dev\\Atomic Runtime"),
+ PathBuf::from("C:\\Program Files (Arm)\\Common Files\\Equestria.dev\\AtomicRuntime"),
+ PathBuf::from("C:\\Program Files (Arm)\\Common Files\\Equestria.dev\\Atomic Runtime"),
+ PathBuf::from("C:\\Program Files\\Common Files\\AtomicRuntime"),
+ PathBuf::from("C:\\Program Files\\Common Files\\Atomic Runtime"),
+ PathBuf::from("C:\\Program Files (x86)\\Common Files\\AtomicRuntime"),
+ PathBuf::from("C:\\Program Files (x86)\\Common Files\\Atomic Runtime"),
+ PathBuf::from("C:\\Program Files (Arm)\\Common Files\\AtomicRuntime"),
+ PathBuf::from("C:\\Program Files (Arm)\\Common Files\\Atomic Runtime"),
+ PathBuf::from("C:\\Windows\\AtomicRuntime"),
+ PathBuf::from("C:\\Windows\\Atomic Runtime"),
+ PathBuf::from("C:\\Program Files\\Equestria.dev\\AtomicRuntime"),
+ PathBuf::from("C:\\Program Files\\Equestria.dev\\Atomic Runtime"),
+ PathBuf::from("C:\\Program Files (x86)\\Equestria.dev\\AtomicRuntime"),
+ PathBuf::from("C:\\Program Files (x86)\\Equestria.dev\\Atomic Runtime"),
+ PathBuf::from("C:\\Program Files (Arm)\\Equestria.dev\\AtomicRuntime"),
+ PathBuf::from("C:\\Program Files (Arm)\\Equestria.dev\\Atomic Runtime"),
+ PathBuf::from("C:\\Program Files\\AtomicRuntime"),
+ PathBuf::from("C:\\Program Files\\Atomic Runtime"),
+ PathBuf::from("C:\\Program Files (x86)\\AtomicRuntime"),
+ PathBuf::from("C:\\Program Files (x86)\\Atomic Runtime"),
+ PathBuf::from("C:\\Program Files (Arm)\\AtomicRuntime"),
+ PathBuf::from("C:\\Program Files (Arm)\\Atomic Runtime"),
+ PathBuf::from("C:\\ProgramData\\AtomicRuntime"),
+ PathBuf::from("C:\\ProgramData\\Atomic Runtime"),
+ get_home_search()
+ ]
+}
+
+#[cfg(target_os = "macos")]
+const PLATFORM: &str = "macOS/Darwin";
+
+#[cfg(target_os = "linux")]
+const PLATFORM: &str = "Linux";
+
+#[cfg(target_os = "windows")]
+const PLATFORM: &str = "Windows";
+
+#[cfg(target_arch = "aarch64")]
+const ARCH: &str = "ARM64";
+
+#[cfg(target_arch = "x86_64")]
+const ARCH: &str = "x86_64";
+
+fn show_system_info() {
+ println!("atomic-launcher: Starting atomic-launcher on {} ({})", PLATFORM, ARCH);
+}
+
+// TODO: Rename these to "Atomic"
+
+#[cfg(target_os = "macos")]
+const BINARY_PATH: &str = "Contents/MacOS/Electron";
+
+#[cfg(target_os = "linux")]
+const BINARY_PATH: &str = "electron";
+
+#[cfg(target_os = "windows")]
+const BINARY_PATH: &str = "electron.exe";
+
+#[cfg(target_os = "macos")]
+const APP_DATA_PATH: &str = "../Resources/app";
+
+#[cfg(any(target_os = "linux", target_os = "windows"))]
+const APP_DATA_PATH: &str = "./resources/app";
+
+fn main() {
+ show_system_info();
+ println!("atomic-launcher: Compiled against rustc {}", version());
+
+ let my_path_buf = current_exe()
+ .unwrap_or(PathBuf::from("/"));
+ let my_path = my_path_buf
+ .parent()
+ .unwrap_or(Path::new("/"))
+ .to_str()
+ .unwrap_or("/");
+
+ println!("atomic-launcher: Current directory: {}", my_path);
+
+ let mut found_app = false;
+ let app_path_unparsed = &format!("{}/{}", my_path, APP_DATA_PATH);
+ let app_path = Path::new(app_path_unparsed);
+
+ if app_path.exists() {
+ found_app = true;
+ } else {
+ println!("atomic-launcher: Warning: Could not find Electron-compatible app. Looked in {}. The default atomic-runtime application will be opened instead.", app_path
+ .to_str()
+ .unwrap_or("/"));
+ }
+
+ let runtime_search_paths = get_search_paths();
+
+ println!("atomic-launcher: Looking for atomic-runtime in: {}", runtime_search_paths
+ .iter()
+ .map(|i| i
+ .to_str()
+ .unwrap_or("/"))
+ .collect::<Vec<&str>>()
+ .join(", ")
+ .as_str());
+ let mut valid_path: Option<PathBuf> = None;
+
+ for path in runtime_search_paths {
+ let path_str = path.to_str().unwrap_or("/");
+ if path.as_path().exists() && Path::new(&format!("{}/{}", path_str, BINARY_PATH)).exists() {
+ valid_path = Some(path);
+ break;
+ }
+ }
+
+ if let Some(path) = valid_path {
+ println!("atomic-launcher: Found atomic-runtime at {}", Path::new(&format!("{}/{}", path
+ .to_str()
+ .unwrap_or(""), BINARY_PATH))
+ .to_str()
+ .unwrap_or(""));
+ let mut cmd = Command::new(Path::new(&format!("{}/{}", path
+ .to_str()
+ .unwrap_or(""), BINARY_PATH)));
+ println!("atomic-launcher: Executing: {:?}", cmd);
+
+ if found_app {
+ cmd.arg(app_path);
+ }
+
+ if let Ok(mut app) = cmd.spawn() {
+ exit(app.wait()
+ .unwrap_or_default()
+ .code()
+ .unwrap_or(255));
+ } else {
+ eprintln!("atomic-launcher: Application failed to start.");
+ exit(3);
+ }
+
+ } else {
+ eprintln!("atomic-launcher: Could not find a valid atomic-runtime path. Aborting.");
+ exit(2);
+ }
+}