Commit 768927f7 authored by Kristof Korwisi's avatar Kristof Korwisi
Browse files

Merge branch '116-preextracted-resources' into 'master'

Resolve "Version with preextracted resources"

See merge request decker/decker!57
parents 6b054d58 25ef0f7e
......@@ -2,6 +2,7 @@
import Common
import Exception
import External
import Flags (hasPreextractedResources)
import Project
import Resources
import Shake
......@@ -179,7 +180,7 @@ main = do
removeFilesAfter (directories ^. project) cruft
old <- liftIO getOldResources
forM_ old $ \dir -> removeFilesAfter dir ["//"]
when isDevelopmentVersion $
when (isDevelopmentVersion && not hasPreextractedResources) $
removeFilesAfter (directories ^. appData) ["//"]
--
phony "help" $ do
......
......@@ -64,6 +64,9 @@ profile: build-profile
stack exec -- decker clean
stack exec --work-dir .stack-work-profile -- decker +RTS -p
preextracted:
stack build -j 8 --fast --flag decker:preextractedresources
install: yarn build
stack exec -- decker clean
mkdir -p $(local-bin-path)
......@@ -80,7 +83,7 @@ install-resources: yarn
version:
@echo "$(decker-name)"
.PHONY: build clean test install dist docs yarn
.PHONY: build clean test install dist docs yarn preextracted
##### Copy JS dependencies that can't be packed with webpack
......
......@@ -102,6 +102,8 @@ library:
else:
source-dirs: src-mac
exposed-modules: "System.Decker.OS"
- condition: flag(preextractedresources)
cpp-options: "-DPREEXTRACTEDRESOURCES"
executables:
decker:
......@@ -138,3 +140,9 @@ default-extensions:
- OverloadedStrings
- TemplateHaskell
- TupleSections
flags:
preextractedresources:
description: Assumes that the resources are already preextracted and will not extract them again or delete them
manual: true
default: false
......@@ -176,3 +176,6 @@ Haskell soure code readability depends heavily on consistent formatting
conventions. With decker, formatting is automated using the excellent
[hindent]() tool. Formatting is checked for each commit that is uploaded to the
GitLab repository.
## Compile Flags
The Decker executable contains per default all necessary supporting files and extracts them on the first run. Some packaging solutions prefer to already extract the files during the installation. To support this, a compile flag `preextractedresources` is available which instructs Decker to work with the already extracted resource files. Invoke `stack --flag decker:preextractedresources` to compile such a version.
\ No newline at end of file
{-- Author: Jan-Philipp Stauffert <jan-philipp.stauffert@uni-wuerzburg.de.de> --}
module System.Decker.OS
( defaultProvisioning
, preextractedResourceFolder
) where
import Common
import System.Environment
import System.FilePath
defaultProvisioning :: Provisioning
defaultProvisioning = SymLink
preextractedResourceFolder :: IO FilePath
preextractedResourceFolder = do
exep <- getExecutablePath
return $ joinPath [(takeDirectory exep), "..", "Resources", "resource"]
{-- Author: Jan-Philipp Stauffert <jan-philipp.stauffert@uni-wuerzburg.de.de> --}
module System.Decker.OS
( defaultProvisioning
, preextractedResourceFolder
) where
import Common
import System.Environment
import System.FilePath
defaultProvisioning :: Provisioning
defaultProvisioning = Copy
preextractedResourceFolder :: IO FilePath
preextractedResourceFolder = do
exep <- getExecutablePath
return $ joinPath [(takeDirectory exep), "..", "resource"]
{-- Author: Jan-Philipp Stauffert <jan-philipp.stauffert@uni-wuerzburg.de.de> --}
{-# LANGUAGE CPP #-}
module Flags
( hasPreextractedResources
) where
hasPreextractedResources :: Bool
#ifdef PREEXTRACTEDRESOURCES
hasPreextractedResources = True
#else
hasPreextractedResources = False
#endif
......@@ -14,6 +14,8 @@ import Control.Monad
import Control.Monad.Extra
import Data.List.Split (splitOn)
import Exception
import Flags
import System.Decker.OS
import System.Directory
import System.Environment
import System.Exit
......@@ -23,10 +25,13 @@ import Text.Regex.TDFA
deckerResourceDir :: IO FilePath
deckerResourceDir =
getXdgDirectory
XdgData
("decker" ++
"-" ++ deckerVersion ++ "-" ++ deckerGitBranch ++ "-" ++ deckerGitCommitId)
if hasPreextractedResources
then preextractedResourceFolder
else getXdgDirectory
XdgData
("decker" ++
"-" ++
deckerVersion ++ "-" ++ deckerGitBranch ++ "-" ++ deckerGitCommitId)
-- | Get the absolute paths of resource folders
-- with version numbers older than the current one
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment