Skip to content

Commit

Permalink
Bring back dprectool, dragging Rust along with it
Browse files Browse the repository at this point in the history
It should work mostly the same, the command line flags are the same and
the behavior should also match up for the most part.

This reintroduces Rust into the project, only at the fringes for now, so
it can yet be avoided with -DTOOLS=OFF. But it will probably be
integrated into Drawdance to deal with stuff like file handling and
such, where using C is just terrible damage. The integration is less of
a back-and-forth mess than it was with Rustpile, since we no longer do
any linking in Rust space, we only produce static libraries in it and
let cmake deal with actually putting the executables together.
  • Loading branch information
askmeaboutlo0m committed Aug 31, 2023
1 parent 45deaf3 commit 38b741d
Show file tree
Hide file tree
Showing 18 changed files with 1,075 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ if(SERVER)
endif()

if(TOOLS)
message(STATUS "Someone deleted the tools")
message(STATUS "Adding tools")
# Currently only the command-line tools use Rust, so this is included here.
include(Cargo)
add_subdirectory(src/tools)
endif()

# This must run once all target creation is finished since it walks the list of
Expand Down
296 changes: 296 additions & 0 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[workspace]
members = []
resolver = "2"
members = [
"src/drawdance/rust",
"src/tools/dprectool",
]

[workspace.package]
version = "2.2.0-pre"
Expand Down
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Unreleased Version 2.2.0-pre
* Fix: Turn off input event compression, which causes jaggy lines on slow devices.
* Feature: Draw a hatching pattern on frames in the timeline that are the same as the currently visible one, making it easier to figure out if it's being re-used.
* Fix: Make flipbook extend the playback range if it was on the last frame and new ones are added to the timeline.
* Feature: Bring back dprectool, the command-line tool that converts Drawpile recordings. It should work mostly the same as it did in Drawpile 2.1.

2023-08-26 Version 2.2.0-beta.7
* Fix: Make classic brushes not go brighter when smudging into transparency. Thanks to cada for reporting.
Expand Down
11 changes: 6 additions & 5 deletions pkg/custom-apprun.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ case "${1-}" in
--client)
shift
;;
--tools)
exec=usr/bin/drawpile-cli
--dprectool)
exec=usr/bin/dprectool
shift
;;
--help)
Expand All @@ -26,9 +26,10 @@ case "${1-}" in
echo "--server"
echo " Runs the Drawpile dedicated server."
fi
if [ -x "$this_dir"/usr/bin/drawpile-cli ]; then
echo "--tools"
echo " Runs the Drawpile command-line tools."
if [ -x "$this_dir"/usr/bin/dprectool ]; then
echo "--dprectool"
echo " Runs dprectool, a command-line tool for"
echo " interconverting Drawpile recordings."
fi
exit 0
;;
Expand Down
10 changes: 10 additions & 0 deletions src/drawdance/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "drawdance"
version = "2.2.0-pre"
edition = "2021"

[lib]
path = "lib.rs"

[build-dependencies]
bindgen = "0.66.1"
26 changes: 26 additions & 0 deletions src/drawdance/rust/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
use std::env;
use std::path::PathBuf;

fn main() {
println!("cargo:rerun-if-changed=wrapper.h");

let bindings = bindgen::Builder::default()
.header("wrapper.h")
.clang_arg("-I../bundled")
.clang_arg("-I../libcommon")
.clang_arg("-I../libmsg")
.clang_arg("-I../libengine")
.allowlist_function("(DP|json)_.*")
.allowlist_type("(DP|JSON)_.*")
.allowlist_var("DP_.*")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.prepend_enum_name(false)
.generate()
.expect("Couldn't generate bindings for drawdance");

let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings for drawdance");
}
7 changes: 7 additions & 0 deletions src/drawdance/rust/engine/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later

mod player;
mod recorder;

pub use player::{Player, PlayerError};
pub use recorder::{Recorder, RecorderError};
Loading

0 comments on commit 38b741d

Please sign in to comment.