Add plugin bundling, sourced from target/plugin.rbxm

This commit is contained in:
Lucien Greathouse
2018-06-25 00:53:21 -07:00
parent 4138bb7ee1
commit 5a5da3240f
3 changed files with 58 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ use rand;
use project::Project;
use web::{self, WebConfig};
use session::Session;
use roblox_studio;
pub fn serve(project_dir: &PathBuf, override_port: Option<u64>) {
let server_id = rand::random::<u64>();
@@ -26,6 +27,8 @@ pub fn serve(project_dir: &PathBuf, override_port: Option<u64>) {
println!("Using project {:#?}", project);
roblox_studio::install_bundled_plugin();
let mut session = Session::new(project.clone());
session.start();

View File

@@ -1,10 +1,19 @@
//! Interactions with Roblox Studio's installation, including its location and
//! mechanisms like PluginSettings.
#![allow(dead_code)]
use std::path::PathBuf;
use std::env;
static ROJO_PLUGIN_ID: &'static str = "1211549683";
#[cfg(all(not(debug_assertions), not(feature = "bundle-plugin")))]
compile_error!("`bundle-plugin` feature must be set for release builds.");
#[cfg(feature = "bundle-plugin")]
static PLUGIN_RBXM: &'static [u8] = include_bytes!("../target/plugin.rbxm");
const ROJO_HOTSWAP_PLUGIN_ID: &'static str = "0";
const ROJO_RELEASE_PLUGIN_ID: &'static str = "1997686364";
#[cfg(target_os = "windows")]
pub fn get_install_location() -> Option<PathBuf> {
@@ -25,4 +34,45 @@ pub fn get_install_location() -> Option<PathBuf> {
pub fn get_install_location() -> Option<PathBuf> {
// Roblox Studio doesn't install on any other platforms!
None
}
#[cfg(feature = "bundle-plugin")]
pub fn get_plugin_location() -> Option<PathBuf> {
let mut location = get_install_location()?;
location.push("InstalledPlugins");
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)
}
#[cfg(feature = "bundle-plugin")]
pub fn install_bundled_plugin() -> Option<()> {
use std::fs::create_dir_all;
println!("Installing plugin...");
// TODO: Check error of this value; the only one we actually want to ignore
// is ErrorKind::AlreadyExists probably.
let _ = create_dir_all(get_plugin_location()?);
// TODO: Copy PLUGIN_RBXM to plugin_location/Plugin.rbxm
// TODO: Update PluginMetadata.json
Some(())
}
#[cfg(not(feature = "bundle-plugin"))]
pub fn install_bundled_plugin() {
println!("Skipping plugin installation, bundle-plugin not set.");
}