about summary refs log tree commit diff
path: root/users/grfn
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2021-09-11T14·23+0200
committersterni <sternenseemann@systemli.org>2021-09-11T16·00+0000
commit2f750e4a14be68f275f6fe23995eb9a994e0f5de (patch)
treefa825b6379206cef791600c6df70d0bce2fa5b29 /users/grfn
parenta63057414df62f2b680692018fddbcbeae32f15f (diff)
refactor(grfn/xanthous): avoid unnecessary recompilation r/2850
hpack is a bit dumb when generating the list of modules for a cabal
file's component if multiple of them live in the same directory.
Specifically it seems to assume that all modules in the source-dirs
of a particular component are also necessary for its compilation.

This is quite bad in the case of xanthous since both library and
executable have source-dirs: src, so all modules will be compiled
twice: Once for the library and then again for the executable
despite it depending on the library (actually 4 times in total
since we need to build a unprofiled and profiled object for each
module…).

To fix this we just move Main.hs into its own directory and change
the executable's source-dirs, so hpack doesn't get confused anymore.
Since all components now have their own source-dirs, unnecessary
redundant compilation should be down to 0. The diff of the cabal
file shows quite nicely how many module recompilation we've gotten
rid of.

Change-Id: I2df4fab9b0299b3a2b5d3005508c79b2d9796039
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3533
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'users/grfn')
-rw-r--r--users/grfn/xanthous/app/Main.hs (renamed from users/grfn/xanthous/src/Main.hs)0
-rw-r--r--users/grfn/xanthous/package.yaml2
-rw-r--r--users/grfn/xanthous/xanthous.cabal62
3 files changed, 3 insertions, 61 deletions
diff --git a/users/grfn/xanthous/src/Main.hs b/users/grfn/xanthous/app/Main.hs
index 6d88405fd9e0..6d88405fd9e0 100644
--- a/users/grfn/xanthous/src/Main.hs
+++ b/users/grfn/xanthous/app/Main.hs
diff --git a/users/grfn/xanthous/package.yaml b/users/grfn/xanthous/package.yaml
index fa217f80dc59..605b1cab8c7e 100644
--- a/users/grfn/xanthous/package.yaml
+++ b/users/grfn/xanthous/package.yaml
@@ -116,7 +116,7 @@ library:
   source-dirs: src
 
 executable:
-  source-dirs: src
+  source-dirs: app
   main: Main.hs
   dependencies:
   - xanthous
diff --git a/users/grfn/xanthous/xanthous.cabal b/users/grfn/xanthous/xanthous.cabal
index 45f85616b6d7..fc17ceaa20a7 100644
--- a/users/grfn/xanthous/xanthous.cabal
+++ b/users/grfn/xanthous/xanthous.cabal
@@ -4,7 +4,7 @@ cabal-version: 1.12
 --
 -- see: https://github.com/sol/hpack
 --
--- hash: 761fd1d1a9f9f9fdf8e14e56922558f7968401c879dcb95ca697dab03d1e9eec
+-- hash: c12ae4038a2e1f287de557b72b8493da05ccbf428e7ac7862349c46d241f342f
 
 name:           xanthous
 version:        0.1.0.0
@@ -29,7 +29,6 @@ source-repository head
 library
   exposed-modules:
       Data.Aeson.Generic.DerivingVia
-      Main
       Xanthous.AI.Gormlak
       Xanthous.App
       Xanthous.App.Autocommands
@@ -188,66 +187,9 @@ library
 executable xanthous
   main-is: Main.hs
   other-modules:
-      Data.Aeson.Generic.DerivingVia
-      Xanthous.AI.Gormlak
-      Xanthous.App
-      Xanthous.App.Autocommands
-      Xanthous.App.Common
-      Xanthous.App.Prompt
-      Xanthous.App.Time
-      Xanthous.Command
-      Xanthous.Data
-      Xanthous.Data.App
-      Xanthous.Data.Entities
-      Xanthous.Data.EntityChar
-      Xanthous.Data.EntityMap
-      Xanthous.Data.EntityMap.Graphics
-      Xanthous.Data.Levels
-      Xanthous.Data.Memo
-      Xanthous.Data.NestedMap
-      Xanthous.Data.VectorBag
-      Xanthous.Entities.Character
-      Xanthous.Entities.Creature
-      Xanthous.Entities.Creature.Hippocampus
-      Xanthous.Entities.Draw.Util
-      Xanthous.Entities.Entities
-      Xanthous.Entities.Environment
-      Xanthous.Entities.Item
-      Xanthous.Entities.Marker
-      Xanthous.Entities.Raws
-      Xanthous.Entities.RawTypes
-      Xanthous.Game
-      Xanthous.Game.Arbitrary
-      Xanthous.Game.Draw
-      Xanthous.Game.Env
-      Xanthous.Game.Lenses
-      Xanthous.Game.Memo
-      Xanthous.Game.Prompt
-      Xanthous.Game.State
-      Xanthous.Generators.Level
-      Xanthous.Generators.Level.CaveAutomata
-      Xanthous.Generators.Level.Dungeon
-      Xanthous.Generators.Level.LevelContents
-      Xanthous.Generators.Level.Util
-      Xanthous.Generators.Level.Village
-      Xanthous.Generators.Speech
-      Xanthous.Messages
-      Xanthous.Messages.Template
-      Xanthous.Monad
-      Xanthous.Orphans
-      Xanthous.Prelude
-      Xanthous.Random
-      Xanthous.Util
-      Xanthous.Util.Comonad
-      Xanthous.Util.Graph
-      Xanthous.Util.Graphics
-      Xanthous.Util.Inflection
-      Xanthous.Util.JSON
-      Xanthous.Util.Optparse
-      Xanthous.Util.QuickCheck
       Paths_xanthous
   hs-source-dirs:
-      src
+      app
   default-extensions:
       BlockArguments
       ConstraintKinds