Skip to content

Commit

Permalink
Add shake dist target to build optimized binary
Browse files Browse the repository at this point in the history
  • Loading branch information
avh4 committed Sep 22, 2020
1 parent 11f1c35 commit 572822d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,6 +4,7 @@
/_stdout.txt
*.tix
/.stack-work/
/.stack-work-dist/
/stack.yaml.lock
/.shake/
/_build/
Expand Down
17 changes: 15 additions & 2 deletions Shakefile.hs
Expand Up @@ -12,12 +12,17 @@ main = do
shakeColor = True,
shakeVersion = shakefilesHash
} $ do

let workDirDist = "--work-dir=.stack-work-dist"

StdoutTrim stackLocalInstallRoot <- liftIO $ cmd "stack path --local-install-root"
StdoutTrim stackLocalInstallRootDist <- liftIO $ cmd "stack" "path" workDirDist "--local-install-root"
StdoutTrim stackLocalBin <- liftIO $ cmd "stack path --local-bin"
StdoutTrim gitDescribe <- liftIO $ cmd "git" [ "describe", "--abbrev=8", "--always" ]
StdoutTrim gitSha <- liftIO $ cmd "git" [ "describe", "--always", "--match", "NOT A TAG", "--dirty" ]

let elmFormat = stackLocalInstallRoot </> "bin/elm-format" <.> exe
let elmFormat = stackLocalInstallRoot </> "bin" </> "elm-format" <.> exe
let elmFormatDist = stackLocalInstallRootDist </> "bin" </> "elm-format" <.> exe
let shellcheck = stackLocalBin </> "shellcheck" <.> exe

want [ "test" ]
Expand All @@ -32,9 +37,11 @@ main = do
phony "build" $ need [ elmFormat ]
phony "stack-test" $ need [ "_build/stack-test.ok" ]
phony "profile" $ need [ "_build/tests/test-files/prof.ok" ]
phony "dist" $ need [ elmFormatDist ]

phony "clean" $ do
cmd_ "stack clean"
cmd_ "stack" "clean"
cmd_ "stack" "clean" workDirDist
removeFilesAfter "_build" [ "//*" ]
removeFilesAfter ""
[ "_input.elm"
Expand Down Expand Up @@ -72,6 +79,12 @@ main = do
need generatedSourceFiles
cmd_ "stack build --test --no-run-tests"

elmFormatDist %> \out -> do
sourceFiles <- getDirectoryFiles "" sourceFilesPattern
need sourceFiles
need generatedSourceFiles
cmd_ "stack" "build" workDirDist "--ghc-options=-O2"

"_build/bin/elm-format-prof" %> \out -> do
StdoutTrim profileInstallRoot <- liftIO $ cmd "stack path --profile --local-install-root"
sourceFiles <- getDirectoryFiles "" sourceFilesPattern
Expand Down

0 comments on commit 572822d

Please sign in to comment.