File tree Expand file tree Collapse file tree 5 files changed +49
-0
lines changed Expand file tree Collapse file tree 5 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ executable build-elm-format
1212 Shakefiles.ElmFormat.IntegrationTests
1313 Shakefiles.Extra
1414 Shakefiles.Haskell
15+ Shakefiles.NestedCheckout
1516 Shakefiles.NixBuild
1617 Shakefiles.Platform
1718 Shakefiles.Shellcheck
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import qualified Shakefiles.Dependencies
1313import qualified Shakefiles.Signature
1414import Shakefiles.Extra
1515import qualified Shakefiles.NixBuild
16+ import qualified Shakefiles.NestedCheckout
1617
1718
1819main :: IO ()
@@ -46,6 +47,9 @@ rules = do
4647
4748 phony " build" $ need [ " elm-format" ]
4849 phony " elm-format" $ need [ elmFormat ]
50+ phony " generated" $ need
51+ [ " generated/Build_elm_format.hs"
52+ ]
4953 phony " unit-tests" $ need
5054 [ " _build/cabal/elm-format-lib/test.ok"
5155 , " _build/cabal/elm-format-test-lib/test.ok"
@@ -135,4 +139,6 @@ rules = do
135139
136140 Shakefiles.ElmFormat.IntegrationTests. rules gitSha elmFormat
137141
142+ Shakefiles.NestedCheckout. rules
143+
138144 Shakefiles.Shellcheck. rules shellcheck
Original file line number Diff line number Diff line change @@ -108,7 +108,10 @@ executable target projectName gitDescribe =
108108 Shakefiles.Platform. all
109109
110110 let buildInDocker =
111+ []
112+ let buildViaNix =
111113 [ Shakefiles.Platform. LinuxX86
114+ , Shakefiles.Platform. LinuxAarch64
112115 ]
113116 let buildOnCi =
114117 [ Shakefiles.Platform. Windows
@@ -134,6 +137,17 @@ executable target projectName gitDescribe =
134137 need [ binDir </> binFile ]
135138 cmd_ " tar" " zcvf" out " -C" binDir binFile
136139
140+ forEach buildViaNix $ \ target -> do
141+ let zipExt = Shakefiles.Platform. zipFormatFor target
142+
143+ (" publish" </> " *" </> projectName ++ " -*-" ++ show target <.> zipExt) %> \ out -> do
144+ let tag = takeDirectory1 $ dropDirectory1 out
145+ StdoutTrim sha <- cmd " git" " rev-list" " -n1" (" tags/" ++ tag)
146+ let binDir = " _build" </> " nix-build" </> " from-git" </> sha </> " out" </> " default" </> " dist." <> show target </> " bin"
147+ let binFile = projectName ++ Shakefiles.Platform. binExt target
148+ need [ binDir </> binFile ]
149+ cmd_ " tar" " zcvf" out " -C" binDir binFile
150+
137151 forEach buildOnCi $ \ target -> do
138152 let ciArchiveLabel = Shakefiles.Platform. ciArchiveLabel target
139153 let zipExt = Shakefiles.Platform. zipFormatFor target
Original file line number Diff line number Diff line change 1+ module Shakefiles.NestedCheckout where
2+
3+ import Development.Shake
4+ import Development.Shake.FilePath
5+ import qualified System.Directory
6+
7+ rules :: Rules ()
8+ rules = do
9+ " _build/git/checkout/*.ok" %> \ out -> do
10+ let cloneDir = dropExtension out
11+ let sha = dropDirectory1 $ dropDirectory1 $ dropDirectory1 cloneDir
12+ exists <- liftIO $ System.Directory. doesDirectoryExist cloneDir
13+ if exists
14+ then return ()
15+ else cmd_ " git" " clone" " --local" " ." cloneDir
16+ cmd_ (Cwd cloneDir) " git" " reset" " --hard" sha
17+ cmd_ (Cwd cloneDir) " ./dev/build.sh" " generated"
18+ writeFileChanged out sha
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ module Shakefiles.NixBuild where
22
33import Development.Shake
44import Development.Shake.FilePath
5+ import qualified System.Directory
56
67rules :: Rules ()
78rules = do
@@ -26,3 +27,12 @@ rules = do
2627
2728 cmd_ " nix-build" " -A" attr " -o" gcroot
2829 copyFileChanged (gcroot </> foldl (</>) " " rest) out
30+
31+ " _build/nix-build/from-git/*/out/default/*/bin/elm-format" %> \ out -> do
32+ let (b1: b2: b3: sha: _: _: attr: rest) = splitDirectories out
33+ gcroot <- liftIO $ System.Directory. makeAbsolute (b1 </> b2 </> b3 </> sha </> " gcroots/default" </> attr)
34+
35+ let checkoutDir = " _build/git/checkout" </> sha
36+ need [ checkoutDir <.> " ok" ]
37+ cmd_ (Cwd checkoutDir) " nix-build" " -A" attr " -o" gcroot
38+ copyFileChanged (gcroot </> foldl (</>) " " rest) out
You can’t perform that action at this time.
0 commit comments