Skip to content

Commit

Permalink
Make accessing the emulator and importer easier
Browse files Browse the repository at this point in the history
  • Loading branch information
Aszarsha authored and baskerville committed Mar 3, 2020
1 parent 53dcb4a commit c4a5e04
Show file tree
Hide file tree
Showing 20 changed files with 546 additions and 271 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/armhf.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .github/workflows/dev.yml

This file was deleted.

3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
/css/*-user.css
/hyphenation-patterns
/dictionaries
/src/wrapper/*.so
/src/wrapper/*.dylib
/src/mupdf_wrapper/*/
/dist
/plato-*.zip
/thirdparty/*/*
Expand Down
14 changes: 0 additions & 14 deletions Dockerfile

This file was deleted.

29 changes: 0 additions & 29 deletions Dockerfile.dev

This file was deleted.

33 changes: 31 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,38 @@
use std::env;

fn main() {
if env::var("HOST") != env::var("TARGET") {
println!("cargo:rustc-flags=-L libs -l jpeg -l png16 -l openjp2 -l jbig2dec -l bz2 -l z -l m");
let target = env::var("TARGET").unwrap();

// Cross-compiling for Kobo.
if target == "arm-unknown-linux-gnueabihf" {
println!("cargo:rustc-env=PKG_CONFIG_ALLOW_CROSS=1");
println!("cargo:rustc-link-search=src/mupdf_wrapper/Kobo");
println!("cargo:rustc-link-search=libs");
println!("cargo:rustc-link-lib=dylib=stdc++");
// Handle the Linux and macOS platforms.
} else {
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();

match target_os.as_ref() {
"linux" => {
println!("cargo:rustc-link-search=src/mupdf_wrapper/Linux");
println!("cargo:rustc-link-lib=dylib=stdc++");
},
"macos" => {
println!("cargo:rustc-link-search=src/mupdf_wrapper/Darwin");
println!("cargo:rustc-link-lib=dylib=c++");
},
_ => panic!("Unsupported platform: {}.", target_os),
}

println!("cargo:rustc-link-lib=mupdf-third");
}

// Needed in all cases.
println!("cargo:rustc-link-lib=z");
println!("cargo:rustc-link-lib=bz2");
println!("cargo:rustc-link-lib=jpeg");
println!("cargo:rustc-link-lib=png16");
println!("cargo:rustc-link-lib=openjp2");
println!("cargo:rustc-link-lib=jbig2dec");
}
11 changes: 6 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ case "$method" in
fast)
./download.sh 'libs/*'
cd libs

ln -s libz.so.1 libz.so
ln -s libbz2.so.1.0 libbz2.so

Expand All @@ -24,15 +24,13 @@ case "$method" in

ln -s libdjvulibre.so.21 libdjvulibre.so
;;

slow)
shift
cd thirdparty
./download.sh "$@"
./build.sh "$@"
cd ..
cd src/wrapper
./build-kobo.sh
cd ../..

[ -e libs ] || mkdir libs

Expand All @@ -49,7 +47,6 @@ case "$method" in

cp thirdparty/djvulibre/libdjvu/.libs/libdjvulibre.so libs
cp thirdparty/mupdf/build/release/libmupdf.so libs
cp src/wrapper/libmupdfwrapper.so libs
;;

skip)
Expand All @@ -60,4 +57,8 @@ case "$method" in
;;
esac

cd src/mupdf_wrapper
./build-kobo.sh
cd ../..

cargo build --release --target=arm-unknown-linux-gnueabihf
1 change: 0 additions & 1 deletion dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ cp libs/libharfbuzz.so dist/libs/libharfbuzz.so.0

cp libs/libdjvulibre.so dist/libs/libdjvulibre.so.21
cp libs/libmupdf.so dist/libs
cp libs/libmupdfwrapper.so dist/libs

cp -R hyphenation-patterns dist
cp -R keyboard-layouts dist
Expand Down
28 changes: 25 additions & 3 deletions doc/BUILD.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## Preliminary
## Plato

### Preliminary

Install the appropriate [compiler toolchain](https://github.com/kobolabs/Kobo-Reader/tree/master/toolchain) (the binaries of the `bin` directory need to be in your path).

Expand All @@ -14,16 +16,36 @@ Install the appropriate target:
rustup target add arm-unknown-linux-gnueabihf
```

## Build Phase
### Build phase

```sh
git clone https://github.com/baskerville/plato.git
cd plato
./build.sh
```

## Distribution
### Distribution

```sh
./dist.sh
```

## Emulator and importer

Install the required dependencies: *MuPDF 1.16.1*, *DjVuLibre*, *HarfBuzz*, *OpenJPEG*, *jpeg*, *jbig2dec*, *zlib*.

### Emulator

Install one additional dependency: *SDL2*.

You can then run the emulator with:
```sh
./run-emulator.sh
```

### Importer

You can install the importer with:
```sh
./install-importer.sh
```
18 changes: 0 additions & 18 deletions doc/EMULATOR.md

This file was deleted.

18 changes: 0 additions & 18 deletions doc/IMPORTER.md

This file was deleted.

3 changes: 3 additions & 0 deletions install-importer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/sh

./service.sh install_importer "$@"
3 changes: 3 additions & 0 deletions run-emulator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/sh

./service.sh run_emulator "$@"
31 changes: 31 additions & 0 deletions service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#! /bin/sh

if [ $# -lt 1 ]; then
printf 'Usage: %s CMD [OPTS].\n' "${0##*/}" 1>&2
exit 1
fi

WRAPPER_PATH=src/mupdf_wrapper
TARGET_OS=$(uname -s)

if ! [ -e "${WRAPPER_PATH}/${TARGET_OS}" ]; then
cd "$WRAPPER_PATH" || exit 1
./build.sh
cd ../..
fi

CMD=$1
shift

case "$CMD" in
run_emulator)
cargo run --bin plato-emulator --features emulator "$@"
;;
install_importer)
cargo install --path . --bin plato-import --features importer "$@"
;;
*)
printf 'Unknown command: %s.\n' "$CMD" 1>&2
exit 1
;;
esac
3 changes: 2 additions & 1 deletion src/document/mupdf_sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ pub enum FzSeparations {}
pub enum FzImage {}

#[link(name="mupdf")]
#[link(name="mupdfwrapper")]
#[link(name="mupdf_wrapper", kind="static")]

extern {
pub fn fz_new_context_imp(alloc_ctx: *const FzAllocContext, locks_ctx: *const FzLocksContext, cache_size: libc::size_t, version: *const libc::c_char) -> *mut FzContext;
pub fn fz_drop_context(ctx: *mut FzContext);
Expand Down
Loading

0 comments on commit c4a5e04

Please sign in to comment.