-
Notifications
You must be signed in to change notification settings - Fork 4
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
janerjak
wants to merge
19
commits into
bym-refitted:main
Choose a base branch
from
janerjak:macos-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ca58387
I give up, use npm instead
janerjak a3f8ccf
Merge branch 'vscode-wrong-task-env' into macos-support
janerjak 5dcce0f
Revert debug changes to desperately get yarn working from cargo
janerjak d2a6c02
Working yarn on macOS within VS code
janerjak 557ef08
Merge branch 'vscode-wrong-task-env' into macos-support
janerjak 5057d0a
macOS basically working (using the Flash player from /Applications)
janerjak 0fd4e63
Add .DS_Store and desktop.ini to .gitignore
janerjak 248bd63
Add .dmg auto install script
janerjak 5919669
Flash player info is now of type PathBuf, PathBuf, String, differenti…
janerjak c9432aa
WIP automount .dmg on macOS
janerjak 618dc12
macOS app extraction implemented
janerjak a6b655d
Revert requested changes (that were leftovers from debugging)
janerjak 715e3d4
Revert launch.json changes
janerjak 98cd0ff
Remove more debug println
janerjak 15f026b
Remove flash runtime path event to UI
janerjak 2ab2c65
No longer always download runtime
janerjak 8a46cc5
Leave runtime package as an optional (simplify get_platform_flash_run…
janerjak a0fb2d7
Fix wrong web file name on macOS, simplify get_platform_flash_runtime…
janerjak 4c9c7a8
Revert formatting changes on launch.json
janerjak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/zsh | ||
|
||
VOLUME=`hdiutil attach -nobrowse "$1" | grep Volumes | cut -f 3` | ||
cp -rf "$VOLUME"/*.app "$2" | ||
hdiutil detach "$VOLUME" | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
use std::{ | ||
fs, | ||
path::PathBuf, | ||
process::Command, | ||
}; | ||
use regex::Regex; | ||
|
||
use crate::RUNTIMES_DIR; | ||
|
||
pub fn potentially_extract_runtime( | ||
executable_path: PathBuf, | ||
package_path: PathBuf, | ||
platform: &str, | ||
) -> Result<(), String> { | ||
if executable_path == package_path { | ||
// Nothing to do | ||
return Ok(()); | ||
} | ||
match platform { | ||
"darwin" | "macos" => extract_runtime_macos(executable_path, package_path), | ||
_ => Err("Runtime extraction not supported on this platform".to_string()) | ||
} | ||
} | ||
|
||
fn extract_runtime_macos( | ||
executable_path: PathBuf, | ||
package_path: PathBuf, | ||
) -> Result<(), String> { | ||
let hdiutil_process = Command::new("hdiutil") | ||
.arg("attach") | ||
.arg("-nobrowse") | ||
.arg(package_path) | ||
.output() | ||
.map_err(|err| err.to_string())?; | ||
|
||
if !hdiutil_process.status.success() { | ||
return Err(format!( | ||
"Mounting .dmg failed: {}", | ||
String::from_utf8_lossy(&hdiutil_process.stderr) | ||
)); | ||
} | ||
|
||
// Extract path to mounted volume from process output | ||
let regex = Regex::new(r"(/Volumes/[\w\s]+)").unwrap(); | ||
let hdiutil_output_string = String::from_utf8_lossy(&hdiutil_process.stdout); | ||
let mounted_volume; | ||
if let Some(matching_volume_capture) = regex.captures(&hdiutil_output_string) { | ||
mounted_volume = matching_volume_capture.get(0).unwrap().as_str().trim(); | ||
} | ||
else { | ||
return Err("Mount command returned no path to the volume".to_string()); | ||
} | ||
|
||
// Copy runtime executable from volume to runtime folder | ||
let volume_read_result = fs::read_dir(mounted_volume) | ||
.map_err(|err| err.to_string())?; | ||
|
||
let volume_apps: Vec<_> = volume_read_result | ||
.filter_map(|file_entry| { | ||
let file_entry = file_entry.ok()?; | ||
let file_path = file_entry.path(); | ||
if !file_path.is_file() && file_path.extension()?.eq("app") { | ||
Some(file_path) | ||
} | ||
else { | ||
None | ||
} | ||
}) | ||
.collect(); | ||
|
||
// Ensure only one .app is contained | ||
let app_file_count = volume_apps.len(); | ||
if app_file_count != 1 { | ||
return Err(format!( | ||
"Unexpected number of app files within volume: {}, expected 1, contained files: {:?}", | ||
app_file_count, | ||
volume_apps, | ||
)); | ||
} | ||
|
||
// Copy the only .app folder to runtime folder using system copy command | ||
let source_app_folder = volume_apps.first().unwrap(); | ||
let dest_folder = format!("{}/", RUNTIMES_DIR); | ||
let copy_process = Command::new("cp") | ||
.arg("-rf") | ||
.arg(source_app_folder) | ||
.arg(&dest_folder) | ||
.output() | ||
.map_err(|err| err.to_string())?; | ||
|
||
if !copy_process.status.success() { | ||
return Err(format!( | ||
"Copying .app from: {:?} to {}, error: {}", | ||
source_app_folder, | ||
dest_folder, | ||
String::from_utf8_lossy(&hdiutil_process.stderr), | ||
)); | ||
} | ||
|
||
// Finally check if the executable path is now available | ||
if !executable_path.exists() { | ||
return Err(format!( | ||
"After extraction, the expected executable path is still not available: {:?}", | ||
executable_path, | ||
)); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script is never used?