diff options
-rw-r--r-- | Build/EvilSplicer.hs | 94 | ||||
-rw-r--r-- | Command/WebApp.hs | 6 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | Utility/WebApp.hs | 13 | ||||
-rw-r--r-- | doc/bugs/make_SHA512E_the_default.mdwn | 18 |
5 files changed, 82 insertions, 51 deletions
diff --git a/Build/EvilSplicer.hs b/Build/EvilSplicer.hs index 08b54226c..a43a971fd 100644 --- a/Build/EvilSplicer.hs +++ b/Build/EvilSplicer.hs @@ -290,17 +290,61 @@ expandExpressionSplice s lls = concat [before, spliced:padding, end] {- Tweaks code output by GHC in splices to actually build. Yipes. -} mangleCode :: String -> String -mangleCode = declaration_parens +mangleCode = flip_colon + . lambdaparens + . declaration_parens . case_layout . case_layout_multiline - . remove_declaration_splices . yesod_url_render_hack - . yesod_static_route_render_hack . nested_instances . collapse_multiline_strings . remove_package_version . emptylambda where + {- Lambdas are often output without parens around them. + - This breaks when the lambda is immediately applied to a + - parameter. + - + - For example: + - + - renderRoute (StaticR sub_a1nUH) + - = \ (a_a1nUI, b_a1nUJ) + - -> (((pack "static") : a_a1nUI), + - b_a1nUJ) + - (renderRoute sub_a1nUH) + - + - There are sometimes many lines of lambda code that need to be + - parenthesised. Approach: find the "->" and scan down the + - column to the first non-whitespace. This is assumed + - to be the expression after the lambda. + - + - Runs recursively on the body of the lambda, to handle nested + - lambdas. + -} + lambdaparens = parsecAndReplace $ do + -- skip lambdas inside tuples or parens + prefix <- noneOf "(, \n" + preindent <- many1 $ oneOf " \n" + string "\\ " + lambdaparams <- restofline + indent <- many1 $ char ' ' + string "-> " + firstline <- restofline + lambdalines <- many $ try $ do + string indent + char ' ' + l <- restofline + return $ indent ++ " " ++ l + return $ concat + [ prefix:preindent + , "(\\ " ++ lambdaparams ++ "\n" + , indent ++ "-> " + , lambdaparens $ intercalate "\n" (firstline:lambdalines) + , ")\n" + ] + + restofline = manyTill (noneOf "\n") newline + {- For some reason, GHC sometimes doesn't like the multiline - strings it creates. It seems to get hung up on \{ at the - start of a new line sometimes, wanting it to not be escaped. @@ -357,7 +401,7 @@ mangleCode = declaration_parens case_layout_multiline = parsecAndReplace $ do newline indent <- many1 $ char ' ' - firstline <- manyTill (noneOf "\n") newline + firstline <- restofline string indent indent2 <- many1 $ char ' ' @@ -420,44 +464,10 @@ mangleCode = declaration_parens oken <- many $ satisfy isAlphaNum <|> oneOf "-.'" return $ t:oken -{- This works around a problem in the expanded template haskell for Yesod's - - static site route rendering. - - - - renderRoute (StaticR sub_a1nUH) - - = \ (a_a1nUI, b_a1nUJ) - - -> (((pack "static") : a_a1nUI), b_a1nUJ) - - (renderRoute sub_a1nUH) - - - - That is missing parens around the lambda expression (which - - is supposed to be applied to renderRoute). Add those parens. - -} -yesod_static_route_render_hack :: String -> String -yesod_static_route_render_hack = parsecAndReplace $ do - def <- string "renderRoute (StaticR sub_a1nUH)" - whitespace - string "= \\ (" - t1 <- token - string ", " - t2 <- token - string ")" - whitespace - f <- string "-> (((pack \"static\") : " - string t1 - string "), " - string t2 - string ")" - return $ concat - [ def - , " = (\\ (", t1, ",", t2, ") " - , f, t1, "), ", t2, "))" - ] - where - whitespace :: Parser String - whitespace = many $ oneOf " \t\r\n" - - token :: Parser String - token = many1 $ satisfy isAlphaNum <|> oneOf "_" - + {- This works when it's "GHC.Types.:", but we strip + - that above, so have to fix up after it here. + - The ; is added by case_layout. -} + flip_colon = replace "; : _ " "; _ : " {- This works around a problem in the expanded template haskell for Yesod - type-safe url rendering. diff --git a/Command/WebApp.hs b/Command/WebApp.hs index 2d01b0d15..90abd4d27 100644 --- a/Command/WebApp.hs +++ b/Command/WebApp.hs @@ -150,7 +150,7 @@ firstRun listenhost = do sendurlback v _origout _origerr url _htmlshim = putMVar v url openBrowser :: Maybe FilePath -> FilePath -> Maybe Handle -> Maybe Handle -> IO () -openBrowser cmd htmlshim outh errh = do +openBrowser mcmd htmlshim outh errh = do hPutStrLn (fromMaybe stdout outh) $ "Launching web browser on " ++ url environ <- cleanEnvironment (_, _, _, pid) <- createProcess p @@ -163,7 +163,9 @@ openBrowser cmd htmlshim outh errh = do hPutStrLn (fromMaybe stderr errh) "failed to start web browser" where url = fileUrl htmlshim - p = proc (fromMaybe browserCommand cmd) [htmlshim] + p = case mcmd of + Just cmd -> proc cmd [htmlshim] + Nothing -> browserProc htmlshim {- web.browser is a generic git config setting for a web browser program -} webBrowser :: Git.Repo -> Maybe FilePath @@ -176,7 +176,7 @@ android: Build/EvilSplicer # Some additional dependencies needed by the expanded splices. sed -i 's/^ Build-Depends: / Build-Depends: yesod-routes, yesod-core, shakespeare-css, shakespeare-js, shakespeare, blaze-markup, file-embed, wai-app-static, /' tmp/androidtree/git-annex.cabal # Avoid warnings due to sometimes unused imports added for the splices. - sed -i 's/-Wall/-Wall -fno-warn-unused-imports/' tmp/androidtree/git-annex.cabal + sed -i 's/GHC-Options: \\(.*\\)-Wall/GHC-Options: \\1-Wall -fno-warn-unused-imports /i' tmp/androidtree/git-annex.cabal # Cabal cannot cross compile with custom build type, so workaround. sed -i 's/Build-type: Custom/Build-type: Simple/' tmp/androidtree/git-annex.cabal if [ ! -e tmp/androidtree/dist/setup/setup ]; then \ diff --git a/Utility/WebApp.hs b/Utility/WebApp.hs index 97a6879ec..bafc9ac22 100644 --- a/Utility/WebApp.hs +++ b/Utility/WebApp.hs @@ -40,12 +40,17 @@ import Control.Concurrent localhost :: HostName localhost = "localhost" -{- Command to use to run a web browser. -} -browserCommand :: FilePath +{- Builds a command to use to start or open a web browser showing an url. -} +browserProc :: String -> CreateProcess #ifdef darwin_HOST_OS -browserCommand = "open" +browserProc url = proc "open" [url] #else -browserCommand = "xdg-open" +#ifdef __ANDROID__ +browserProc url = proc "am" + ["start", "-a", "android.intent.action.VIEW", "-d", url] +#else +browserProc url = proc "xdg-open" [url] +#endif #endif {- Binds to a socket on localhost, or possibly a different specified diff --git a/doc/bugs/make_SHA512E_the_default.mdwn b/doc/bugs/make_SHA512E_the_default.mdwn index 068cd7ab7..8a32ab697 100644 --- a/doc/bugs/make_SHA512E_the_default.mdwn +++ b/doc/bugs/make_SHA512E_the_default.mdwn @@ -1,6 +1,9 @@ What steps will reproduce the problem? -As described in http://git-annex.branchable.com/backends/#comment-3c1cd45d2a015b4fc412dd813293ad7d , sha512 is faster. On my 64-bit system, the speed difference is about 1.5times. +As described in +http://git-annex.branchable.com/backends/#comment-3c1cd45d2a015b4fc412dd813293ad7d +, sha512 is faster. On my 64-bit system, the speed difference is about +1.5times. What is the expected output? What do you see instead? @@ -10,4 +13,15 @@ What version of git-annex are you using? On what operating system? Please provide any additional information below. - +> You are free to change the default in your own annexes. This is very easy +> to do: `echo '* annex.backend=SHA512E' > .gitattributes` +> +> I don't anticipate moving to SHA512, because +> +> 1. It makes `ls -l` really ugly. Each symlink takes like 4 lines +> on an 80 column terminal. +> 2. There are better hashes coming. Particularly SHA3. That should be +> faster and/or more secure. And without adding so much length to the +> hash. +> +> --[[Joey]] |