cabal-helper 0.8.1.0 → 0.8.1.1
raw patch · 16 files changed
+407/−287 lines, 16 filesdep +pretty-showdep +textdep ~Cabaldep ~basedep ~cabal-planPVP ok
version bump matches the API change (PVP)
Dependencies added: pretty-show, text
Dependency ranges changed: Cabal, base, cabal-plan, containers
API changes (from Hackage documentation)
Files
- LICENSE +77/−64
- cabal-helper.cabal +27/−13
- lib/Distribution/Helper.hs +18/−12
- src/CabalHelper/Compiletime/Compat/Environment.hs +16/−0
- src/CabalHelper/Compiletime/Compat/ProgramDb.hs +30/−0
- src/CabalHelper/Compiletime/Compat/Version.hs +24/−0
- src/CabalHelper/Compiletime/Compile.hs +74/−36
- src/CabalHelper/Compiletime/Data.hs +6/−5
- src/CabalHelper/Compiletime/GuessGhc.hs +0/−92
- src/CabalHelper/Compiletime/Log.hs +6/−5
- src/CabalHelper/Compiletime/Types.hs +9/−7
- src/CabalHelper/Compiletime/Wrapper.hs +97/−33
- src/CabalHelper/Runtime/Main.hs +5/−5
- src/CabalHelper/Shared/Common.hs +6/−5
- src/CabalHelper/Shared/InterfaceTypes.hs +6/−5
- src/CabalHelper/Shared/Sandbox.hs +6/−5
LICENSE view
@@ -1,5 +1,5 @@- GNU AFFERO GENERAL PUBLIC LICENSE- Version 3, 19 November 2007+ GNU GENERAL PUBLIC LICENSE+ Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies@@ -7,15 +7,17 @@ Preamble - The GNU Affero General Public License is a free, copyleft license for-software and other kinds of works, specifically designed to ensure-cooperation with the community in the case of network server software.+ The GNU General Public License is a free, copyleft license for+software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast,-our General Public Licenses are intended to guarantee your freedom to+the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free-software for all its users.+software for all its users. We, the Free Software Foundation, use the+GNU General Public License for most of our software; it applies also to+any other work released this way by its authors. You can apply it to+your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you@@ -24,35 +26,45 @@ want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. - Developers that use our General Public Licenses protect your rights-with two steps: (1) assert copyright on the software, and (2) offer-you this License which gives you legal permission to copy, distribute-and/or modify the software.+ To protect your rights, we need to prevent others from denying you+these rights or asking you to surrender the rights. Therefore, you have+certain responsibilities if you distribute copies of the software, or if+you modify it: responsibilities to respect the freedom of others. - A secondary benefit of defending all users' freedom is that-improvements made in alternate versions of the program, if they-receive widespread use, become available for other developers to-incorporate. Many developers of free software are heartened and-encouraged by the resulting cooperation. However, in the case of-software used on network servers, this result may fail to come about.-The GNU General Public License permits making a modified version and-letting the public access it on a server without ever releasing its-source code to the public.+ For example, if you distribute copies of such a program, whether+gratis or for a fee, you must pass on to the recipients the same+freedoms that you received. You must make sure that they, too, receive+or can get the source code. And you must show them these terms so they+know their rights. - The GNU Affero General Public License is designed specifically to-ensure that, in such cases, the modified source code becomes available-to the community. It requires the operator of a network server to-provide the source code of the modified version running there to the-users of that server. Therefore, public use of a modified version, on-a publicly accessible server, gives the public access to the source-code of the modified version.+ Developers that use the GNU GPL protect your rights with two steps:+(1) assert copyright on the software, and (2) offer you this License+giving you legal permission to copy, distribute and/or modify it. - An older license, called the Affero General Public License and-published by Affero, was designed to accomplish similar goals. This is-a different license, not a version of the Affero GPL, but Affero has-released a new version of the Affero GPL which permits relicensing under-this license.+ For the developers' and authors' protection, the GPL clearly explains+that there is no warranty for this free software. For both users' and+authors' sake, the GPL requires that modified versions be marked as+changed, so that their problems will not be attributed erroneously to+authors of previous versions. + Some devices are designed to deny users access to install or run+modified versions of the software inside them, although the manufacturer+can do so. This is fundamentally incompatible with the aim of+protecting users' freedom to change the software. The systematic+pattern of such abuse occurs in the area of products for individuals to+use, which is precisely where it is most unacceptable. Therefore, we+have designed this version of the GPL to prohibit the practice for those+products. If such problems arise substantially in other domains, we+stand ready to extend this provision to those domains in future versions+of the GPL, as needed to protect the freedom of users.++ Finally, every program is threatened constantly by software patents.+States should not allow patents to restrict development and use of+software on general-purpose computers, but in those that do, we wish to+avoid the special danger that patents applied to a free program could+make it effectively proprietary. To prevent this, the GPL assures that+patents cannot be used to render the program non-free.+ The precise terms and conditions for copying, distribution and modification follow. @@ -60,7 +72,7 @@ 0. Definitions. - "This License" refers to version 3 of the GNU Affero General Public License.+ "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.@@ -537,45 +549,35 @@ the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. - 13. Remote Network Interaction; Use with the GNU General Public License.-- Notwithstanding any other provision of this License, if you modify the-Program, your modified version must prominently offer all users-interacting with it remotely through a computer network (if your version-supports such interaction) an opportunity to receive the Corresponding-Source of your version by providing access to the Corresponding Source-from a network server at no charge, through some standard or customary-means of facilitating copying of software. This Corresponding Source-shall include the Corresponding Source for any work covered by version 3-of the GNU General Public License that is incorporated pursuant to the-following paragraph.+ 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed-under version 3 of the GNU General Public License into a single+under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work,-but the work with which it is combined will remain governed by version-3 of the GNU General Public License.+but the special requirements of the GNU Affero General Public License,+section 13, concerning interaction through a network will apply to the+combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of-the GNU Affero General Public License from time to time. Such new versions-will be similar in spirit to the present version, but may differ in detail to+the GNU General Public License from time to time. Such new versions will+be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the-Program specifies that a certain numbered version of the GNU Affero General+Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the-GNU Affero General Public License, you may choose any version ever published+GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future-versions of the GNU Affero General Public License can be used, that proxy's+versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. @@ -633,29 +635,40 @@ Copyright (C) <year> <name of author> This program is free software: you can redistribute it and/or modify- it under the terms of the GNU Affero General Public License as published by+ it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- GNU Affero General Public License for more details.+ GNU General Public License for more details. - You should have received a copy of the GNU Affero General Public License+ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. - If your software can interact with users remotely through a computer-network, you should also make sure that it provides a way for users to-get its source. For example, if your program is a web application, its-interface could display a "Source" link that leads users to an archive-of the code. There are many ways you could offer source, and different-solutions will be better for different programs; see section 13 for the-specific requirements.+ If the program does terminal interaction, make it output a short+notice like this when it starts in an interactive mode: + <program> Copyright (C) <year> <name of author>+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.+ This is free software, and you are welcome to redistribute it+ under certain conditions; type `show c' for details.++The hypothetical commands `show w' and `show c' should show the appropriate+parts of the General Public License. Of course, your program's commands+might be different; for a GUI interface, you would use an "about box".+ You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary.-For more information on this, and how to apply and follow the GNU AGPL, see+For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.++ The GNU General Public License does not permit incorporating your program+into proprietary programs. If your program is a subroutine library, you+may consider it more useful to permit linking proprietary applications with+the library. If this is what you want to do, use the GNU Lesser General+Public License instead of this License. But first, please read+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
cabal-helper.cabal view
@@ -1,5 +1,5 @@ name: cabal-helper-version: 0.8.1.0+version: 0.8.1.1 synopsis: Simple interface to some of Cabal's configuration state, mainly used by ghc-mod description:@@ -24,11 +24,10 @@ is installed into a private, isolated, package database in @$XDG_CACHE_HOME/cabal-helper@ so as to not interfere with the user's package database.-license: AGPL-3+license: GPL-3 license-file: LICENSE-license-files: LICENSE-author: Daniel Gröber <dxld@darkboxed.org>-maintainer: dxld@darkboxed.org+author: Daniel Gröber <cabal-helper@dxld.at>+maintainer: cabal-helper@dxld.at category: Distribution build-type: Simple cabal-version: 2.0@@ -96,9 +95,12 @@ ghc-options: -Wall + -- well actually this is a "runtime"-tool-depends :)+ build-tool-depends: cabal-helper:cabal-helper-wrapper+ build-depends: base < 5 && >= 4.7- build-depends: Cabal < 2.3 && >= 2.0 || < 1.26 && >= 1.14- , cabal-plan < 0.4 && >= 0.3.0.0+ build-depends: Cabal < 2.5 && >= 2.0 || < 1.26 && >= 1.14+ , cabal-plan < 0.5 && >= 0.3.0.0 , containers < 1 && >= 0.5.5.1 , directory < 1.4 && >= 1.2.1.0 , filepath < 1.5 && >= 1.3.0.0@@ -125,10 +127,10 @@ hs-source-dirs: src other-modules: CabalHelper.Compiletime.Compat.Environment+ CabalHelper.Compiletime.Compat.ProgramDb CabalHelper.Compiletime.Compat.Version CabalHelper.Compiletime.Compile CabalHelper.Compiletime.Data- CabalHelper.Compiletime.GuessGhc CabalHelper.Compiletime.Log CabalHelper.Compiletime.Types CabalHelper.Shared.Common@@ -139,12 +141,16 @@ build-depends: base < 5 && >= 4.7 if os(windows) build-depends: base >= 4.7- build-depends: Cabal < 2.3 && >= 2.0 || < 1.26 && >= 1.14+ build-depends: Cabal < 2.5 && >= 2.0 || < 1.26 && >= 1.14+ , cabal-plan < 0.5 && >= 0.3.0.0+ , containers < 1 && >= 0.5.5.1 , bytestring < 0.11 && >= 0.9.2.1 , directory < 1.4 && >= 1.2.1.0 , filepath < 1.5 && >= 1.3.0.0 , mtl < 2.3 && >= 2.0 , process < 1.7 && >= 1.1.0.1+ , pretty-show < 1.9 && >= 1.8.1+ , text < 1.3 && >= 1.0.0.0 , template-haskell < 2.14 && >= 2.7.0.0 , temporary < 1.3 && >= 1.2.1 , transformers < 0.6 && >= 0.3.0.0@@ -169,10 +175,10 @@ hs-source-dirs: src other-modules: CabalHelper.Compiletime.Compat.Environment+ CabalHelper.Compiletime.Compat.ProgramDb CabalHelper.Compiletime.Compat.Version CabalHelper.Compiletime.Compile CabalHelper.Compiletime.Data- CabalHelper.Compiletime.GuessGhc CabalHelper.Compiletime.Log CabalHelper.Compiletime.Types CabalHelper.Shared.Common@@ -183,12 +189,16 @@ build-depends: base < 5 && >= 4.7 if os(windows) build-depends: base >= 4.7- build-depends: Cabal < 2.3 && >= 2.0 || < 1.26 && >= 1.14+ build-depends: Cabal < 2.5 && >= 2.0 || < 1.26 && >= 1.14+ , cabal-plan < 0.5 && >= 0.3.0.0+ , containers < 1 && >= 0.5.5.1 , bytestring < 0.11 && >= 0.9.2.1 , directory < 1.4 && >= 1.2.1.0 , filepath < 1.5 && >= 1.3.0.0 , mtl < 2.3 && >= 2.0 , process < 1.7 && >= 1.1.0.1+ , pretty-show < 1.9 && >= 1.8.1+ , text < 1.3 && >= 1.0.0.0 , template-haskell < 2.14 && >= 2.7.0.0 , temporary < 1.3 && >= 1.2.1 , transformers < 0.6 && >= 0.3.0.0@@ -216,10 +226,10 @@ hs-source-dirs: src other-modules: CabalHelper.Compiletime.Compat.Environment+ CabalHelper.Compiletime.Compat.ProgramDb CabalHelper.Compiletime.Compat.Version CabalHelper.Compiletime.Compile CabalHelper.Compiletime.Data- CabalHelper.Compiletime.GuessGhc CabalHelper.Compiletime.Log CabalHelper.Compiletime.Types CabalHelper.Shared.Common@@ -230,12 +240,16 @@ build-depends: base < 5 && >= 4.7 if os(windows) build-depends: base >= 4.7- build-depends: Cabal < 2.3 && >= 2.0 || < 1.26 && >= 1.14+ build-depends: Cabal < 2.5 && >= 2.0 || < 1.26 && >= 1.14+ , cabal-plan < 0.5 && >= 0.3.0.0+ , containers < 1 && >= 0.5.5.1 , bytestring < 0.11 && >= 0.9.2.1 , directory < 1.4 && >= 1.2.1.0 , filepath < 1.5 && >= 1.3.0.0 , mtl < 2.3 && >= 2.0 , process < 1.7 && >= 1.1.0.1+ , pretty-show < 1.9 && >= 1.8.1+ , text < 1.3 && >= 1.0.0.0 , template-haskell < 2.14 && >= 2.7.0.0 , temporary < 1.3 && >= 1.2.1 , transformers < 0.6 && >= 0.3.0.0
lib/Distribution/Helper.hs view
@@ -1,17 +1,17 @@--- ghc-mod: Making Haskell development *more* fun--- Copyright (C) 2015,2017 Daniel Gröber <dxld ÄT darkboxed DOT org>+-- cabal-helper: Simple interface to Cabal's configuration state+-- Copyright (C) 2015-2018 Daniel Gröber <cabal-helper@dxld.at> -- -- This program is free software: you can redistribute it and/or modify--- it under the terms of the GNU Affero General Public License as published by+-- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--- GNU Affero General Public License for more details.+-- GNU General Public License for more details. ----- You should have received a copy of the GNU Affero General Public License+-- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. {-# LANGUAGE CPP, RecordWildCards, FlexibleContexts, ConstraintKinds,@@ -21,8 +21,8 @@ {-| Module : Distribution.Helper-License : AGPL-3-Maintainer : dxld@darkboxed.org+License : GPL-3+Maintainer : cabal-helper@dxld.at Portability : POSIX -} @@ -113,7 +113,7 @@ import Data.Typeable import Data.Function import Data.Functor.Apply-import Distribution.Simple.BuildPaths (exeExtension)+import Distribution.System (buildOS, OS(Windows)) import System.Environment import System.FilePath hiding ((<.>)) import qualified System.FilePath as FP@@ -369,7 +369,7 @@ , "--with-cabal=" ++ cabalProgram qePrograms ] exe <- findLibexecExe- let args' = progArgs ++ qeProjectDir:qeDistDir:args+ let args' = progArgs ++ "v1-style":qeProjectDir:qeDistDir:args out <- qeReadProcess exe args' "" (Right <$> evaluate out) `E.catch` \(SomeException _) -> return $ Left $ concat@@ -501,10 +501,11 @@ tryFindCabalHelperTreeDistDir = do exe <- canonicalizePath =<< getExecutablePath' mplan <- findPlanJson exe+ let mdistdir = takeDirectory . takeDirectory <$> mplan cwd <- getCurrentDirectory let candidates = sortBy (compare `on` ddType) $ concat- [ maybeToList $ DistDir NewBuildDist <$> mplan+ [ maybeToList $ DistDir NewBuildDist <$> mdistdir , [ DistDir OldBuildDist $ (!!3) $ iterate takeDirectory exe ] , if takeFileName exe == "ghc" -- we're probably in ghci; try CWD then [ DistDir NewBuildDist $ cwd </> "dist-newstyle"@@ -539,7 +540,10 @@ isCabalHelperUnit Unit { uPId = PkgId (PkgName n) _ , uType = UnitTypeLocal- } | n == "cabal-helper" = True+ , uComps+ } | n == "cabal-helper" &&+ Map.member (CompNameExe "cabal-helper-wrapper") uComps+ = True isCabalHelperUnit _ = False toOldBuildDistDir x = return $ Just x @@ -580,4 +584,6 @@ lookupEnv' k = lookup k <$> getEnvironment exeExtension' :: FilePath-exeExtension' = Distribution.Simple.BuildPaths.exeExtension+exeExtension'+ | Windows <- buildOS = "exe"+ | otherwise = ""
src/CabalHelper/Compiletime/Compat/Environment.hs view
@@ -1,3 +1,19 @@+-- cabal-helper: Simple interface to Cabal's configuration state+-- Copyright (C) 2017 Daniel Gröber <cabal-helper@dxld.at>+--+-- This program is free software: you can redistribute it and/or modify+-- it under the terms of the GNU General Public License as published by+-- the Free Software Foundation, either version 3 of the License, or+-- (at your option) any later version.+--+-- This program is distributed in the hope that it will be useful,+-- but WITHOUT ANY WARRANTY; without even the implied warranty of+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+-- GNU General Public License for more details.+--+-- You should have received a copy of the GNU General Public License+-- along with this program. If not, see <http://www.gnu.org/licenses/>.+ {-# LANGUAGE CPP #-} module CabalHelper.Compiletime.Compat.Environment where
+ src/CabalHelper/Compiletime/Compat/ProgramDb.hs view
@@ -0,0 +1,30 @@+-- cabal-helper: Simple interface to Cabal's configuration state+-- Copyright (C) 2018 Daniel Gröber <cabal-helper@dxld.at>+--+-- This program is free software: you can redistribute it and/or modify+-- it under the terms of the GNU General Public License as published by+-- the Free Software Foundation, either version 3 of the License, or+-- (at your option) any later version.+--+-- This program is distributed in the hope that it will be useful,+-- but WITHOUT ANY WARRANTY; without even the implied warranty of+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+-- GNU General Public License for more details.+--+-- You should have received a copy of the GNU General Public License+-- along with this program. If not, see <http://www.gnu.org/licenses/>.++{-# LANGUAGE CPP #-}+module CabalHelper.Compiletime.Compat.ProgramDb+ ( defaultProgramDb+ , programPath+ , lookupProgram+ , ghcProgram+ , ghcPkgProgram+ ) where++import Distribution.Simple.Program++#if !MIN_VERSION_Cabal(2,0,0)+defaultProgramDb = defaultProgramConfiguration+#endif
src/CabalHelper/Compiletime/Compat/Version.hs view
@@ -1,9 +1,26 @@+-- cabal-helper: Simple interface to Cabal's configuration state+-- Copyright (C) 2017-2018 Daniel Gröber <cabal-helper@dxld.at>+--+-- This program is free software: you can redistribute it and/or modify+-- it under the terms of the GNU General Public License as published by+-- the Free Software Foundation, either version 3 of the License, or+-- (at your option) any later version.+--+-- This program is distributed in the hope that it will be useful,+-- but WITHOUT ANY WARRANTY; without even the implied warranty of+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+-- GNU General Public License for more details.+--+-- You should have received a copy of the GNU General Public License+-- along with this program. If not, see <http://www.gnu.org/licenses/>.+ {-# LANGUAGE CPP #-} module CabalHelper.Compiletime.Compat.Version ( DataVersion , toDataVersion , fromDataVersion , Data.Version.showVersion+ , makeDataVersion ) where import qualified Data.Version@@ -22,4 +39,11 @@ #else toDataVersion = id fromDataVersion = id+#endif++makeDataVersion :: [Int] -> Data.Version.Version+#if MIN_VERSION_base(4,8,0)+makeDataVersion = Data.Version.makeVersion+#else+makeDataVersion xs = Data.Version.Version xs [] #endif
src/CabalHelper/Compiletime/Compile.hs view
@@ -1,16 +1,17 @@--- Copyright (C) 2015,2017 Daniel Gröber <dxld ÄT darkboxed DOT org>+-- cabal-helper: Simple interface to Cabal's configuration state+-- Copyright (C) 2015-2018 Daniel Gröber <cabal-helper@dxld.at> -- -- This program is free software: you can redistribute it and/or modify--- it under the terms of the GNU Affero General Public License as published by+-- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--- GNU Affero General Public License for more details.+-- GNU General Public License for more details. ----- You should have received a copy of the GNU Affero General Public License+-- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. {-# LANGUAGE RecordWildCards, FlexibleContexts, NamedFieldPuns, DeriveFunctor, GADTs #-}@@ -18,11 +19,12 @@ {-| Module : CabalHelper.Compiletime.Compile Description : Runtime compilation machinery-License : AGPL-3+License : GPL-3 -} module CabalHelper.Compiletime.Compile where +import Cabal.Plan import Control.Applicative import Control.Arrow import Control.Exception as E@@ -47,6 +49,10 @@ import System.IO.Temp import Prelude ++import qualified Data.Text as Text+import qualified Data.Map.Strict as Map+ import Distribution.System (buildPlatform) import Distribution.Text (display) @@ -81,13 +87,15 @@ -- executable. data CompilationProductScope = CPSGlobal | CPSProject -compileHelper :: Options -> Version -> FilePath -> FilePath -> IO (Either ExitCode FilePath)-compileHelper opts hdrCabalVersion projdir distdir = do+compileHelper :: Options -> Version -> FilePath -> Maybe (PlanJson, FilePath) -> FilePath -> IO (Either ExitCode FilePath)+compileHelper opts hdrCabalVersion projdir mnewstyle distdir = do+ ghcVer <- ghcVersion opts Just (prepare, comp) <- runMaybeT $ msum $ case oCabalPkgDb opts of Nothing -> [ compileCabalSource- , compileSandbox+ , compileNewBuild ghcVer+ , compileSandbox ghcVer , compileGlobal , MaybeT $ Just <$> compileWithCabalInPrivatePkgDb ]@@ -104,7 +112,7 @@ vLog opts $ "helper already compiled, using exe: "++compExePath return (Right compExePath) else do- vLog opts $ "helper exe does not exist, compiling"++compExePath+ vLog opts $ "helper exe does not exist, compiling "++compExePath prepare >> compile comp cp opts where@@ -115,21 +123,38 @@ -- | Check if this version is globally available compileGlobal :: MaybeT IO (IO (), Compile) compileGlobal = do- ver <- MaybeT $ find (== hdrCabalVersion) <$> listCabalVersions opts+ cabal_versions <- listCabalVersions opts+ ver <- MaybeT $ return $ find (== hdrCabalVersion) cabal_versions vLog opts $ logMsg ++ "user/global package-db" return $ (return (), compileWithPkg Nothing ver CPSGlobal) -- | Check if this version is available in the project sandbox- compileSandbox :: MaybeT IO (IO (), Compile)- compileSandbox = do- let ghcVer = ghcVersion opts- mdb_path = getSandboxPkgDb projdir (display buildPlatform) =<< ghcVer+ compileSandbox :: Version -> MaybeT IO (IO (), Compile)+ compileSandbox ghcVer = do+ let mdb_path = getSandboxPkgDb projdir (display buildPlatform) ghcVer sandbox <- PackageDbDir <$> MaybeT mdb_path- ver <- MaybeT $ logIOError opts "compileSandbox" $- find (== hdrCabalVersion) <$> listCabalVersions' opts (Just sandbox)+ cabal_versions <- listCabalVersions' opts (Just sandbox)+ ver <- MaybeT $ return $ find (== hdrCabalVersion) cabal_versions vLog opts $ logMsg ++ "sandbox package-db" return $ (return (), compileWithPkg (Just sandbox) ver CPSProject) + compileNewBuild :: Version -> MaybeT IO (IO (), Compile)+ compileNewBuild ghcVer = do+ (PlanJson {pjUnits}, distdir_newstyle) <- maybe mzero pure mnewstyle+ let cabal_pkgid =+ PkgId (PkgName (Text.pack "Cabal"))+ (Ver $ versionBranch hdrCabalVersion)+ mcabal_unit = listToMaybe $+ Map.elems $ Map.filter (\Unit {..} -> uPId == cabal_pkgid) pjUnits+ Unit {} <- maybe mzero pure mcabal_unit+ let inplace_db_path = distdir_newstyle+ </> "packagedb" </> ("ghc-" ++ showVersion ghcVer)+ inplace_db = PackageDbDir inplace_db_path+ cabal_versions <- listCabalVersions' opts (Just inplace_db)+ ver <- MaybeT $ return $ find (== hdrCabalVersion) cabal_versions+ vLog opts $ logMsg ++ "v2-build package-db " ++ inplace_db_path+ return $ (return (), compileWithPkg (Just inplace_db) ver CPSProject)+ -- | Compile the requested Cabal version into an isolated package-db if it's -- not there already compileWithCabalInPrivatePkgDb :: IO (IO (), Compile)@@ -322,6 +347,13 @@ , "Cabal" ++ showVersion cabalVersion ] +readProcess' :: Options -> FilePath -> [String] -> String -> IO String+readProcess' opts@Options{..} exe args inp = do+ vLog opts $ intercalate " " $ map formatProcessArg (oGhcPkgProgram:args)+ outp <- readProcess exe args inp+ vLog opts $ unlines $ map ("=> "++) $ lines outp+ return outp+ callProcessStderr' :: Options -> Maybe FilePath -> FilePath -> [String] -> IO ExitCode callProcessStderr' opts mwd exe args = do@@ -377,7 +409,7 @@ withSystemTempDirectory "cabal-helper-Cabal-source" $ \tmpdir -> do (srcdir, cabalVer) <- case ever of Left HEAD -> do- second CabalHEAD <$> unpackCabalHEAD tmpdir+ second CabalHEAD <$> unpackCabalHEAD opts tmpdir Right ver -> do message ver let patch = fromMaybe nopCabalPatchDescription $@@ -578,13 +610,13 @@ callProcessStderr opts (Just tmpdir) (oCabalProgram opts) args return $ CabalSourceDir dir -unpackCabalHEAD :: FilePath -> IO (CabalSourceDir, CommitId)-unpackCabalHEAD tmpdir = do+unpackCabalHEAD :: Options -> FilePath -> IO (CabalSourceDir, CommitId)+unpackCabalHEAD opts tmpdir = do let dir = tmpdir </> "cabal-head.git" url = "https://github.com/haskell/cabal.git" ExitSuccess <- rawSystem "git" [ "clone", "--depth=1", url, dir] commit <-- withDirectory_ dir $ trim <$> readProcess "git" ["rev-parse", "HEAD"] ""+ withDirectory_ dir $ trim <$> readProcess' opts "git" ["rev-parse", "HEAD"] "" return (CabalSourceDir $ dir </> "Cabal", CommitId commit) where withDirectory_ :: FilePath -> IO a -> IO a@@ -629,40 +661,46 @@ where sver = showVersion cabalVer -listCabalVersions :: Options -> IO [Version]+listCabalVersions :: Options -> MaybeT IO [Version] listCabalVersions opts = listCabalVersions' opts Nothing --- TODO: Include sandbox? Probably only relevant for build-type:custom projects.-listCabalVersions' :: Options -> Maybe PackageDbDir -> IO [Version]-listCabalVersions' Options {..} mdb = do- let mdbopt = ("--package-conf="++) <$> unPackageDbDir <$> mdb- opts = ["list", "--simple-output", "Cabal"] ++ maybeToList mdbopt+listCabalVersions' :: Options -> Maybe PackageDbDir -> MaybeT IO [Version]+listCabalVersions' opts@Options {..} mdb = do+ case mdb of+ Nothing -> mzero+ Just (PackageDbDir db_path) -> do+ exists <- liftIO $ doesDirectoryExist db_path+ case exists of+ False -> mzero+ True -> MaybeT $ logIOError opts "listCabalVersions'" $ Just <$> do+ let mdbopt = ("--package-conf="++) <$> unPackageDbDir <$> mdb+ args = ["list", "--simple-output", "Cabal"] ++ maybeToList mdbopt - catMaybes . map (fmap snd . parsePkgId . fromString) . words- <$> readProcess oGhcPkgProgram opts ""+ catMaybes . map (fmap snd . parsePkgId . fromString) . words+ <$> readProcess' opts oGhcPkgProgram args "" cabalVersionExistsInPkgDb :: Options -> Version -> PackageDbDir -> IO Bool cabalVersionExistsInPkgDb opts cabalVer db@(PackageDbDir db_path) = do exists <- doesDirectoryExist db_path case exists of False -> return False- True -> do+ True -> fromMaybe False <$> runMaybeT (do vers <- listCabalVersions' opts (Just db)- return $ cabalVer `elem` vers+ return $ cabalVer `elem` vers) ghcVersion :: Options -> IO Version-ghcVersion Options {..} = do- parseVer . trim <$> readProcess oGhcProgram ["--numeric-version"] ""+ghcVersion opts@Options {..} = do+ parseVer . trim <$> readProcess' opts oGhcProgram ["--numeric-version"] "" ghcPkgVersion :: Options -> IO Version-ghcPkgVersion Options {..} = do- parseVer . trim . dropWhile (not . isDigit) <$> readProcess oGhcPkgProgram ["--version"] ""+ghcPkgVersion opts@Options {..} = do+ parseVer . trim . dropWhile (not . isDigit) <$> readProcess' opts oGhcPkgProgram ["--version"] "" newtype CabalInstallVersion = CabalInstallVersion { cabalInstallVer :: Version } cabalInstallVersion :: Options -> IO CabalInstallVersion-cabalInstallVersion Options {..} = do+cabalInstallVersion opts@Options {..} = do CabalInstallVersion . parseVer . trim- <$> readProcess oCabalProgram ["--numeric-version"] ""+ <$> readProcess' opts oCabalProgram ["--numeric-version"] "" createPkgDb :: Options -> CabalVersion -> IO PackageDbDir createPkgDb opts@Options {..} cabalVer = do
src/CabalHelper/Compiletime/Data.hs view
@@ -1,16 +1,17 @@--- Copyright (C) 2015,2017 Daniel Gröber <dxld ÄT darkboxed DOT org>+-- cabal-helper: Simple interface to Cabal's configuration state+-- Copyright (C) 2015-2017 Daniel Gröber <cabal-helper@dxld.at> -- -- This program is free software: you can redistribute it and/or modify--- it under the terms of the GNU Affero General Public License as published by+-- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--- GNU Affero General Public License for more details.+-- GNU General Public License for more details. ----- You should have received a copy of the GNU Affero General Public License+-- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. {-# LANGUAGE TemplateHaskell, ScopedTypeVariables #-}@@ -19,7 +20,7 @@ {-| Module : CabalHelper.Compiletime.Data Description : Embeds source code for runtime component using TH-License : AGPL-3+License : GPL-3 -} module CabalHelper.Compiletime.Data where
− src/CabalHelper/Compiletime/GuessGhc.hs
@@ -1,92 +0,0 @@--- Copyright (c) 2003-2014, Isaac Jones, Simon Marlow, Martin Sjögren,--- Bjorn Bringert, Krasimir Angelov,--- Malcolm Wallace, Ross Patterson, Ian Lynagh,--- Duncan Coutts, Thomas Schilling,--- Johan Tibell, Mikhail Glushenkov--- All rights reserved.---- Redistribution and use in source and binary forms, with or without--- modification, are permitted provided that the following conditions are--- met:---- * Redistributions of source code must retain the above copyright--- notice, this list of conditions and the following disclaimer.---- * Redistributions in binary form must reproduce the above--- copyright notice, this list of conditions and the following--- disclaimer in the documentation and/or other materials provided--- with the distribution.---- * Neither the name of Isaac Jones nor the names of other--- contributors may be used to endorse or promote products derived--- from this software without specific prior written permission.---- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS--- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT--- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR--- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT--- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,--- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT--- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,--- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY--- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT--- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE--- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.--{-|-Module : CabalHelper.Compiletime.GuessGhc-Description : Logic for finding @ghc-pkg@ based on path to @ghc@-License : BSD3--}--module CabalHelper.Compiletime.GuessGhc (guessToolFromGhcPath) where--import Data.Maybe-import Data.Char-import Distribution.Simple.BuildPaths-import System.Directory-import System.FilePath--guessToolFromGhcPath :: FilePath -- ^ Tool name- -> FilePath -- ^ GHC exe path- -> IO (Maybe FilePath)-guessToolFromGhcPath toolname ghcPath- = do let- path = ghcPath- dir = takeDirectory path- versionSuffix = takeVersionSuffix (dropExeExtension path)- guessNormal = dir </> toolname <.> exeExtension'- guessGhcVersioned = dir </> (toolname ++ "-ghc" ++ versionSuffix)- <.> exeExtension'- guessVersioned = dir </> (toolname ++ versionSuffix)- <.> exeExtension'- guesses | null versionSuffix = [guessNormal]- | otherwise = [guessGhcVersioned,- guessVersioned,- guessNormal]- exists <- mapM doesFileExist guesses- return $ listToMaybe [ file | (file, True) <- zip guesses exists ]-- where takeVersionSuffix :: FilePath -> String- takeVersionSuffix = takeWhileEndLE isSuffixChar-- isSuffixChar :: Char -> Bool- isSuffixChar c = isDigit c || c == '.' || c == '-'-- dropExeExtension :: FilePath -> FilePath- dropExeExtension filepath =- case splitExtension filepath of- (filepath', extension) | extension == exeExtension' -> filepath'- | otherwise -> filepath---- | @takeWhileEndLE p@ is equivalent to @reverse . takeWhile p . reverse@, but--- is usually faster (as well as being easier to read).-takeWhileEndLE :: (a -> Bool) -> [a] -> [a]-takeWhileEndLE p = fst . foldr go ([], False)- where- go x (rest, done)- | not done && p x = (x:rest, False)- | otherwise = (rest, True)--exeExtension' :: FilePath-exeExtension' = Distribution.Simple.BuildPaths.exeExtension
src/CabalHelper/Compiletime/Log.hs view
@@ -1,16 +1,17 @@--- Copyright (C) 2017 Daniel Gröber <dxld ÄT darkboxed DOT org>+-- cabal-helper: Simple interface to Cabal's configuration state+-- Copyright (C) 2017-2018 Daniel Gröber <cabal-helper@dxld.at> -- -- This program is free software: you can redistribute it and/or modify--- it under the terms of the GNU Affero General Public License as published by+-- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--- GNU Affero General Public License for more details.+-- GNU General Public License for more details. ----- You should have received a copy of the GNU Affero General Public License+-- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. {-# LANGUAGE ScopedTypeVariables #-}@@ -18,7 +19,7 @@ {-| Module : CabalHelper.Compiletime.Log Description : Basic logging facilities-License : AGPL-3+License : GPL-3 -} module CabalHelper.Compiletime.Log where
src/CabalHelper/Compiletime/Types.hs view
@@ -1,16 +1,17 @@--- Copyright (C) 2015 Daniel Gröber <dxld ÄT darkboxed DOT org>+-- cabal-helper: Simple interface to Cabal's configuration state+-- Copyright (C) 2015-2018 Daniel Gröber <cabal-helper@dxld.at> -- -- This program is free software: you can redistribute it and/or modify--- it under the terms of the GNU Affero General Public License as published by+-- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--- GNU Affero General Public License for more details.+-- GNU General Public License for more details. ----- You should have received a copy of the GNU Affero General Public License+-- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. {-# LANGUAGE DeriveGeneric, DeriveDataTypeable, DefaultSignatures #-}@@ -18,7 +19,7 @@ {-| Module : CabalHelper.Compiletime.Types Description : Types used throughout-License : AGPL-3+License : GPL-3 -} module CabalHelper.Compiletime.Types where@@ -26,7 +27,8 @@ import Data.Version data Options = Options {- oVerbose :: Bool+ oHelp :: Bool+ , oVerbose :: Bool , oGhcProgram :: FilePath , oGhcPkgProgram :: FilePath , oCabalProgram :: FilePath@@ -37,4 +39,4 @@ newtype PackageDbDir = PackageDbDir { unPackageDbDir :: FilePath } defaultOptions :: Options-defaultOptions = Options False "ghc" "ghc-pkg" "cabal" Nothing Nothing+defaultOptions = Options False False "ghc" "ghc-pkg" "cabal" Nothing Nothing
src/CabalHelper/Compiletime/Wrapper.hs view
@@ -1,21 +1,22 @@ -- cabal-helper: Simple interface to Cabal's configuration state--- Copyright (C) 2015 Daniel Gröber <dxld ÄT darkboxed DOT org>+-- Copyright (C) 2015-2018 Daniel Gröber <cabal-helper@dxld.at> -- -- This program is free software: you can redistribute it and/or modify--- it under the terms of the GNU Affero General Public License as published by+-- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--- GNU Affero General Public License for more details.+-- GNU General Public License for more details. ----- You should have received a copy of the GNU Affero General Public License+-- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>.-{-# LANGUAGE RecordWildCards, FlexibleContexts #-}+{-# LANGUAGE RecordWildCards, NamedFieldPuns, FlexibleContexts, ViewPatterns #-} module Main where +import Cabal.Plan import Control.Applicative import Control.Monad import Data.Char@@ -23,6 +24,7 @@ import Data.Maybe import Data.String import Text.Printf+import Text.Show.Pretty import System.Console.GetOpt import System.Environment import System.Directory@@ -32,15 +34,20 @@ import System.IO import Prelude +import qualified Data.Text as Text+import qualified Data.Map.Strict as Map+ import Distribution.System (buildPlatform) import Distribution.Text (display) import Distribution.Verbosity (silent, deafening) import Distribution.Package (packageName, packageVersion)+import Distribution.Simple.GHC as GHC (configure) import Paths_cabal_helper (version)+import CabalHelper.Compiletime.Compat.ProgramDb+ ( defaultProgramDb, programPath, lookupProgram, ghcProgram, ghcPkgProgram) import CabalHelper.Compiletime.Compat.Version import CabalHelper.Compiletime.Compile-import CabalHelper.Compiletime.GuessGhc import CabalHelper.Compiletime.Types import CabalHelper.Shared.Common import CabalHelper.Shared.InterfaceTypes@@ -59,11 +66,17 @@ \ [--with-cabal=CABAL_PATH]\n\ \ [--with-cabal-version=VERSION]\n\ \ [--with-cabal-pkg-db=PKG_DB]\n\-\ PROJ_DIR DIST_DIR ( print-exe | package-id | [CABAL_HELPER_ARGS...] ) )\n"+\ v1-style PROJ_DIR DIST_DIR \n\+\ ( print-exe | package-id | [CABAL_HELPER_ARGS...] )\n\+\ v2-style PROJ_DIR DIST_NEWSTYLE_DIR DIST_DIR\n\+\ ( print-exe | package-id | [CABAL_HELPER_ARGS...] )\n\+\)\n" globalArgSpec :: [OptDescr (Options -> Options)] globalArgSpec =- [ option "" ["verbose"] "Be more verbose" $+ [ option "h" ["help"] "Display help message" $+ NoArg $ \o -> o { oHelp = True }+ , option "" ["verbose"] "Be more verbose" $ NoArg $ \o -> o { oVerbose = True } , option "" ["with-ghc"] "GHC executable to use" $@@ -98,13 +111,27 @@ guessProgramPaths :: Options -> IO Options guessProgramPaths opts = do- if not (same oGhcProgram opts dopts) && same oGhcPkgProgram opts dopts- then do- mghcPkg <- guessToolFromGhcPath "ghc-pkg" (oGhcProgram opts)- return opts {- oGhcPkgProgram = fromMaybe (oGhcPkgProgram opts) mghcPkg- }- else return opts+ let v | oVerbose opts = deafening+ | otherwise = silent++ mGhcPath0 | same oGhcProgram opts dopts = Nothing+ | otherwise = Just $ oGhcProgram opts+ mGhcPkgPath0 | same oGhcPkgProgram opts dopts = Nothing+ | otherwise = Just $ oGhcPkgProgram opts++ (_compiler, _mplatform, progdb)+ <- GHC.configure+ v+ mGhcPath0+ mGhcPkgPath0+ defaultProgramDb++ let mghcPath1 = programPath <$> lookupProgram ghcProgram progdb+ mghcPkgPath1 = programPath <$> lookupProgram ghcPkgProgram progdb++ return $ opts { oGhcProgram = fromMaybe (oGhcProgram opts) mghcPath1+ , oGhcPkgProgram = fromMaybe (oGhcProgram opts) mghcPkgPath1+ } where same f o o' = f o == f o' dopts = defaultOptions@@ -121,6 +148,7 @@ (opts', args) <- parseCommandArgs defaultOptions <$> getArgs opts <- overrideVerbosityEnvVar =<< guessProgramPaths opts' case args of+ _ | oHelp opts -> usage [] -> usage "help":[] -> usage "version":[] -> putStrLn $ showVersion version@@ -128,7 +156,7 @@ "print-appcachedir":[] -> putStrLn =<< appCacheDir "print-build-platform":[] -> putStrLn $ display buildPlatform - projdir:_distdir:"package-id":[] -> do+ _:projdir:_distdir:"package-id":[] -> do let v | oVerbose opts = deafening | otherwise = silent -- ghc-mod will catch multiple cabal files existing before we get here@@ -137,27 +165,63 @@ putStrLn $ show $ [Just $ ChResponseVersion (display (packageName gpd)) (toDataVersion $ packageVersion gpd)] - projdir:distdir:args' -> do+ "v2-style":projdir:distdir_newstyle:unitid':args' -> do+ let unitid = UnitId $ Text.pack unitid'+ let plan_path = distdir_newstyle </> "cache" </> "plan.json"+ plan@PlanJson {pjCabalLibVersion=Ver (makeDataVersion -> pjCabalLibVersion) }+ <- decodePlanJson plan_path+ case oCabalVersion opts of+ Just ver | pjCabalLibVersion /= ver -> let+ sver = showVersion ver+ spjVer = showVersion pjCabalLibVersion+ in panic $ printf "\+\Cabal version %s was requested but plan.json was written by version %s" sver spjVer+ _ -> case Map.lookup unitid $ pjUnits plan of+ Just u@Unit {uType} | uType /= UnitTypeLocal -> do+ panic $ "\+\UnitId '"++ unitid' ++"' points to non-local unit: " ++ ppShow u+ Just Unit {uDistDir=Nothing} -> panic $ printf "\+\plan.json doesn't contain 'dist-dir' for UnitId '"++ unitid' ++"'"+ Just Unit {uType=UnitTypeLocal, uDistDir=Just distdir} ->+ runHelper opts projdir (Just (plan, distdir_newstyle)) distdir pjCabalLibVersion args'+ _ -> let+ units = map (\(UnitId u) -> Text.unpack u)+ $ Map.keys+ $ Map.filter ((==UnitTypeLocal) . uType)+ $ pjUnits plan++ units_list = unlines $ map (" "++) units+ in+ panic $ "\+\UnitId '"++ unitid' ++"' not found in plan.json, available local units:\n" ++ units_list++ "v1-style":projdir:distdir:args' -> do cfgf <- canonicalizePath (distdir </> "setup-config") mhdr <- getCabalConfigHeader cfgf- case mhdr of- Nothing -> panic $ printf "\+ case (mhdr, oCabalVersion opts) of+ (Nothing, _) -> panic $ printf "\ \Could not read Cabal's persistent setup configuration header\n\ \- Check first line of: %s\n\ \- Maybe try: $ cabal configure" cfgf- Just (hdrCabalVersion, _) -> do- case oCabalVersion opts of- Just ver | hdrCabalVersion /= ver -> panic $ printf "\+ (Just (hdrCabalVersion, _), Just ver)+ | hdrCabalVersion /= ver -> panic $ printf "\ \Cabal version %s was requested but setup configuration was\n\ \written by version %s" (showVersion ver) (showVersion hdrCabalVersion)- _ -> do- eexe <- compileHelper opts hdrCabalVersion projdir distdir- case eexe of- Left e -> exitWith e- Right exe ->- case args' of- "print-exe":_ -> putStrLn exe- _ -> do- (_,_,_,h) <- createProcess $ proc exe args- exitWith =<< waitForProcess h- _ -> error "invalid command line"+ (Just (hdrCabalVersion, _), _) ->+ runHelper opts projdir Nothing distdir hdrCabalVersion args'+ _ -> do+ hPutStrLn stderr "Invalid command line!"+ usage+ exitWith $ ExitFailure 1++runHelper :: Options -> FilePath -> Maybe (PlanJson, FilePath) -> FilePath -> DataVersion -> [String] -> IO ()+runHelper opts projdir mnewstyle distdir cabal_ver args' = do+ eexe <- compileHelper opts cabal_ver projdir mnewstyle distdir+ case eexe of+ Left e -> exitWith e+ Right exe -> do+ case args' of+ "print-exe":_ -> putStrLn exe+ _ -> do+ (_,_,_,h) <- createProcess $ proc exe $ projdir : distdir : args'+ exitWith =<< waitForProcess h
src/CabalHelper/Runtime/Main.hs view
@@ -1,16 +1,17 @@--- Copyright (C) 2015 Daniel Gröber <dxld ÄT darkboxed DOT org>+-- cabal-helper: Simple interface to Cabal's configuration state+-- Copyright (C) 2015-2018 Daniel Gröber <cabal-helper@dxld.at> -- -- This program is free software: you can redistribute it and/or modify--- it under the terms of the GNU Affero General Public License as published by+-- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--- GNU Affero General Public License for more details.+-- GNU General Public License for more details. ----- You should have received a copy of the GNU Affero General Public License+-- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. {-# LANGUAGE CPP, BangPatterns, RecordWildCards, RankNTypes, ViewPatterns #-}@@ -86,7 +87,6 @@ import Distribution.Simple.BuildPaths ( autogenModuleName , cppHeaderName- , exeExtension ) import Distribution.Simple.Compiler ( PackageDB(..)
@@ -1,22 +1,23 @@--- Copyright (C) 2015 Daniel Gröber <dxld ÄT darkboxed DOT org>+-- cabal-helper: Simple interface to Cabal's configuration state+-- Copyright (C) 2015-2018 Daniel Gröber <cabal-helper@dxld.at> -- -- This program is free software: you can redistribute it and/or modify--- it under the terms of the GNU Affero General Public License as published by+-- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--- GNU Affero General Public License for more details.+-- GNU General Public License for more details. ----- You should have received a copy of the GNU Affero General Public License+-- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. {-| Module : CabalHelper.Shared.Common Description : Shared utility functions-License : AGPL-3+License : GPL-3 -} {-# LANGUAGE CPP, DeriveDataTypeable, OverloadedStrings #-}
@@ -1,16 +1,17 @@--- Copyright (C) 2015,2017 Daniel Gröber <dxld ÄT darkboxed DOT org>+-- cabal-helper: Simple interface to Cabal's configuration state+-- Copyright (C) 2015-2018 Daniel Gröber <cabal-helper@dxld.at> -- -- This program is free software: you can redistribute it and/or modify--- it under the terms of the GNU Affero General Public License as published by+-- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--- GNU Affero General Public License for more details.+-- GNU General Public License for more details. ----- You should have received a copy of the GNU Affero General Public License+-- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. {-# LANGUAGE DeriveGeneric, DeriveDataTypeable, DefaultSignatures #-}@@ -18,7 +19,7 @@ {-| Module : CabalHelper.Shared.InterfaceTypes Description : Types which are used by c-h library and executable to communicate-License : AGPL-3+License : GPL-3 These types are used to communicate between the cabal-helper library and main executable, using Show/Read. If any types in this module change the major
@@ -1,22 +1,23 @@--- Copyright (C) 2015 Daniel Gröber <dxld ÄT darkboxed DOT org>+-- cabal-helper: Simple interface to Cabal's configuration state+-- Copyright (C) 2015-2017 Daniel Gröber <cabal-helper@dxld.at> -- -- This program is free software: you can redistribute it and/or modify--- it under the terms of the GNU Affero General Public License as published by+-- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--- GNU Affero General Public License for more details.+-- GNU General Public License for more details. ----- You should have received a copy of the GNU Affero General Public License+-- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. {-| Module : CabalHelper.Shared.Sandbox Description : Extracting information from @cabal.sandbox.config@ files-License : AGPL-3+License : GPL-3 -} module CabalHelper.Shared.Sandbox where