diff options
author | Yuchen Pei <hi@ypei.me> | 2022-06-08 23:53:08 +1000 |
---|---|---|
committer | Yuchen Pei <hi@ypei.me> | 2022-06-08 23:53:08 +1000 |
commit | f7a7705332075449326a12816169aefa3acd1d00 (patch) | |
tree | ac912d2fe45029f3ab6479597f070c48800ad054 /src/CabalHelper/Runtime/HelperMain.hs | |
parent | 0e9df088226d80669dd0882ed743bca871dce61c (diff) |
- removing version constraints in cabal file so that build works with
ghc-9.2.2 + cabal-3.6.2.0
- fixing a do block indentation
- fixing a small poblem with ciSourceDirs because Cabal 3.6.2.0 has
hsSourceDirs :: BuildInfo -> [SymbolicPath PackageDir SourceDir]
instead of
BuildInfo -> [ FilePath ]
Diffstat (limited to 'src/CabalHelper/Runtime/HelperMain.hs')
-rw-r--r-- | src/CabalHelper/Runtime/HelperMain.hs | 122 |
1 files changed, 62 insertions, 60 deletions
diff --git a/src/CabalHelper/Runtime/HelperMain.hs b/src/CabalHelper/Runtime/HelperMain.hs index 983223b..3758181 100644 --- a/src/CabalHelper/Runtime/HelperMain.hs +++ b/src/CabalHelper/Runtime/HelperMain.hs @@ -24,6 +24,7 @@ module CabalHelper.Runtime.HelperMain (helper_main) where import Distribution.Simple.Utils (cabalVersion) import Distribution.Simple.Configure +import Distribution.Utils.Path import Distribution.Package ( PackageIdentifier , PackageId @@ -278,68 +279,68 @@ helper_main args = do let cmds = collectCmdOptions args' flip mapM cmds $$ \x -> do - case x of - "version":[] -> - return $ Just $ ChResponseVersion ("Cabal", toDataVersion cabalVersion) - - "package-id":[] -> - return $ Just $ ChResponseVersion $ (,) - (display (packageName gpd)) - (toDataVersion (packageVersion gpd)) - - "flags":[] -> do - return $ Just $ ChResponseFlags $ sort $ - map (flagName' &&& flagDefault) $ genPackageFlags gpd - - "config-flags":[] -> do - return $ Just $ ChResponseFlags $ sort $ - map (first unFlagName) - $ unFlagAssignment - $ configConfigurationsFlags - $ configFlags lbi - - "non-default-config-flags":[] -> do - let flagDefinitons = genPackageFlags gpd - flagAssgnments = + case x of + "version":[] -> + return $ Just $ ChResponseVersion ("Cabal", toDataVersion cabalVersion) + + "package-id":[] -> + return $ Just $ ChResponseVersion $ (,) + (display (packageName gpd)) + (toDataVersion (packageVersion gpd)) + + "flags":[] -> do + return $ Just $ ChResponseFlags $ sort $ + map (flagName' &&& flagDefault) $ genPackageFlags gpd + + "config-flags":[] -> do + return $ Just $ ChResponseFlags $ sort $ + map (first unFlagName) + $ unFlagAssignment + $ configConfigurationsFlags + $ configFlags lbi + + "non-default-config-flags":[] -> do + let flagDefinitons = genPackageFlags gpd + flagAssgnments = #if CH_MIN_VERSION_Cabal(2,2,0) - unFlagAssignment $ configConfigurationsFlags + unFlagAssignment $ configConfigurationsFlags #else - configConfigurationsFlags + configConfigurationsFlags #endif - $ configFlags lbi - nonDefaultFlags = - [ (flag_name, val) - | flag <- flagDefinitons - , let flag_name' = unFlagName $ flagName flag - , let def_val = flagDefault flag - , (unFlagName -> flag_name, val) <- flagAssgnments - , flag_name == flag_name' - , val /= def_val - ] - return $ Just $ ChResponseFlags $ sort nonDefaultFlags - - "write-autogen-files":[] -> do - initialBuildStepsForAllComponents distdir pd lbi v - return Nothing - - "compiler-id":[] -> do - let CompilerId comp ver = compilerId $ compiler lbi - return $ Just $ ChResponseVersion $ (,) (show comp) (toDataVersion ver) - - "component-info":[] -> do - res <- componentsInfo lvd pt - return $ Just $ ChResponseComponentsInfo res - - "print-lbi":flags -> - case flags of - ["--human"] -> print lbi >> return Nothing - _ -> return $ Just $ ChResponseLbi $ show lbi - - cmd:_ | not (cmd `elem` commands) -> - errMsg ("Unknown command: " ++ cmd) >> usage >> exitFailure - _ -> - errMsg "Invalid usage!" >> usage >> exitFailure - + $ configFlags lbi + nonDefaultFlags = + [ (flag_name, val) + | flag <- flagDefinitons + , let flag_name' = unFlagName $ flagName flag + , let def_val = flagDefault flag + , (unFlagName -> flag_name, val) <- flagAssgnments + , flag_name == flag_name' + , val /= def_val + ] + return $ Just $ ChResponseFlags $ sort nonDefaultFlags + + "write-autogen-files":[] -> do + initialBuildStepsForAllComponents distdir pd lbi v + return Nothing + + "compiler-id":[] -> do + let CompilerId comp ver = compilerId $ compiler lbi + return $ Just $ ChResponseVersion $ (,) (show comp) (toDataVersion ver) + + "component-info":[] -> do + res <- componentsInfo lvd pt + return $ Just $ ChResponseComponentsInfo res + + "print-lbi":flags -> + case flags of + ["--human"] -> print lbi >> return Nothing + _ -> return $ Just $ ChResponseLbi $ show lbi + + cmd:_ | not (cmd `elem` commands) -> + errMsg ("Unknown command: " ++ cmd) >> usage >> exitFailure + _ -> + errMsg "Invalid usage!" >> usage >> exitFailure + type ProjectType = String -- either "v1" or "v2" componentsInfo @@ -371,7 +372,8 @@ componentsInfo lvd@(lbi, v, distdir) pt = do $ ChComponentInfo <$> ZipList comp_name <*> ZipList (map snd ciGhcOptions) - <*> ZipList (map snd ciSourceDirs) + <*> ZipList (map (map getSymbolicPath . snd) + ciSourceDirs) <*> ZipList (map snd ciEntrypoints) return uiComponents |