|
| 1 | +{-# LANGUAGE CPP #-} |
1 | 2 | {-# LANGUAGE TemplateHaskell #-}
|
2 | 3 | {-# LANGUAGE OverloadedStrings #-}
|
3 | 4 |
|
@@ -47,6 +48,13 @@ import Prelude
|
47 | 48 | import Stack.Types.Config
|
48 | 49 | import Stack.Types.PackageIdentifier
|
49 | 50 | import Stack.Types.PackageName
|
| 51 | +#ifdef mingw32_HOST_OS |
| 52 | +import qualified Crypto.Hash.SHA1 as SHA1 |
| 53 | +import qualified Data.ByteString as B |
| 54 | +import qualified Data.ByteString.Base16 as Base16 |
| 55 | +import qualified Data.ByteString.Char8 as B8 |
| 56 | +import qualified Data.Text.Encoding as T |
| 57 | +#endif |
50 | 58 |
|
51 | 59 | -- | Extensions for anything that can be a Haskell module.
|
52 | 60 | haskellModuleExts :: [Text]
|
@@ -205,11 +213,22 @@ distRelativeDir = do
|
205 | 213 | parseRelDir $
|
206 | 214 | packageIdentifierString
|
207 | 215 | (PackageIdentifier cabalPackageName cabalPkgVer)
|
| 216 | + |
| 217 | +#ifdef mingw32_HOST_OS |
| 218 | + -- This is an attempt to shorten path to stack build artifacts dir on Windows to |
| 219 | + -- decrease our chances of hitting 260 symbol path limit. |
| 220 | + -- The idea is to calculate SHA1 hash from concatenated platform and cabal strings, |
| 221 | + -- encode with base 16 and take first 8 symbols of it. |
| 222 | + let concatenatedText = T.pack . toFilePath $ platform </> cabal |
| 223 | + sha1 = SHA1.hash $ T.encodeUtf8 concatenatedText |
| 224 | + platformAndCabal <- parseRelDir . B8.unpack . B.take 8 $ Base16.encode sha1 |
| 225 | +#else |
| 226 | + let platformAndCabal = platform </> cabal |
| 227 | +#endif |
208 | 228 | return $
|
209 | 229 | workDirRel </>
|
210 | 230 | $(mkRelDir "dist") </>
|
211 |
| - platform </> |
212 |
| - cabal |
| 231 | + platformAndCabal |
213 | 232 |
|
214 | 233 | -- | Get a URL for a raw file on Github
|
215 | 234 | rawGithubUrl :: Text -- ^ user/org name
|
|
0 commit comments