From 72c5a8b2db5c98fe251580eab5c64596d71027f0 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Sat, 9 Mar 2024 17:57:11 -0800 Subject: [PATCH 01/34] Use git submodule reference to libprojectM --- .gitmodules | 3 +++ Cargo.toml | 2 +- projectm-sys/Cargo.toml | 10 +++---- projectm-sys/build.rs | 57 ++++++++++++++++++++++++---------------- projectm-sys/libprojectM | 1 + 5 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 .gitmodules create mode 160000 projectm-sys/libprojectM diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..637cac7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "projectm-sys/libprojectM"] + path = projectm-sys/libprojectM + url = https://github.com/projectM-visualizer/projectm.git diff --git a/Cargo.toml b/Cargo.toml index e05ed68..744a15c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" [dependencies] libc = "0.2.147" -projectm-sys = { path = "projectm-sys", version = "1.0.8", features = ["playlist"] } +projectm-sys = { path = "projectm-sys", version = "1.1.0", features = ["playlist"] } rand = "0.8.5" [features] diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index e0a54ba..f2f9568 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "projectm-sys" -version = "1.0.8" +version = "1.1.0" edition = "2021" rust-version = "1.65" -authors = ["AnomieVision "] +authors = ["AnomieVision ", "Mischa Spiegelmock "] description = "Bindings for ProjectM" license = "LGPL-3.0-or-later" -repository = "https://github.com/anomievision/projectm-sys" +repository = "https://github.com/projectM-visualizer/projectm-rs" documentation = "https://docs.rs/projectm-sys/latest" keywords = ["visualization", "audio", "sound", "projectm"] categories = ["multimedia", "multimedia::video", "multimedia::audio"] @@ -17,9 +17,9 @@ links = "projectm" [build-dependencies] cmake = "0.1.50" -bindgen = "0.66.1" +bindgen = "0.69.4" lazy_static = "1.4.0" [features] default = ["playlist"] -playlist = [] \ No newline at end of file +playlist = [] diff --git a/projectm-sys/build.rs b/projectm-sys/build.rs index 03bba86..92fdd1b 100644 --- a/projectm-sys/build.rs +++ b/projectm-sys/build.rs @@ -1,30 +1,43 @@ -#[macro_use] extern crate lazy_static; -use std::{env, path::Path, process::Command}; +use lazy_static::lazy_static; +use std::env; +use std::path::PathBuf; +use std::process::{Command, Stdio}; mod build_bindgen; use crate::build_bindgen::bindgen; -lazy_static! { - static ref PROJECTM_BUILD: String = format!("{}/projectm", env::var("OUT_DIR").unwrap()); +fn update_submodules() -> Result<(), Box> { + let status = Command::new("git") + .args(["submodule", "update", "--init", "--recursive"]) + .stdout(Stdio::inherit()) // Optionally output stdout/stderr to help with debugging + .stderr(Stdio::inherit()) + .status()?; + + if !status.success() { + return Err(Box::new(std::io::Error::new( + std::io::ErrorKind::Other, + "Submodule update failed", + ))); + } + + Ok(()) } fn main() { - if !Path::new(PROJECTM_BUILD.as_str()).exists() { - let _ = Command::new("git") - .args([ - "-c", - "advice.detachedHead=false", - "clone", - "--recurse-submodules", - "--depth=1", - "--branch", - "v4.0.0", - "https://github.com/projectM-visualizer/projectm.git", - &PROJECTM_BUILD, - ]) - .status(); + let projectm_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("libprojectM"); + + // Ensure the submodule is updated and initialized + if !projectm_path.exists() { + println!("cargo:warning=The libprojectM submodule is not checked out. Please run 'git submodule update --init --recursive' and try building again."); + std::process::exit(1); + } + + // Attempt to update and initialize submodules recursively + if let Err(e) = update_submodules() { + println!("cargo:warning=Failed to update submodules: {}", e); + std::process::exit(1); } // Feature: enable-playlist @@ -37,7 +50,7 @@ fn main() { } #[cfg(target_os = "windows")] - let dst = cmake::Config::new(PROJECTM_BUILD.as_str()) + let dst = cmake::Config::new(&*projectm_path) .generator("Visual Studio 17 2022") .define( "CMAKE_TOOLCHAIN_FILE", @@ -55,17 +68,17 @@ fn main() { .build(); #[cfg(target_os = "linux")] - let dst = cmake::Config::new(PROJECTM_BUILD.as_str()) + let dst = cmake::Config::new(&*projectm_path) .define("ENABLE_PLAYLIST", enable_playlist().as_str()) .build(); #[cfg(target_os = "macos")] - let dst = cmake::Config::new(PROJECTM_BUILD.as_str()) + let dst = cmake::Config::new(&*projectm_path) .define("ENABLE_PLAYLIST", enable_playlist().as_str()) .build(); #[cfg(target_os = "emscripten")] - let dst = cmake::Config::new(PROJECTM_BUILD.as_str()) + let dst = cmake::Config::new(&*projectm_path) .define("ENABLE_PLAYLIST", enable_playlist().as_str()) .define("ENABLE_EMSCRIPTEN", "ON") .build(); diff --git a/projectm-sys/libprojectM b/projectm-sys/libprojectM new file mode 160000 index 0000000..50c64d4 --- /dev/null +++ b/projectm-sys/libprojectM @@ -0,0 +1 @@ +Subproject commit 50c64d4e653a9f6dcb97f59f377b8796eed278fe From 69700a8cd76bacf70cf582d72b662f7a9315f151 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Sat, 9 Mar 2024 17:59:59 -0800 Subject: [PATCH 02/34] v4.1.0 --- .gitmodules | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitmodules b/.gitmodules index 637cac7..fb80c48 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,5 @@ [submodule "projectm-sys/libprojectM"] path = projectm-sys/libprojectM url = https://github.com/projectM-visualizer/projectm.git +[submodule "libprojectM"] + branch = v4.1.0 From 04341cb956fc375a994ef817f6df881f7ce01cb3 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Sat, 9 Mar 2024 18:02:38 -0800 Subject: [PATCH 03/34] bump --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 744a15c..3a59755 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "projectm" -version = "2.0.1-alpha" +version = "4.1.0-alpha.1" edition = "2021" rust-version = "1.65" -authors = ["AnomieVision "] +authors = ["AnomieVision ", "Mischa Spiegelmock " description = "Bindings for ProjectM" license = " LGPL-3.0-or-later" repository = "https://github.com/projectM-visualizer/projectm-rs" #https://github.com/anomievision/projectm-rs From 3359b15ea1703faf37c0384610aae8531eced822 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Sat, 9 Mar 2024 18:03:04 -0800 Subject: [PATCH 04/34] bump --- projectm-sys/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index f2f9568..2420916 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm-sys" -version = "1.1.0" +version = "4.1.0-alpha.1" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "] From f90e3fb0c8cfe1fc6746d387627a82456c6dd2c4 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Sat, 9 Mar 2024 18:04:03 -0800 Subject: [PATCH 05/34] oops --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3a59755..55ca5c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "projectm" version = "4.1.0-alpha.1" edition = "2021" rust-version = "1.65" -authors = ["AnomieVision ", "Mischa Spiegelmock " +authors = ["AnomieVision ", "Mischa Spiegelmock "] description = "Bindings for ProjectM" license = " LGPL-3.0-or-later" repository = "https://github.com/projectM-visualizer/projectm-rs" #https://github.com/anomievision/projectm-rs From a36a96450e800931d939c02ae7777dc4a886d04c Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Sat, 9 Mar 2024 18:04:19 -0800 Subject: [PATCH 06/34] oops --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 55ca5c4..349df45 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" [dependencies] libc = "0.2.147" -projectm-sys = { path = "projectm-sys", version = "1.1.0", features = ["playlist"] } +projectm-sys = { path = "projectm-sys", version = "4.1.0-alpha.1", features = ["playlist"] } rand = "0.8.5" [features] From 1820e464d74ba34f7f240c4888480b0f8daf383a Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Tue, 22 Oct 2024 17:13:22 -0700 Subject: [PATCH 07/34] projectm-4.1.2 --- projectm-sys/Cargo.toml | 2 +- projectm-sys/libprojectM | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index 2420916..a5c72ca 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm-sys" -version = "4.1.0-alpha.1" +version = "4.1.2" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "] diff --git a/projectm-sys/libprojectM b/projectm-sys/libprojectM index 50c64d4..db035da 160000 --- a/projectm-sys/libprojectM +++ b/projectm-sys/libprojectM @@ -1 +1 @@ -Subproject commit 50c64d4e653a9f6dcb97f59f377b8796eed278fe +Subproject commit db035da5623b46ac6313b3b84d9c1ecbfc405b7b From 470705ce919455306aae1cd5671e3d945ca91754 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Tue, 22 Oct 2024 17:14:01 -0700 Subject: [PATCH 08/34] projectm-4.1.2 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 349df45..c74849e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm" -version = "4.1.0-alpha.1" +version = "4.1.2" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "] From 4399b86ce8318504be057bec8b7d2852bd199a51 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Tue, 22 Oct 2024 17:15:07 -0700 Subject: [PATCH 09/34] projectm-4.1.2 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c74849e..1d442c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" [dependencies] libc = "0.2.147" -projectm-sys = { path = "projectm-sys", version = "4.1.0-alpha.1", features = ["playlist"] } +projectm-sys = { path = "projectm-sys", version = "4.1.2", features = ["playlist"] } rand = "0.8.5" [features] From 65be5519279de0256deb264aa89eaeed8d242f54 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Tue, 22 Oct 2024 17:15:28 -0700 Subject: [PATCH 10/34] projectm-4.1.2 --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index fb80c48..a330f63 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,4 +2,4 @@ path = projectm-sys/libprojectM url = https://github.com/projectM-visualizer/projectm.git [submodule "libprojectM"] - branch = v4.1.0 + branch = v4.1.2 From 8805c9eda7fc6e9e39b5eddbd5024e09a338898c Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Tue, 22 Oct 2024 17:16:18 -0700 Subject: [PATCH 11/34] ignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 088ba6b..67366cb 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,7 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk + +.DS_Store + +.idea/ \ No newline at end of file From 6c698d665958560625814902a5f2ca2c65ca1162 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Tue, 22 Oct 2024 17:34:22 -0700 Subject: [PATCH 12/34] exclude --- Cargo.toml | 3 ++- projectm-sys/Cargo.toml | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1d442c9..2daa75e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,8 @@ readme = "README.md" [dependencies] libc = "0.2.147" -projectm-sys = { path = "projectm-sys", version = "4.1.2", features = ["playlist"] } +#projectm-sys = { path = "projectm-sys", version = "4.1.2", features = ["playlist"] } +projectm-sys = { version = "4.1.2", features = ["playlist"] } rand = "0.8.5" [features] diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index a5c72ca..41cb4e1 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -13,6 +13,9 @@ categories = ["multimedia", "multimedia::video", "multimedia::audio"] readme = "README.md" links = "projectm" +include = ["src/**", "Cargo.toml", "build.rs", "README.md", "LICENSE"] +exclude = ["docs/**", "libprojectM/docs/**", "libprojectM/web/**", "libprojectM/screenshots/**"] + [dependencies] [build-dependencies] From 64f88f7e52eae7f660fe7dbc7fbff0702943f82a Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Tue, 22 Oct 2024 19:04:18 -0700 Subject: [PATCH 13/34] make package smaller --- projectm-sys/Cargo.toml | 25 +++++++++++++++++++++++-- projectm-sys/build_bindgen.rs | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index 41cb4e1..e0c1ae0 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -8,12 +8,33 @@ description = "Bindings for ProjectM" license = "LGPL-3.0-or-later" repository = "https://github.com/projectM-visualizer/projectm-rs" documentation = "https://docs.rs/projectm-sys/latest" -keywords = ["visualization", "audio", "sound", "projectm"] +keywords = ["visualization", "audio", "sound", "projectm"] categories = ["multimedia", "multimedia::video", "multimedia::audio"] readme = "README.md" links = "projectm" -include = ["src/**", "Cargo.toml", "build.rs", "README.md", "LICENSE"] +include = ["src/**", + "src/**", + "Cargo.toml", + "build.rs", + "README.md", + "LICENSE", + "build_bindgen.rs", + "libprojectM/CMakeLists.txt", + "libprojectM/src/**", + "libprojectM/include/**", + "libprojectM/presets/**", + "libprojectM/cmake/**", + "libprojectM/vendor/**", + "libprojectM/vendor/projectm-eval/**", + "libprojectM/vendor/**/CMakeLists.txt", + "libprojectM/vendor/**/cmake/**", + "libprojectM/**/*.cmake", + "libprojectM/**/*.h", + "libprojectM/**/*.hpp", + "libprojectM/config*", + "bindgen/**", +] exclude = ["docs/**", "libprojectM/docs/**", "libprojectM/web/**", "libprojectM/screenshots/**"] [dependencies] diff --git a/projectm-sys/build_bindgen.rs b/projectm-sys/build_bindgen.rs index 07399ff..5f00b9d 100644 --- a/projectm-sys/build_bindgen.rs +++ b/projectm-sys/build_bindgen.rs @@ -18,7 +18,7 @@ pub fn bindgen() { .header(get_header()) .allowlist_function("projectm_.*") .clang_arg(format!("-I{}/include", out_dir.display())) - .parse_callbacks(Box::new(bindgen::CargoCallbacks)) + .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) .generate() .expect("Unable to generate bindings"); From 946b74f43ef28501e0a8c2a8d88f7a0da5f636ee Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 23 Oct 2024 09:14:07 -0700 Subject: [PATCH 14/34] version updates --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2daa75e..5e49d4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,14 +7,14 @@ authors = ["AnomieVision ", "Mischa Spiegelmock Date: Wed, 30 Oct 2024 20:13:15 -0700 Subject: [PATCH 15/34] improve packaging of libprojectM source --- projectm-sys/Cargo.toml | 34 +++++---- projectm-sys/build.rs | 164 +++++++++++----------------------------- 2 files changed, 63 insertions(+), 135 deletions(-) diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index e0c1ae0..3ed5ab1 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm-sys" -version = "4.1.2" +version = "4.1.2-1" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "] @@ -13,29 +13,31 @@ categories = ["multimedia", "multimedia::video", "multimedia::audio"] readme = "README.md" links = "projectm" -include = ["src/**", +include = [ "src/**", "Cargo.toml", "build.rs", "README.md", "LICENSE", "build_bindgen.rs", - "libprojectM/CMakeLists.txt", - "libprojectM/src/**", - "libprojectM/include/**", - "libprojectM/presets/**", - "libprojectM/cmake/**", - "libprojectM/vendor/**", - "libprojectM/vendor/projectm-eval/**", - "libprojectM/vendor/**/CMakeLists.txt", - "libprojectM/vendor/**/cmake/**", - "libprojectM/**/*.cmake", - "libprojectM/**/*.h", - "libprojectM/**/*.hpp", - "libprojectM/config*", + "libprojectM/**", "bindgen/**", ] -exclude = ["docs/**", "libprojectM/docs/**", "libprojectM/web/**", "libprojectM/screenshots/**"] + +# Exclude unnecessary files to reduce crate size +exclude = [ + "docs/**", + "libprojectM/docs/**", + "libprojectM/web/**", + "libprojectM/screenshots/**", + "libprojectM/tests/**", + "libprojectM/examples/**", + "libprojectM/.git/**", + "libprojectM/.github/**", + "libprojectM/*.md", + ".git/**", + ".gitmodules", +] [dependencies] diff --git a/projectm-sys/build.rs b/projectm-sys/build.rs index 92fdd1b..c5f693f 100644 --- a/projectm-sys/build.rs +++ b/projectm-sys/build.rs @@ -1,141 +1,67 @@ -extern crate lazy_static; - -use lazy_static::lazy_static; use std::env; use std::path::PathBuf; -use std::process::{Command, Stdio}; mod build_bindgen; use crate::build_bindgen::bindgen; -fn update_submodules() -> Result<(), Box> { - let status = Command::new("git") - .args(["submodule", "update", "--init", "--recursive"]) - .stdout(Stdio::inherit()) // Optionally output stdout/stderr to help with debugging - .stderr(Stdio::inherit()) - .status()?; - - if !status.success() { - return Err(Box::new(std::io::Error::new( - std::io::ErrorKind::Other, - "Submodule update failed", - ))); - } - - Ok(()) -} - fn main() { let projectm_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("libprojectM"); - // Ensure the submodule is updated and initialized + // Check if the libprojectM source code exists if !projectm_path.exists() { - println!("cargo:warning=The libprojectM submodule is not checked out. Please run 'git submodule update --init --recursive' and try building again."); - std::process::exit(1); - } - - // Attempt to update and initialize submodules recursively - if let Err(e) = update_submodules() { - println!("cargo:warning=Failed to update submodules: {}", e); + println!("cargo:warning=The libprojectM source code is missing."); + println!("cargo:warning=If you are building from a git clone, please run 'git submodule update --init --recursive'."); + println!("cargo:warning=If you downloaded this crate from crates.io, please ensure that the crate was packaged correctly."); std::process::exit(1); } - // Feature: enable-playlist - fn enable_playlist() -> String { - if cfg!(feature = "playlist") { - "ON".to_string() - } else { - "OFF".to_string() - } - } - - #[cfg(target_os = "windows")] - let dst = cmake::Config::new(&*projectm_path) - .generator("Visual Studio 17 2022") - .define( - "CMAKE_TOOLCHAIN_FILE", - format!( - "{}/scripts/buildsystems/vcpkg.cmake", - env::var("VCPKG_INSTALLATION_ROOT").unwrap() - ), - ) - .define("VCPKG_TARGET_TRIPLET", "x64-windows-static-md") - .define( - "CMAKE_MSVC_RUNTIME_LIBRARY", - "MultiThreaded$<$:Debug>DLL", - ) - .define("ENABLE_PLAYLIST", enable_playlist().as_str()) - .build(); - - #[cfg(target_os = "linux")] - let dst = cmake::Config::new(&*projectm_path) - .define("ENABLE_PLAYLIST", enable_playlist().as_str()) - .build(); - - #[cfg(target_os = "macos")] - let dst = cmake::Config::new(&*projectm_path) - .define("ENABLE_PLAYLIST", enable_playlist().as_str()) - .build(); - - #[cfg(target_os = "emscripten")] - let dst = cmake::Config::new(&*projectm_path) - .define("ENABLE_PLAYLIST", enable_playlist().as_str()) - .define("ENABLE_EMSCRIPTEN", "ON") - .build(); - - println!("cargo:rustc-link-search=native={}/lib", dst.display()); - - #[cfg(target_os = "windows")] - if Ok("release".to_owned()) == env::var("PROFILE") { - println!("cargo:rustc-link-lib=dylib=projectM-4"); - - #[cfg(feature = "playlist")] - println!("cargo:rustc-link-lib=dylib=projectM-4-playlist"); - } else { - println!("cargo:rustc-link-lib=dylib=projectM-4d"); - - #[cfg(feature = "playlist")] - println!("cargo:rustc-link-lib=dylib=projectM-4-playlistd"); - } - - #[cfg(target_os = "linux")] - if Ok("release".to_owned()) == env::var("PROFILE") { - println!("cargo:rustc-link-lib=dylib=libprojectM=4"); - - #[cfg(feature = "playlist")] - println!("cargo:rustc-link-lib=dylib=projectM-4-playlist"); + // Determine if the 'playlist' feature is enabled + let enable_playlist = if cfg!(feature = "playlist") { + "ON" } else { - println!("cargo:rustc-link-lib=dylib=projectM-4d"); - - #[cfg(feature = "playlist")] - println!("cargo:rustc-link-lib=dylib=projectM-4-playlistd"); + "OFF" + }; + + // Configure and build libprojectM using CMake + let mut cmake_config = cmake::Config::new(&projectm_path); + cmake_config.define("ENABLE_PLAYLIST", enable_playlist); + + // Platform-specific configurations + if cfg!(target_os = "windows") { + // Ensure VCPKG is set up correctly + let vcpkg_root = env::var("VCPKG_INSTALLATION_ROOT").expect("VCPKG_INSTALLATION_ROOT is not set"); + cmake_config + .generator("Visual Studio 17 2022") + .define( + "CMAKE_TOOLCHAIN_FILE", + format!("{}/scripts/buildsystems/vcpkg.cmake", vcpkg_root), + ) + .define("VCPKG_TARGET_TRIPLET", "x64-windows-static-md") + .define( + "CMAKE_MSVC_RUNTIME_LIBRARY", + "MultiThreaded$<$:Debug>DLL", + ); + } else if cfg!(target_os = "emscripten") { + cmake_config.define("ENABLE_EMSCRIPTEN", "ON"); } - #[cfg(target_os = "macos")] - if Ok("release".to_owned()) == env::var("PROFILE") { - println!("cargo:rustc-link-lib=dylib=projectM-4"); - - #[cfg(feature = "playlist")] - println!("cargo:rustc-link-lib=dylib=projectM-4-playlist"); - } else { - println!("cargo:rustc-link-lib=dylib=projectM-4d"); + let dst = cmake_config.build(); - #[cfg(feature = "playlist")] - println!("cargo:rustc-link-lib=dylib=projectM-4-playlistd"); - } + println!("cargo:rustc-link-search=native={}/lib", dst.display()); - #[cfg(target_os = "emscripten")] - if Ok("release".to_owned()) == env::var("PROFILE") { - println!("cargo:rustc-link-lib=static=projectM-4"); + // Determine the library name based on the build profile + let profile = env::var("PROFILE").unwrap(); + let lib_suffix = if profile == "release" { "" } else { "d" }; + let lib_name = format!("projectM-4{}", lib_suffix); - #[cfg(feature = "playlist")] - println!("cargo:rustc-link-lib=dylib=projectM-4-playlist"); - } else { - println!("cargo:rustc-link-lib=static=projectM-4d"); + println!("cargo:rustc-link-lib=dylib={}", lib_name); - #[cfg(feature = "playlist")] - println!("cargo:rustc-link-lib=dylib=projectM-4-playlistd"); + // Handle the 'playlist' feature + if cfg!(feature = "playlist") { + let playlist_lib_name = format!("{}-playlist", lib_name); + println!("cargo:rustc-link-lib=dylib={}", playlist_lib_name); } - bindgen() -} + // Run bindgen to generate Rust bindings + bindgen(); +} \ No newline at end of file From 807bb6dadcb0b87710a2d52e6f3377e8024920bb Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 20:14:25 -0700 Subject: [PATCH 16/34] improve packaging of libprojectM source --- projectm-sys/build.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/projectm-sys/build.rs b/projectm-sys/build.rs index c5f693f..73c6722 100644 --- a/projectm-sys/build.rs +++ b/projectm-sys/build.rs @@ -28,8 +28,13 @@ fn main() { // Platform-specific configurations if cfg!(target_os = "windows") { - // Ensure VCPKG is set up correctly - let vcpkg_root = env::var("VCPKG_INSTALLATION_ROOT").expect("VCPKG_INSTALLATION_ROOT is not set"); + let vcpkg_root = match env::var("VCPKG_INSTALLATION_ROOT") { + Ok(val) => val, + Err(_) => { + println!("cargo:warning=VCPKG_INSTALLATION_ROOT is not set. Please set it to your VCPKG installation directory."); + std::process::exit(1); + } + }; cmake_config .generator("Visual Studio 17 2022") .define( @@ -50,7 +55,7 @@ fn main() { println!("cargo:rustc-link-search=native={}/lib", dst.display()); // Determine the library name based on the build profile - let profile = env::var("PROFILE").unwrap(); + let profile = env::var("PROFILE").unwrap_or_else(|_| "release".to_string()); let lib_suffix = if profile == "release" { "" } else { "d" }; let lib_name = format!("projectM-4{}", lib_suffix); From 5d28d57bf6d4fe6b24882a552ffb5cfce650495e Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 20:25:08 -0700 Subject: [PATCH 17/34] fix package include files list --- projectm-sys/Cargo.toml | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index 3ed5ab1..adabd96 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -20,25 +20,22 @@ include = [ "README.md", "LICENSE", "build_bindgen.rs", - "libprojectM/**", + "libprojectM/CMakeLists.txt", + "libprojectM/src/**", + "libprojectM/include/**", + "libprojectM/presets/CMakeLists.txt", + "libprojectM/cmake/**", + "libprojectM/vendor/**", + "libprojectM/vendor/projectm-eval/**", + "libprojectM/vendor/**/CMakeLists.txt", + "libprojectM/vendor/**/cmake/**", + "libprojectM/**/*.cmake", + "libprojectM/**/*.h", + "libprojectM/**/*.hpp", + "libprojectM/config*", "bindgen/**", ] -# Exclude unnecessary files to reduce crate size -exclude = [ - "docs/**", - "libprojectM/docs/**", - "libprojectM/web/**", - "libprojectM/screenshots/**", - "libprojectM/tests/**", - "libprojectM/examples/**", - "libprojectM/.git/**", - "libprojectM/.github/**", - "libprojectM/*.md", - ".git/**", - ".gitmodules", -] - [dependencies] [build-dependencies] From 414bf18504a81dd6e8a4dd137cb7a420c76ddb3a Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 20:37:33 -0700 Subject: [PATCH 18/34] bump versions --- Cargo.toml | 8 ++++---- projectm-sys/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5e49d4b..cb11614 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,10 +12,10 @@ categories = ["multimedia", "multimedia::video", "multimedia::audio"] readme = "README.md" [dependencies] -libc = "0.2.147" -projectm-sys = { path = "projectm-sys", version = "4.1.2", features = ["playlist"] } -#projectm-sys = { version = "4.1.2", features = ["playlist"] } -rand = "0.8.5" +libc = "0.2" +#projectm-sys = { path = "projectm-sys", version = "4.1.2-1", features = ["playlist"] } +projectm-sys = { version = "4.1.2-1", features = ["playlist"] } +rand = "0.8" [features] default = ["playlist"] diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index adabd96..b5184e2 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm-sys" -version = "4.1.2-1" +version = "4.1.3" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "] From fdcd0aa8c43872343067a07640d9dacc10153fa1 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 20:38:18 -0700 Subject: [PATCH 19/34] update bindgen --- projectm-sys/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index b5184e2..c427234 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -40,7 +40,7 @@ include = [ [build-dependencies] cmake = "0.1.50" -bindgen = "0.69.4" +bindgen = "0.70.1" lazy_static = "1.4.0" [features] From 4f690948d3e2afeb9994b7ec272214d0d1ed6b58 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 20:40:17 -0700 Subject: [PATCH 20/34] bump versions --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cb11614..89a5acf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm" -version = "4.1.2" +version = "4.1.3" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "] @@ -14,7 +14,7 @@ readme = "README.md" [dependencies] libc = "0.2" #projectm-sys = { path = "projectm-sys", version = "4.1.2-1", features = ["playlist"] } -projectm-sys = { version = "4.1.2-1", features = ["playlist"] } +projectm-sys = { version = "4.1.3", features = ["playlist"] } rand = "0.8" [features] From bce7df360c9ee2c5ac42c459a7b2e3e5a930262a Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 21:01:06 -0700 Subject: [PATCH 21/34] build paths --- Cargo.toml | 8 +++---- projectm-sys/Cargo.toml | 2 +- projectm-sys/build.rs | 53 +++++++++++++++++++---------------------- 3 files changed, 29 insertions(+), 34 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 89a5acf..f68e4ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm" -version = "4.1.3" +version = "2.0.1-rc.1" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "] @@ -13,10 +13,10 @@ readme = "README.md" [dependencies] libc = "0.2" -#projectm-sys = { path = "projectm-sys", version = "4.1.2-1", features = ["playlist"] } -projectm-sys = { version = "4.1.3", features = ["playlist"] } +projectm-sys = { path = "projectm-sys", version = "1", features = ["playlist"] } +#projectm-sys = { version = "4.1.3", features = ["playlist"] } rand = "0.8" [features] default = ["playlist"] -playlist = [] +playlist = ["projectm-sys/playlist"] \ No newline at end of file diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index c427234..4b50f67 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm-sys" -version = "4.1.3" +version = "1.0.9" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "] diff --git a/projectm-sys/build.rs b/projectm-sys/build.rs index 73c6722..9910478 100644 --- a/projectm-sys/build.rs +++ b/projectm-sys/build.rs @@ -5,12 +5,15 @@ mod build_bindgen; use crate::build_bindgen::bindgen; fn main() { - let projectm_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("libprojectM"); + let projectm_path = + PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("libprojectM"); // Check if the libprojectM source code exists if !projectm_path.exists() { println!("cargo:warning=The libprojectM source code is missing."); - println!("cargo:warning=If you are building from a git clone, please run 'git submodule update --init --recursive'."); + println!( + "cargo:warning=If you are building from a git clone, please run 'git submodule update --init --recursive'." + ); println!("cargo:warning=If you downloaded this crate from crates.io, please ensure that the crate was packaged correctly."); std::process::exit(1); } @@ -24,28 +27,14 @@ fn main() { // Configure and build libprojectM using CMake let mut cmake_config = cmake::Config::new(&projectm_path); - cmake_config.define("ENABLE_PLAYLIST", enable_playlist); + cmake_config + .define("ENABLE_PLAYLIST", enable_playlist) + .define("BUILD_TESTING", "OFF") + .define("BUILD_EXAMPLES", "OFF"); // Platform-specific configurations if cfg!(target_os = "windows") { - let vcpkg_root = match env::var("VCPKG_INSTALLATION_ROOT") { - Ok(val) => val, - Err(_) => { - println!("cargo:warning=VCPKG_INSTALLATION_ROOT is not set. Please set it to your VCPKG installation directory."); - std::process::exit(1); - } - }; - cmake_config - .generator("Visual Studio 17 2022") - .define( - "CMAKE_TOOLCHAIN_FILE", - format!("{}/scripts/buildsystems/vcpkg.cmake", vcpkg_root), - ) - .define("VCPKG_TARGET_TRIPLET", "x64-windows-static-md") - .define( - "CMAKE_MSVC_RUNTIME_LIBRARY", - "MultiThreaded$<$:Debug>DLL", - ); + // Windows-specific configurations (if any) } else if cfg!(target_os = "emscripten") { cmake_config.define("ENABLE_EMSCRIPTEN", "ON"); } @@ -54,17 +43,23 @@ fn main() { println!("cargo:rustc-link-search=native={}/lib", dst.display()); + // Determine the library name based on the build profile // Determine the library name based on the build profile let profile = env::var("PROFILE").unwrap_or_else(|_| "release".to_string()); - let lib_suffix = if profile == "release" { "" } else { "d" }; - let lib_name = format!("projectM-4{}", lib_suffix); - - println!("cargo:rustc-link-lib=dylib={}", lib_name); - // Handle the 'playlist' feature - if cfg!(feature = "playlist") { - let playlist_lib_name = format!("{}-playlist", lib_name); - println!("cargo:rustc-link-lib=dylib={}", playlist_lib_name); + if profile == "release" { + // Release mode library names + println!("cargo:rustc-link-lib=dylib=projectM-4"); + if cfg!(feature = "playlist") { + println!("cargo:rustc-link-lib=dylib=projectM-4-playlist"); + } + } else { + // Debug mode library names + println!("cargo:rustc-link-lib=dylib=projectM-4d"); + if cfg!(feature = "playlist") { + // Adjusted to match the actual library name + println!("cargo:rustc-link-lib=dylib=projectM-4-playlistd"); + } } // Run bindgen to generate Rust bindings From ec5881ee802db71cb70dfd54faa452b7ffae44e4 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 21:01:49 -0700 Subject: [PATCH 22/34] rc --- Cargo.toml | 2 +- projectm-sys/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f68e4ba..6575b57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" [dependencies] libc = "0.2" -projectm-sys = { path = "projectm-sys", version = "1", features = ["playlist"] } +projectm-sys = { path = "projectm-sys", version = "1.0.9-rc.1", features = ["playlist"] } #projectm-sys = { version = "4.1.3", features = ["playlist"] } rand = "0.8" diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index 4b50f67..5902720 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm-sys" -version = "1.0.9" +version = "1.0.9-rc.1" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "] From 12579f61e0be988666275de664cbdb3c8a69e17e Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 21:05:28 -0700 Subject: [PATCH 23/34] bump versions --- Cargo.toml | 4 ++-- projectm-sys/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6575b57..f75d400 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm" -version = "2.0.1-rc.1" +version = "2.0.1" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "] @@ -14,7 +14,7 @@ readme = "README.md" [dependencies] libc = "0.2" projectm-sys = { path = "projectm-sys", version = "1.0.9-rc.1", features = ["playlist"] } -#projectm-sys = { version = "4.1.3", features = ["playlist"] } +#projectm-sys = { version = "1.0.9-rc.1", features = ["playlist"] } rand = "0.8" [features] diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index 5902720..4b50f67 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm-sys" -version = "1.0.9-rc.1" +version = "1.0.9" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "] From 6c9480a9d8ccf3536ddbb8113d0bc2c921e32f38 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 21:09:20 -0700 Subject: [PATCH 24/34] fmt --- projectm-sys/build.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/projectm-sys/build.rs b/projectm-sys/build.rs index 9910478..46ae405 100644 --- a/projectm-sys/build.rs +++ b/projectm-sys/build.rs @@ -5,8 +5,7 @@ mod build_bindgen; use crate::build_bindgen::bindgen; fn main() { - let projectm_path = - PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("libprojectM"); + let projectm_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("libprojectM"); // Check if the libprojectM source code exists if !projectm_path.exists() { @@ -64,4 +63,4 @@ fn main() { // Run bindgen to generate Rust bindings bindgen(); -} \ No newline at end of file +} From edea9fb1435099d1afce9d37e1c2fc2919eef173 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 21:13:17 -0700 Subject: [PATCH 25/34] update submodules when cloning --- .github/workflows/build_emscripten.yml | 4 +++- .github/workflows/build_linux.yml | 6 ++++-- .github/workflows/build_osx.yml | 4 +++- .github/workflows/build_windows.yml | 8 +++++--- .github/workflows/publish_crate.yml | 6 ++++-- .github/workflows/publish_sys_crate.yml | 6 ++++-- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build_emscripten.yml b/.github/workflows/build_emscripten.yml index f7fb510..dd83a9f 100644 --- a/.github/workflows/build_emscripten.yml +++ b/.github/workflows/build_emscripten.yml @@ -20,7 +20,9 @@ jobs: RUST_BACKTRACE: full steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup EMSDK uses: mymindstorm/setup-emsdk@v11 diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index e732b9f..ac7ee8c 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -20,8 +20,10 @@ jobs: RUST_BACKTRACE: full steps: - - uses: actions/checkout@v3 - + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install Packages run: | sudo apt-get update diff --git a/.github/workflows/build_osx.yml b/.github/workflows/build_osx.yml index 3a0949d..a472547 100644 --- a/.github/workflows/build_osx.yml +++ b/.github/workflows/build_osx.yml @@ -20,7 +20,9 @@ jobs: RUST_BACKTRACE: full steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + submodules: recursive - name: Update Local Toolchain run: | diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 1e37ae9..c56aaa7 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -20,11 +20,13 @@ jobs: RUST_BACKTRACE: full steps: - - uses: actions/checkout@v3 - + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install Dependencies run: vcpkg --triplet=x64-windows-static-md install glew - + - name: Update Local Toolchain run: | rustup update diff --git a/.github/workflows/publish_crate.yml b/.github/workflows/publish_crate.yml index 61cd036..99194f6 100644 --- a/.github/workflows/publish_crate.yml +++ b/.github/workflows/publish_crate.yml @@ -13,7 +13,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + submodules: recursive - name: Install Packages run: | @@ -52,6 +54,6 @@ jobs: - name: Publish env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} run: | cargo publish --token $CARGO_REGISTRY_TOKEN \ No newline at end of file diff --git a/.github/workflows/publish_sys_crate.yml b/.github/workflows/publish_sys_crate.yml index 46b7170..7183f1a 100644 --- a/.github/workflows/publish_sys_crate.yml +++ b/.github/workflows/publish_sys_crate.yml @@ -13,7 +13,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + submodules: recursive - name: Install Packages run: | @@ -45,7 +47,7 @@ jobs: - name: Publish env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} run: | cd projectm-sys cargo publish --token $CARGO_REGISTRY_TOKEN \ No newline at end of file From fb8bc84b6956f8db8bececff1ea2e9bb73bc3a4a Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 21:16:16 -0700 Subject: [PATCH 26/34] versions --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f75d400..625f68e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,8 @@ readme = "README.md" [dependencies] libc = "0.2" -projectm-sys = { path = "projectm-sys", version = "1.0.9-rc.1", features = ["playlist"] } -#projectm-sys = { version = "1.0.9-rc.1", features = ["playlist"] } +#projectm-sys = { path = "projectm-sys", version = "1.0.9-rc.1", features = ["playlist"] } +projectm-sys = { version = "1.0.9" } rand = "0.8" [features] From 5a3c3e8fa9b186adcbbc2e5d2c67013f8430f445 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 21:31:17 -0700 Subject: [PATCH 27/34] add vcpkg stuff back --- projectm-sys/Cargo.toml | 1 + projectm-sys/build.rs | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index 4b50f67..be655c2 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -33,6 +33,7 @@ include = [ "libprojectM/**/*.h", "libprojectM/**/*.hpp", "libprojectM/config*", + "libprojectM/vcpkg*", "bindgen/**", ] diff --git a/projectm-sys/build.rs b/projectm-sys/build.rs index 46ae405..2fcb479 100644 --- a/projectm-sys/build.rs +++ b/projectm-sys/build.rs @@ -33,7 +33,24 @@ fn main() { // Platform-specific configurations if cfg!(target_os = "windows") { - // Windows-specific configurations (if any) + let vcpkg_root = match env::var("VCPKG_INSTALLATION_ROOT") { + Ok(val) => val, + Err(_) => { + println!("cargo:warning=VCPKG_INSTALLATION_ROOT is not set. Please set it to your VCPKG installation directory."); + std::process::exit(1); + } + }; + cmake_config + .generator("Visual Studio 17 2022") + .define( + "CMAKE_TOOLCHAIN_FILE", + format!("{}/scripts/buildsystems/vcpkg.cmake", vcpkg_root), + ) + .define("VCPKG_TARGET_TRIPLET", "x64-windows-static-md") + .define( + "CMAKE_MSVC_RUNTIME_LIBRARY", + "MultiThreaded$<$:Debug>DLL", + ); } else if cfg!(target_os = "emscripten") { cmake_config.define("ENABLE_EMSCRIPTEN", "ON"); } From d9230fe02528856513a8a1bd74b90f117fbb187d Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 21:43:34 -0700 Subject: [PATCH 28/34] restore platform-specific build steps --- projectm-sys/build.rs | 54 ++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/projectm-sys/build.rs b/projectm-sys/build.rs index 2fcb479..a2cb905 100644 --- a/projectm-sys/build.rs +++ b/projectm-sys/build.rs @@ -5,34 +5,25 @@ mod build_bindgen; use crate::build_bindgen::bindgen; fn main() { + // Get the path to the projectM source code let projectm_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("libprojectM"); // Check if the libprojectM source code exists if !projectm_path.exists() { println!("cargo:warning=The libprojectM source code is missing."); - println!( - "cargo:warning=If you are building from a git clone, please run 'git submodule update --init --recursive'." - ); + println!("cargo:warning=If you are building from a git clone, please run 'git submodule update --init --recursive'."); println!("cargo:warning=If you downloaded this crate from crates.io, please ensure that the crate was packaged correctly."); std::process::exit(1); } // Determine if the 'playlist' feature is enabled - let enable_playlist = if cfg!(feature = "playlist") { - "ON" - } else { - "OFF" - }; + let enable_playlist = if cfg!(feature = "playlist") { "ON" } else { "OFF" }; - // Configure and build libprojectM using CMake - let mut cmake_config = cmake::Config::new(&projectm_path); - cmake_config - .define("ENABLE_PLAYLIST", enable_playlist) - .define("BUILD_TESTING", "OFF") - .define("BUILD_EXAMPLES", "OFF"); + let dst; // Platform-specific configurations if cfg!(target_os = "windows") { + // Ensure VCPKG installation root is set let vcpkg_root = match env::var("VCPKG_INSTALLATION_ROOT") { Ok(val) => val, Err(_) => { @@ -40,7 +31,9 @@ fn main() { std::process::exit(1); } }; - cmake_config + + // Configure and build libprojectM using CMake for Windows + dst = cmake::Config::new(&projectm_path) .generator("Visual Studio 17 2022") .define( "CMAKE_TOOLCHAIN_FILE", @@ -50,34 +43,47 @@ fn main() { .define( "CMAKE_MSVC_RUNTIME_LIBRARY", "MultiThreaded$<$:Debug>DLL", - ); + ) + .define("ENABLE_PLAYLIST", enable_playlist) + .define("BUILD_TESTING", "OFF") + .define("BUILD_EXAMPLES", "OFF") + .build(); } else if cfg!(target_os = "emscripten") { - cmake_config.define("ENABLE_EMSCRIPTEN", "ON"); + // Configure and build libprojectM using CMake for Emscripten + dst = cmake::Config::new(&projectm_path) + .define("ENABLE_PLAYLIST", enable_playlist) + .define("BUILD_TESTING", "OFF") + .define("BUILD_EXAMPLES", "OFF") + .define("ENABLE_EMSCRIPTEN", "ON") + .build(); + } else { + // Configure and build libprojectM using CMake for other platforms + dst = cmake::Config::new(&projectm_path) + .define("ENABLE_PLAYLIST", enable_playlist) + .define("BUILD_TESTING", "OFF") + .define("BUILD_EXAMPLES", "OFF") + .build(); } - let dst = cmake_config.build(); - + // Specify the library search path println!("cargo:rustc-link-search=native={}/lib", dst.display()); - // Determine the library name based on the build profile // Determine the library name based on the build profile let profile = env::var("PROFILE").unwrap_or_else(|_| "release".to_string()); + // Platform-independent library linking if profile == "release" { - // Release mode library names println!("cargo:rustc-link-lib=dylib=projectM-4"); if cfg!(feature = "playlist") { println!("cargo:rustc-link-lib=dylib=projectM-4-playlist"); } } else { - // Debug mode library names println!("cargo:rustc-link-lib=dylib=projectM-4d"); if cfg!(feature = "playlist") { - // Adjusted to match the actual library name println!("cargo:rustc-link-lib=dylib=projectM-4-playlistd"); } } // Run bindgen to generate Rust bindings bindgen(); -} +} \ No newline at end of file From 9bf061bc0a45718865b058efcdb6035139bb18f4 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 21:47:08 -0700 Subject: [PATCH 29/34] use static linking on windows/emscripten --- projectm-sys/build.rs | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/projectm-sys/build.rs b/projectm-sys/build.rs index a2cb905..a485b62 100644 --- a/projectm-sys/build.rs +++ b/projectm-sys/build.rs @@ -71,16 +71,32 @@ fn main() { // Determine the library name based on the build profile let profile = env::var("PROFILE").unwrap_or_else(|_| "release".to_string()); - // Platform-independent library linking - if profile == "release" { - println!("cargo:rustc-link-lib=dylib=projectM-4"); - if cfg!(feature = "playlist") { - println!("cargo:rustc-link-lib=dylib=projectM-4-playlist"); + // Platform-specific library linking + if cfg!(target_os = "windows") || cfg!(target_os = "emscripten") { + // Use static linking for Windows and Emscripten + if profile == "release" { + println!("cargo:rustc-link-lib=static=projectM-4"); + if cfg!(feature = "playlist") { + println!("cargo:rustc-link-lib=static=projectM-4-playlist"); + } + } else { + println!("cargo:rustc-link-lib=static=projectM-4d"); + if cfg!(feature = "playlist") { + println!("cargo:rustc-link-lib=static=projectM-4-playlistd"); + } } } else { - println!("cargo:rustc-link-lib=dylib=projectM-4d"); - if cfg!(feature = "playlist") { - println!("cargo:rustc-link-lib=dylib=projectM-4-playlistd"); + // Use dynamic linking for other platforms (Linux, macOS) + if profile == "release" { + println!("cargo:rustc-link-lib=dylib=projectM-4"); + if cfg!(feature = "playlist") { + println!("cargo:rustc-link-lib=dylib=projectM-4-playlist"); + } + } else { + println!("cargo:rustc-link-lib=dylib=projectM-4d"); + if cfg!(feature = "playlist") { + println!("cargo:rustc-link-lib=dylib=projectM-4-playlistd"); + } } } From 17e567bdad02fa6dfa100305b9d13aa4e068df28 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 21:58:33 -0700 Subject: [PATCH 30/34] vcpkg root --- projectm-sys/Cargo.toml | 2 +- projectm-sys/build.rs | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index be655c2..295b799 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm-sys" -version = "1.0.9" +version = "1.0.10-rc.1" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "] diff --git a/projectm-sys/build.rs b/projectm-sys/build.rs index a485b62..c59f94c 100644 --- a/projectm-sys/build.rs +++ b/projectm-sys/build.rs @@ -6,12 +6,15 @@ use crate::build_bindgen::bindgen; fn main() { // Get the path to the projectM source code - let projectm_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("libprojectM"); + let projectm_path = + PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("libprojectM"); // Check if the libprojectM source code exists if !projectm_path.exists() { println!("cargo:warning=The libprojectM source code is missing."); - println!("cargo:warning=If you are building from a git clone, please run 'git submodule update --init --recursive'."); + println!( + "cargo:warning=If you are building from a git clone, please run 'git submodule update --init --recursive'." + ); println!("cargo:warning=If you downloaded this crate from crates.io, please ensure that the crate was packaged correctly."); std::process::exit(1); } @@ -32,12 +35,32 @@ fn main() { } }; + let vcpkg_root = PathBuf::from(vcpkg_root); + let vcpkg_toolchain = vcpkg_root + .join("scripts") + .join("buildsystems") + .join("vcpkg.cmake"); + + if !vcpkg_toolchain.exists() { + println!( + "cargo:warning=The vcpkg toolchain file was not found at: {}", + vcpkg_toolchain.display() + ); + std::process::exit(1); + } + + // Set VCPKG_ROOT for CMake + env::set_var("VCPKG_ROOT", &vcpkg_root); + + // Optionally set CMAKE_PREFIX_PATH + let vcpkg_installed = vcpkg_root.join("installed").join("x64-windows-static-md"); + // Configure and build libprojectM using CMake for Windows dst = cmake::Config::new(&projectm_path) .generator("Visual Studio 17 2022") .define( "CMAKE_TOOLCHAIN_FILE", - format!("{}/scripts/buildsystems/vcpkg.cmake", vcpkg_root), + &vcpkg_toolchain, ) .define("VCPKG_TARGET_TRIPLET", "x64-windows-static-md") .define( @@ -45,6 +68,12 @@ fn main() { "MultiThreaded$<$:Debug>DLL", ) .define("ENABLE_PLAYLIST", enable_playlist) + .define( + "projectM_Eval_DIR", + &projectm_path.join("vendor").join("projectm-eval"), + ) + .define("CMAKE_PREFIX_PATH", &vcpkg_installed) + .define("CMAKE_VERBOSE_MAKEFILE", "ON") .define("BUILD_TESTING", "OFF") .define("BUILD_EXAMPLES", "OFF") .build(); From 8b506ac6c33b52b3260880e5aabe6914da013969 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 21:59:30 -0700 Subject: [PATCH 31/34] bump versions --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 625f68e..178af7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" [dependencies] libc = "0.2" #projectm-sys = { path = "projectm-sys", version = "1.0.9-rc.1", features = ["playlist"] } -projectm-sys = { version = "1.0.9" } +projectm-sys = { version = "1.0.10-rc.1" } rand = "0.8" [features] From 9b624cc570b895d24e4a5c3b4a4e909ea958ebf6 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 22:06:41 -0700 Subject: [PATCH 32/34] bump versions --- Cargo.toml | 2 +- projectm-sys/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 178af7f..15fcb47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" [dependencies] libc = "0.2" #projectm-sys = { path = "projectm-sys", version = "1.0.9-rc.1", features = ["playlist"] } -projectm-sys = { version = "1.0.10-rc.1" } +projectm-sys = { version = "1.0.10" } rand = "0.8" [features] diff --git a/projectm-sys/Cargo.toml b/projectm-sys/Cargo.toml index 295b799..54a1eda 100644 --- a/projectm-sys/Cargo.toml +++ b/projectm-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm-sys" -version = "1.0.10-rc.1" +version = "1.0.10" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "] From ab92a6b27dd349597ad3f011744e7b747e3f5167 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 22:08:42 -0700 Subject: [PATCH 33/34] rustfmt --- projectm-sys/build.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/projectm-sys/build.rs b/projectm-sys/build.rs index c59f94c..43d20ee 100644 --- a/projectm-sys/build.rs +++ b/projectm-sys/build.rs @@ -6,8 +6,7 @@ use crate::build_bindgen::bindgen; fn main() { // Get the path to the projectM source code - let projectm_path = - PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("libprojectM"); + let projectm_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("libprojectM"); // Check if the libprojectM source code exists if !projectm_path.exists() { @@ -20,7 +19,11 @@ fn main() { } // Determine if the 'playlist' feature is enabled - let enable_playlist = if cfg!(feature = "playlist") { "ON" } else { "OFF" }; + let enable_playlist = if cfg!(feature = "playlist") { + "ON" + } else { + "OFF" + }; let dst; @@ -58,10 +61,7 @@ fn main() { // Configure and build libprojectM using CMake for Windows dst = cmake::Config::new(&projectm_path) .generator("Visual Studio 17 2022") - .define( - "CMAKE_TOOLCHAIN_FILE", - &vcpkg_toolchain, - ) + .define("CMAKE_TOOLCHAIN_FILE", &vcpkg_toolchain) .define("VCPKG_TARGET_TRIPLET", "x64-windows-static-md") .define( "CMAKE_MSVC_RUNTIME_LIBRARY", @@ -131,4 +131,4 @@ fn main() { // Run bindgen to generate Rust bindings bindgen(); -} \ No newline at end of file +} From ca72a3c5f6acf2f7935617cd81e47766108e221a Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 30 Oct 2024 22:21:45 -0700 Subject: [PATCH 34/34] bump versions --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 15fcb47..9dc90ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "projectm" -version = "2.0.1" +version = "2.0.2" edition = "2021" rust-version = "1.65" authors = ["AnomieVision ", "Mischa Spiegelmock "]