-
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.
- Loading branch information
Showing
13 changed files
with
217 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
packages: trace-foreign-calls, example-pkg-A, example-pkg-B | ||
|
||
package trace-foreign-calls | ||
tests: True | ||
|
||
package example-pkg-A | ||
tests: True | ||
|
||
package example-pkg-B | ||
tests: True |
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,30 @@ | ||
Copyright (c) 2024, Edsko de Vries | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
|
||
* Neither the name of Edsko de Vries nor the names of other | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,3 @@ | ||
int xkcdRandomNumber() { | ||
return 4; | ||
} |
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 @@ | ||
// https://xkcd.com/221/ | ||
int xkcdRandomNumber(); |
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,47 @@ | ||
cabal-version: 3.0 | ||
name: example-pkg-A | ||
version: 0.1.0 | ||
synopsis: Example package A | ||
description: This is an example that imports a foreign function. The | ||
function is used in example package B. | ||
license: BSD-3-Clause | ||
license-file: LICENSE | ||
author: Edsko de Vries | ||
maintainer: [email protected] | ||
category: Development | ||
build-type: Simple | ||
extra-source-files: cbits/cbits.h | ||
cbits/cbits.c | ||
tested-with: GHC ==9.6.4 | ||
|
||
common lang | ||
ghc-options: | ||
-Wall | ||
build-depends: | ||
base >= 4.18 && < 4.19 | ||
default-language: | ||
GHC2021 | ||
|
||
library | ||
import: | ||
lang | ||
exposed-modules: | ||
ExamplePkgA | ||
hs-source-dirs: | ||
src | ||
include-dirs: | ||
cbits | ||
c-sources: | ||
cbits/cbits.c | ||
|
||
test-suite test-A | ||
import: | ||
lang | ||
ghc-options: | ||
-main-is TestA | ||
type: | ||
exitcode-stdio-1.0 | ||
main-is: | ||
test/TestA.hs | ||
build-depends: | ||
example-pkg-A |
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 @@ | ||
{-# LANGUAGE CApiFFI #-} | ||
|
||
module ExamplePkgA (someForeignFunInA) where | ||
|
||
import Foreign.C | ||
|
||
foreign import capi "cbits.h xkcdRandomNumber" someForeignFunInA :: IO 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,6 @@ | ||
module TestA (main) where | ||
|
||
import ExamplePkgA | ||
|
||
main :: IO () | ||
main = print =<< someForeignFunInA |
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,30 @@ | ||
Copyright (c) 2024, Edsko de Vries | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
|
||
* Neither the name of Edsko de Vries nor the names of other | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,45 @@ | ||
cabal-version: 3.0 | ||
name: example-pkg-B | ||
version: 0.1.0 | ||
synopsis: Example package B | ||
description: This is an example of a package with a /dependency/ that | ||
imports a foreign function. We want to be able to enable | ||
the plugin on that dependency, without changing its | ||
cabal file. | ||
license: BSD-3-Clause | ||
license-file: LICENSE | ||
author: Edsko de Vries | ||
maintainer: [email protected] | ||
category: Development | ||
build-type: Simple | ||
tested-with: GHC ==9.6.4 | ||
|
||
common lang | ||
ghc-options: | ||
-Wall | ||
build-depends: | ||
base >= 4.18 && < 4.19 | ||
default-language: | ||
GHC2021 | ||
|
||
library | ||
import: | ||
lang | ||
exposed-modules: | ||
ExamplePkgB | ||
hs-source-dirs: | ||
src | ||
build-depends: | ||
example-pkg-A >= 0.1 && < 2 | ||
|
||
test-suite test-B | ||
import: | ||
lang | ||
ghc-options: | ||
-main-is TestB | ||
type: | ||
exitcode-stdio-1.0 | ||
main-is: | ||
test/TestB.hs | ||
build-depends: | ||
example-pkg-B |
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 ExamplePkgB (someWrapperInB) where | ||
|
||
import ExamplePkgA | ||
|
||
someWrapperInB :: IO Int | ||
someWrapperInB = fromIntegral <$> someForeignFunInA |
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 TestB (main) where | ||
|
||
import ExamplePkgB | ||
|
||
main :: IO () | ||
main = print =<< someWrapperInB |
This file was deleted.
Oops, something went wrong.