Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[POC] macOS support #9

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,31 @@
"build",
"--manifest-path=./src-tauri/Cargo.toml",
"--no-default-features"
]
],
},
// task for the `beforeDevCommand` if used, must be configured in `.vscode/tasks.json`
"preLaunchTask": "ui:dev"
},
{
"type": "lldb",
"request": "launch",
"name": "Tauri Development Debug yarn tauri dev",
"cargo": {
"args": [
"build",
"--manifest-path=./src-tauri/Cargo.toml",
"--no-default-features"
],
},
// task for the `beforeDevCommand` if used, must be configured in `.vscode/tasks.json`
"postDebugTask": "ui:tauri-dev"
},
{
"type": "lldb",
"request": "launch",
"name": "Tauri Production Debug",
"cargo": {
"args": ["build", "--release", "--manifest-path=./src-tauri/Cargo.toml"]
"args": ["build", "--release", "--manifest-path=./src-tauri/Cargo.toml"],
},
// task for the `beforeBuildCommand` if used, must be configured in `.vscode/tasks.json`
"preLaunchTask": "ui:build"
Expand Down
23 changes: 21 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,33 @@
"isBackground": true,
// change this to your `beforeDevCommand`:
"command": "yarn",
"args": ["dev"]
"args": ["dev"],
},
{
"label": "ui:tauri-dev",
"type": "shell",
// `dev` keeps running in the background
// ideally you should also configure a `problemMatcher`
// see https://code.visualstudio.com/docs/editor/tasks#_can-a-background-task-be-used-as-a-prelaunchtask-in-launchjson
"isBackground": true,
// change this to your `beforeDevCommand`:
"command": "yarn",
"args": ["tauri", "dev"],
"group": {
"kind": "test",
"isDefault": true,
}
},
{
"label": "ui:build",
"type": "shell",
// change this to your `beforeBuildCommand`:
"command": "yarn",
"args": ["build"]
"args": ["build"],
"group": {
"kind": "build",
"isDefault": true,
}
}
]
}
3 changes: 2 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ async fn initialize_app(app: AppHandle) -> Result<(), String> {
}

#[command]
fn launch_game(build_name: &str, language: &str, token: Option<&str>) -> Result<(), String> {
fn launch_game(app: AppHandle, build_name: &str, language: &str, token: Option<&str>) -> Result<(), String> {
let (flash_runtime_path, _) = get_platform_flash_runtime(&env::consts::OS)?;
emit_event(&app, "infoLog", ("Flash runtime path: ").to_string() + &flash_runtime_path.clone().into_os_string().into_string().unwrap());

if !flash_runtime_path.exists() {
eprintln!("cannot find file: {}", flash_runtime_path.display());
Expand Down
14 changes: 12 additions & 2 deletions src-tauri/src/version_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,22 @@ pub async fn download_runtime(
}

pub fn get_platform_flash_runtime(platform: &str) -> Result<(PathBuf, String), String> {
// NOTE: This match case was only meant to match darwin, but it is named macos (for a long time now)
let flash_runtimes = match platform {
"windows" => Ok("flashplayer.exe".to_string()),
"darwin" => Ok("flashplayer.dmg".to_string()),
"darwin" | "macos" => Ok("flashplayer.dmg".to_string()),
"linux" => Ok("flashplayer".to_string()),
_ => Err(format!("unsupported platform: {}", platform)),
};

flash_runtimes.map(|runtime| (PathBuf::from(RUNTIMES_DIR).join(runtime.clone()), runtime))
flash_runtimes.map(|runtime| {
if matches!(platform, "darwin" | "macos") {
// Return path to the systems Flash Player explicitly
(PathBuf::from("/Applications/Flash Player.app/Contents/MacOS/Flash Player"), runtime)
}
else {
// Use RUNTIMES_DIR as usual
(PathBuf::from(RUNTIMES_DIR).join(runtime.clone()), runtime)
}
})
}
1 change: 1 addition & 0 deletions src/lib/utils/invokeApiRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
type HttpVerb,
ResponseType,
} from "@tauri-apps/api/http";
import { addInfoLog } from "$lib/stores/debugLogStore";

/**
* Represents a generic API response.
Expand Down
7 changes: 5 additions & 2 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@

const initializeLauncher = async () => {
try {
const [launcherVersionManifest, currentGameVersionManifest, _] =
await Promise.all([
const [
launcherVersionManifest,
currentGameVersionManifest,
_
] = await Promise.all([
getVersion(),
invoke<string>("get_current_game_version"),
invoke("initialize_app"),
Expand Down