Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use partial SHA1 instead of full platform name and Cabal version on Windows #1027

Merged
merged 1 commit into from
Sep 27, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/Stack/Constants.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedStrings #-}

Expand Down Expand Up @@ -47,6 +48,13 @@ import Prelude
import Stack.Types.Config
import Stack.Types.PackageIdentifier
import Stack.Types.PackageName
#ifdef mingw32_HOST_OS
import qualified Crypto.Hash.SHA1 as SHA1
import qualified Data.ByteString as B
import qualified Data.ByteString.Base16 as Base16
import qualified Data.ByteString.Char8 as B8
import qualified Data.Text.Encoding as T
#endif

-- | Extensions for anything that can be a Haskell module.
haskellModuleExts :: [Text]
Expand Down Expand Up @@ -205,11 +213,22 @@ distRelativeDir = do
parseRelDir $
packageIdentifierString
(PackageIdentifier cabalPackageName cabalPkgVer)

#ifdef mingw32_HOST_OS
-- This is an attempt to shorten path to stack build artifacts dir on Windows to
-- decrease our chances of hitting 260 symbol path limit.
-- The idea is to calculate SHA1 hash from concatenated platform and cabal strings,
-- encode with base 16 and take first 8 symbols of it.
let concatenatedText = T.pack . toFilePath $ platform </> cabal
sha1 = SHA1.hash $ T.encodeUtf8 concatenatedText
platformAndCabal <- parseRelDir . B8.unpack . B.take 8 $ Base16.encode sha1
#else
let platformAndCabal = platform </> cabal
#endif
return $
workDirRel </>
$(mkRelDir "dist") </>
platform </>
cabal
platformAndCabal

-- | Get a URL for a raw file on Github
rawGithubUrl :: Text -- ^ user/org name
Expand Down