;shake: cabalfiles: use (and require) hpack, to avoid building
hpack should be in $PATH, and it should be the version that's in the current stack release, to avoid commit conflicts.
This commit is contained in:
		
							parent
							
								
									ff76db9fb2
								
							
						
					
					
						commit
						7673778022
					
				
							
								
								
									
										20
									
								
								Shake.hs
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								Shake.hs
									
									
									
									
									
								
							| @ -19,6 +19,7 @@ more platform independence. It requires stack and will auto-install | |||||||
| the haskell packages above when needed. | the haskell packages above when needed. | ||||||
| 
 | 
 | ||||||
| Some of the commands below require additional command-line tools, including: | Some of the commands below require additional command-line tools, including: | ||||||
|  | - hpack (same version that's in current stack release) | ||||||
| - GNU date (on mac: brew install coreutils) | - GNU date (on mac: brew install coreutils) | ||||||
| - groff | - groff | ||||||
| - m4 | - m4 | ||||||
| @ -261,15 +262,20 @@ main = do | |||||||
|       -- Regenerate .cabal files from package.yaml files. |       -- Regenerate .cabal files from package.yaml files. | ||||||
|       -- (used by "cabalfiles" and "setversion") |       -- (used by "cabalfiles" and "setversion") | ||||||
|       let gencabalfiles = do |       let gencabalfiles = do | ||||||
|  | 
 | ||||||
|  |           -- Update cabal files with stack build. | ||||||
|           -- stack 1.7+ no longer updates cabal files with --dry-run, we must do a full build. |           -- stack 1.7+ no longer updates cabal files with --dry-run, we must do a full build. | ||||||
|           -- stack can fail to update cabal files while returning zero exit code, |           -- stack can return zero exit code while failing to update cabal files so | ||||||
|           -- we need to check for the error message (specifically) on stderr. |           -- we need to check for the error message (specifically) on stderr. | ||||||
|           err <- fromStdouterr <$> |           -- out <- fromStdouterr <$>  -- (getting both stdout and stderr here just as an example) | ||||||
|             (cmd (EchoStdout True) (EchoStderr True) Shell "stack build --fast" :: Action (Stdouterr String)) |           --   (cmd (EchoStdout True) (EchoStderr True) Shell "stack build" :: Action (Stdouterr String)) | ||||||
|           -- Or use hpack directly. It should be the same version that's in current stack. |           -- when ("was generated with a newer version of hpack" `isInfixOf` out) $ | ||||||
|           -- (cmd Shell "hpack" :: Action (Stderr String)) |           --   liftIO $ putStr out >> exitFailure | ||||||
|           when ("was generated with a newer version of hpack" `isInfixOf` err) $ | 
 | ||||||
|             liftIO $ putStr err >> exitFailure |           -- Or update them with hpack directly. | ||||||
|  |           -- It should be the same hpack version that's in current stack, to avoid commit conflicts. | ||||||
|  |           forM_ pkgdirs $ \d -> cmd_ (Cwd d) Shell "hpack --no-hash" | ||||||
|  | 
 | ||||||
|           when commit $ do |           when commit $ do | ||||||
|             let msg = ";cabal: update cabal files" |             let msg = ";cabal: update cabal files" | ||||||
|             cmd Shell gitcommit ("-m '"++msg++"' --") cabalfiles |             cmd Shell gitcommit ("-m '"++msg++"' --") cabalfiles | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user