mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 12:45:05 +00:00
@@ -17,6 +17,7 @@
|
|||||||
* Better settings controls ([#725])
|
* Better settings controls ([#725])
|
||||||
* Rework patch visualizer with many fixes and improvements ([#726])
|
* Rework patch visualizer with many fixes and improvements ([#726])
|
||||||
* Added support for syncing in `.toml` files ([#633])
|
* Added support for syncing in `.toml` files ([#633])
|
||||||
|
* Add `plugin` flag to the `build` command that outputs to the local plugins folder ([#735])
|
||||||
|
|
||||||
[#668]: https://github.com/rojo-rbx/rojo/pull/668
|
[#668]: https://github.com/rojo-rbx/rojo/pull/668
|
||||||
[#674]: https://github.com/rojo-rbx/rojo/pull/674
|
[#674]: https://github.com/rojo-rbx/rojo/pull/674
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
[#725]: https://github.com/rojo-rbx/rojo/pull/725
|
[#725]: https://github.com/rojo-rbx/rojo/pull/725
|
||||||
[#726]: https://github.com/rojo-rbx/rojo/pull/726
|
[#726]: https://github.com/rojo-rbx/rojo/pull/726
|
||||||
[#633]: https://github.com/rojo-rbx/rojo/pull/633
|
[#633]: https://github.com/rojo-rbx/rojo/pull/633
|
||||||
|
[#735]: https://github.com/rojo-rbx/rojo/pull/735
|
||||||
|
|
||||||
## [7.3.0] - April 22, 2023
|
## [7.3.0] - April 22, 2023
|
||||||
* Added `$attributes` to project format. ([#574])
|
* Added `$attributes` to project format. ([#574])
|
||||||
|
|||||||
@@ -31,11 +31,12 @@ fn bench_build_place(c: &mut Criterion, name: &str, path: &str) {
|
|||||||
fn place_setup<P: AsRef<Path>>(input_path: P) -> (TempDir, BuildCommand) {
|
fn place_setup<P: AsRef<Path>>(input_path: P) -> (TempDir, BuildCommand) {
|
||||||
let dir = tempdir().unwrap();
|
let dir = tempdir().unwrap();
|
||||||
let input = input_path.as_ref().to_path_buf();
|
let input = input_path.as_ref().to_path_buf();
|
||||||
let output = dir.path().join("output.rbxlx");
|
let output = Some(dir.path().join("output.rbxlx"));
|
||||||
|
|
||||||
let options = BuildCommand {
|
let options = BuildCommand {
|
||||||
project: input,
|
project: input,
|
||||||
watch: false,
|
watch: false,
|
||||||
|
plugin: None,
|
||||||
output,
|
output,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::{bail, Context};
|
||||||
use clap::Parser;
|
use clap::{CommandFactory, Parser};
|
||||||
use fs_err::File;
|
use fs_err::File;
|
||||||
use memofs::Vfs;
|
use memofs::Vfs;
|
||||||
|
use roblox_install::RobloxStudio;
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
use crate::serve_session::ServeSession;
|
use crate::serve_session::ServeSession;
|
||||||
@@ -16,6 +17,8 @@ use super::resolve_path;
|
|||||||
|
|
||||||
const UNKNOWN_OUTPUT_KIND_ERR: &str = "Could not detect what kind of file to build. \
|
const UNKNOWN_OUTPUT_KIND_ERR: &str = "Could not detect what kind of file to build. \
|
||||||
Expected output file to end in .rbxl, .rbxlx, .rbxm, or .rbxmx.";
|
Expected output file to end in .rbxl, .rbxlx, .rbxm, or .rbxmx.";
|
||||||
|
const UNKNOWN_PLUGIN_KIND_ERR: &str = "Could not detect what kind of file to build. \
|
||||||
|
Expected plugin file to end in .rbxm or .rbxmx.";
|
||||||
|
|
||||||
/// Generates a model or place file from the Rojo project.
|
/// Generates a model or place file from the Rojo project.
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
@@ -28,7 +31,13 @@ pub struct BuildCommand {
|
|||||||
///
|
///
|
||||||
/// Should end in .rbxm, .rbxl, .rbxmx, or .rbxlx.
|
/// Should end in .rbxm, .rbxl, .rbxmx, or .rbxlx.
|
||||||
#[clap(long, short)]
|
#[clap(long, short)]
|
||||||
pub output: PathBuf,
|
pub output: Option<PathBuf>,
|
||||||
|
|
||||||
|
/// Alternative to the output flag that outputs the result in the local plugins folder.
|
||||||
|
///
|
||||||
|
/// Should end in .rbxm or .rbxl.
|
||||||
|
#[clap(long, short)]
|
||||||
|
pub plugin: Option<PathBuf>,
|
||||||
|
|
||||||
/// Whether to automatically rebuild when any input files change.
|
/// Whether to automatically rebuild when any input files change.
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
@@ -37,18 +46,52 @@ pub struct BuildCommand {
|
|||||||
|
|
||||||
impl BuildCommand {
|
impl BuildCommand {
|
||||||
pub fn run(self) -> anyhow::Result<()> {
|
pub fn run(self) -> anyhow::Result<()> {
|
||||||
let project_path = resolve_path(&self.project);
|
let (output_path, output_kind) = match (self.output, self.plugin) {
|
||||||
|
(Some(_), Some(_)) => {
|
||||||
|
BuildCommand::command()
|
||||||
|
.error(
|
||||||
|
clap::ErrorKind::ArgumentConflict,
|
||||||
|
"the argument '--output <OUTPUT>' cannot be used with '--plugin <PLUGIN>'",
|
||||||
|
)
|
||||||
|
.exit();
|
||||||
|
}
|
||||||
|
(None, None) => {
|
||||||
|
BuildCommand::command()
|
||||||
|
.error(
|
||||||
|
clap::ErrorKind::MissingRequiredArgument,
|
||||||
|
"one of the following arguments must be provided: \n --output <OUTPUT>\n --plugin <PLUGIN>",
|
||||||
|
)
|
||||||
|
.exit();
|
||||||
|
}
|
||||||
|
(Some(output), None) => {
|
||||||
|
let output_kind =
|
||||||
|
OutputKind::from_output_path(&output).context(UNKNOWN_OUTPUT_KIND_ERR)?;
|
||||||
|
|
||||||
let output_kind = detect_output_kind(&self.output).context(UNKNOWN_OUTPUT_KIND_ERR)?;
|
(output, output_kind)
|
||||||
|
}
|
||||||
|
(None, Some(plugin)) => {
|
||||||
|
if plugin.is_absolute() {
|
||||||
|
bail!("plugin flag path cannot be absolute.")
|
||||||
|
}
|
||||||
|
|
||||||
|
let output_kind =
|
||||||
|
OutputKind::from_plugin_path(&plugin).context(UNKNOWN_PLUGIN_KIND_ERR)?;
|
||||||
|
let studio = RobloxStudio::locate()?;
|
||||||
|
|
||||||
|
(studio.plugins_path().join(&plugin), output_kind)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let project_path = resolve_path(&self.project);
|
||||||
|
|
||||||
log::trace!("Constructing in-memory filesystem");
|
log::trace!("Constructing in-memory filesystem");
|
||||||
let vfs = Vfs::new_default();
|
let vfs = Vfs::new_default();
|
||||||
vfs.set_watch_enabled(self.watch);
|
vfs.set_watch_enabled(self.watch);
|
||||||
|
|
||||||
let session = ServeSession::new(vfs, &project_path)?;
|
let session = ServeSession::new(vfs, project_path)?;
|
||||||
let mut cursor = session.message_queue().cursor();
|
let mut cursor = session.message_queue().cursor();
|
||||||
|
|
||||||
write_model(&session, &self.output, output_kind)?;
|
write_model(&session, &output_path, output_kind)?;
|
||||||
|
|
||||||
if self.watch {
|
if self.watch {
|
||||||
let rt = Runtime::new().unwrap();
|
let rt = Runtime::new().unwrap();
|
||||||
@@ -58,7 +101,7 @@ impl BuildCommand {
|
|||||||
let (new_cursor, _patch_set) = rt.block_on(receiver).unwrap();
|
let (new_cursor, _patch_set) = rt.block_on(receiver).unwrap();
|
||||||
cursor = new_cursor;
|
cursor = new_cursor;
|
||||||
|
|
||||||
write_model(&session, &self.output, output_kind)?;
|
write_model(&session, &output_path, output_kind)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +129,8 @@ enum OutputKind {
|
|||||||
Rbxl,
|
Rbxl,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn detect_output_kind(output: &Path) -> Option<OutputKind> {
|
impl OutputKind {
|
||||||
|
fn from_output_path(output: &Path) -> Option<OutputKind> {
|
||||||
let extension = output.extension()?.to_str()?;
|
let extension = output.extension()?.to_str()?;
|
||||||
|
|
||||||
match extension {
|
match extension {
|
||||||
@@ -98,6 +142,17 @@ fn detect_output_kind(output: &Path) -> Option<OutputKind> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn from_plugin_path(output: &Path) -> Option<OutputKind> {
|
||||||
|
let extension = output.extension()?.to_str()?;
|
||||||
|
|
||||||
|
match extension {
|
||||||
|
"rbxmx" => Some(OutputKind::Rbxmx),
|
||||||
|
"rbxm" => Some(OutputKind::Rbxm),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn xml_encode_config() -> rbx_xml::EncodeOptions {
|
fn xml_encode_config() -> rbx_xml::EncodeOptions {
|
||||||
rbx_xml::EncodeOptions::new().property_behavior(rbx_xml::EncodePropertyBehavior::WriteUnknown)
|
rbx_xml::EncodeOptions::new().property_behavior(rbx_xml::EncodePropertyBehavior::WriteUnknown)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user