From fef3bb99faf54332a527de1db51df502e6b1fcf4 Mon Sep 17 00:00:00 2001 From: Andrea Bedini Date: Wed, 23 Aug 2023 11:02:42 +0800 Subject: [PATCH 01/12] fix(Cabal-syntax): Remove left-over file after #8980 --- Cabal-syntax/src/Distribution/Fields/Lexer.hs | 605 ------------------ 1 file changed, 605 deletions(-) delete mode 100644 Cabal-syntax/src/Distribution/Fields/Lexer.hs diff --git a/Cabal-syntax/src/Distribution/Fields/Lexer.hs b/Cabal-syntax/src/Distribution/Fields/Lexer.hs deleted file mode 100644 index a24606f64ff..00000000000 --- a/Cabal-syntax/src/Distribution/Fields/Lexer.hs +++ /dev/null @@ -1,605 +0,0 @@ -{- FOURMOLU_DISABLE -} -{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-missing-signatures #-} -{-# LANGUAGE CPP #-} -{-# LANGUAGE MagicHash #-} -{-# LINE 1 "templates/Lexer.x" #-} ------------------------------------------------------------------------------ --- | --- Module : Distribution.Fields.Lexer --- License : BSD3 --- --- Maintainer : cabal-devel@haskell.org --- Portability : portable --- --- Lexer for the cabal files. -{-# LANGUAGE CPP #-} -{-# LANGUAGE BangPatterns #-} -#ifdef CABAL_PARSEC_DEBUG -{-# LANGUAGE PatternGuards #-} -#endif -{-# OPTIONS_GHC -fno-warn-unused-imports #-} -module Distribution.Fields.Lexer - (ltest, lexToken, Token(..), LToken(..) - ,bol_section, in_section, in_field_layout, in_field_braces - ,mkLexState) where - --- [Note: bootstrapping parsec parser] --- --- We manually produce the `Lexer.hs` file from `boot/Lexer.x` (make lexer) --- because bootstrapping cabal-install would be otherwise tricky. --- Alex is (atm) tricky package to build, cabal-install has some magic --- to move bundled generated files in place, so rather we don't depend --- on it before we can build it ourselves. --- Therefore there is one thing less to worry in bootstrap.sh, which is a win. --- --- See also https://github.com/haskell/cabal/issues/4633 --- - -import Prelude () -import qualified Prelude as Prelude -import Distribution.Compat.Prelude - -import Distribution.Fields.LexerMonad -import Distribution.Parsec.Position (Position (..), incPos, retPos) -import Data.ByteString (ByteString) -import qualified Data.ByteString as B -import qualified Data.ByteString.Char8 as B.Char8 -import qualified Data.Word as Word - -#ifdef CABAL_PARSEC_DEBUG -import Debug.Trace -import qualified Data.Vector as V -import qualified Data.Text as T -import qualified Data.Text.Encoding as T -import qualified Data.Text.Encoding.Error as T -#endif -#if __GLASGOW_HASKELL__ >= 603 -#include "ghcconfig.h" -#elif defined(__GLASGOW_HASKELL__) -#include "config.h" -#endif -#if __GLASGOW_HASKELL__ >= 503 -import Data.Array -#else -import Array -#endif -#if __GLASGOW_HASKELL__ >= 503 -import Data.Array.Base (unsafeAt) -import GHC.Exts -#else -import GlaExts -#endif -alex_tab_size :: Int -alex_tab_size = 8 -alex_base :: AlexAddr -alex_base = AlexA# - "\x12\xff\xff\xff\xf9\xff\xff\xff\xfb\xff\xff\xff\x01\x00\x00\x00\x2f\x00\x00\x00\x50\x00\x00\x00\xd0\x00\x00\x00\x50\x01\x00\x00\xd0\x01\x00\x00\x50\x02\x00\x00\x81\x00\x00\x00\xfe\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x69\xff\xff\xff\x03\x00\x00\x00\x09\x00\x00\x00\xf8\x00\x00\x00\xe2\xff\xff\xff\xd0\x02\x00\x00\x71\xff\xff\xff\x0b\x00\x00\x00\x0d\x00\x00\x00\x00\x00\x00\x00\x5f\xff\xff\xff\x5d\xff\xff\xff\x00\x00\x00\x00\xf0\x02\x00\x00\x00\x00\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x13\x03\x00\x00\x6a\x00\x00\x00\x00\x00\x00\x00\x15\x00\x00\x00\x66\x03\x00\x00\x98\x00\x00\x00\x80\xff\xff\xff\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x70\x03\x00\x00\x00\x00\x00\x00\xef\x03\x00\x00\x13\x04\x00\x00"# - -alex_table :: AlexAddr -alex_table = AlexA# - "\x00\x00\x18\x00\x11\x00\x17\x00\x02\x00\x17\x00\x16\x00\x0b\x00\x16\x00\x0f\x00\x03\x00\x17\x00\x0f\x00\x17\x00\x16\x00\x13\x00\x16\x00\x15\x00\x10\x00\x17\x00\x15\x00\x17\x00\x16\x00\x17\x00\x16\x00\x11\x00\x19\x00\x02\x00\x1a\x00\x1c\x00\x0b\x00\x22\x00\x10\x00\x03\x00\x27\x00\x0f\x00\x00\x00\x00\x00\x12\x00\x00\x00\x12\x00\x10\x00\x00\x00\x15\x00\x00\x00\x00\x00\x12\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x21\x00\x1c\x00\xff\xff\xff\xff\x1d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x21\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x25\x00\x22\x00\xff\xff\xff\xff\x23\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x25\x00\x00\x00\x00\x00\x21\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0d\x00\x00\x00\x0c\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x21\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x25\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x00\x1e\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x25\x00\x00\x00\x00\x00\x14\x00\x00\x00\x26\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\x00\x00\x00\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x26\x00\x00\x00\x14\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0b\x00\x27\x00\xff\xff\xff\xff\x28\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0b\x00\x2d\x00\x1b\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x2c\x00\x2c\x00\x2d\x00\x2d\x00\x2d\x00\x08\x00\x09\x00\x2d\x00\xff\xff\x11\x00\x17\x00\x00\x00\x00\x00\x16\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2b\x00\x00\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2c\x00\x2d\x00\x2c\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2a\x00\x2d\x00\x29\x00\x2d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x2d\x00\xff\xff\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\xff\xff\xff\xff\x2d\x00\x2d\x00\x2d\x00\x0a\x00\x09\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x2d\x00\xff\xff\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x2d\x00\xff\xff\x2d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x2d\x00\xff\xff\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\xff\xff\xff\xff\x2d\x00\x2d\x00\x2d\x00\x09\x00\x09\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x2d\x00\xff\xff\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x2d\x00\xff\xff\x2d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x2e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x30\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\xff\xff\x2d\x00\xff\xff\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2d\x00\x00\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2d\x00\x00\x00\x2d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x2e\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x2f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# - -alex_check :: AlexAddr -alex_check = AlexA# - "\xff\xff\xef\x00\x09\x00\x0a\x00\x09\x00\x0a\x00\x0d\x00\x09\x00\x0d\x00\xa0\x00\x09\x00\x0a\x00\x09\x00\x0a\x00\x0d\x00\x2d\x00\x0d\x00\xa0\x00\x09\x00\x0a\x00\x09\x00\x0a\x00\x0d\x00\x0a\x00\x0d\x00\x20\x00\xbb\x00\x20\x00\xbf\x00\x0a\x00\x20\x00\x0a\x00\xa0\x00\x20\x00\x0a\x00\x20\x00\xff\xff\xff\xff\x2d\x00\xff\xff\x2d\x00\x20\x00\xff\xff\x20\x00\xff\xff\xff\xff\x2d\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\xff\xff\xff\xff\x09\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\xff\xff\x7d\x00\xff\xff\xff\xff\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x20\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x09\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\xff\xff\x7d\x00\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\xff\xff\xff\xff\xc2\x00\xff\xff\xc2\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\xff\xff\xc2\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\xff\xff\xc2\x00\xff\xff\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x7f\x00\x09\x00\x0a\x00\xff\xff\xff\xff\x0d\x00\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x2d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\xff\xff\xff\xff\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\xff\xff\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x22\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\xff\xff\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5c\x00\xff\xff\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x7f\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\xff\xff\x7d\x00\x21\x00\x7f\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\xff\xff\xff\xff\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5c\x00\xff\xff\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7c\x00\xff\xff\x7e\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x22\x00\xff\xff\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x22\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5c\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x00\x5c\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"# - -alex_deflt :: AlexAddr -alex_deflt = AlexA# - "\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\x24\x00\x07\x00\x07\x00\x07\x00\x07\x00\x0a\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x13\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x1b\x00\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\xff\xff\xff\xff\xff\xff\x24\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x1b\x00\x1b\x00"# - -alex_accept = listArray (0 :: Int, 48) - [ AlexAcc 30 - , AlexAcc 29 - , AlexAcc 28 - , AlexAcc 27 - , AlexAccNone - , AlexAccNone - , AlexAccNone - , AlexAcc 26 - , AlexAcc 25 - , AlexAcc 24 - , AlexAccSkip - , AlexAccSkip - , AlexAcc 23 - , AlexAcc 22 - , AlexAccNone - , AlexAcc 21 - , AlexAcc 20 - , AlexAccNone - , AlexAccNone - , AlexAccSkip - , AlexAccNone - , AlexAccNone - , AlexAcc 19 - , AlexAcc 18 - , AlexAccNone - , AlexAccNone - , AlexAcc 17 - , AlexAccNone - , AlexAcc 16 - , AlexAcc 15 - , AlexAcc 14 - , AlexAcc 13 - , AlexAcc 12 - , AlexAccSkip - , AlexAcc 11 - , AlexAcc 10 - , AlexAcc 9 - , AlexAccSkip - , AlexAccNone - , AlexAcc 8 - , AlexAcc 7 - , AlexAcc 6 - , AlexAcc 5 - , AlexAcc 4 - , AlexAcc 3 - , AlexAcc 2 - , AlexAcc 1 - , AlexAcc 0 - , AlexAccNone - ] - -alex_actions = array (0 :: Int, 31) - [ (30,alex_action_0) - , (29,alex_action_20) - , (28,alex_action_16) - , (27,alex_action_3) - , (26,alex_action_8) - , (25,alex_action_8) - , (24,alex_action_8) - , (23,alex_action_5) - , (22,alex_action_4) - , (21,alex_action_3) - , (20,alex_action_16) - , (19,alex_action_1) - , (18,alex_action_1) - , (17,alex_action_0) - , (16,alex_action_25) - , (15,alex_action_25) - , (14,alex_action_24) - , (13,alex_action_23) - , (12,alex_action_22) - , (11,alex_action_19) - , (10,alex_action_19) - , (9,alex_action_18) - , (8,alex_action_15) - , (7,alex_action_15) - , (6,alex_action_14) - , (5,alex_action_13) - , (4,alex_action_12) - , (3,alex_action_11) - , (2,alex_action_10) - , (1,alex_action_9) - , (0,alex_action_9) - ] - -{-# LINE 163 "templates/Lexer.x" #-} --- | Tokens of outer cabal file structure. Field values are treated opaquely. -data Token = TokSym !ByteString -- ^ Haskell-like identifier, number or operator - | TokStr !ByteString -- ^ String in quotes - | TokOther !ByteString -- ^ Operators and parens - | Indent !Int -- ^ Indentation token - | TokFieldLine !ByteString -- ^ Lines after @:@ - | Colon - | OpenBrace - | CloseBrace - | EOF - | LexicalError InputStream --TODO: add separate string lexical error - deriving Show - -data LToken = L !Position !Token - deriving Show - -toki :: (ByteString -> Token) -> Position -> Int -> ByteString -> Lex LToken -toki t pos len input = return $! L pos (t (B.take len input)) - -tok :: Token -> Position -> Int -> ByteString -> Lex LToken -tok t pos _len _input = return $! L pos t - -checkLeadingWhitespace :: Position -> Int -> ByteString -> Lex Int -checkLeadingWhitespace pos len bs - | B.any (== 9) (B.take len bs) = do - addWarningAt pos LexWarningTab - checkWhitespace pos len bs - | otherwise = checkWhitespace pos len bs - -checkWhitespace :: Position -> Int -> ByteString -> Lex Int -checkWhitespace pos len bs - -- UTF8 NBSP is 194 160. This function is called on whitespace bytestrings, - -- therefore counting 194 bytes is enough to count non-breaking spaces. - -- We subtract the amount of 194 bytes to convert bytes length into char length - | B.any (== 194) (B.take len bs) = do - addWarningAt pos LexWarningNBSP - return $ len - B.count 194 (B.take len bs) - | otherwise = return len - --- ----------------------------------------------------------------------------- --- The input type - -type AlexInput = InputStream - -alexInputPrevChar :: AlexInput -> Char -alexInputPrevChar _ = error "alexInputPrevChar not used" - -alexGetByte :: AlexInput -> Maybe (Word.Word8,AlexInput) -alexGetByte = B.uncons - -lexicalError :: Position -> InputStream -> Lex LToken -lexicalError pos inp = do - setInput B.empty - return $! L pos (LexicalError inp) - -lexToken :: Lex LToken -lexToken = do - pos <- getPos - inp <- getInput - st <- getStartCode - case alexScan inp st of - AlexEOF -> return (L pos EOF) - AlexError inp' -> - let !len_bytes = B.length inp - B.length inp' in - --FIXME: we want len_chars here really - -- need to decode utf8 up to this point - lexicalError (incPos len_bytes pos) inp' - AlexSkip inp' len_chars -> do - checkPosition pos inp inp' len_chars - adjustPos (incPos len_chars) - setInput inp' - lexToken - AlexToken inp' len_chars action -> do - checkPosition pos inp inp' len_chars - adjustPos (incPos len_chars) - setInput inp' - let !len_bytes = B.length inp - B.length inp' - t <- action pos len_bytes inp - --traceShow t $ return tok - return t - -checkPosition :: Position -> ByteString -> ByteString -> Int -> Lex () -#ifdef CABAL_PARSEC_DEBUG -checkPosition pos@(Position lineno colno) inp inp' len_chars = do - text_lines <- getDbgText - let len_bytes = B.length inp - B.length inp' - pos_txt | lineno-1 < V.length text_lines = T.take len_chars (T.drop (colno-1) (text_lines V.! (lineno-1))) - | otherwise = T.empty - real_txt = B.take len_bytes inp - when (pos_txt /= T.decodeUtf8 real_txt) $ - traceShow (pos, pos_txt, T.decodeUtf8 real_txt) $ - traceShow (take 3 (V.toList text_lines)) $ return () - where - getDbgText = Lex $ \s@LexState{ dbgText = txt } -> LexResult s txt -#else -checkPosition _ _ _ _ = return () -#endif - -lexAll :: Lex [LToken] -lexAll = do - t <- lexToken - case t of - L _ EOF -> return [t] - _ -> do ts <- lexAll - return (t : ts) - -ltest :: Int -> String -> Prelude.IO () -ltest code s = - let (ws, xs) = execLexer (setStartCode code >> lexAll) (B.Char8.pack s) - in traverse_ print ws >> traverse_ print xs - -mkLexState :: ByteString -> LexState -mkLexState input = LexState - { curPos = Position 1 1 - , curInput = input - , curCode = 0 - , warnings = [] -#ifdef CABAL_PARSEC_DEBUG - , dbgText = V.fromList . lines' . T.decodeUtf8With T.lenientDecode $ input -#endif - } - -#ifdef CABAL_PARSEC_DEBUG -lines' :: T.Text -> [T.Text] -lines' s1 - | T.null s1 = [] - | otherwise = case T.break (\c -> c == '\r' || c == '\n') s1 of - (l, s2) | Just (c,s3) <- T.uncons s2 - -> case T.uncons s3 of - Just ('\n', s4) | c == '\r' -> l `T.snoc` '\r' `T.snoc` '\n' : lines' s4 - _ -> l `T.snoc` c : lines' s3 - - | otherwise - -> [l] -#endif - -bol_field_braces,bol_field_layout,bol_section,in_field_braces,in_field_layout,in_section :: Int -bol_field_braces = 1 -bol_field_layout = 2 -bol_section = 3 -in_field_braces = 4 -in_field_layout = 5 -in_section = 6 -alex_action_0 = \pos len _ -> do - when (len /= 0) $ addWarningAt pos LexWarningBOM - setPos pos -- reset position as if BOM didn't exist - setStartCode bol_section - lexToken -alex_action_1 = \pos len inp -> checkWhitespace pos len inp >> adjustPos retPos >> lexToken -alex_action_3 = \pos len inp -> checkLeadingWhitespace pos len inp >>= \len' -> - -- len' is character whitespace length (counting nbsp as one) - if B.length inp == len - then return (L pos EOF) - else do - -- Small hack: if char and byte length mismatch - -- subtract the difference, so lexToken will count position correctly. - -- Proper (and slower) fix is to count utf8 length in lexToken - when (len' /= len) $ adjustPos (incPos (len' - len)) - setStartCode in_section - return (L pos (Indent len')) -alex_action_4 = tok OpenBrace -alex_action_5 = tok CloseBrace -alex_action_8 = toki TokSym -alex_action_9 = \pos len inp -> return $! L pos (TokStr (B.take (len - 2) (B.tail inp))) -alex_action_10 = toki TokOther -alex_action_11 = toki TokOther -alex_action_12 = tok Colon -alex_action_13 = tok OpenBrace -alex_action_14 = tok CloseBrace -alex_action_15 = \_ _ _ -> adjustPos retPos >> setStartCode bol_section >> lexToken -alex_action_16 = \pos len inp -> checkLeadingWhitespace pos len inp >>= \len' -> - if B.length inp == len - then return (L pos EOF) - else do - -- Small hack: if char and byte length mismatch - -- subtract the difference, so lexToken will count position correctly. - -- Proper (and slower) fix is to count utf8 length in lexToken - when (len' /= len) $ adjustPos (incPos (len' - len)) - setStartCode in_field_layout - return (L pos (Indent len')) -alex_action_18 = toki TokFieldLine -alex_action_19 = \_ _ _ -> adjustPos retPos >> setStartCode bol_field_layout >> lexToken -alex_action_20 = \_ _ _ -> setStartCode in_field_braces >> lexToken -alex_action_22 = toki TokFieldLine -alex_action_23 = tok OpenBrace -alex_action_24 = tok CloseBrace -alex_action_25 = \_ _ _ -> adjustPos retPos >> setStartCode bol_field_braces >> lexToken - -#define ALEX_GHC 1 -#define ALEX_LATIN1 1 -#define ALEX_NOPRED 1 --- ----------------------------------------------------------------------------- --- ALEX TEMPLATE --- --- This code is in the PUBLIC DOMAIN; you may copy it freely and use --- it for any purpose whatsoever. - --- ----------------------------------------------------------------------------- --- INTERNALS and main scanner engine - -#ifdef ALEX_GHC -# define ILIT(n) n# -# define IBOX(n) (I# (n)) -# define FAST_INT Int# --- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex. -# if __GLASGOW_HASKELL__ > 706 -# define GTE(n,m) (tagToEnum# (n >=# m)) -# define EQ(n,m) (tagToEnum# (n ==# m)) -# else -# define GTE(n,m) (n >=# m) -# define EQ(n,m) (n ==# m) -# endif -# define PLUS(n,m) (n +# m) -# define MINUS(n,m) (n -# m) -# define TIMES(n,m) (n *# m) -# define NEGATE(n) (negateInt# (n)) -# define IF_GHC(x) (x) -#else -# define ILIT(n) (n) -# define IBOX(n) (n) -# define FAST_INT Int -# define GTE(n,m) (n >= m) -# define EQ(n,m) (n == m) -# define PLUS(n,m) (n + m) -# define MINUS(n,m) (n - m) -# define TIMES(n,m) (n * m) -# define NEGATE(n) (negate (n)) -# define IF_GHC(x) -#endif - -#ifdef ALEX_GHC -data AlexAddr = AlexA# Addr# --- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex. -#if __GLASGOW_HASKELL__ < 503 -uncheckedShiftL# = shiftL# -#endif - -{-# INLINE alexIndexInt16OffAddr #-} -alexIndexInt16OffAddr :: AlexAddr -> Int# -> Int# -alexIndexInt16OffAddr (AlexA# arr) off = -#ifdef WORDS_BIGENDIAN - narrow16Int# i - where - i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low) - high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) - low = int2Word# (ord# (indexCharOffAddr# arr off')) - off' = off *# 2# -#else -#if __GLASGOW_HASKELL__ >= 901 - int16ToInt# -#endif - (indexInt16OffAddr# arr off) -#endif -#else -alexIndexInt16OffAddr arr off = arr ! off -#endif - -#ifdef ALEX_GHC -{-# INLINE alexIndexInt32OffAddr #-} -alexIndexInt32OffAddr :: AlexAddr -> Int# -> Int# -alexIndexInt32OffAddr (AlexA# arr) off = -#ifdef WORDS_BIGENDIAN - narrow32Int# i - where - i = word2Int# ((b3 `uncheckedShiftL#` 24#) `or#` - (b2 `uncheckedShiftL#` 16#) `or#` - (b1 `uncheckedShiftL#` 8#) `or#` b0) - b3 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 3#))) - b2 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 2#))) - b1 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#))) - b0 = int2Word# (ord# (indexCharOffAddr# arr off')) - off' = off *# 4# -#else -#if __GLASGOW_HASKELL__ >= 901 - int32ToInt# -#endif - (indexInt32OffAddr# arr off) -#endif -#else -alexIndexInt32OffAddr arr off = arr ! off -#endif - -#ifdef ALEX_GHC - -#if __GLASGOW_HASKELL__ < 503 -quickIndex arr i = arr ! i -#else --- GHC >= 503, unsafeAt is available from Data.Array.Base. -quickIndex = unsafeAt -#endif -#else -quickIndex arr i = arr ! i -#endif - --- ----------------------------------------------------------------------------- --- Main lexing routines - -data AlexReturn a - = AlexEOF - | AlexError !AlexInput - | AlexSkip !AlexInput !Int - | AlexToken !AlexInput !Int a - --- alexScan :: AlexInput -> StartCode -> AlexReturn a -alexScan input__ IBOX(sc) - = alexScanUser undefined input__ IBOX(sc) - -alexScanUser user__ input__ IBOX(sc) - = case alex_scan_tkn user__ input__ ILIT(0) input__ sc AlexNone of - (AlexNone, input__') -> - case alexGetByte input__ of - Nothing -> -#ifdef ALEX_DEBUG - trace ("End of input.") $ -#endif - AlexEOF - Just _ -> -#ifdef ALEX_DEBUG - trace ("Error.") $ -#endif - AlexError input__' - - (AlexLastSkip input__'' len, _) -> -#ifdef ALEX_DEBUG - trace ("Skipping.") $ -#endif - AlexSkip input__'' len - - (AlexLastAcc k input__''' len, _) -> -#ifdef ALEX_DEBUG - trace ("Accept.") $ -#endif - AlexToken input__''' len (alex_actions ! k) - --- Push the input through the DFA, remembering the most recent accepting --- state it encountered. - -alex_scan_tkn user__ orig_input len input__ s last_acc = - input__ `seq` -- strict in the input - let - new_acc = (check_accs (alex_accept `quickIndex` IBOX(s))) - in - new_acc `seq` - case alexGetByte input__ of - Nothing -> (new_acc, input__) - Just (c, new_input) -> -#ifdef ALEX_DEBUG - trace ("State: " ++ show IBOX(s) ++ ", char: " ++ show c) $ -#endif - case fromIntegral c of { IBOX(ord_c) -> - let - base = alexIndexInt32OffAddr alex_base s - offset = PLUS(base,ord_c) - - new_s = if GTE(offset,ILIT(0)) - && let check = alexIndexInt16OffAddr alex_check offset - in EQ(check,ord_c) - then alexIndexInt16OffAddr alex_table offset - else alexIndexInt16OffAddr alex_deflt s - in - case new_s of - ILIT(-1) -> (new_acc, input__) - -- on an error, we want to keep the input *before* the - -- character that failed, not after. - _ -> alex_scan_tkn user__ orig_input -#ifdef ALEX_LATIN1 - PLUS(len,ILIT(1)) - -- issue 119: in the latin1 encoding, *each* byte is one character -#else - (if c < 0x80 || c >= 0xC0 then PLUS(len,ILIT(1)) else len) - -- note that the length is increased ONLY if this is the 1st byte in a char encoding) -#endif - new_input new_s new_acc - } - where - check_accs (AlexAccNone) = last_acc - check_accs (AlexAcc a ) = AlexLastAcc a input__ IBOX(len) - check_accs (AlexAccSkip) = AlexLastSkip input__ IBOX(len) -#ifndef ALEX_NOPRED - check_accs (AlexAccPred a predx rest) - | predx user__ orig_input IBOX(len) input__ - = AlexLastAcc a input__ IBOX(len) - | otherwise - = check_accs rest - check_accs (AlexAccSkipPred predx rest) - | predx user__ orig_input IBOX(len) input__ - = AlexLastSkip input__ IBOX(len) - | otherwise - = check_accs rest -#endif - -data AlexLastAcc - = AlexNone - | AlexLastAcc !Int !AlexInput !Int - | AlexLastSkip !AlexInput !Int - -data AlexAcc user - = AlexAccNone - | AlexAcc Int - | AlexAccSkip -#ifndef ALEX_NOPRED - | AlexAccPred Int (AlexAccPred user) (AlexAcc user) - | AlexAccSkipPred (AlexAccPred user) (AlexAcc user) - -type AlexAccPred user = user -> AlexInput -> Int -> AlexInput -> Bool - --- ----------------------------------------------------------------------------- --- Predicates on a rule - -alexAndPred p1 p2 user__ in1 len in2 - = p1 user__ in1 len in2 && p2 user__ in1 len in2 - ---alexPrevCharIsPred :: Char -> AlexAccPred _ -alexPrevCharIs c _ input__ _ _ = c == alexInputPrevChar input__ - -alexPrevCharMatches f _ input__ _ _ = f (alexInputPrevChar input__) - ---alexPrevCharIsOneOfPred :: Array Char Bool -> AlexAccPred _ -alexPrevCharIsOneOf arr _ input__ _ _ = arr ! alexInputPrevChar input__ - ---alexRightContext :: Int -> AlexAccPred _ -alexRightContext IBOX(sc) user__ _ _ input__ = - case alex_scan_tkn user__ input__ ILIT(0) input__ sc AlexNone of - (AlexNone, _) -> False - _ -> True - -- TODO: there's no need to find the longest - -- match when checking the right context, just - -- the first match will do. -#endif From 846852173d7c9abaac55b3d47e5f7d98b60965e8 Mon Sep 17 00:00:00 2001 From: Bryan Richter Date: Tue, 5 Sep 2023 13:51:30 +0300 Subject: [PATCH 02/12] gitlab-ci/brew.sh/curl: fail with more noise --- .gitlab/brew.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab/brew.sh b/.gitlab/brew.sh index a7bc6024124..7970113f98a 100644 --- a/.gitlab/brew.sh +++ b/.gitlab/brew.sh @@ -9,7 +9,7 @@ brew_dir="${CI_PROJECT_DIR}/.brew" if [ ! -e "${brew_dir}" ]; then mkdir -p "${brew_dir}" - curl -L "https://github.com/Homebrew/brew/archive/refs/tags/${BREW_VERSION}.tar.gz" | tar xz --strip 1 -C "${brew_dir}" + curl --fail-with-body -L "https://github.com/Homebrew/brew/archive/refs/tags/${BREW_VERSION}.tar.gz" | tar xz --strip 1 -C "${brew_dir}" fi export PATH="${brew_dir}/bin:${brew_dir}/sbin:$PATH" From b13ba8342c71b9177fec29070969d36585b9c082 Mon Sep 17 00:00:00 2001 From: Lin Runze Date: Mon, 28 Aug 2023 19:14:36 +0800 Subject: [PATCH 03/12] Add support for LoongArch 64-bit architecture --- Cabal-syntax/src/Distribution/System.hs | 4 +++- Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs | 4 ++-- Cabal/src/Distribution/Simple/PreProcess.hs | 1 + changelog.d/pr-9215 | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 changelog.d/pr-9215 diff --git a/Cabal-syntax/src/Distribution/System.hs b/Cabal-syntax/src/Distribution/System.hs index ad1cdedf57a..041d13a3be7 100644 --- a/Cabal-syntax/src/Distribution/System.hs +++ b/Cabal-syntax/src/Distribution/System.hs @@ -183,7 +183,7 @@ buildOS = classifyOS Permissive System.Info.os -- | These are the known Arches: I386, X86_64, PPC, PPC64, Sparc, -- Arm, AArch64, Mips, SH, IA64, S390, S390X, Alpha, Hppa, Rs6000, --- M68k, Vax, RISCV64, JavaScript and Wasm32. +-- M68k, Vax, RISCV64, LoongArch64, JavaScript and Wasm32. -- -- The following aliases can also be used: -- * PPC alias: powerpc @@ -211,6 +211,7 @@ data Arch | M68k | Vax | RISCV64 + | LoongArch64 | JavaScript | Wasm32 | OtherArch String @@ -240,6 +241,7 @@ knownArches = , M68k , Vax , RISCV64 + , LoongArch64 , JavaScript , Wasm32 ] diff --git a/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs b/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs index f2d22f7755a..900aedc0ca3 100644 --- a/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs +++ b/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs @@ -27,9 +27,9 @@ tests = testGroup "Distribution.Utils.Structured" -- The difference is in encoding of newtypes #if MIN_VERSION_base(4,7,0) , testCase "GenericPackageDescription" $ - md5Check (Proxy :: Proxy GenericPackageDescription) 0xedd391339de1201511636bbb563fa5db + md5Check (Proxy :: Proxy GenericPackageDescription) 0x6ad1e12c6f88291e9b8c131d239eda70 , testCase "LocalBuildInfo" $ - md5Check (Proxy :: Proxy LocalBuildInfo) 0x40253e3699453643336bdc7911717af0 + md5Check (Proxy :: Proxy LocalBuildInfo) 0xbc7ac84a9bc43345c812af222c3e5ba0 #endif ] diff --git a/Cabal/src/Distribution/Simple/PreProcess.hs b/Cabal/src/Distribution/Simple/PreProcess.hs index 92c45026a94..31e228812d6 100644 --- a/Cabal/src/Distribution/Simple/PreProcess.hs +++ b/Cabal/src/Distribution/Simple/PreProcess.hs @@ -863,6 +863,7 @@ platformDefines lbi = M68k -> ["m68k"] Vax -> ["vax"] RISCV64 -> ["riscv64"] + LoongArch64 -> ["loongarch64"] JavaScript -> ["javascript"] Wasm32 -> ["wasm32"] OtherArch _ -> [] diff --git a/changelog.d/pr-9215 b/changelog.d/pr-9215 new file mode 100644 index 00000000000..3e8b1159f25 --- /dev/null +++ b/changelog.d/pr-9215 @@ -0,0 +1,3 @@ +synopsis: Add support for 64-bit LoongArch architecture +prs: #9215 +packages: Cabal Cabal-syntax From 6946384ebde3b342b26bd1d23a588c28f77fabde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9cate=20Moonlight?= Date: Mon, 11 Sep 2023 00:05:12 +0200 Subject: [PATCH 04/12] Support text-2.1 in Cabal and Cabal-syntax (#9242) * Support text-2.1 in Cabal and Cabal-syntax * Add changelog entry * Use tasty-quickcheck 0.10.1.2 This avoid picking a tasty-quickcheck that can have tasty-1.5 * Revert "Use tasty-quickcheck 0.10.1.2" This reverts commit da03d8d560d6acf6aa62b3b2e5d013974083b642. --- Cabal-syntax/Cabal-syntax.cabal | 2 +- Cabal/Cabal.cabal | 2 +- changelog.d/pr-9242 | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelog.d/pr-9242 diff --git a/Cabal-syntax/Cabal-syntax.cabal b/Cabal-syntax/Cabal-syntax.cabal index a915c48db94..1ce638579d7 100644 --- a/Cabal-syntax/Cabal-syntax.cabal +++ b/Cabal-syntax/Cabal-syntax.cabal @@ -39,7 +39,7 @@ library mtl >= 2.1 && < 2.4, parsec >= 3.1.13.0 && < 3.2, pretty >= 1.1.1 && < 1.2, - text (>= 1.2.3.0 && < 1.3) || (>= 2.0 && < 2.1), + text (>= 1.2.3.0 && < 1.3) || (>= 2.0 && < 2.2), time >= 1.4.0.1 && < 1.13, -- transformers-0.4.0.0 doesn't have record syntax e.g. for Identity -- See also https://github.com/ekmett/transformers-compat/issues/35 diff --git a/Cabal/Cabal.cabal b/Cabal/Cabal.cabal index 48615f1a81a..87cd7138812 100644 --- a/Cabal/Cabal.cabal +++ b/Cabal/Cabal.cabal @@ -305,7 +305,7 @@ library -- See also https://github.com/ekmett/transformers-compat/issues/35 transformers (>= 0.3 && < 0.4) || (>=0.4.1.0 && <0.7), mtl >= 2.1 && < 2.4, - text (>= 1.2.3.0 && < 1.3) || (>= 2.0 && < 2.1), + text (>= 1.2.3.0 && < 1.3) || (>= 2.0 && < 2.2), parsec >= 3.1.13.0 && < 3.2 other-modules: diff --git a/changelog.d/pr-9242 b/changelog.d/pr-9242 new file mode 100644 index 00000000000..dfabc5fd982 --- /dev/null +++ b/changelog.d/pr-9242 @@ -0,0 +1,3 @@ +synopsis: Support text-2.1 in Cabal and Cabal-syntax +packages: Cabal Cabal-syntax +prs: #9242 From 869e0e59c87102f8e062e3596ee89007154a5a1a Mon Sep 17 00:00:00 2001 From: Bodigrim Date: Sat, 9 Sep 2023 20:30:35 +0100 Subject: [PATCH 05/12] Allow bytestring-0.12 --- Cabal-syntax/Cabal-syntax.cabal | 2 +- Cabal/Cabal.cabal | 2 +- cabal-install-solver/cabal-install-solver.cabal | 2 +- cabal-install/cabal-install.cabal | 2 +- cabal-testsuite/cabal-testsuite.cabal | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cabal-syntax/Cabal-syntax.cabal b/Cabal-syntax/Cabal-syntax.cabal index 1ce638579d7..8a230ba5e2a 100644 --- a/Cabal-syntax/Cabal-syntax.cabal +++ b/Cabal-syntax/Cabal-syntax.cabal @@ -31,7 +31,7 @@ library array >= 0.4.0.1 && < 0.6, base >= 4.9 && < 5, binary >= 0.7 && < 0.9, - bytestring >= 0.10.0.0 && < 0.12, + bytestring >= 0.10.0.0 && < 0.13, containers >= 0.5.0.0 && < 0.7, deepseq >= 1.3.0.1 && < 1.6, directory >= 1.2 && < 1.4, diff --git a/Cabal/Cabal.cabal b/Cabal/Cabal.cabal index 87cd7138812..5ac700ad461 100644 --- a/Cabal/Cabal.cabal +++ b/Cabal/Cabal.cabal @@ -37,7 +37,7 @@ library Cabal-syntax ^>= 3.11, array >= 0.4.0.1 && < 0.6, base >= 4.9 && < 5, - bytestring >= 0.10.0.0 && < 0.12, + bytestring >= 0.10.0.0 && < 0.13, containers >= 0.5.0.0 && < 0.7, deepseq >= 1.3.0.1 && < 1.6, directory >= 1.2 && < 1.4, diff --git a/cabal-install-solver/cabal-install-solver.cabal b/cabal-install-solver/cabal-install-solver.cabal index 7849e53b5b6..3aa2a435a11 100644 --- a/cabal-install-solver/cabal-install-solver.cabal +++ b/cabal-install-solver/cabal-install-solver.cabal @@ -106,7 +106,7 @@ library build-depends: , array >=0.4 && <0.6 , base >=4.10 && <4.19 - , bytestring >=0.10.6.0 && <0.12 + , bytestring >=0.10.6.0 && <0.13 , Cabal ^>=3.11 , Cabal-syntax ^>=3.11 , containers >=0.5.6.2 && <0.7 diff --git a/cabal-install/cabal-install.cabal b/cabal-install/cabal-install.cabal index dfc4a2d9ec5..ff0cf9fcb2d 100644 --- a/cabal-install/cabal-install.cabal +++ b/cabal-install/cabal-install.cabal @@ -208,7 +208,7 @@ library base16-bytestring >= 0.1.1 && < 1.1.0.0, base64-bytestring >= 1.0 && < 1.3, binary >= 0.7.3 && < 0.9, - bytestring >= 0.10.6.0 && < 0.12, + bytestring >= 0.10.6.0 && < 0.13, containers >= 0.5.6.2 && < 0.7, cryptohash-sha256 >= 0.11 && < 0.12, directory >= 1.3.7.0 && < 1.4, diff --git a/cabal-testsuite/cabal-testsuite.cabal b/cabal-testsuite/cabal-testsuite.cabal index 01278468e62..125ba5ecd55 100644 --- a/cabal-testsuite/cabal-testsuite.cabal +++ b/cabal-testsuite/cabal-testsuite.cabal @@ -61,7 +61,7 @@ library , async ^>= 2.2.1 , attoparsec ^>= 0.13.2.2 || ^>=0.14.1 , base64-bytestring ^>= 1.0.0.0 || ^>= 1.1.0.0 || ^>= 1.2.0.0 - , bytestring ^>= 0.10.0.2 || ^>= 0.11.0.0 + , bytestring ^>= 0.10.0.2 || ^>= 0.11.0.0 || ^>= 0.12.0.0 , containers ^>= 0.5.0.0 || ^>= 0.6.0.1 , cryptohash-sha256 ^>= 0.11.101.0 , directory ^>= 1.2.0.1 || ^>= 1.3.0.0 From 68f41aa4ae3c5bd4b02c17eaac258e91e88e6f5b Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Wed, 6 Sep 2023 16:14:06 +0100 Subject: [PATCH 06/12] Fix typo in code-generators documentation --- doc/cabal-package.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/cabal-package.rst b/doc/cabal-package.rst index 71340330526..17d190155fa 100644 --- a/doc/cabal-package.rst +++ b/doc/cabal-package.rst @@ -1269,7 +1269,7 @@ the :pkg-field:`test-module` field. preprocessors. These executables are invoked as so: ``exe-name TARGETDIR [SOURCEDIRS] -- [GHCOPTIONS]``. The arguments are, in order a target dir for output, a sequence of all source directories with source files of - local lib components that the given test stanza dependens on, and + local lib components that the given test stanza depends on, and following a double dash, all options cabal would pass to ghc for a build. They are expected to output a newline-seperated list of generated modules which have been written to the targetdir From fa54e31d329ae259160035a9d5c9eebac4b892df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 09:23:10 +0200 Subject: [PATCH 07/12] Bump actions/checkout from 3 to 4 (#9232) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrea Bedini --- .github/workflows/bootstrap.yml | 2 +- .github/workflows/changelogs.yml | 4 ++-- .github/workflows/format.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/quick-jobs.yml | 4 ++-- .github/workflows/users-guide.yml | 2 +- .github/workflows/validate.yml | 6 +++--- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/bootstrap.yml b/.github/workflows/bootstrap.yml index 74a1d857f58..c1734736e4c 100644 --- a/.github/workflows/bootstrap.yml +++ b/.github/workflows/bootstrap.yml @@ -34,7 +34,7 @@ jobs: key: bootstrap-${{ runner.os }}-${{ matrix.ghc }}-20221115-${{ github.sha }} restore-keys: bootstrap-${{ runner.os }}-${{ matrix.ghc }}-20221115- - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # See https://github.com/haskell/cabal/pull/8739 - name: Sudo chmod to permit ghcup to update its cache run: | diff --git a/.github/workflows/changelogs.yml b/.github/workflows/changelogs.yml index 425e5117188..c0ec46a6d1b 100644 --- a/.github/workflows/changelogs.yml +++ b/.github/workflows/changelogs.yml @@ -50,7 +50,7 @@ jobs: run: cabal v2-update # Cannot install it from tarball due to # https://github.com/haskell/cabal/issues/7360 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: "fgaz/changelog-d" path: "changelog-d" @@ -59,7 +59,7 @@ jobs: pushd changelog-d cabal v2-install popd - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run changelog-d run: | changelog-d changelog.d diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 7e75af1af62..ba5f85c9b82 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -9,7 +9,7 @@ jobs: fourmolu: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: haskell-actions/run-fourmolu@v8 with: pattern: | diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8eea2ece61b..fa12e98b878 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,7 +8,7 @@ jobs: hlint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: haskell/actions/hlint-setup@v2 with: version: "3.5" diff --git a/.github/workflows/quick-jobs.yml b/.github/workflows/quick-jobs.yml index d309cc97c09..9426ed79724 100644 --- a/.github/workflows/quick-jobs.yml +++ b/.github/workflows/quick-jobs.yml @@ -48,7 +48,7 @@ jobs: run: cabal v2-update - name: Install alex run: cabal v2-install alex --constraint='alex ==3.2.7.3' - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Regenerate files run: | make -B lexer @@ -87,7 +87,7 @@ jobs: ghcup install cabal --set latest - name: Update Hackage index run: cabal v2-update - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install doctest run: make doctest-install - name: Doctest diff --git a/.github/workflows/users-guide.yml b/.github/workflows/users-guide.yml index cd8137fbc38..ac6d65baedb 100644 --- a/.github/workflows/users-guide.yml +++ b/.github/workflows/users-guide.yml @@ -49,7 +49,7 @@ jobs: python-version: ['3.10'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 00512be6120..b1fc53a2352 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -55,7 +55,7 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # See the following link for a breakdown of the following step # https://github.com/haskell/actions/issues/7#issuecomment-745697160 @@ -197,7 +197,7 @@ jobs: # cause it does not work with the git version included in it, see: # https://github.com/actions/checkout/issues/170 # https://github.com/actions/checkout/issues/295 - # - uses: actions/checkout@v3 + # - uses: actions/checkout@v4 - name: Checkout run: | echo $GITHUB_REF $GITHUB_SHA @@ -251,7 +251,7 @@ jobs: ghc: ${{ fromJSON (needs.validate.outputs.GHC_FOR_RELEASE) }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # See https://github.com/haskell/cabal/pull/8739 - name: Sudo chmod to permit ghcup to update its cache From a0d815c4773a9d7aa0f48cc5bd08947d282dc917 Mon Sep 17 00:00:00 2001 From: Sebastian Tee <48444491+SebTee@users.noreply.github.com> Date: Fri, 15 Sep 2023 03:19:20 +0100 Subject: [PATCH 08/12] Support authentication tokens for uploading to Hackage (#9058) * Add token authorization for cabal upload Add token flag. If a token is set ignore the username and password. The token is passed to Hackage in the Authorization header. * Add token flag to upload documentation * Add token authentication for cabal report * Update auth token documentation and changelog * Add token flag to config integration tests * Add auth token header to plain-http transport * Add documentation and reduce wildcard usage Use Nothing in pattern matching instead of wildcards. * Add auth token headers to wget and powershell * Fix auth token header for powershell transport Powershell has to have the Authorization token set in the Header dictionary parameter. Some headers (e.g. User-Agent) have to be set as a request parameter. * Fix code formatting to comply with fourmolu --- .../Client/BuildReports/Upload.hs | 7 ++- .../src/Distribution/Client/Config.hs | 19 +++++- .../src/Distribution/Client/HttpUtils.hs | 63 ++++++++++++------- cabal-install/src/Distribution/Client/Main.hs | 3 + .../src/Distribution/Client/Setup.hs | 34 ++++++++-- .../Distribution/Client/Types/Credentials.hs | 10 ++- .../src/Distribution/Client/Upload.hs | 51 +++++++++------ cabal-install/tests/IntegrationTests2.hs | 1 + .../IntegrationTests2/config/default-config | 1 + .../IntegrationTests2/nix-config/nix-false | 1 + .../IntegrationTests2/nix-config/nix-true | 1 + changelog.d/issue-6738 | 12 ++++ doc/cabal-commands.rst | 12 ++++ 13 files changed, 163 insertions(+), 52 deletions(-) create mode 100644 changelog.d/issue-6738 diff --git a/cabal-install/src/Distribution/Client/BuildReports/Upload.hs b/cabal-install/src/Distribution/Client/BuildReports/Upload.hs index d7ce5d0e7bc..253daf6bc0c 100644 --- a/cabal-install/src/Distribution/Client/BuildReports/Upload.hs +++ b/cabal-install/src/Distribution/Client/BuildReports/Upload.hs @@ -28,6 +28,7 @@ import Distribution.Client.HttpUtils import Distribution.Client.Setup ( RepoContext (..) ) +import Distribution.Client.Types.Credentials (Auth) import Distribution.Simple.Utils (die') import System.FilePath.Posix ( () @@ -36,7 +37,7 @@ import System.FilePath.Posix type BuildReportId = URI type BuildLog = String -uploadReports :: Verbosity -> RepoContext -> (String, String) -> URI -> [(BuildReport, Maybe BuildLog)] -> IO () +uploadReports :: Verbosity -> RepoContext -> Auth -> URI -> [(BuildReport, Maybe BuildLog)] -> IO () uploadReports verbosity repoCtxt auth uri reports = do for_ reports $ \(report, mbBuildLog) -> do buildId <- postBuildReport verbosity repoCtxt auth uri report @@ -44,7 +45,7 @@ uploadReports verbosity repoCtxt auth uri reports = do Just buildLog -> putBuildLog verbosity repoCtxt auth buildId buildLog Nothing -> return () -postBuildReport :: Verbosity -> RepoContext -> (String, String) -> URI -> BuildReport -> IO BuildReportId +postBuildReport :: Verbosity -> RepoContext -> Auth -> URI -> BuildReport -> IO BuildReportId postBuildReport verbosity repoCtxt auth uri buildReport = do let fullURI = uri{uriPath = "/package" prettyShow (BuildReport.package buildReport) "reports"} transport <- repoContextGetTransport repoCtxt @@ -87,7 +88,7 @@ postBuildReport verbosity repoCtxt auth uri buildReport = do putBuildLog :: Verbosity -> RepoContext - -> (String, String) + -> Auth -> BuildReportId -> BuildLog -> IO () diff --git a/cabal-install/src/Distribution/Client/Config.hs b/cabal-install/src/Distribution/Client/Config.hs index 13f94146c08..a590c339cd8 100644 --- a/cabal-install/src/Distribution/Client/Config.hs +++ b/cabal-install/src/Distribution/Client/Config.hs @@ -95,7 +95,11 @@ import Distribution.Client.Types , isRelaxDeps , unRepoName ) -import Distribution.Client.Types.Credentials (Password (..), Username (..)) +import Distribution.Client.Types.Credentials + ( Password (..) + , Token (..) + , Username (..) + ) import Distribution.Utils.NubList ( NubList , fromNubList @@ -569,6 +573,7 @@ instance Semigroup SavedConfig where UploadFlags { uploadCandidate = combine uploadCandidate , uploadDoc = combine uploadDoc + , uploadToken = combine uploadToken , uploadUsername = combine uploadUsername , uploadPassword = combine uploadPassword , uploadPasswordCmd = combine uploadPasswordCmd @@ -579,7 +584,8 @@ instance Semigroup SavedConfig where combinedSavedReportFlags = ReportFlags - { reportUsername = combine reportUsername + { reportToken = combine reportToken + , reportUsername = combine reportUsername , reportPassword = combine reportPassword , reportVerbosity = combine reportVerbosity } @@ -1275,7 +1281,7 @@ configFieldDescriptions src = ++ toSavedConfig liftReportFlag (commandOptions reportCommand ParseArgs) - ["verbose", "username", "password"] + ["verbose", "token", "username", "password"] [] -- FIXME: this is a hack, hiding the user name and password. -- But otherwise it masks the upload ones. Either need to @@ -1340,6 +1346,13 @@ deprecatedFieldDescriptions = (optionalFlag parsecFilePath) globalCacheDir (\d cfg -> cfg{globalCacheDir = d}) + , liftUploadFlag $ + simpleFieldParsec + "hackage-token" + (Disp.text . fromFlagOrDefault "" . fmap unToken) + (optionalFlag (fmap Token parsecToken)) + uploadToken + (\d cfg -> cfg{uploadToken = d}) , liftUploadFlag $ simpleFieldParsec "hackage-username" diff --git a/cabal-install/src/Distribution/Client/HttpUtils.hs b/cabal-install/src/Distribution/Client/HttpUtils.hs index 8cf9bce7203..5b470a8f80f 100644 --- a/cabal-install/src/Distribution/Client/HttpUtils.hs +++ b/cabal-install/src/Distribution/Client/HttpUtils.hs @@ -27,6 +27,7 @@ import Distribution.Client.Types ( RemoteRepo (..) , unRepoName ) +import Distribution.Client.Types.Credentials (Auth) import Distribution.Client.Utils ( withTempFileName ) @@ -353,7 +354,7 @@ data HttpTransport = HttpTransport -> String -> Maybe Auth -> IO (HttpCode, String) - -- ^ POST a resource to a URI, with optional auth (username, password) + -- ^ POST a resource to a URI, with optional 'Auth' -- and return the HTTP status code and any redirect URL. , postHttpFile :: Verbosity @@ -362,7 +363,7 @@ data HttpTransport = HttpTransport -> Maybe Auth -> IO (HttpCode, String) -- ^ POST a file resource to a URI using multipart\/form-data encoding, - -- with optional auth (username, password) and return the HTTP status + -- with optional 'Auth' and return the HTTP status -- code and any error string. , putHttpFile :: Verbosity @@ -371,8 +372,8 @@ data HttpTransport = HttpTransport -> Maybe Auth -> [Header] -> IO (HttpCode, String) - -- ^ PUT a file resource to a URI, with optional auth - -- (username, password), extra headers and return the HTTP status code + -- ^ PUT a file resource to a URI, with optional 'Auth', + -- extra headers and return the HTTP status code -- and any error string. , transportSupportsHttps :: Bool -- ^ Whether this transport supports https or just http. @@ -387,13 +388,12 @@ data HttpTransport = HttpTransport type HttpCode = Int type ETag = String -type Auth = (String, String) noPostYet :: Verbosity -> URI -> String - -> Maybe (String, String) + -> Maybe Auth -> IO (Int, String) noPostYet verbosity _ _ _ = die' verbosity "Posting (for report upload) is not implemented yet" @@ -536,12 +536,13 @@ curlTransport prog = (Just (URIAuth u _ _)) | not (null u) -> Just $ filter (/= '@') u _ -> Nothing -- prefer passed in auth to auth derived from uri. If neither exist, then no auth - let mbAuthString = case (explicitAuth, uriDerivedAuth) of - (Just (uname, passwd), _) -> Just (uname ++ ":" ++ passwd) - (Nothing, Just a) -> Just a + let mbAuthStringToken = case (explicitAuth, uriDerivedAuth) of + (Just (Right token), _) -> Just $ Right token + (Just (Left (uname, passwd)), _) -> Just $ Left (uname ++ ":" ++ passwd) + (Nothing, Just a) -> Just $ Left a (Nothing, Nothing) -> Nothing - case mbAuthString of - Just up -> + case mbAuthStringToken of + Just (Left up) -> progInvocation { progInvokeInput = Just . IODataText . unlines $ @@ -550,6 +551,12 @@ curlTransport prog = ] , progInvokeArgs = ["--config", "-"] ++ progInvokeArgs progInvocation } + Just (Right token) -> + progInvocation + { progInvokeArgs = + ["--header", "Authorization: X-ApiKey " ++ token] + ++ progInvokeArgs progInvocation + } Nothing -> progInvocation posthttpfile verbosity uri path auth = do @@ -702,6 +709,7 @@ wgetTransport prog = ++ "boundary=" ++ boundary ] + ++ maybeToList (authTokenHeader auth) out <- runWGet verbosity (addUriAuth auth uri) args (code, _etag) <- parseOutput verbosity uri out withFile responseFile ReadMode $ \hnd -> do @@ -723,6 +731,7 @@ wgetTransport prog = ++ [ "--header=" ++ show name ++ ": " ++ value | Header name value <- headers ] + ++ maybeToList (authTokenHeader auth) out <- runWGet verbosity (addUriAuth auth uri) args (code, _etag) <- parseOutput verbosity uri out @@ -730,13 +739,16 @@ wgetTransport prog = resp <- hGetContents hnd evaluate $ force (code, resp) - addUriAuth Nothing uri = uri - addUriAuth (Just (user, pass)) uri = + authTokenHeader (Just (Right token)) = Just $ "--header=Authorization: X-ApiKey " ++ token + authTokenHeader _ = Nothing + + addUriAuth (Just (Left (user, pass))) uri = uri { uriAuthority = Just a{uriUserInfo = user ++ ":" ++ pass ++ "@"} } where a = fromMaybe (URIAuth "" "" "") (uriAuthority uri) + addUriAuth _ uri = uri runWGet verbosity uri args = do -- We pass the URI via STDIN because it contains the users' credentials @@ -918,14 +930,16 @@ powershellTransport prog = in "AddRange(\"bytes\", " ++ escape start ++ ", " ++ escape end ++ ");" name -> "Headers.Add(" ++ escape (show name) ++ "," ++ escape value ++ ");" - setupAuth auth = + setupAuth (Just (Left (uname, passwd))) = [ "$request.Credentials = new-object System.Net.NetworkCredential(" - ++ escape uname - ++ "," - ++ escape passwd - ++ ",\"\");" - | (uname, passwd) <- maybeToList auth + ++ escape uname + ++ "," + ++ escape passwd + ++ ",\"\");" ] + setupAuth (Just (Right token)) = + ["$request.Headers[\"Authorization\"] = " ++ escape ("X-ApiKey " ++ token)] + setupAuth Nothing = [] uploadFileAction method _uri fullPath = [ "$request.Method = " ++ show method @@ -1027,6 +1041,7 @@ plainHttpTransport = , Header HdrContentLength (show (LBS8.length body)) , Header HdrAccept ("text/plain") ] + ++ maybeToList (authTokenHeader auth) req = Request { rqURI = uri @@ -1046,7 +1061,8 @@ plainHttpTransport = , rqHeaders = Header HdrContentLength (show (LBS8.length body)) : Header HdrAccept "text/plain" - : headers + : maybeToList (authTokenHeader auth) + ++ headers , rqBody = body } (_, resp) <- cabalBrowse verbosity auth (request req) @@ -1076,9 +1092,14 @@ plainHttpTransport = setOutHandler (debug verbosity) setUserAgent userAgent setAllowBasicAuth False - setAuthorityGen (\_ _ -> return auth) + case auth of + Just (Left x) -> setAuthorityGen (\_ _ -> return $ Just x) + _ -> setAuthorityGen (\_ _ -> return Nothing) act + authTokenHeader (Just (Right token)) = Just $ Header HdrAuthorization ("X-ApiKey " ++ token) + authTokenHeader _ = Nothing + fixupEmptyProxy (Proxy uri _) | null uri = NoProxy fixupEmptyProxy p = p diff --git a/cabal-install/src/Distribution/Client/Main.hs b/cabal-install/src/Distribution/Client/Main.hs index 1a3cc94d49f..efe6bdf1f73 100644 --- a/cabal-install/src/Distribution/Client/Main.hs +++ b/cabal-install/src/Distribution/Client/Main.hs @@ -1118,6 +1118,7 @@ uploadAction uploadFlags extraArgs globalFlags = do Upload.uploadDoc verbosity repoContext + (flagToMaybe $ uploadToken uploadFlags') (flagToMaybe $ uploadUsername uploadFlags') maybe_password (fromFlag (uploadCandidate uploadFlags')) @@ -1126,6 +1127,7 @@ uploadAction uploadFlags extraArgs globalFlags = do Upload.upload verbosity repoContext + (flagToMaybe $ uploadToken uploadFlags') (flagToMaybe $ uploadUsername uploadFlags') maybe_password (fromFlag (uploadCandidate uploadFlags')) @@ -1199,6 +1201,7 @@ reportAction reportFlags extraArgs globalFlags = do Upload.report verbosity repoContext + (flagToMaybe $ reportToken reportFlags') (flagToMaybe $ reportUsername reportFlags') (flagToMaybe $ reportPassword reportFlags') diff --git a/cabal-install/src/Distribution/Client/Setup.hs b/cabal-install/src/Distribution/Client/Setup.hs index 44224d9559b..6d04d401a8a 100644 --- a/cabal-install/src/Distribution/Client/Setup.hs +++ b/cabal-install/src/Distribution/Client/Setup.hs @@ -93,7 +93,7 @@ import Distribution.Client.Compat.Prelude hiding (get) import Prelude () import Distribution.Client.Types.AllowNewer (AllowNewer (..), AllowOlder (..), RelaxDeps (..)) -import Distribution.Client.Types.Credentials (Password (..), Username (..)) +import Distribution.Client.Types.Credentials (Password (..), Token (..), Username (..)) import Distribution.Client.Types.Repo (LocalRepo (..), RemoteRepo (..)) import Distribution.Client.Types.WriteGhcEnvironmentFilesPolicy @@ -1648,7 +1648,8 @@ runCommand = -- ------------------------------------------------------------ data ReportFlags = ReportFlags - { reportUsername :: Flag Username + { reportToken :: Flag Token + , reportUsername :: Flag Username , reportPassword :: Flag Password , reportVerbosity :: Flag Verbosity } @@ -1657,7 +1658,8 @@ data ReportFlags = ReportFlags defaultReportFlags :: ReportFlags defaultReportFlags = ReportFlags - { reportUsername = mempty + { reportToken = mempty + , reportUsername = mempty , reportPassword = mempty , reportVerbosity = toFlag normal } @@ -1675,6 +1677,17 @@ reportCommand = , commandDefaultFlags = defaultReportFlags , commandOptions = \_ -> [ optionVerbosity reportVerbosity (\v flags -> flags{reportVerbosity = v}) + , option + ['t'] + ["token"] + "Hackage authentication Token." + reportToken + (\v flags -> flags{reportToken = v}) + ( reqArg' + "TOKEN" + (toFlag . Token) + (flagToList . fmap unToken) + ) , option ['u'] ["username"] @@ -2665,6 +2678,7 @@ data IsCandidate = IsCandidate | IsPublished data UploadFlags = UploadFlags { uploadCandidate :: Flag IsCandidate , uploadDoc :: Flag Bool + , uploadToken :: Flag Token , uploadUsername :: Flag Username , uploadPassword :: Flag Password , uploadPasswordCmd :: Flag [String] @@ -2677,6 +2691,7 @@ defaultUploadFlags = UploadFlags { uploadCandidate = toFlag IsCandidate , uploadDoc = toFlag False + , uploadToken = mempty , uploadUsername = mempty , uploadPassword = mempty , uploadPasswordCmd = mempty @@ -2692,7 +2707,7 @@ uploadCommand = , commandNotes = Just $ \_ -> "You can store your Hackage login in the ~/.config/cabal/config file\n" ++ "(the %APPDATA%\\cabal\\config file on Windows)\n" - ++ relevantConfigValuesText ["username", "password", "password-command"] + ++ relevantConfigValuesText ["token", "username", "password", "password-command"] , commandUsage = \pname -> "Usage: " ++ pname ++ " upload [FLAGS] TARFILES\n" , commandDefaultFlags = defaultUploadFlags @@ -2718,6 +2733,17 @@ uploadCommand = uploadDoc (\v flags -> flags{uploadDoc = v}) trueArg + , option + ['t'] + ["token"] + "Hackage authentication token." + uploadToken + (\v flags -> flags{uploadToken = v}) + ( reqArg' + "TOKEN" + (toFlag . Token) + (flagToList . fmap unToken) + ) , option ['u'] ["username"] diff --git a/cabal-install/src/Distribution/Client/Types/Credentials.hs b/cabal-install/src/Distribution/Client/Types/Credentials.hs index da208111c1f..5de185f178f 100644 --- a/cabal-install/src/Distribution/Client/Types/Credentials.hs +++ b/cabal-install/src/Distribution/Client/Types/Credentials.hs @@ -1,9 +1,15 @@ module Distribution.Client.Types.Credentials - ( Username (..) + ( Auth + , Token (..) + , Username (..) , Password (..) ) where -import Prelude (String) +import Prelude (Either, String) +-- | Either (username, password) or authentacation token +type Auth = Either (String, String) String + +newtype Token = Token {unToken :: String} newtype Username = Username {unUsername :: String} newtype Password = Password {unPassword :: String} diff --git a/cabal-install/src/Distribution/Client/Upload.hs b/cabal-install/src/Distribution/Client/Upload.hs index 7f78ee8e2e3..8b028a573cc 100644 --- a/cabal-install/src/Distribution/Client/Upload.hs +++ b/cabal-install/src/Distribution/Client/Upload.hs @@ -11,7 +11,12 @@ import Distribution.Client.Setup ( IsCandidate (..) , RepoContext (..) ) -import Distribution.Client.Types.Credentials (Password (..), Username (..)) +import Distribution.Client.Types.Credentials + ( Auth + , Password (..) + , Token (..) + , Username (..) + ) import Distribution.Client.Types.Repo (RemoteRepo (..), Repo, maybeRepoRemote) import Distribution.Client.Types.RepoName (unRepoName) @@ -32,8 +37,6 @@ import qualified System.FilePath.Posix as FilePath.Posix (()) import System.IO (hFlush, stdout) import System.IO.Echo (withoutInputEcho) -type Auth = Maybe (String, String) - -- > stripExtensions ["tar", "gz"] "foo.tar.gz" -- Just "foo" -- > stripExtensions ["tar", "gz"] "foo.gz.tar" @@ -48,12 +51,13 @@ stripExtensions exts path = foldM f path (reverse exts) upload :: Verbosity -> RepoContext + -> Maybe Token -> Maybe Username -> Maybe Password -> IsCandidate -> [FilePath] -> IO () -upload verbosity repoCtxt mUsername mPassword isCandidate paths = do +upload verbosity repoCtxt mToken mUsername mPassword isCandidate paths = do let repos :: [Repo] repos = repoContextRepos repoCtxt transport <- repoContextGetTransport repoCtxt @@ -87,9 +91,7 @@ upload verbosity repoCtxt mUsername mPassword isCandidate paths = do IsPublished -> "" ] } - Username username <- maybe (promptUsername domain) return mUsername - Password password <- maybe (promptPassword domain) return mPassword - let auth = Just (username, password) + auth <- Just <$> createAuth domain mToken mUsername mPassword for_ paths $ \path -> do notice verbosity $ "Uploading " ++ path ++ "... " case fmap takeFileName (stripExtensions ["tar", "gz"] path) of @@ -109,12 +111,13 @@ upload verbosity repoCtxt mUsername mPassword isCandidate paths = do uploadDoc :: Verbosity -> RepoContext + -> Maybe Token -> Maybe Username -> Maybe Password -> IsCandidate -> FilePath -> IO () -uploadDoc verbosity repoCtxt mUsername mPassword isCandidate path = do +uploadDoc verbosity repoCtxt mToken mUsername mPassword isCandidate path = do let repos = repoContextRepos repoCtxt transport <- repoContextGetTransport repoCtxt targetRepo <- @@ -160,11 +163,10 @@ uploadDoc verbosity repoCtxt mUsername mPassword isCandidate path = do || Unsafe.head reversePkgid /= '-' ) $ die' verbosity "Expected a file name matching the pattern -docs.tar.gz" - Username username <- maybe (promptUsername domain) return mUsername - Password password <- maybe (promptPassword domain) return mPassword - let auth = Just (username, password) - headers = + auth <- Just <$> createAuth domain mToken mUsername mPassword + + let headers = [ Header HdrContentType "application/x-tar" , Header HdrContentEncoding "gzip" ] @@ -212,18 +214,15 @@ promptPassword domain = do putStrLn "" return passwd -report :: Verbosity -> RepoContext -> Maybe Username -> Maybe Password -> IO () -report verbosity repoCtxt mUsername mPassword = do +report :: Verbosity -> RepoContext -> Maybe Token -> Maybe Username -> Maybe Password -> IO () +report verbosity repoCtxt mToken mUsername mPassword = do let repos :: [Repo] repos = repoContextRepos repoCtxt remoteRepos :: [RemoteRepo] remoteRepos = mapMaybe maybeRepoRemote repos for_ remoteRepos $ \remoteRepo -> do let domain = maybe "Hackage" uriRegName $ uriAuthority (remoteRepoURI remoteRepo) - Username username <- maybe (promptUsername domain) return mUsername - Password password <- maybe (promptPassword domain) return mPassword - let auth :: (String, String) - auth = (username, password) + auth <- createAuth domain mToken mUsername mPassword reportsDir <- defaultReportsDir let srcDir :: FilePath @@ -257,7 +256,7 @@ handlePackage -> Verbosity -> URI -> URI - -> Auth + -> Maybe Auth -> IsCandidate -> FilePath -> IO () @@ -294,3 +293,17 @@ handlePackage transport verbosity uri packageUri auth isCandidate path = formatWarnings :: String -> String formatWarnings x = "Warnings:\n" ++ (unlines . map ("- " ++) . lines) x + +createAuth + :: String + -> Maybe Token + -> Maybe Username + -> Maybe Password + -> IO Auth +createAuth domain mToken mUsername mPassword = case mToken of + Just token -> return $ Right $ unToken token + -- Use username and password if no token is provided + Nothing -> do + Username username <- maybe (promptUsername domain) return mUsername + Password password <- maybe (promptPassword domain) return mPassword + return $ Left (username, password) diff --git a/cabal-install/tests/IntegrationTests2.hs b/cabal-install/tests/IntegrationTests2.hs index fd9ed4ca19d..bf6e25c5b87 100644 --- a/cabal-install/tests/IntegrationTests2.hs +++ b/cabal-install/tests/IntegrationTests2.hs @@ -2075,6 +2075,7 @@ testConfigOptionComments = do "-- overwrite-policy" @=? findLineWith True "overwrite-policy" defaultConfigFile "-- install-method" @=? findLineWith True "install-method" defaultConfigFile "installdir" @=? findLineWith False "installdir" defaultConfigFile + "-- token" @=? findLineWith True "token" defaultConfigFile "-- username" @=? findLineWith True "username" defaultConfigFile "-- password" @=? findLineWith True "password" defaultConfigFile "-- password-command" @=? findLineWith True "password-command" defaultConfigFile diff --git a/cabal-install/tests/IntegrationTests2/config/default-config b/cabal-install/tests/IntegrationTests2/config/default-config index fab39496295..7ea0ac65d56 100644 --- a/cabal-install/tests/IntegrationTests2/config/default-config +++ b/cabal-install/tests/IntegrationTests2/config/default-config @@ -118,6 +118,7 @@ jobs: $ncpus -- overwrite-policy: -- install-method: installdir: /home/colton/.cabal/bin +-- token: -- username: -- password: -- password-command: diff --git a/cabal-install/tests/IntegrationTests2/nix-config/nix-false b/cabal-install/tests/IntegrationTests2/nix-config/nix-false index da13ba3874f..a85555fa5cd 100644 --- a/cabal-install/tests/IntegrationTests2/nix-config/nix-false +++ b/cabal-install/tests/IntegrationTests2/nix-config/nix-false @@ -111,6 +111,7 @@ jobs: $ncpus -- package-env: -- overwrite-policy: -- install-method: +-- token: -- username: -- password: -- password-command: diff --git a/cabal-install/tests/IntegrationTests2/nix-config/nix-true b/cabal-install/tests/IntegrationTests2/nix-config/nix-true index d45c34a5fdf..a7134c5c7fa 100644 --- a/cabal-install/tests/IntegrationTests2/nix-config/nix-true +++ b/cabal-install/tests/IntegrationTests2/nix-config/nix-true @@ -111,6 +111,7 @@ jobs: $ncpus -- package-env: -- overwrite-policy: -- install-method: +-- token: -- username: -- password: -- password-command: diff --git a/changelog.d/issue-6738 b/changelog.d/issue-6738 new file mode 100644 index 00000000000..d2bf4053756 --- /dev/null +++ b/changelog.d/issue-6738 @@ -0,0 +1,12 @@ +synopsis: Add support for authentication tokens for uploading to Hackage +packages: cabal-install +prs: #9058 +issues: #6738 + +description: { + +A new flag `--token` (`-t`) has been created. Token authentication takes +precedence over username and password meaning that, if a token is set, +the username and password flags are ignored. + +} \ No newline at end of file diff --git a/doc/cabal-commands.rst b/doc/cabal-commands.rst index 1c0776602ed..64077c97bb7 100644 --- a/doc/cabal-commands.rst +++ b/doc/cabal-commands.rst @@ -1109,6 +1109,12 @@ to Hackage. documentation for a published package (and not a candidate), add ``--publish``. +.. option:: -t TOKEN or -tTOKEN, --token=TOKEN + + Your Hackage authentication token. You can create and delete + authentication tokens on Hackage's `account management page + `__. + .. option:: -u USERNAME or -uUSERNAME, --username=USERNAME Your Hackage username. @@ -1138,6 +1144,12 @@ cabal report ``cabal report [FLAGS]`` uploads build reports to Hackage. +.. option:: -t TOKEN or -tTOKEN, --token=TOKEN + + Your Hackage authentication token. You can create and delete + authentication tokens on Hackage's `account management page + `__. + .. option:: -u USERNAME or -uUSERNAME, --username=USERNAME Your Hackage username. From d521b4e06984fe93f0b00d38773e0c83d42d4875 Mon Sep 17 00:00:00 2001 From: Andrea Bedini Date: Wed, 30 Aug 2023 18:18:18 +0800 Subject: [PATCH 09/12] Partially revert #8071 --- Cabal/src/Distribution/Simple/Configure.hs | 27 +------------------ Cabal/src/Distribution/Simple/Setup/Config.hs | 7 +---- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Configure.hs b/Cabal/src/Distribution/Simple/Configure.hs index f35f98f4fcb..d43a8f74de8 100644 --- a/Cabal/src/Distribution/Simple/Configure.hs +++ b/Cabal/src/Distribution/Simple/Configure.hs @@ -767,22 +767,6 @@ configure (pkg_descr0, pbi) cfg = do ) return False - let compilerSupportsGhciLibs :: Bool - compilerSupportsGhciLibs = - case compilerId comp of - CompilerId GHC version - | version > mkVersion [9, 3] && windows -> - False - CompilerId GHC _ -> - True - CompilerId GHCJS _ -> - True - _ -> False - where - windows = case compPlatform of - Platform _ Windows -> True - Platform _ _ -> False - let ghciLibByDefault = case compilerId comp of CompilerId GHC _ -> @@ -799,15 +783,6 @@ configure (pkg_descr0, pbi) cfg = do not (GHCJS.isDynamic comp) _ -> False - withGHCiLib_ <- - case fromFlagOrDefault ghciLibByDefault (configGHCiLib cfg) of - True | not compilerSupportsGhciLibs -> do - warn verbosity $ - "--enable-library-for-ghci is no longer supported on Windows with" - ++ " GHC 9.4 and later; ignoring..." - return False - v -> return v - let sharedLibsByDefault | fromFlag (configDynExe cfg) = -- build a shared library if dynamically-linked @@ -912,7 +887,7 @@ configure (pkg_descr0, pbi) cfg = do , withProfExeDetail = ProfDetailNone , withOptimization = fromFlag $ configOptimization cfg , withDebugInfo = fromFlag $ configDebugInfo cfg - , withGHCiLib = withGHCiLib_ + , withGHCiLib = fromFlagOrDefault ghciLibByDefault $ configGHCiLib cfg , splitSections = split_sections , splitObjs = split_objs , stripExes = strip_exe diff --git a/Cabal/src/Distribution/Simple/Setup/Config.hs b/Cabal/src/Distribution/Simple/Setup/Config.hs index 05fd07f33ca..210460d12b4 100644 --- a/Cabal/src/Distribution/Simple/Setup/Config.hs +++ b/Cabal/src/Distribution/Simple/Setup/Config.hs @@ -322,12 +322,7 @@ defaultConfigFlags progDb = , configCabalFilePath = NoFlag , configVerbosity = Flag normal , configUserInstall = Flag False -- TODO: reverse this -#if defined(mingw32_HOST_OS) - -- See #8062 and GHC #21019. - , configGHCiLib = Flag False -#else - , configGHCiLib = NoFlag -#endif + , configGHCiLib = Flag True , configSplitSections = Flag False , configSplitObjs = Flag False -- takes longer, so turn off by default , configStripExes = NoFlag From be82acce87f7216e3150257b642b724a68a1e1ac Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Wed, 6 Sep 2023 17:08:46 +1000 Subject: [PATCH 10/12] Only use relocatable linker flag if linker supports it --- Cabal/src/Distribution/Simple/Program/Ld.hs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Program/Ld.hs b/Cabal/src/Distribution/Simple/Program/Ld.hs index d7449b93964..dc42d582942 100644 --- a/Cabal/src/Distribution/Simple/Program/Ld.hs +++ b/Cabal/src/Distribution/Simple/Program/Ld.hs @@ -18,6 +18,8 @@ module Distribution.Simple.Program.Ld import Distribution.Compat.Prelude import Prelude () +import qualified Data.Map as Map + import Distribution.Simple.Compiler (arResponseFilesSupported) import Distribution.Simple.Flag ( fromFlagOrDefault @@ -67,10 +69,14 @@ combineObjectFiles verbosity lbi ld target files = do -- have a slight problem. What we have to do is link files in batches into -- a temp object file and then include that one in the next batch. - let simpleArgs = ["-r", "-o", target] + putStrLn "\n\n\n" + print ld + putStrLn "\n\n\n" + + let simpleArgs = prependRelocatableFlag ["-o", target] - initialArgs = ["-r", "-o", target] - middleArgs = ["-r", "-o", target, tmpfile] + initialArgs = prependRelocatableFlag ["-o", target] + middleArgs = prependRelocatableFlag ["-o", target, tmpfile] finalArgs = middleArgs simple = programInvocation ld simpleArgs @@ -104,3 +110,10 @@ combineObjectFiles verbosity lbi ld target files = do runProgramInvocation verbosity inv renameFile target tmpfile run invs + + -- Prepend "-r" to the list if the linker supports relocatable outputs. + prependRelocatableFlag :: [String] -> [String] + prependRelocatableFlag xs = + case Map.lookup "Supports relocatable output" $ programProperties ld of + Just "YES" -> "-r" : xs + _other -> xs From becad538eac721798a33e1eb39244bd2c6837075 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Mon, 18 Sep 2023 11:13:37 +1000 Subject: [PATCH 11/12] Fix configuation of ldProgram Standard GNU `ld` ues `--relocatable` while `ld.gold` uses a `-relocatable` flag (with a single `-`). Code will now detect both versions. --- Cabal/src/Distribution/Simple/Program/Builtin.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Cabal/src/Distribution/Simple/Program/Builtin.hs b/Cabal/src/Distribution/Simple/Program/Builtin.hs index 1f3db0740f3..7fcd1318c0a 100644 --- a/Cabal/src/Distribution/Simple/Program/Builtin.hs +++ b/Cabal/src/Distribution/Simple/Program/Builtin.hs @@ -370,7 +370,9 @@ ldProgram = -- `lld` only accepts `-help`. `catchIO` (\_ -> return "") let k = "Supports relocatable output" - v = if "--relocatable" `isInfixOf` ldHelpOutput then "YES" else "NO" + -- Standard GNU `ld` ues `--relocatable` while `ld.gold` uses + -- `-relocatable` (single `-`). + v = if "-relocatable" `isInfixOf` ldHelpOutput then "YES" else "NO" m = Map.insert k v (programProperties ldProg) return $ ldProg{programProperties = m} } From 90dad39972ceb9df7cc62531e058fd2f70a3a114 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Mon, 18 Sep 2023 11:24:59 +1000 Subject: [PATCH 12/12] Chain configuration of ldProgram `ldProgram` gets configured in two places, a seemingly default and a GHC specific version. The later needs to be updated so that it first calls the default configuration and then the new GHC version. --- Cabal/src/Distribution/Simple/GHC/Internal.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Cabal/src/Distribution/Simple/GHC/Internal.hs b/Cabal/src/Distribution/Simple/GHC/Internal.hs index e5f8938fc41..40499d08485 100644 --- a/Cabal/src/Distribution/Simple/GHC/Internal.hs +++ b/Cabal/src/Distribution/Simple/GHC/Internal.hs @@ -114,7 +114,9 @@ configureToolchain _implInfo ghcProg ghcInfo = . addKnownProgram ldProgram { programFindLocation = findProg ldProgramName extraLdPath - , programPostConf = configureLd + , programPostConf = \v cp -> + -- Call any existing configuration first and then add any new configuration + configureLd v =<< programPostConf ldProgram v cp } . addKnownProgram arProgram