-
Notifications
You must be signed in to change notification settings - Fork 414
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
test(ctypes): showcase deps field not supporting the full dependency specification #11443
Open
Khady
wants to merge
6
commits into
ocaml:main
Choose a base branch
from
Khady:louis/ctypes-deps-lang
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d3790ba
test(ctypes): showcase deps field not supporting the full dependency …
Khady dc226c8
ctypes: make the deps field support bindings
Khady 6000a89
test(ctypes): showcase lack of variable support
Khady 3ddcca6
ctypes: load user vars to decoding env
Khady 7ac582d
test(ctypes): add example of inline dep on a path
Khady c4e6221
test(ctypes): ensure all .h are present and used
Khady File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ | ||
#define BAR_VERSION 1 |
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 @@ | ||
#define BAZ_VERSION 1 |
21 changes: 21 additions & 0 deletions
21
test/blackbox-tests/test-cases/ctypes/deps-full-spec.t/dune
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,21 @@ | ||
(executable | ||
(name example) | ||
(flags | ||
(:standard -w -9-27)) | ||
(ctypes | ||
(external_library_name libexample) | ||
(build_flags_resolver pkg_config) | ||
(deps | ||
(:foo_h "foo.h") | ||
(:bar_h bar.h) | ||
baz.h) | ||
(headers | ||
(preamble | ||
"#include <example.h>\n#include \"%{foo_h}\"\n#include \"%{bar_h}\"\n#include \"baz.h\"\n#include \"%{dep:qux.h}\"")) | ||
(type_description | ||
(instance Types) | ||
(functor Type_description)) | ||
(function_description | ||
(instance Functions) | ||
(functor Function_description)) | ||
(generated_entry_point C))) |
5 changes: 5 additions & 0 deletions
5
test/blackbox-tests/test-cases/ctypes/deps-full-spec.t/dune-project
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,5 @@ | ||
(lang dune 3.8) | ||
|
||
(using ctypes 0.3) | ||
|
||
(use_standard_c_and_cxx_flags false) |
6 changes: 6 additions & 0 deletions
6
test/blackbox-tests/test-cases/ctypes/deps-full-spec.t/example.ml
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 @@ | ||
let () = | ||
Printf.printf "%d\n" (C.Functions.add2 C.Types.foo_version); | ||
Printf.printf "%d\n" (C.Functions.add2 C.Types.bar_version); | ||
Printf.printf "%d\n" (C.Functions.add2 C.Types.baz_version); | ||
Printf.printf "%d\n" (C.Functions.add2 C.Types.qux_version); | ||
() |
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 @@ | ||
#define FOO_VERSION 1 |
8 changes: 8 additions & 0 deletions
8
test/blackbox-tests/test-cases/ctypes/deps-full-spec.t/function_description.ml
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 @@ | ||
open Ctypes | ||
|
||
module Types = Types_generated | ||
|
||
module Functions (F : Ctypes.FOREIGN) = struct | ||
open F | ||
let add2 = foreign "example_add2" (int @-> returning int) | ||
end |
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 @@ | ||
#define QUX_VERSION 1 |
18 changes: 18 additions & 0 deletions
18
test/blackbox-tests/test-cases/ctypes/deps-full-spec.t/run.t
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,18 @@ | ||
Build an example library as a DLL and set up the environment so that it looks | ||
like a system/distro library that can be probed with pkg-config and dynamically | ||
loaded. | ||
|
||
Then generate cstubs for it, build an executable that uses those cstubs, and | ||
run the executable that tests the library through the cstubs. | ||
|
||
$ LIBEX=$(realpath "$PWD/../libexample") | ||
$ DYLD_LIBRARY_PATH="$LIBEX" LD_LIBRARY_PATH="$LIBEX" PKG_CONFIG_PATH="$LIBEX/pkgconfig" PKG_CONFIG_ARGN="--define-prefix" dune exec ./example.exe | ||
File "dune", line 14, characters 38-46: | ||
14 | "#include <example.h>\n#include \"%{foo_h}\"\n#include \"%{bar_h}\"\n#include \"baz.h\"\n#include \"%{dep:qux.h}\"")) | ||
^^^^^^^^ | ||
Error: %{foo_h} isn't allowed in this position. | ||
File "dune", line 14, characters 61-69: | ||
14 | "#include <example.h>\n#include \"%{foo_h}\"\n#include \"%{bar_h}\"\n#include \"baz.h\"\n#include \"%{dep:qux.h}\"")) | ||
^^^^^^^^ | ||
Error: %{bar_h} isn't allowed in this position. | ||
[1] |
9 changes: 9 additions & 0 deletions
9
test/blackbox-tests/test-cases/ctypes/deps-full-spec.t/type_description.ml
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 @@ | ||
module Types (F : Ctypes.TYPE) = struct | ||
open F | ||
|
||
let foo_version = constant "FOO_VERSION" int | ||
let bar_version = constant "BAR_VERSION" int | ||
let baz_version = constant "BAZ_VERSION" int | ||
let qux_version = constant "QUX_VERSION" int | ||
|
||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what to look at to be able to fix this error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be
%{dep:foo.h}
? `There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I want to use the name of the dependency, this is on purpose.