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.
Merge pull request haskell#10171 from alt-romes/wip/romes/10168
Lookup main-is C sources in hs-source-dirs
- Loading branch information
Showing
17 changed files
with
134 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
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,6 @@ | ||
module Main ( main ) where | ||
|
||
import Lib ( myMax ) | ||
|
||
main :: IO () | ||
main = print $ myMax 10 100 |
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,12 @@ | ||
#include <stdio.h> | ||
#include <HsFFI.h> | ||
#ifdef __GLASGOW_HASKELL__ | ||
#include "Lib_stub.h" | ||
#endif | ||
|
||
int main(int argc, char *argv[]) { | ||
hs_init(&argc, &argv); | ||
printf("%lld\n", myMax(10,100)); | ||
hs_exit(); | ||
return 0; | ||
} |
27 changes: 27 additions & 0 deletions
27
cabal-testsuite/PackageTests/CMain/10168/haskell-c-tests.cabal
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,27 @@ | ||
cabal-version: 2.0 | ||
|
||
name: haskell-c-tests | ||
version: 0.1.0.0 | ||
build-type: Simple | ||
|
||
library | ||
exposed-modules: Lib | ||
hs-source-dirs: src | ||
ghc-options: -stubdir autogen-stubs | ||
build-depends: base | ||
default-language: Haskell2010 | ||
|
||
executable c-exe | ||
main-is: main.c | ||
hs-source-dirs: c-app | ||
ghc-options: -no-hs-main | ||
include-dirs: autogen-stubs | ||
build-depends: base, haskell-c-tests | ||
default-language: Haskell2010 | ||
|
||
executable haskell-exe | ||
main-is: Main.hs | ||
hs-source-dirs: app | ||
ghc-options: -threaded -rtsopts -with-rtsopts=-N | ||
build-depends: base, haskell-c-tests | ||
default-language: Haskell2010 |
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,10 @@ | ||
# Setup configure | ||
Configuring haskell-c-tests-0.1.0.0... | ||
Warning: [unknown-directory] 'include-dirs: autogen-stubs' specifies a directory which does not exist. | ||
# Setup build | ||
Preprocessing library for haskell-c-tests-0.1.0.0... | ||
Building library for haskell-c-tests-0.1.0.0... | ||
Preprocessing executable 'c-exe' for haskell-c-tests-0.1.0.0... | ||
Building executable 'c-exe' for haskell-c-tests-0.1.0.0... | ||
Preprocessing executable 'haskell-exe' for haskell-c-tests-0.1.0.0... | ||
Building executable 'haskell-exe' for haskell-c-tests-0.1.0.0... |
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,7 @@ | ||
import Test.Cabal.Prelude | ||
-- Test building an executable whose main-is is a C source found in the hs-source-dirs. | ||
-- It is a bit counter intuitive that we look for non-haskell sources in | ||
-- `hs-source-dirs`, but that is a behaviour that users rely on (see #10168) | ||
-- and there's no good reason to break it. | ||
main = setupTest $ do | ||
setup_build [] |
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,6 @@ | ||
module Lib ( myMax ) where | ||
|
||
myMax :: Int -> Int -> Int | ||
myMax x1 x2 = if x1 > x2 then x1 else x2 | ||
|
||
foreign export ccall myMax :: Int -> Int -> Int |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.