forked from haskell/cabal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow preprocessors to specify extra C sources
Add functionality to allow preprocessors like hsc2hs and C2HS to inform Cabal of extra C sources that they create that need to be compiled and linked. Includes hsc2hs-based test case.
- Loading branch information
Showing
10 changed files
with
181 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module PackageTests.PreProcessExtraSources.Check (suite) where | ||
|
||
import PackageTests.PackageTester | ||
(PackageSpec(..), assertBuildSucceeded, cabal_build) | ||
import System.FilePath | ||
import Test.Tasty.HUnit | ||
|
||
suite :: FilePath -> Assertion | ||
suite ghcPath = do | ||
let spec = PackageSpec | ||
{ directory = "PackageTests" </> "PreProcessExtraSources" | ||
, distPref = Nothing | ||
, configOpts = ["--enable-tests", "--enable-benchmarks"] | ||
} | ||
result <- cabal_build spec ghcPath | ||
assertBuildSucceeded result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{-# LANGUAGE ForeignFunctionInterface #-} | ||
module Foo where | ||
|
||
import Foreign.C.Types | ||
|
||
#def int incr(int x) { return x + 1; } | ||
|
||
foreign import ccall unsafe "Foo_hsc.h incr" | ||
incr :: CInt -> CInt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Main where | ||
|
||
import Foo | ||
|
||
main :: IO () | ||
main = do | ||
let x = incr 4 | ||
return () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: PreProcessExtraSources | ||
version: 0.1 | ||
license: BSD3 | ||
author: Ian Ross | ||
stability: stable | ||
category: PackageTests | ||
build-type: Simple | ||
Cabal-version: >= 1.2 | ||
|
||
description: | ||
Check that preprocessors that generate extra C sources are handled. | ||
|
||
Library | ||
exposed-modules: Foo | ||
build-depends: base | ||
|
||
Executable my-executable | ||
main-is: Main.hs | ||
other-modules: Foo | ||
build-depends: base | ||
|
||
Test-Suite my-test-suite | ||
main-is: Main.hs | ||
type: exitcode-stdio-1.0 | ||
other-modules: Foo | ||
build-depends: base | ||
|
||
Benchmark my-benchmark | ||
main-is: Main.hs | ||
type: exitcode-stdio-1.0 | ||
other-modules: Foo | ||
build-depends: base |
Nice, it also ended up being less code.