Skip to content

Commit

Permalink
Download and embed ImageMagick binaries during build
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-si committed Feb 25, 2020
1 parent 702a3e8 commit 4df8c84
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.stack-work/
perspec.cabal
*~
Perspec.app
/.stack-work
/imagemagick
/imagemagick.tar.gz
/Perspec.app
/perspec.cabal
11 changes: 8 additions & 3 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Graphics.Gloss
import Graphics.Gloss.Interface.IO.Game as Gl
import Graphics.Gloss.Juicy
import Protolude as P
import System.Directory
import System.Environment
import System.FilePath
import System.Process

Expand Down Expand Up @@ -321,9 +323,12 @@ correctAndWrite :: [Text] -> IO ()
correctAndWrite args = do
let
conversionMode = CallConversion
-- TODO: Add CLI flag to automatically use local during build
convertBin = "convert" -- global
-- convertBin = "./convert" -- local
convertBin = "./imagemagick/bin/convert"

currentDir <- getCurrentDirectory

setEnv "MAGICK_HOME" (currentDir ++ "/imagemagick")
setEnv "DYLD_LIBRARY_PATH" (currentDir ++ "/imagemagick/lib")

-- TODO: Add CLI flag to switch between them
case conversionMode of
Expand Down
14 changes: 13 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Perspec.app: ~/.local/bin/perspec
Perspec.app: ~/.local/bin/perspec imagemagick
platypus \
--name Perspec \
--app-icon images/icon.icns \
Expand All @@ -7,6 +7,7 @@ Perspec.app: ~/.local/bin/perspec
--author "Adrian Sieber" \
--bundled-file ~/.local/bin/perspec \
--bundled-file app-aux-files/Credits.html \
--bundled-file imagemagick \
--bundle-identifier org.adrian.Perspec \
--droppable \
--optimize-nib \
Expand All @@ -16,5 +17,16 @@ Perspec.app: ~/.local/bin/perspec
$@


imagemagick:
rm -f imagemagick.tar.gz
curl \
https://imagemagick.org/download/binaries/ImageMagick-x86_64-apple-darwin19.2.0.tar.gz \
-o imagemagick.tar.gz
tar -xf imagemagick.tar.gz

rm -rf imagemagick
mv ImageMagick-7.0.9 imagemagick


~/.local/bin/perspec: app source
stack install
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ description: |
dependencies:
- base >= 4.7 && < 5
- directory
- filepath
- gloss
- gloss-juicy
Expand Down
11 changes: 5 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ Original | In Progress | Corrected

## Installation

Uses ImageMagick's `convert` command under the hood.
Check out its
[installation instructions](https://imagemagick.org/script/download.php)
to make it available on your system.


### Prebuilt

#### MacOS
Expand All @@ -34,6 +28,11 @@ with [Platypus](https://sveinbjorn.org/platypus).

### From Source

Uses ImageMagick's `convert` command under the hood.
Check out its
[installation instructions](https://imagemagick.org/script/download.php)
to make it available on your system.

Build it from source with Haskell's
[stack](https://docs.haskellstack.org/en/stable/install_and_upgrade/).

Expand Down

0 comments on commit 4df8c84

Please sign in to comment.