1module Distribution.Types.BuildInfo.Lens ( 2 BuildInfo, 3 HasBuildInfo (..), 4 HasBuildInfos (..), 5 ) where 6 7import Prelude () 8import Distribution.Compat.Prelude 9import Distribution.Compat.Lens 10 11import Distribution.Compiler (PerCompilerFlavor) 12import Distribution.ModuleName (ModuleName) 13import Distribution.Types.BuildInfo (BuildInfo) 14import Distribution.Types.Dependency (Dependency) 15import Distribution.Types.ExeDependency (ExeDependency) 16import Distribution.Types.LegacyExeDependency (LegacyExeDependency) 17import Distribution.Types.Mixin (Mixin) 18import Distribution.Types.PkgconfigDependency (PkgconfigDependency) 19import Language.Haskell.Extension (Extension, Language) 20 21import qualified Distribution.Types.BuildInfo as T 22 23-- | Classy lenses for 'BuildInfo'. 24class HasBuildInfo a where 25 buildInfo :: Lens' a BuildInfo 26 27 buildable :: Lens' a Bool 28 buildable = buildInfo . buildable 29 {-# INLINE buildable #-} 30 31 buildTools :: Lens' a [LegacyExeDependency] 32 buildTools = buildInfo . buildTools 33 {-# INLINE buildTools #-} 34 35 buildToolDepends :: Lens' a [ExeDependency] 36 buildToolDepends = buildInfo . buildToolDepends 37 {-# INLINE buildToolDepends #-} 38 39 cppOptions :: Lens' a [String] 40 cppOptions = buildInfo . cppOptions 41 {-# INLINE cppOptions #-} 42 43 asmOptions :: Lens' a [String] 44 asmOptions = buildInfo . asmOptions 45 {-# INLINE asmOptions #-} 46 47 cmmOptions :: Lens' a [String] 48 cmmOptions = buildInfo . cmmOptions 49 {-# INLINE cmmOptions #-} 50 51 ccOptions :: Lens' a [String] 52 ccOptions = buildInfo . ccOptions 53 {-# INLINE ccOptions #-} 54 55 cxxOptions :: Lens' a [String] 56 cxxOptions = buildInfo . cxxOptions 57 {-# INLINE cxxOptions #-} 58 59 ldOptions :: Lens' a [String] 60 ldOptions = buildInfo . ldOptions 61 {-# INLINE ldOptions #-} 62 63 pkgconfigDepends :: Lens' a [PkgconfigDependency] 64 pkgconfigDepends = buildInfo . pkgconfigDepends 65 {-# INLINE pkgconfigDepends #-} 66 67 frameworks :: Lens' a [String] 68 frameworks = buildInfo . frameworks 69 {-# INLINE frameworks #-} 70 71 extraFrameworkDirs :: Lens' a [String] 72 extraFrameworkDirs = buildInfo . extraFrameworkDirs 73 {-# INLINE extraFrameworkDirs #-} 74 75 asmSources :: Lens' a [FilePath] 76 asmSources = buildInfo . asmSources 77 {-# INLINE asmSources #-} 78 79 cmmSources :: Lens' a [FilePath] 80 cmmSources = buildInfo . cmmSources 81 {-# INLINE cmmSources #-} 82 83 cSources :: Lens' a [FilePath] 84 cSources = buildInfo . cSources 85 {-# INLINE cSources #-} 86 87 cxxSources :: Lens' a [FilePath] 88 cxxSources = buildInfo . cxxSources 89 {-# INLINE cxxSources #-} 90 91 jsSources :: Lens' a [FilePath] 92 jsSources = buildInfo . jsSources 93 {-# INLINE jsSources #-} 94 95 hsSourceDirs :: Lens' a [FilePath] 96 hsSourceDirs = buildInfo . hsSourceDirs 97 {-# INLINE hsSourceDirs #-} 98 99 otherModules :: Lens' a [ModuleName] 100 otherModules = buildInfo . otherModules 101 {-# INLINE otherModules #-} 102 103 virtualModules :: Lens' a [ModuleName] 104 virtualModules = buildInfo . virtualModules 105 {-# INLINE virtualModules #-} 106 107 autogenModules :: Lens' a [ModuleName] 108 autogenModules = buildInfo . autogenModules 109 {-# INLINE autogenModules #-} 110 111 defaultLanguage :: Lens' a (Maybe Language) 112 defaultLanguage = buildInfo . defaultLanguage 113 {-# INLINE defaultLanguage #-} 114 115 otherLanguages :: Lens' a [Language] 116 otherLanguages = buildInfo . otherLanguages 117 {-# INLINE otherLanguages #-} 118 119 defaultExtensions :: Lens' a [Extension] 120 defaultExtensions = buildInfo . defaultExtensions 121 {-# INLINE defaultExtensions #-} 122 123 otherExtensions :: Lens' a [Extension] 124 otherExtensions = buildInfo . otherExtensions 125 {-# INLINE otherExtensions #-} 126 127 oldExtensions :: Lens' a [Extension] 128 oldExtensions = buildInfo . oldExtensions 129 {-# INLINE oldExtensions #-} 130 131 extraLibs :: Lens' a [String] 132 extraLibs = buildInfo . extraLibs 133 {-# INLINE extraLibs #-} 134 135 extraGHCiLibs :: Lens' a [String] 136 extraGHCiLibs = buildInfo . extraGHCiLibs 137 {-# INLINE extraGHCiLibs #-} 138 139 extraBundledLibs :: Lens' a [String] 140 extraBundledLibs = buildInfo . extraBundledLibs 141 {-# INLINE extraBundledLibs #-} 142 143 extraLibFlavours :: Lens' a [String] 144 extraLibFlavours = buildInfo . extraLibFlavours 145 {-# INLINE extraLibFlavours #-} 146 147 extraDynLibFlavours :: Lens' a [String] 148 extraDynLibFlavours = buildInfo . extraDynLibFlavours 149 {-# INLINE extraDynLibFlavours #-} 150 151 extraLibDirs :: Lens' a [String] 152 extraLibDirs = buildInfo . extraLibDirs 153 {-# INLINE extraLibDirs #-} 154 155 includeDirs :: Lens' a [FilePath] 156 includeDirs = buildInfo . includeDirs 157 {-# INLINE includeDirs #-} 158 159 includes :: Lens' a [FilePath] 160 includes = buildInfo . includes 161 {-# INLINE includes #-} 162 163 autogenIncludes :: Lens' a [FilePath] 164 autogenIncludes = buildInfo . autogenIncludes 165 {-# INLINE autogenIncludes #-} 166 167 installIncludes :: Lens' a [FilePath] 168 installIncludes = buildInfo . installIncludes 169 {-# INLINE installIncludes #-} 170 171 options :: Lens' a (PerCompilerFlavor [String]) 172 options = buildInfo . options 173 {-# INLINE options #-} 174 175 profOptions :: Lens' a (PerCompilerFlavor [String]) 176 profOptions = buildInfo . profOptions 177 {-# INLINE profOptions #-} 178 179 sharedOptions :: Lens' a (PerCompilerFlavor [String]) 180 sharedOptions = buildInfo . sharedOptions 181 {-# INLINE sharedOptions #-} 182 183 staticOptions :: Lens' a (PerCompilerFlavor [String]) 184 staticOptions = buildInfo . staticOptions 185 {-# INLINE staticOptions #-} 186 187 customFieldsBI :: Lens' a [(String,String)] 188 customFieldsBI = buildInfo . customFieldsBI 189 {-# INLINE customFieldsBI #-} 190 191 targetBuildDepends :: Lens' a [Dependency] 192 targetBuildDepends = buildInfo . targetBuildDepends 193 {-# INLINE targetBuildDepends #-} 194 195 mixins :: Lens' a [Mixin] 196 mixins = buildInfo . mixins 197 {-# INLINE mixins #-} 198 199 200instance HasBuildInfo BuildInfo where 201 buildInfo = id 202 {-# INLINE buildInfo #-} 203 204 buildable f s = fmap (\x -> s { T.buildable = x }) (f (T.buildable s)) 205 {-# INLINE buildable #-} 206 207 buildTools f s = fmap (\x -> s { T.buildTools = x }) (f (T.buildTools s)) 208 {-# INLINE buildTools #-} 209 210 buildToolDepends f s = fmap (\x -> s { T.buildToolDepends = x }) (f (T.buildToolDepends s)) 211 {-# INLINE buildToolDepends #-} 212 213 cppOptions f s = fmap (\x -> s { T.cppOptions = x }) (f (T.cppOptions s)) 214 {-# INLINE cppOptions #-} 215 216 asmOptions f s = fmap (\x -> s { T.asmOptions = x }) (f (T.asmOptions s)) 217 {-# INLINE asmOptions #-} 218 219 cmmOptions f s = fmap (\x -> s { T.cmmOptions = x }) (f (T.cmmOptions s)) 220 {-# INLINE cmmOptions #-} 221 222 ccOptions f s = fmap (\x -> s { T.ccOptions = x }) (f (T.ccOptions s)) 223 {-# INLINE ccOptions #-} 224 225 cxxOptions f s = fmap (\x -> s { T.cxxOptions = x }) (f (T.cxxOptions s)) 226 {-# INLINE cxxOptions #-} 227 228 ldOptions f s = fmap (\x -> s { T.ldOptions = x }) (f (T.ldOptions s)) 229 {-# INLINE ldOptions #-} 230 231 pkgconfigDepends f s = fmap (\x -> s { T.pkgconfigDepends = x }) (f (T.pkgconfigDepends s)) 232 {-# INLINE pkgconfigDepends #-} 233 234 frameworks f s = fmap (\x -> s { T.frameworks = x }) (f (T.frameworks s)) 235 {-# INLINE frameworks #-} 236 237 extraFrameworkDirs f s = fmap (\x -> s { T.extraFrameworkDirs = x }) (f (T.extraFrameworkDirs s)) 238 {-# INLINE extraFrameworkDirs #-} 239 240 asmSources f s = fmap (\x -> s { T.asmSources = x }) (f (T.asmSources s)) 241 {-# INLINE asmSources #-} 242 243 cmmSources f s = fmap (\x -> s { T.cmmSources = x }) (f (T.cmmSources s)) 244 {-# INLINE cmmSources #-} 245 246 cSources f s = fmap (\x -> s { T.cSources = x }) (f (T.cSources s)) 247 {-# INLINE cSources #-} 248 249 cxxSources f s = fmap (\x -> s { T.cSources = x }) (f (T.cxxSources s)) 250 {-# INLINE cxxSources #-} 251 252 jsSources f s = fmap (\x -> s { T.jsSources = x }) (f (T.jsSources s)) 253 {-# INLINE jsSources #-} 254 255 hsSourceDirs f s = fmap (\x -> s { T.hsSourceDirs = x }) (f (T.hsSourceDirs s)) 256 {-# INLINE hsSourceDirs #-} 257 258 otherModules f s = fmap (\x -> s { T.otherModules = x }) (f (T.otherModules s)) 259 {-# INLINE otherModules #-} 260 261 virtualModules f s = fmap (\x -> s { T.virtualModules = x }) (f (T.virtualModules s)) 262 {-# INLINE virtualModules #-} 263 264 autogenModules f s = fmap (\x -> s { T.autogenModules = x }) (f (T.autogenModules s)) 265 {-# INLINE autogenModules #-} 266 267 defaultLanguage f s = fmap (\x -> s { T.defaultLanguage = x }) (f (T.defaultLanguage s)) 268 {-# INLINE defaultLanguage #-} 269 270 otherLanguages f s = fmap (\x -> s { T.otherLanguages = x }) (f (T.otherLanguages s)) 271 {-# INLINE otherLanguages #-} 272 273 defaultExtensions f s = fmap (\x -> s { T.defaultExtensions = x }) (f (T.defaultExtensions s)) 274 {-# INLINE defaultExtensions #-} 275 276 otherExtensions f s = fmap (\x -> s { T.otherExtensions = x }) (f (T.otherExtensions s)) 277 {-# INLINE otherExtensions #-} 278 279 oldExtensions f s = fmap (\x -> s { T.oldExtensions = x }) (f (T.oldExtensions s)) 280 {-# INLINE oldExtensions #-} 281 282 extraLibs f s = fmap (\x -> s { T.extraLibs = x }) (f (T.extraLibs s)) 283 {-# INLINE extraLibs #-} 284 285 extraGHCiLibs f s = fmap (\x -> s { T.extraGHCiLibs = x }) (f (T.extraGHCiLibs s)) 286 {-# INLINE extraGHCiLibs #-} 287 288 extraBundledLibs f s = fmap (\x -> s { T.extraBundledLibs = x }) (f (T.extraBundledLibs s)) 289 {-# INLINE extraBundledLibs #-} 290 291 extraLibFlavours f s = fmap (\x -> s { T.extraLibFlavours = x }) (f (T.extraLibFlavours s)) 292 {-# INLINE extraLibFlavours #-} 293 294 extraDynLibFlavours f s = fmap (\x -> s { T.extraDynLibFlavours = x}) (f (T.extraDynLibFlavours s)) 295 {-# INLINE extraDynLibFlavours #-} 296 297 extraLibDirs f s = fmap (\x -> s { T.extraLibDirs = x }) (f (T.extraLibDirs s)) 298 {-# INLINE extraLibDirs #-} 299 300 includeDirs f s = fmap (\x -> s { T.includeDirs = x }) (f (T.includeDirs s)) 301 {-# INLINE includeDirs #-} 302 303 includes f s = fmap (\x -> s { T.includes = x }) (f (T.includes s)) 304 {-# INLINE includes #-} 305 306 autogenIncludes f s = fmap (\x -> s { T.autogenIncludes = x }) (f (T.autogenIncludes s)) 307 {-# INLINE autogenIncludes #-} 308 309 installIncludes f s = fmap (\x -> s { T.installIncludes = x }) (f (T.installIncludes s)) 310 {-# INLINE installIncludes #-} 311 312 options f s = fmap (\x -> s { T.options = x }) (f (T.options s)) 313 {-# INLINE options #-} 314 315 profOptions f s = fmap (\x -> s { T.profOptions = x }) (f (T.profOptions s)) 316 {-# INLINE profOptions #-} 317 318 sharedOptions f s = fmap (\x -> s { T.sharedOptions = x }) (f (T.sharedOptions s)) 319 {-# INLINE sharedOptions #-} 320 321 staticOptions f s = fmap (\x -> s { T.staticOptions = x }) (f (T.staticOptions s)) 322 {-# INLINE staticOptions #-} 323 324 customFieldsBI f s = fmap (\x -> s { T.customFieldsBI = x }) (f (T.customFieldsBI s)) 325 {-# INLINE customFieldsBI #-} 326 327 targetBuildDepends f s = fmap (\x -> s { T.targetBuildDepends = x }) (f (T.targetBuildDepends s)) 328 {-# INLINE targetBuildDepends #-} 329 330 mixins f s = fmap (\x -> s { T.mixins = x }) (f (T.mixins s)) 331 {-# INLINE mixins #-} 332 333class HasBuildInfos a where 334 traverseBuildInfos :: Traversal' a BuildInfo 335