forked from rojo-rbx/rojo
Simplify plugin installation by using Plugins instead of InstalledPlugins
This commit is contained in:
@@ -27,7 +27,7 @@ pub fn serve(project_dir: &PathBuf, override_port: Option<u64>) {
|
|||||||
|
|
||||||
println!("Using project {:#?}", project);
|
println!("Using project {:#?}", project);
|
||||||
|
|
||||||
roblox_studio::install_bundled_plugin();
|
roblox_studio::install_bundled_plugin().unwrap();
|
||||||
|
|
||||||
let mut session = Session::new(project.clone());
|
let mut session = Session::new(project.clone());
|
||||||
session.start();
|
session.start();
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ use std::env;
|
|||||||
compile_error!("`bundle-plugin` feature must be set for release builds.");
|
compile_error!("`bundle-plugin` feature must be set for release builds.");
|
||||||
|
|
||||||
#[cfg(feature = "bundle-plugin")]
|
#[cfg(feature = "bundle-plugin")]
|
||||||
static PLUGIN_RBXM: &'static [u8] = include_bytes!("../target/plugin.rbxm");
|
static PLUGIN_RBXM: &'static [u8] = include_bytes!("../target/plugin.rbxmx");
|
||||||
|
|
||||||
const ROJO_HOTSWAP_PLUGIN_ID: &'static str = "0";
|
|
||||||
const ROJO_RELEASE_PLUGIN_ID: &'static str = "1997686364";
|
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
pub fn get_install_location() -> Option<PathBuf> {
|
pub fn get_install_location() -> Option<PathBuf> {
|
||||||
@@ -36,43 +33,30 @@ pub fn get_install_location() -> Option<PathBuf> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "bundle-plugin")]
|
|
||||||
pub fn get_plugin_location() -> Option<PathBuf> {
|
pub fn get_plugin_location() -> Option<PathBuf> {
|
||||||
let mut location = get_install_location()?;
|
let mut location = get_install_location()?;
|
||||||
|
|
||||||
location.push("InstalledPlugins");
|
location.push("Plugins/Rojo.rbxmx");
|
||||||
location.push(ROJO_RELEASE_PLUGIN_ID);
|
|
||||||
|
|
||||||
Some(location)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "bundle-plugin"))]
|
|
||||||
pub fn get_plugin_location() -> Option<PathBuf> {
|
|
||||||
let mut location = get_install_location()?;
|
|
||||||
|
|
||||||
location.push("InstalledPlugins");
|
|
||||||
location.push(ROJO_HOTSWAP_PLUGIN_ID);
|
|
||||||
|
|
||||||
Some(location)
|
Some(location)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "bundle-plugin")]
|
#[cfg(feature = "bundle-plugin")]
|
||||||
pub fn install_bundled_plugin() -> Option<()> {
|
pub fn install_bundled_plugin() -> Option<()> {
|
||||||
use std::fs::create_dir_all;
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
println!("Installing plugin...");
|
println!("Installing plugin...");
|
||||||
|
|
||||||
// TODO: Check error of this value; the only one we actually want to ignore
|
let mut file = File::create(get_plugin_location()?).ok()?;
|
||||||
// is ErrorKind::AlreadyExists probably.
|
file.write_all(PLUGIN_RBXM).ok()?;
|
||||||
let _ = create_dir_all(get_plugin_location()?);
|
|
||||||
|
|
||||||
// TODO: Copy PLUGIN_RBXM to plugin_location/Plugin.rbxm
|
|
||||||
// TODO: Update PluginMetadata.json
|
|
||||||
|
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "bundle-plugin"))]
|
#[cfg(not(feature = "bundle-plugin"))]
|
||||||
pub fn install_bundled_plugin() {
|
pub fn install_bundled_plugin() -> Option<()> {
|
||||||
println!("Skipping plugin installation, bundle-plugin not set.");
|
println!("Skipping plugin installation, bundle-plugin not set.");
|
||||||
|
|
||||||
|
Some(())
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user