Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pkg-configs section (#169) #185

Merged
merged 5 commits into from
Dec 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Hpack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ packageDependencies Package{..} = nub . sortBy (comparing (lexicographically . f
deps xs = [(name, version) | (name, version) <- (Map.toList . unDependencies . sectionDependencies) xs]

section :: a -> Section a
section a = Section a [] mempty [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Nothing [] mempty
section a = Section a [] mempty [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Nothing [] mempty []

packageConfig :: FilePath
packageConfig = "package.yaml"
Expand Down Expand Up @@ -255,6 +255,7 @@ data CommonOptions a = CommonOptions {
, commonOptionsBuildable :: Maybe Bool
, commonOptionsWhen :: Maybe (List (ConditionalSection a))
, commonOptionsBuildTools :: Maybe Dependencies
, commonOptionsPkgConfigs :: Maybe (List String)
} deriving (Eq, Show, Generic)

instance HasFieldNames (CommonOptions a)
Expand Down Expand Up @@ -472,6 +473,7 @@ data Section a = Section {
, sectionBuildable :: Maybe Bool
, sectionConditionals :: [Conditional (Section a)]
, sectionBuildTools :: Dependencies
, sectionPkgConfigs :: [String]
} deriving (Eq, Show, Functor, Foldable, Traversable)

data Conditional a = Conditional {
Expand Down Expand Up @@ -852,6 +854,7 @@ mergeSections a globalOptions options
, sectionDependencies = sectionDependencies options <> sectionDependencies globalOptions
, sectionConditionals = map (fmap (a <$)) (sectionConditionals globalOptions) ++ sectionConditionals options
, sectionBuildTools = sectionBuildTools options <> sectionBuildTools globalOptions
, sectionPkgConfigs = sectionPkgConfigs globalOptions ++ sectionPkgConfigs options
}

toSection_ :: a -> CommonOptions a -> ([FieldName], Section a)
Expand Down Expand Up @@ -880,6 +883,7 @@ toSection_ a CommonOptions{..}
, sectionDependencies = fromMaybe mempty commonOptionsDependencies
, sectionConditionals = conditionals
, sectionBuildTools = fromMaybe mempty commonOptionsBuildTools
, sectionPkgConfigs = fromMaybeList commonOptionsPkgConfigs
}
)
where
Expand Down
1 change: 1 addition & 0 deletions src/Hpack/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ renderSection renderSectionData Section{..} =
, renderLdOptions sectionLdOptions
, renderDependencies "build-depends" sectionDependencies
, renderDependencies "build-tools" sectionBuildTools
, Field "pkgconfig-depends" (CommaSeparatedList sectionPkgConfigs)
]
++ maybe [] (return . renderBuildable) sectionBuildable
++ map (renderConditional renderSectionData) sectionConditionals
Expand Down
10 changes: 10 additions & 0 deletions test/Hpack/ConfigSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ spec = do
captureUnknownFieldsValue . toSection <$> decodeEither input
`shouldBe` Right (section Empty){sectionExtraLibraries = ["foo", "bar"]}

it "accepts pkg-configs" $ do
let input = [i|
pkg-configs:
- QtWebKit
- weston
|]
captureUnknownFieldsValue . toSection <$> decodeEither input
`shouldBe` Right (section Empty){sectionPkgConfigs = [ "QtWebKit", "weston" ]}

it "accepts extra-frameworks-dirs" $ do
let input = [i|
extra-frameworks-dirs:
Expand All @@ -157,6 +166,7 @@ spec = do
captureUnknownFieldsValue . toSection <$> decodeEither input
`shouldBe` Right (section Empty){sectionExtraFrameworksDirs = ["foo", "bar"]}


it "accepts frameworks" $ do
let input = [i|
frameworks:
Expand Down