From afa61289a566cde77811b0d130463b26c08fc00b Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sat, 14 Jan 2023 16:13:58 +0100 Subject: [PATCH] INSTRUCTIONS --- README.md | 20 +++++++++----------- build_and_run.sh | 5 +++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b9841ad..9c96330 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,20 @@ ## How to build and run -### Prerequisites -- Gradle -- Rust toolchain +### On Linux -### Compile Rust code +Run `./build_and_run.sh` to build the Rust library and run the Java tests with it. -`cargo build` +If you want to use it in another project (for example, because you copied `RustPlayer` to your project to test it) then you need a little bit of extra setup. +You need to make sure that you set the `LD_LIBRARY_PATH` environment variable to the what is printed at the end of the script. Then everything will be fine. -### Copy shared library +If you don't like setting `LD_LIBRARY_PATH` then you can also run `sudo cp target/release/libminmax_wrapper.so /usr/lib/x86_64-linux-gnu/jni/` (if you're not on GNU/Linux because you use Alpine on your desktop, Iglunix or whatever crazy things people are doing these days) replace the `x86_64-linux-gnu` with your target triplet, but you are probably on GNU/Linux and don't need to worry about this and if you aren't you know all of this stuff anyways). After running the command you can just run `RustPlayer` without any setup. And your global Java native libs will be polluted forever. Or until you run `sudo rm /usr/lib/x86_64-linux-gnu/jni/libminmax_wrapper.so`. -Copy the shared library in `target/debug/librs_wrapper.so` (or a `.dll` on windows) to the current working directory or the system wide library directory. -### Build the jar +### On MacOS -Use `./gradlew jar` or whatever you like I don't know. +It should probably the same as linux? except for the `cp` part apples native library layout is different. but actually the error message will tell you where it looks so you can just copy it there i think? havent tested it -### Run the program +### On Windows -Maybe it works now. If you get a link error you might need to set the `LD_LIBRARY_PATH` env var to the path of the directory of the shared library (on linux). Or you have to copy it to the systems library directory. Or something else. But it should work. \ No newline at end of file +you're on your own but you can do this, it's similar to linux except you have to run `cargo build --release` yourself and have to `target/release/minmax_wrapper.dll` to the directories where the other library are (the link error message will tell you where that is) \ No newline at end of file diff --git a/build_and_run.sh b/build_and_run.sh index ed1b308..f1ecd7d 100755 --- a/build_and_run.sh +++ b/build_and_run.sh @@ -19,3 +19,8 @@ echo "Setting LD_LIBRARY_PATH to $LD_LIBRARY_PATH" echo "Running Java tests. If this fails, there's something wrong :/" cd "$SCRIPT_DIR/minmax-java" ./gradlew build + +echo +echo "To use this player in another project, set the following environment variable:" +echo +echo "export LD_LIBRARY_PATH=\"$SCRIPT_DIR/target/release\""