Commit 626524ba authored by Jan-Philipp Stauffert's avatar Jan-Philipp Stauffert

Add preextracted resources flag

parent 72c44758
......@@ -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
......
......@@ -101,6 +101,8 @@ library:
else:
source-dirs: src-mac
exposed-modules: "System.Decker.OS"
- condition: flag(preextractedresources)
cpp-options: "-DPREEXTRACTEDRESOURCES"
executables:
decker:
......@@ -137,3 +139,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