Skip to content

Commit 5fe5e41

Browse files
Merge branch 'ocaml:main' into main
2 parents 827183c + d05db2c commit 5fe5e41

File tree

13 files changed

+373
-63
lines changed

13 files changed

+373
-63
lines changed

.github/workflows/debug-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020

2121
steps:
2222
- name: Checkout Repo
23-
uses: actions/checkout@v3
23+
uses: actions/checkout@v4
2424

2525
- name: Use OCaml ${{ matrix.ocaml-compiler }}
26-
uses: ocaml/setup-ocaml@v2
26+
uses: ocaml/setup-ocaml@v3
2727
with:
2828
ocaml-compiler: ${{ matrix.ocaml-compiler }}
2929
dune-cache: ${{ matrix.os != 'macos-latest' }}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: Dune 3.16.0
3+
tags: [dune, platform]
4+
changelog: |
5+
### Added
6+
7+
- Allow libraries with the same `(name ..)` in projects as long as they don't
8+
conflict during resolution (via `enabled_if`). (#10307, @anmonteiro,
9+
@jchavarri)
10+
11+
- `dune describe pp` now finds the exact module and the stanza it belongs to,
12+
instead of guessing the name of the preprocessed file. (#10321, @anmonteiro)
13+
14+
- Print the result of `dune describe pp` with the respective dialect printer.
15+
(#10322, @anmonteiro)
16+
17+
- Add new flag `--context` to `dune ocaml-merlin`, which allows to select a
18+
Dune context when requesting Merlin config. Add `dune describe contexts`
19+
subcommand. Introduce a field `generate_merlin_rules` for contexts declared
20+
in the workspace, that allows to optionally produce Merlin rules for other
21+
contexts besides the one selected for Merlin (#10324, @jchavarri)
22+
23+
- Melange: add include paths for private library `.cmj` files during JS
24+
emission. (#10416, @anmonteiro)
25+
26+
- `dune ocaml-merlin`: communicate additional directives `SOURCE_ROOT`,
27+
`UNIT_NAME` (the actual name with wrapping) and `INDEX` with the paths to the
28+
index(es). (#10422, @voodoos)
29+
30+
- Add a new alias `@ocaml-index` that uses the `ocaml-index` binary to generate
31+
indexes that can be read by tools such as Merlin to provide project-wide
32+
references search. (#10422, @voodoos)
33+
34+
- Merlin: add optional `(merlin_reader CMD)` construct to `(dialect)` stanza to
35+
configure a Merlin reader (#8567, @andreypopp)
36+
37+
### Changed
38+
39+
- Melange: treat private libraries with `(package ..)` as public libraries,
40+
fixing an issue where `import` paths were wrongly emitted. (#10415,
41+
@anmonteiro)
42+
43+
- Install `.glob` files for Coq theories too (#10602, @ejgallego)
44+
45+
### Fixed
46+
47+
- Don't try to document nonexistent libraries in doc-new target (#10319, fixes
48+
#10056, @jonludlam)
49+
50+
- Make `dune-site`'s `load_all` function look for `META` files so that it
51+
doesn't fail on empty directories in the plugin directory (#10458, fixes
52+
#10457, @shym)
53+
54+
- Fix incorrect warning for libraries defined inside nonexistant directories
55+
using `(subdir ..)` and used by executables using `dune-build-info` (#10525,
56+
@rgrinberg)
57+
58+
- Don't try to take build lock when running `coq top --no-build` (#10547, fixes
59+
#7671, @lzy0505)
60+
61+
- Make sure to truncate Dune's lock file after locking and unlocking so that
62+
users cannot observe incorrect PID's (#10575, @rgrinberg)
63+
64+
- MDX: link MDX binary with `byte_complete`. This fixes `(libraries)` with
65+
foreign archives on Linux. (#10586, fixes #10582, @anmonteiro)
66+
67+
- Virtual libraries: fix an issue where linking an executable involving several
68+
virtual libries would cause an error. (#10581, fixes #10460, @rgrinberg)
69+
---
70+
71+
We're happy to announce the release of Dune 3.16.0.
72+
73+
Among the list of chances, this release contains improvements to Melange
74+
support and a way to look for references in a whole project using Merlin and
75+
OCaml LSP.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
packages:
3+
- name: "camlzip"
4+
tested_version: "1.11"
5+
used_libraries:
6+
- camlzip
7+
---
8+
9+
(* We open both files (`source` with `In_channel.open_bin` and `dest` with `Gzip.open_out`)
10+
and transfer bytes through a bytes buffer. *)
11+
12+
let buffer_size = 4096
13+
14+
let gzip source dest =
15+
let gz_file = Gzip.open_out ~level:9 dest in
16+
let buffer = Bytes.make buffer_size '*' in
17+
let ic = In_channel.open_bin source in
18+
let rec aux () =
19+
let len = In_channel.input ic buffer 0 buffer_size in
20+
if len <> 0 then
21+
begin
22+
Gzip.output gz_file buffer 0 len;
23+
aux ()
24+
end
25+
in
26+
aux ();
27+
Gzip.close_out gz_file;
28+
In_channel.close ic
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
packages:
3+
- name: "camlzip"
4+
tested_version: "1.11"
5+
used_libraries:
6+
- camlzip
7+
---
8+
9+
(*
10+
The [Zip](/p/camlzip/latest/doc/Zip/index.html) module doesn't provide a function that works on a directory.
11+
12+
Thus, we write a helper-function to traverse the file-system.
13+
Here the given function `f` is called for each regular file with its name as a parameter.
14+
15+
*)
16+
let rec traverse_fs f directory =
17+
if Sys.is_directory directory then
18+
Sys.readdir directory
19+
|> Array.iter
20+
(fun entry ->
21+
traverse
22+
f (directory ^ "/" ^ entry))
23+
else
24+
f directory
25+
26+
27+
(* First, we open the ZIP file for writing. *)
28+
let zip zip_filename directory_name =
29+
let zip_file = Zip.open_out zip_filename in
30+
31+
(* Then, we use `Zip.copy_file_to_entry` to add every file in the directory to the ZIP file. *)
32+
traverse_fs
33+
(fun name ->
34+
Zip.copy_file_to_entry name zip_file name)
35+
directory_name;
36+
(* To finalize the archive, we close the ZIP file. *)
37+
Zip.close_out zip_file
38+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
packages:
3+
- name: "camlzip"
4+
tested_version: "1.11"
5+
used_libraries:
6+
- camlzip
7+
---
8+
9+
(* To decompress a single file using the [Gzip](/p/camlzip/latest/doc/Gzip/index.html) module from `camlzip`,
10+
we open both files (`source` with `Gzip.open_in` and `dest` with `Out_channel.open_bin`) and transfer bytes through a bytes buffer. *)
11+
12+
let buffer_size = 4096
13+
14+
let gunzip source dest =
15+
let gz_file = Gzip.open_in source in
16+
let buffer = Bytes.make buffer_size '*' in
17+
let oc = Out_channel.open_bin dest in
18+
let rec aux () =
19+
let len = Gzip.input gz_file buffer 0 buffer_size in
20+
if len <> 0 then
21+
begin
22+
Out_channel.output oc buffer 0 len;
23+
aux ()
24+
end
25+
in
26+
aux ();
27+
Gzip.close_in gz_file;
28+
Out_channel.close oc
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
packages:
3+
- name: "camlzip"
4+
tested_version: "1.11"
5+
used_libraries:
6+
- camlzip
7+
---
8+
9+
(* When unzipping a file from a ZIP archive, we need to create the directory
10+
it is contained in, if it doesn't exist yet. *)
11+
let create_dir_if_not_exists filename =
12+
let rec aux_ensure base l =
13+
if not (Sys.file_exists base) then
14+
Sys.mkdir base 0o755
15+
else
16+
if not (Sys.is_directory base) then
17+
failwith "Error, file exists instead of a directory";
18+
match l with
19+
| [] -> failwith "Should not happen"
20+
| [ _filename ] -> ()
21+
| directory :: l' -> aux_ensure (base ^ "/" ^ directory) l'
22+
in
23+
match String.split_on_char '/' filename with
24+
| [ ] -> failwith "Should not happen (null filename)"
25+
| [ _filename ] -> ()
26+
| directory :: l -> aux_ensure directory l
27+
28+
(* Open the ZIP file for reading. *)
29+
let unzip zip_filename =
30+
let zip = Zip.open_in zip_filename in
31+
32+
(* Iterate over all entries within the ZIP file. *)
33+
let entries = Zip.entries zip in
34+
entries
35+
|> List.iter (fun entry ->
36+
Printf.printf "%s\n" entry.Zip.filename;
37+
create_dir_if_not_exists entry.Zip.filename;
38+
(* If the entry is a directory, just create the directory. *)
39+
if entry.Zip.is_directory then
40+
Sys.mkdir entry.Zip.filename 0o755
41+
42+
(* If the entry is a regular file, decompress it. *)
43+
else
44+
Zip.copy_entry_to_file
45+
zip
46+
entry
47+
entry.Zip.filename);
48+
(* Finally, close the ZIP file. *)
49+
Zip.close_in zip

data/cookbook/tasks.yml

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ categories:
66
- title: Using the ANSI Terminal
77
slug: using-the-ansi-terminal
88
description: >
9-
Use ANSI escape codes for cursor location, font and colour in video text
9+
Use ANSI escape codes for cursor location, font, and colour in video text
1010
terminal emulators.
1111
- title: Compilation & Linking
1212
tasks:
@@ -18,8 +18,14 @@ categories:
1818
C library, using the OCaml foreign function interface.
1919
- title: Compression
2020
tasks:
21-
- title: Read a gzip compressed text file
22-
slug: read-gzip-text-file
21+
- title: Decompress a Single File Compressed With GZIP
22+
slug: decompress-single-file-gzip
23+
- title: Compress a Single File with GZIP
24+
slug: compress-single-file-gzip
25+
- title: Decompress a ZIP Archive Containing Multiple Files
26+
slug: decompress-zip-archive
27+
- title: Create a ZIP Archive Containing Multiple Files
28+
slug: create-zip-archive
2329
- title: Decompressing a Tarball
2430
slug: decompressing-a-tarball
2531
- title: Compress a Directory Into a Tarball
@@ -40,9 +46,9 @@ categories:
4046
tasks:
4147
- title: Calculate the SHA-256 Digest of a File
4248
slug: calculate-sha-256-digest-of-file
43-
- title: Sign and Verify a Message with an HMAC Digest
49+
- title: Sign and Verify a Message With an HMAC Digest
4450
slug: sign-and-verify-hmac-digest
45-
- title: Salt and Hash a Password with PBKDF2
51+
- title: Salt and Hash a Password With PBKDF2
4652
slug: salt-and-hash-password-with-pkgdf2
4753
- title: Data Structures & Algorithms
4854
subcategories:
@@ -113,15 +119,15 @@ categories:
113119
slug: debug-print-a-value
114120
- title: Log a Debug / Error Message to Stdout / Stderr
115121
slug: log-debug-error-message
116-
- title: Log to the UNIX Syslog
122+
- title: Log to the Unix Syslog
117123
slug: log-to-unix-syslog
118124
- title: Encoding
119125
tasks:
120126
- title: URL- / Percent-Encode a String
121127
slug: url-percent-encode-string
122128
- title: Encode a String as application/x-www-form-urlencoded
123129
slug: encode-x-www-form-urlencoded
124-
- title: Encode and Decode Bytestrings from Hex-Strings
130+
- title: Encode and Decode Bytestrings From Hex-Strings
125131
slug: encode-decode-hex
126132
- title: Encode and Decode Base64
127133
slug: encode-decode-base64
@@ -170,13 +176,13 @@ categories:
170176
# slug: trigger-minor-major-collection
171177
- title: Random Values
172178
tasks:
173-
- title: Generate Random `int`, `float` and `char`
179+
- title: Generate Random `int`, `float`, and `char`
174180
slug: generate-random-values
175181
- title: Mathematics
176182
subcategories:
177183
- title: Vector & Matrix Operations
178184
tasks:
179-
- title: Normalize a Vector
185+
- title: Normalise a Vector
180186
slug: normalize-vector
181187
- title: Matrix Addition and Multiplication
182188
slug: matrix-addition-multiplication
@@ -214,7 +220,7 @@ categories:
214220
slug: regex-validate-email
215221
- title: Extract Phone Numbers from Text
216222
slug: regex-extract-phone-numbers
217-
- title: Replace All Occurrences of a Text Pattern with Another Pattern
223+
- title: Replace All Occurrences of a Text Pattern With Another Pattern
218224
slug: regex-replace-pattern
219225
- title: Web Programming
220226
subcategories:
@@ -224,37 +230,39 @@ categories:
224230
slug: make-http-get-request
225231
description: >
226232
Make an HTTP GET request, process response code, follow redirects
227-
- title: Make a HTTP GET Request with Basic Authentication
233+
- title: Make a HTTP GET Request With Basic Authentication
228234
slug: make-http-get-basic-auth
229235
- title: Download a File to a Temporary Directory
230236
slug: download-file-to-temporary-dir
231-
- title: Make a Partial Download with HTTP Range Header
237+
- title: Make a Partial Download With HTTP Range Header
232238
slug: make-partial-download-with-http-range-header
233-
- title: Dealing with HTML
239+
- title: Dealing With HTML
234240
tasks:
235-
- title: Render a HTML Template
241+
- title: Render an HTML Template
236242
slug: render-html-template
237-
- title: Extract all Links from a HTML String
243+
- title: Extract All Links From an HTML String
238244
slug: extract-links-from-html
239245
- title: Check a Webpage for Broken Links
240246
slug: check-webpage-for-broken-links
241247
- title: Running a Web Server
242248
tasks:
243-
- title: Start a Web Server with a Hello World Endpoint
249+
- title: Start a Web Server With a 'Hello World' Endpoint
244250
slug: start-a-web-server-hello-world
245-
- title: Start a Web Server that Serves a HTML Template
251+
- title: Start a Web Server That Serves an HTML Template
246252
slug: start-a-web-server-html-template
247253
- title: Use Basic Authentication to Secure a Route
248254
slug: use-basic-auth-on-web-server
249255
- title: Media Types (MIME)
250256
tasks:
251-
- title: Get MIME Type from String
257+
- title: Get MIME Type From String
252258
slug: get-mime-type-from-string
253-
- title: Get MIME Type from Filename
259+
- title: Get MIME Type From Filename
254260
slug: get-mime-type-from-filename
255-
- title: Parse MIME Type of a HTTP Response
261+
- title: Parse MIME Type of an HTTP Response
256262
slug: parse-mime-type-of-http-response
257-
- title: URL and URI processing
263+
- title: URL and URI Processing
258264
tasks:
259-
- title: Parse a URL from String And Access Individual Parts
260-
slug: parse-url-from-string
265+
- title: Parse a URI from String and Access Individual Parts
266+
slug: uri-parsing
267+
- title: Encode a URI to String
268+
slug: uri-encoding

0 commit comments

Comments
 (0)