Skip to content

Commit

Permalink
Fix Linux publishing not working, add publish+create functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamVenner committed Oct 1, 2023
1 parent 14e97d0 commit 40277e4
Show file tree
Hide file tree
Showing 14 changed files with 238 additions and 145 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ jobs:
matrix:
target: ["--all", "--package fastgmad"]
release: ["", "--release"]
features: ["", "--all-features", "--features workshop"]
features: ["", "--features binary", "--features workshop"]
exclude:
# Exclude combinations that are not needed
- target: "--all"
features: "--features workshop"
- target: "--all"
features: "--all-features"
- target: "--package fastgmad"
features: "--all-features"
features: "--features binary"
steps:
- uses: actions/checkout@v2
- name: Check
Expand Down
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"rust-analyzer.cargo.features": "all",
"rust-analyzer.check.features": [
"binary"
],
"editor.formatOnSave": true
}
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ An extremely fast reimplementation of gmad.exe and gmpublish.exe.
## Features

* Up to **x100 faster** than gmad.exe
* Publish/update Workshop addons **without creating a .GMA**
* Create, extract and publish GMAs **all in one tool**
* Upload addon icons in PNG, JPG or **even GIF format**
* Drop-in replacement for gmad.exe and gmpublish.exe - **usage is identical**
Expand Down Expand Up @@ -45,16 +46,18 @@ fastgmad extract -stdin -out path/to/folder
Publishing GMAs
---------------
>> You can publish .GMAs OR addon directories (a .GMA will be automatically created for you) <<
>> Adding an icon is OPTIONAL for publishing a new Workshop addon. A default icon will be provided for you if you don't add one. <<
Accepted Icon Formats: JPG, PNG, GIF
Icon Max Size: 1 MB
Recommended Icon Dimensions: 512x512
fastgmad publish -addon path/to/gma.gma -icon path/to/icon
fastgmad update -id 1337 -addon path/to/gma.gma
fastgmad update -id 1337 -addon path/to/gma.gma -icon path/to/icon
fastgmad update -id 1337 -addon path/to/gma.gma -changes "fixed something"
fastgmad update -id 1337 -addon path/to/gma.gma -changes "fixed something" -icon path/to/icon
fastgmad publish -addon path/to/addon -icon path/to/icon
fastgmad update -id 1337 -addon path/to/addon
fastgmad update -id 1337 -addon path/to/addon -icon path/to/icon
fastgmad update -id 1337 -addon path/to/addon -changes "fixed something"
fastgmad update -id 1337 -addon path/to/addon -changes "fixed something" -icon path/to/icon
Additional flags
----------------
Expand Down
11 changes: 10 additions & 1 deletion fastgmad-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ fn main() {
log::error!("Make sure these shared libraries are present in the same directory & dynamic linker search path as fastgmad, otherwise Workshop publishing will not work");
}
log::error!("Additionally, it is not recommended to install fastgmad directly in the bin directory of Garry's Mod, as Garry's Mod itself may use a different version of the Steam API and updates can break this. If you have done this, and replaced files in the process, you may have broken your game and will need to verify integrity cache.");

#[cfg(debug_assertions)]
{
eprintln!();
log::error!("DEBUG ASSERTIONS ARE ON: If you're developing fastgmad, don't forget to type `cargo build --all --features binary` to generate the dependencies. Also, you need to `cargo run` with `--features binary`");
}

eprintln!();
Err(err).unwrap()
}
Expand Down Expand Up @@ -136,7 +143,7 @@ fn bin() -> Result<(), FastGmadBinError> {
} else {
match cmd.to_str() {
Some("create") => {
let (conf, out) = CreateGmaConfig::from_args()?;
let (conf, out) = CreateGmaConfig::from_args(std::env::args_os().skip(2))?;
create(conf, out, &mut exit)
}

Expand Down Expand Up @@ -196,6 +203,7 @@ fn extract(conf: ExtractGmaConfig, r#in: ExtractGmadIn, exit: &mut impl FnMut())
Ok(())
}

#[cfg(any(feature = "binary", feature = "workshop"))]
fn publish(conf: WorkshopPublishConfig) -> Result<(), FastGmadBinError> {
// TODO allow both creation+publishing in a single command
let id = fastgmad::workshop::publish_gma(&conf)?;
Expand All @@ -204,6 +212,7 @@ fn publish(conf: WorkshopPublishConfig) -> Result<(), FastGmadBinError> {
Ok(())
}

#[cfg(any(feature = "binary", feature = "workshop"))]
fn update(conf: WorkshopUpdateConfig) -> Result<(), FastGmadBinError> {
log::warn!(
">> You are UPDATING the Workshop item https://steamcommunity.com/sharedfiles/filedetails/?id={} <<\n",
Expand Down
12 changes: 7 additions & 5 deletions fastgmad-bin/src/usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ fastgmad extract -stdin -out path/to/folder

Publishing GMAs
---------------
>> You can publish .GMAs OR addon directories (a .GMA will be automatically created for you) <<
>> Adding an icon is OPTIONAL for publishing a new Workshop addon. A default icon will be provided for you if you don't add one. <<

Accepted Icon Formats: JPG, PNG, GIF
Icon Max Size: 1 MB
Recommended Icon Dimensions: 512x512

fastgmad publish -addon path/to/gma.gma -icon path/to/icon
fastgmad update -id 1337 -addon path/to/gma.gma
fastgmad update -id 1337 -addon path/to/gma.gma -icon path/to/icon
fastgmad update -id 1337 -addon path/to/gma.gma -changes "fixed something"
fastgmad update -id 1337 -addon path/to/gma.gma -changes "fixed something" -icon path/to/icon
fastgmad publish -addon path/to/addon -icon path/to/icon
fastgmad update -id 1337 -addon path/to/addon
fastgmad update -id 1337 -addon path/to/addon -icon path/to/icon
fastgmad update -id 1337 -addon path/to/addon -changes "fixed something"
fastgmad update -id 1337 -addon path/to/addon -changes "fixed something" -icon path/to/icon

Additional flags
----------------
Expand Down
13 changes: 9 additions & 4 deletions fastgmad-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ description = "Fast gmad and gmpublish implementation"
repository = "https://github.com/WilliamVenner/fastgmad"

[features]
binary = ["dep:libloading", "dep:ctrlc", "workshop"]
workshop = ["dep:steamworks"]
binary = ["dep:libloading", "dep:ctrlc", "dep:steamworks"]
workshop = ["dep:fastgmad-publish", "dep:steamworks"]

[dependencies]
walkdir = "2"
Expand All @@ -19,10 +19,15 @@ memchr = "2"
byteorder = "1"
uuid = { version = "1", features = ["v4"] }
log = "0.4"
thiserror = "1"

# `binary` dependencies
ctrlc = { version = "3", optional = true }
steamworks = { version = "0.9", optional = true }
libloading = { version = "0.8", optional = true }
thiserror = "1"

# `workshop` dependencies
fastgmad-publish = { path = "../fastgmad-publish", optional = true }
steamworks = { version = "0.10", optional = true }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["stringapiset"] }
Expand Down
7 changes: 5 additions & 2 deletions fastgmad-lib/src/create/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ pub struct CreateGmaConfig {
}
impl CreateGmaConfig {
#[cfg(feature = "binary")]
pub fn from_args() -> Result<(Self, CreateGmadOut), crate::util::PrintHelp> {
pub fn from_args(mut args: impl Iterator<Item = std::ffi::OsString>) -> Result<(Self, CreateGmadOut), crate::util::PrintHelp> {
use crate::util::PrintHelp;

let mut config = Self::default();
let mut out = None;

let mut args = std::env::args_os().skip(2);
while let Some(arg) = args.next() {
match arg.to_str().ok_or(PrintHelp(Some("Unknown GMAD creation argument")))? {
"-warninvalid" => {
Expand Down Expand Up @@ -81,6 +80,10 @@ impl CreateGmaConfig {
}
}

if config.folder.as_os_str().is_empty() {
return Err(PrintHelp(Some("Please provide a folder to create a GMA from")));
}

Ok((config, out.ok_or(PrintHelp(Some("Please provide an output path for GMAD creation")))?))
}
}
Expand Down
6 changes: 3 additions & 3 deletions fastgmad-lib/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ pub enum FastGmadErrorKind {
/// Shared library error
Libloading(#[from] libloading::Error),

#[cfg(feature = "workshop")]
#[cfg(any(feature = "workshop", feature = "binary"))]
#[error("Steam error ({0})")]
/// Steam error during publishing
SteamError(String),

#[cfg(feature = "workshop")]
#[cfg(any(feature = "workshop", feature = "binary"))]
#[error("Icon too large")]
/// Icon too large
IconTooLarge,

#[cfg(feature = "workshop")]
#[cfg(any(feature = "workshop", feature = "binary"))]
#[error("Icon too small")]
/// Icon too small
IconTooSmall,
Expand Down
5 changes: 4 additions & 1 deletion fastgmad-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#![cfg_attr(not(feature = "binary"), warn(missing_docs))]
#![allow(clippy::unnecessary_literal_unwrap)]

#[cfg(all(feature = "binary", feature = "workshop"))]
compile_error!("Cannot enable both `binary` and `workshop` features (`binary` implies `workshop`)");

const GMA_MAGIC: &[u8] = b"GMAD";
const GMA_VERSION: u8 = 3;

Expand All @@ -29,7 +32,7 @@ pub mod extract;
/// GMA file pattern whitelist
pub mod whitelist;

#[cfg(feature = "workshop")]
#[cfg(any(feature = "binary", feature = "workshop"))]
/// Workshop publishing
pub mod workshop;

Expand Down
Loading

0 comments on commit 40277e4

Please sign in to comment.