forked from ocaml/dune
-
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.
Adds support for globs in dune-action-plugin.
Signed-off-by: Jakub Staron <jstaron@janestreet.com>
- Loading branch information
1 parent
16dbb98
commit 8bb9748
Showing
18 changed files
with
162 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
(library | ||
(name dune_action_plugin) | ||
(public_name dune._dune_action_plugin) | ||
(libraries stdune) | ||
(libraries stdune dune_re dune_glob_lexer) | ||
(synopsis | ||
"Monadic interface for defining scripts with dynamic or complex set of depencencies.")) |
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,19 @@ | ||
open Stdune | ||
|
||
type t = | ||
{ re : Dune_re.re | ||
; repr : string | ||
} | ||
|
||
let test t = Dune_re.execp t.re | ||
|
||
let of_string repr = | ||
let result = | ||
Dune_glob_lexer.parse_string repr | ||
|> Result.map ~f:(fun re -> { re = Dune_re.compile re; repr }) | ||
in | ||
match result with | ||
| Error (_, msg) -> invalid_arg (Printf.sprintf "invalid glob: :%s" msg) | ||
| Ok t -> t | ||
|
||
let to_string (t : t) = t.repr |
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,13 @@ | ||
(** Simple glob support library. *) | ||
|
||
type t | ||
|
||
(** Tests if string matches the glob. *) | ||
val test : t -> string -> bool | ||
|
||
(** Returns textual representation of a glob. *) | ||
val to_string : t -> string | ||
|
||
(** Converts string to glob. Throws [Invalid_argument] exception if string is | ||
not a valid glob. *) | ||
val of_string : string -> 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
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,8 @@ | ||
(library | ||
(name dune_glob_lexer) | ||
(public_name dune._dune_glob_lexer) | ||
(flags (:standard -w -50)) | ||
(synopsis "Internal Dune library, do not use!") | ||
(libraries stdune dune_re)) | ||
|
||
(ocamllex dune_glob_lexer) |
File renamed without changes.
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 |
---|---|---|
|
@@ -65,4 +65,3 @@ and char_set st = parse | |
| exception Failure msg -> | ||
Error (Lexing.lexeme_start lb, msg) | ||
} | ||
|
3 changes: 3 additions & 0 deletions
3
...box-tests/test-cases-with-libs/dune-action-plugin/depends-on-directory-with-glob/bin/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,3 @@ | ||
(executables | ||
(names foo) | ||
(libraries dune_action_plugin)) |
11 changes: 11 additions & 0 deletions
11
...x-tests/test-cases-with-libs/dune-action-plugin/depends-on-directory-with-glob/bin/foo.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,11 @@ | ||
open Dune_action_plugin | ||
|
||
let action = | ||
let open Dune_action_plugin.O in | ||
let glob = Glob.of_string "some_file*" in | ||
let+ listing = | ||
read_directory_with_glob ~path:(Path.of_string "some_dir") ~glob | ||
in | ||
String.concat "\n" listing |> print_endline | ||
|
||
let () = run action |
19 changes: 19 additions & 0 deletions
19
...lackbox-tests/test-cases-with-libs/dune-action-plugin/depends-on-directory-with-glob/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,19 @@ | ||
(data_only_dirs test) | ||
|
||
(alias | ||
(name run_dynamic) | ||
(deps | ||
(package dune) | ||
(source_tree test/) | ||
(glob_files bin/*.exe)) | ||
(action | ||
(chdir | ||
test | ||
(progn | ||
(run %{bin:cram} -test run.t) | ||
(diff? run.t run.t.corrected))))) | ||
|
||
(alias | ||
(name runtest) | ||
(deps | ||
(alias run_dynamic))) |
42 changes: 42 additions & 0 deletions
42
...x-tests/test-cases-with-libs/dune-action-plugin/depends-on-directory-with-glob/test/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,42 @@ | ||
$ echo "(lang dune 2.0)" > dune-project | ||
|
||
$ cat > dune << EOF | ||
> (alias | ||
> (name runtest) | ||
> (action (dynamic-run ./foo.exe))) | ||
> EOF | ||
|
||
$ mkdir some_dir | ||
|
||
$ cat > some_dir/dune << EOF | ||
> (rule | ||
> (target some_file) | ||
> (action | ||
> (progn | ||
> (echo "Building some_file!\n") | ||
> (with-stdout-to %{target} (echo ""))))) | ||
> \ | ||
> (rule | ||
> (target another_file) | ||
> (action | ||
> (progn | ||
> (echo "SHOULD NOT BE PRINTED!") | ||
> (with-stdout-to %{target} (echo ""))))) | ||
> \ | ||
> (rule | ||
> (target some_file_but_different) | ||
> (action | ||
> (progn | ||
> (echo "Building some_file_but_different!\n") | ||
> (with-stdout-to %{target} (echo ""))))) | ||
> EOF | ||
|
||
$ cp ../bin/foo.exe ./ | ||
|
||
$ dune runtest --display short | ||
foo alias runtest | ||
Building some_file! | ||
Building some_file_but_different! | ||
foo alias runtest | ||
some_file | ||
some_file_but_different |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
(library | ||
(name dune_re) | ||
(flags (:standard -w -50)) | ||
(name dune_re) | ||
(public_name dune._dune_re) | ||
(flags (:standard -w -50)) | ||
(synopsis "Internal Dune library, do not use!")) | ||
|
||
(rule (with-stdout-to dune_re.ml (echo "include Re"))) |