From 285c8215b0e220ed95c395a3151e01575633389a Mon Sep 17 00:00:00 2001 From: emir4169 Date: Wed, 30 Jul 2025 22:55:50 +0300 Subject: [PATCH 1/8] fix building for linux --- Cargo.toml | 4 ++-- Makefile.toml | 66 ++++++++++++++++++++++++++++++++++++++++++++------- src/game.rs | 6 +++-- 3 files changed, 63 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3f389c9..bf3af18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ crate-type = ["cdylib", "rlib"] path = "src/game.rs" [[bin]] -name = "one_clicker-windows" +name = "one_clicker-game" path = "src/desktop_main.rs" # Audio formats should be enabled only in bevy_kira_audio @@ -35,7 +35,7 @@ rand = "0.8" bevy_tweening = "0.6" bevy_ninepatch = "0.9" iyes_loopless = "0.9" -bevy_embedded_assets = "0.6" +#bevy_embedded_assets = "0.7" bevy_asset_loader = { version = "0.14", features = ["stageless"] } winapi = { version = "0.3", features = ["winbase","std"]} # Native dependencies diff --git a/Makefile.toml b/Makefile.toml index d6bf91d..54727c1 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -1,8 +1,9 @@ [env] PROJECT_NAME = '${CARGO_MAKE_CRATE_FS_NAME}' -WINDOWS_TARGET = 'x86_64-pc-windows-msvc' -WINDOWS_EXE_NAME = '${PROJECT_NAME}-windows.exe' # Should match whatever is set in Cargo.toml - +WINDOWS_TARGET = 'x86_64-pc-windows-gnu' +WINDOWS_EXE_NAME = '${PROJECT_NAME}-game.exe' # Should match whatever is set in Cargo.toml +LINUX_TARGET = 'x86_64-unknown-linux-gnu' +LINUX_EXE_NAME = '${PROJECT_NAME}-game' [tasks.prepare-release-dir] condition = { env_set = ['PLATFORM'] } @@ -10,10 +11,25 @@ script_runner = '@duckscript' script = ''' rm -r release/${PLATFORM} mkdir release/${PLATFORM} +mkdir release/${PLATFORM}/assets ''' [tasks.zip-platform] condition = { env_set = ['PLATFORM'] } + +[tasks.copy_assets] +condition = { env_set = ['PLATFORM'] } +script_runner = "@shell" +script = ''' +cp assets/game/embedded/* release/${PLATFORM}/assets/ -r +''' +[tasks.copy_assets_linux] +env = { 'PLATFORM' = 'linux' } +run_task = 'copy_assets' +[tasks.copy_assets_windows] +env = { 'PLATFORM' = 'windows' } +run_task = 'copy_assets' + # TODO: Use something more lightweight here to zip the files script_runner = '@rust' script = ''' @@ -96,7 +112,7 @@ run_task = 'prepare-release-dir' [tasks.compile-web] command = 'wasm-pack' args = ['build', '--target', 'web'] -install_crate = { crate_name = 'wasm-pack', test_arg = '--help' } +#install_crate = { crate_name = 'wasm-pack', test_arg = '--help' } [tasks.distrib-web] env = { 'PLATFORM' = 'web' } @@ -138,7 +154,7 @@ args = ['build', '--release', '--target', '${WINDOWS_TARGET}'] [tasks.distrib-windows] env = { 'PLATFORM' = 'windows' } -dependencies = ['prepare-release-dir-windows', 'compile-windows'] +dependencies = ['prepare-release-dir-windows', 'compile-windows','copy_assets_windows'] script_runner = '@duckscript' script = ''' cp target/${WINDOWS_TARGET}/release/${WINDOWS_EXE_NAME} release/${PLATFORM}/${WINDOWS_EXE_NAME} @@ -158,13 +174,45 @@ script = ''' exec ${BUTLER_EXE} push release/windows ${ITCH_USER}/${ITCH_GAME}:windows --userversion ${CARGO_MAKE_PROJECT_VERSION} ''' +[tasks.prepare-release-dir-linux] +env = { 'PLATFORM' = 'linux' } +run_task = 'prepare-release-dir' + +[tasks.compile-linux] +command = 'cargo' +args = ['build', '--release', '--target', '${LINUX_TARGET}'] + +[tasks.distrib-linux] +env = { 'PLATFORM' = 'linux' } +dependencies = ['prepare-release-dir-linux', 'compile-linux', 'copy_assets_linux'] +script_runner = '@duckscript' +script = ''' +cp target/${LINUX_TARGET}/release/${LINUX_EXE_NAME} release/${PLATFORM}/${LINUX_EXE_NAME} +''' +[tasks.run-linux] +condition = { env_set = ['PLATFORM'] } +dependencies = ['distrib-linux'] +script = ''' +release/${PLATFORM}/${LINUX_EXE_NAME} +''' +[tasks.run-windows] +condition = { env_set = ['PLATFORM'] } +dependencies = ['distrib-windows'] +script = ''' +start release/${PLATFORM}/${WINDOWS_EXE_NAME} +''' +[tasks.zip-linux] +env = { 'PLATFORM' = 'linux' } +dependencies = ['distrib-linux'] +run_task = 'zip-platform' + [tasks.distrib] -description = 'Builds Web and Windows versions and places them into the release directory' -run_task = { name = ['distrib-web', 'distrib-windows'] } +description = 'Builds Web, Windows and Linux versions and places them into the release directory' +run_task = { name = ['distrib-web', 'distrib-windows', 'distrib-linux'] } [tasks.zip] -description = 'Creates a ZIP archive containing both Web and Windows builds' -run_task = { name = ['zip-web', 'zip-windows'] } +description = 'Creates a ZIP archive containing all three builds' +run_task = { name = ['zip-web', 'zip-windows', 'zip-linux'] } [tasks.publish] env_files = [ './butler.env' ] diff --git a/src/game.rs b/src/game.rs index 68712ae..b072bf3 100644 --- a/src/game.rs +++ b/src/game.rs @@ -1,6 +1,5 @@ use bevy::prelude::*; use bevy_asset_loader::prelude::*; -use bevy_embedded_assets::EmbeddedAssetPlugin; use bevy_kira_audio::AudioPlugin; use bevy_ninepatch::NinePatchPlugin; use bevy_tweening::TweeningPlugin; @@ -28,8 +27,11 @@ pub fn run(app: &mut App) { ..default() }) .build() - .add_before::(EmbeddedAssetPlugin), ) + //.add_plugin(AssetPlugin{ + // asset_folder: "assets\\game\\embedded".to_string(), + // watch_for_changes: true, + //}) .add_plugin(AudioPlugin) .add_plugin(NinePatchPlugin::<()>::default()) .add_plugin(TweeningPlugin) From 5fd9908b81e26066b8acdbf96c05483147be68fc Mon Sep 17 00:00:00 2001 From: emir4169 Date: Wed, 30 Jul 2025 22:58:01 +0300 Subject: [PATCH 2/8] forgot about this one --- Cargo.toml | 4 ++-- Makefile.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bf3af18..a524eb9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,10 +13,10 @@ path = "src/desktop_main.rs" # Audio formats should be enabled only in bevy_kira_audio [dependencies.bevy] -version = "0.9" +version = "0.10" default-features = false features = [ - "render", + #"render", "bevy_winit", "png", "x11", diff --git a/Makefile.toml b/Makefile.toml index 54727c1..20db0b1 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -1,6 +1,6 @@ [env] PROJECT_NAME = '${CARGO_MAKE_CRATE_FS_NAME}' -WINDOWS_TARGET = 'x86_64-pc-windows-gnu' +WINDOWS_TARGET = 'x86_64-pc-windows-msvc' WINDOWS_EXE_NAME = '${PROJECT_NAME}-game.exe' # Should match whatever is set in Cargo.toml LINUX_TARGET = 'x86_64-unknown-linux-gnu' LINUX_EXE_NAME = '${PROJECT_NAME}-game' From 5e918280563514a76ebaa2f422a6102e651ffc8f Mon Sep 17 00:00:00 2001 From: emir4169 Date: Wed, 30 Jul 2025 23:02:48 +0300 Subject: [PATCH 3/8] dont mind the attempted bevy update --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a524eb9..bf3af18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,10 +13,10 @@ path = "src/desktop_main.rs" # Audio formats should be enabled only in bevy_kira_audio [dependencies.bevy] -version = "0.10" +version = "0.9" default-features = false features = [ - #"render", + "render", "bevy_winit", "png", "x11", From a08572fbd10aff7f5e6342a000f2bed65cbfc9ff Mon Sep 17 00:00:00 2001 From: emir4169 Date: Wed, 30 Jul 2025 23:06:26 +0300 Subject: [PATCH 4/8] bring back wasm-pack installer (i commented it out because it was annoying me) --- Makefile.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.toml b/Makefile.toml index 20db0b1..c21b1d5 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -112,7 +112,7 @@ run_task = 'prepare-release-dir' [tasks.compile-web] command = 'wasm-pack' args = ['build', '--target', 'web'] -#install_crate = { crate_name = 'wasm-pack', test_arg = '--help' } +install_crate = { crate_name = 'wasm-pack', test_arg = '--help' } [tasks.distrib-web] env = { 'PLATFORM' = 'web' } From b2c8b385623801b0fa968ddb59710b7315c3a266 Mon Sep 17 00:00:00 2001 From: emir4169 Date: Wed, 30 Jul 2025 23:07:18 +0300 Subject: [PATCH 5/8] this should fix web even tho i cant test it --- Makefile.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.toml b/Makefile.toml index c21b1d5..205c6a1 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -116,8 +116,8 @@ install_crate = { crate_name = 'wasm-pack', test_arg = '--help' } [tasks.distrib-web] env = { 'PLATFORM' = 'web' } -dependencies = ['prepare-release-dir-web', 'compile-web'] script_runner = '@duckscript' +dependencies = ['prepare-release-dir-web', 'compile-web','copy_assets'] script = ''' cp pkg/${PROJECT_NAME}_bg.wasm release/${PLATFORM}/${PROJECT_NAME}.wasm cp pkg/${PROJECT_NAME}.js release/${PLATFORM}/${PROJECT_NAME}.js From 83b231a82dca879471a2d6971b69ebb770b72563 Mon Sep 17 00:00:00 2001 From: emir4169 Date: Wed, 30 Jul 2025 23:26:22 +0300 Subject: [PATCH 6/8] gee i sure do wonder why copy_assets_windows was broken --- Makefile.toml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 205c6a1..87c7898 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -14,8 +14,7 @@ mkdir release/${PLATFORM} mkdir release/${PLATFORM}/assets ''' -[tasks.zip-platform] -condition = { env_set = ['PLATFORM'] } + [tasks.copy_assets] condition = { env_set = ['PLATFORM'] } @@ -26,10 +25,13 @@ cp assets/game/embedded/* release/${PLATFORM}/assets/ -r [tasks.copy_assets_linux] env = { 'PLATFORM' = 'linux' } run_task = 'copy_assets' + [tasks.copy_assets_windows] env = { 'PLATFORM' = 'windows' } run_task = 'copy_assets' +[tasks.zip-platform] +condition = { env_set = ['PLATFORM'] } # TODO: Use something more lightweight here to zip the files script_runner = '@rust' script = ''' From 5dc6a6508462371327849b1ee1ffb90af24044c1 Mon Sep 17 00:00:00 2001 From: emir4169 Date: Wed, 30 Jul 2025 23:33:42 +0300 Subject: [PATCH 7/8] linux to windows crosscompilation stuff --- Makefile.toml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Makefile.toml b/Makefile.toml index 87c7898..41037bf 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -1,6 +1,7 @@ [env] PROJECT_NAME = '${CARGO_MAKE_CRATE_FS_NAME}' WINDOWS_TARGET = 'x86_64-pc-windows-msvc' +LINUX_WINDOWS_CC_TARGET = 'x86_64-pc-windows-gnu' # for compiling for windows on linux WINDOWS_EXE_NAME = '${PROJECT_NAME}-game.exe' # Should match whatever is set in Cargo.toml LINUX_TARGET = 'x86_64-unknown-linux-gnu' LINUX_EXE_NAME = '${PROJECT_NAME}-game' @@ -154,6 +155,11 @@ run_task = 'prepare-release-dir' command = 'cargo' args = ['build', '--release', '--target', '${WINDOWS_TARGET}'] +[tasks.compile-linux2windows] +command = 'cargo' +args = ['build', '--release', '--target', '${LINUX_WINDOWS_CC_TARGET}'] + + [tasks.distrib-windows] env = { 'PLATFORM' = 'windows' } dependencies = ['prepare-release-dir-windows', 'compile-windows','copy_assets_windows'] @@ -161,6 +167,13 @@ script_runner = '@duckscript' script = ''' cp target/${WINDOWS_TARGET}/release/${WINDOWS_EXE_NAME} release/${PLATFORM}/${WINDOWS_EXE_NAME} ''' +[tasks.distrib-linux2windows] +env = { 'PLATFORM' = 'windows' } +dependencies = ['prepare-release-dir-windows', 'compile-linux2windows','copy_assets_windows'] +script_runner = '@duckscript' +script = ''' +cp target/${LINUX_WINDOWS_CC_TARGET}/release/${WINDOWS_EXE_NAME} release/${PLATFORM}/${WINDOWS_EXE_NAME} +''' [tasks.zip-windows] env = { 'PLATFORM' = 'windows' } @@ -175,6 +188,19 @@ script_runner = '@duckscript' script = ''' exec ${BUTLER_EXE} push release/windows ${ITCH_USER}/${ITCH_GAME}:windows --userversion ${CARGO_MAKE_PROJECT_VERSION} ''' +[tasks.zip-linux2windows] +env = { 'PLATFORM' = 'windows' } +dependencies = ['distrib-linux2windows'] +run_task = 'zip-platform' + +[tasks.publish-linux2windows] +env = { 'PLATFORM' = 'windows' } +dependencies = ['distrib-linux2windows'] +condition = { env_set = ['BUTLER_EXE'] } +script_runner = '@duckscript' +script = ''' +exec ${BUTLER_EXE} push release/windows ${ITCH_USER}/${ITCH_GAME}:windows --userversion ${CARGO_MAKE_PROJECT_VERSION} +''' [tasks.prepare-release-dir-linux] env = { 'PLATFORM' = 'linux' } @@ -203,6 +229,12 @@ dependencies = ['distrib-windows'] script = ''' start release/${PLATFORM}/${WINDOWS_EXE_NAME} ''' +[tasks.run-linux2windows] +condition = { env_set = ['PLATFORM'] } +dependencies = ['distrib-linux2windows'] +script = ''' +wine release/${PLATFORM}/${WINDOWS_EXE_NAME} +''' [tasks.zip-linux] env = { 'PLATFORM' = 'linux' } dependencies = ['distrib-linux'] From c789e252efdf072e25b2ead1e61db8e30d71bfb4 Mon Sep 17 00:00:00 2001 From: emir4169 Date: Thu, 31 Jul 2025 00:09:15 +0300 Subject: [PATCH 8/8] stuff --- Cargo.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index bf3af18..94d83fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,13 @@ console_error_panic_hook = "0.1" web-sys = { version = "0.3", features = ["Window"] } gloo-events = "0.1" wasm-bindgen = "0.2" - +[target.'cfg(target_arch = "wasm32")'.dependencies.uuid] +version = "1.17.0" +# Lets you generate random UUIDs +features = [ + "v4", + "js", +] [profile.dev.package."*"] # Compile all dependencies as release for extra fast opt-level=3