on master help sign in
Merge pull request #214 from obsidiansystems/rename-generated-static-module

Rename generated static module and pkg

commitaeb39a328f955ce3571c3c130feebc618fd41b0e authorRyan Trinkle <ryan.trinkle@gmail.com> dateThu 11 Oct 2018, 15:41 (8 years ago) parentb462e4841bb177
4 files changed+12−6
default.nix+1−1 lib/asset/manifest/src/Obelisk/Asset/Promoted.hs+7−2 skeleton/frontend/frontend.cabal+2−2 skeleton/frontend/src/Frontend.hs+2−1
default.nix+1−1
@@ -144,7 +144,7 @@ rec {
144144 nullIfAbsent = p: if pathExists p then p else null;
145145 haskellOverrides = addLibs;
146146 #TODO: Avoid copying files within the nix store. Right now, obelisk-asset-manifest-generate copies files into a big blob so that the android/ios static assets can be imported from there; instead, we should get everything lined up right before turning it into an APK, so that copies, if necessary, only exist temporarily.
147− processAssets = { src, packageName ? "static", moduleName ? "Static" }: pkgs.runCommand "asset-manifest" {
147+ processAssets = { src, packageName ? "obelisk-generated-static", moduleName ? "Obelisk.Generated.Static" }: pkgs.runCommand "asset-manifest" {
148148 inherit src;
149149 outputs = [ "out" "haskellManifest" "symlinked" ];
150150 buildInputs = [
lib/asset/manifest/src/Obelisk/Asset/Promoted.hs+7−2
@@ -10,6 +10,7 @@ module Obelisk.Asset.Promoted
1010import Obelisk.Asset.Gather
1111
1212import Data.Foldable
13+import qualified Data.List as L
1314import Language.Haskell.TH (runQ, pprint)
1415import Language.Haskell.TH.Syntax hiding (lift)
1516import GHC.TypeLits
@@ -31,11 +32,15 @@ data StaticConfig = StaticConfig
3132
3233writeStaticProject :: Map FilePath FilePath -> FilePath -> StaticConfig -> IO ()
3334writeStaticProject paths target cfg = do
34− createDirectoryIfMissing True $ target </> "src"
35+ createDirectoryIfMissing True target
3536 T.writeFile (target </> T.unpack (_staticConfig_packageName cfg) <.> "cabal") $ staticCabalFile cfg
3637 let modName = _staticConfig_moduleName cfg
38+ (modName', moduleDirPath) = case L.uncons (reverse $ T.splitOn "." modName) of
39+ Nothing -> error $ "writeStaticProject: invalid module name " <> T.unpack modName
40+ Just (name, parents) -> (name, target </> "src" </> T.unpack (T.intercalate "/" $ reverse parents))
41+ createDirectoryIfMissing True moduleDirPath
3742 modContents <- staticModuleFile modName paths
38− T.writeFile (target </> "src" </> T.unpack modName <.> "hs") modContents
43+ T.writeFile (moduleDirPath </> T.unpack modName' <.> "hs") modContents
3944
4045staticCabalFile :: StaticConfig -> Text
4146staticCabalFile cfg = T.unlines
skeleton/frontend/frontend.cabal+2−2
@@ -10,7 +10,7 @@ library
1010 , obelisk-frontend
1111 , obelisk-route
1212 , reflex-dom
13− , static
13+ , obelisk-generated-static
1414 , text
1515 exposed-modules:
1616 Frontend
@@ -24,7 +24,7 @@ executable frontend
2424 , obelisk-frontend
2525 , obelisk-route
2626 , reflex-dom
27− , static
27+ , obelisk-generated-static
2828 , frontend
2929 --TODO: Make these ghc-options optional
3030 ghc-options: -threaded
skeleton/frontend/src/Frontend.hs+2−1
@@ -10,7 +10,8 @@ import Reflex.Dom.Core
1010
1111import Common.Api
1212import Common.Route
13−import Static
13+import Obelisk.Generated.Static
14+
1415
1516frontend :: Frontend (R FrontendRoute)
1617frontend = Frontend