summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Glondu <steph@glondu.net>2023-01-20 12:42:37 +0100
committerStéphane Glondu <steph@glondu.net>2023-01-20 12:42:37 +0100
commit8bfe10d5e61ece439234a7dea3621a6657ec96b3 (patch)
tree494f2569a2abcc1c3c3407da3326a1062020c61b
parentc81cd25884e014ce561660e02e3c02893d5b5a5b (diff)
New upstream version 1.6.9
-rw-r--r--.github/workflows/build.yml107
-rw-r--r--CODEOWNERS2
-rw-r--r--Changes.md (renamed from Changes)7
-rw-r--r--LICENSE.md6
-rw-r--r--README.md34
-rw-r--r--cppo.opam26
-rw-r--r--cppo_ocamlbuild.opam28
-rw-r--r--dune-project44
-rw-r--r--src/cppo_lexer.mll4
-rw-r--r--test/dune20
-rw-r--r--test/test.cppo4
-rw-r--r--test/test.ref142
-rw-r--r--test/version.ref37
13 files changed, 422 insertions, 39 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..6072534
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,107 @@
+---
+name: Build
+on:
+ push:
+ branches:
+ - master # forall push/merge in master
+ pull_request:
+ branches:
+ - "**" # forall submitted Pull Requests
+
+jobs:
+ build:
+ strategy:
+ fail-fast: false
+ matrix:
+ os:
+ - macos-latest
+ - ubuntu-latest
+ - windows-latest
+ ocaml-version:
+ - 4.02.x
+ - 4.03.x
+ - 4.04.x
+ - 4.05.x
+ - 4.06.x
+ - 4.07.x
+ - 4.08.x
+ - 4.09.x
+ - 4.10.x
+ - 4.11.x
+ - 4.12.x
+ - 4.13.x
+
+ runs-on: ${{ matrix.os }}
+
+ env:
+ SKIP_BUILD: |
+ dose
+ lilis
+ rotor
+ SKIP_TEST: |
+ 0install
+ bisect_ppx
+ cconv-ppx
+ decompress
+ extlib-compat
+ General
+
+ steps:
+ - name: Prepare git
+ run: |
+ git config --global core.autocrlf false
+ git config --global init.defaultBranch master
+
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Use OCaml ${{ matrix.ocaml-version }}
+ uses: ocaml/setup-ocaml@v2
+ with:
+ ocaml-compiler: ${{ matrix.ocaml-version }}
+
+ - name: Install dependencies
+ run: opam install --deps-only .
+
+ - name: List installed packages
+ run: opam list
+
+ - name: Build locally
+ run: opam exec -- make
+
+ - name: Upload the build artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: ${{ matrix.os }}-${{ matrix.ocaml-version }}-cppo.exe
+ path: _build/default/src/cppo_main.exe
+
+ - name: Build, test, and install package
+ run: opam install -t .
+
+ - name: Test dependants
+ if: >
+ (runner.os == 'Linux' && matrix.ocaml-version >= '4.04') ||
+ (runner.os == 'macOS' && matrix.ocaml-version >= '4.13')
+ run: |
+ PACKAGES=`opam list -s --color=never --installable --depends-on cppo,cppo_ocamlbuild`
+ echo "Dependants:" $PACKAGES
+ for PACKAGE in $PACKAGES
+ do
+ echo $SKIP_BUILD | tr ' ' '\n' | grep ^$PACKAGE$ > /dev/null &&
+ echo Skip $PACKAGE && continue
+ OPAMWITHTEST=true
+ echo $SKIP_TEST | tr ' ' '\n' | grep ^$PACKAGE$ > /dev/null &&
+ OPAMWITHTEST=false
+ ([ $OPAMWITHTEST == false ] &&
+ echo ::group::Build $PACKAGE) ||
+ echo ::group::Build and test $PACKAGE
+ DEPS_FAILED=false
+ (opam depext $PACKAGE &&
+ opam install --deps-only -t $PACKAGE) || DEPS_FAILED=true
+ [ $DEPS_FAILED == false ] && opam install $PACKAGE
+ echo ::endgroup::
+ [ $DEPS_FAILED == false ] || echo Dependencies broken
+ done
+
+ - name: Uninstall package
+ run: opam uninstall .
diff --git a/CODEOWNERS b/CODEOWNERS
index 2a7c825..9735ff3 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -6,3 +6,5 @@
#
# Interim maintainers who won't be very responsive :-(
* @mjambon @pmetzger
+*.opam @liyishuai
+.github/workflows/ @liyishuai
diff --git a/Changes b/Changes.md
index 48581b7..36d3bb8 100644
--- a/Changes
+++ b/Changes.md
@@ -1,3 +1,10 @@
+## v1.6.9 (2022-05-19)
+- [bug] Fix multiline string support (#81)
+
+## v1.6.8 (2021-09-17)
+- [compat] Allow version strings without patch numbers, _e.g._ `8.13+beta1`
+ The patch number will be set to 0 upon empty, _i.e._ `(8, 13, 0)`
+
## v1.6.7 (2020-12-21)
- [compat] Treat ~ and - the same in semver in order to parse
OCaml 4.12.0 pre-release versions.
diff --git a/LICENSE.md b/LICENSE.md
index f1725ba..c701b0b 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -9,13 +9,13 @@ are met:
2. 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.
-3. The name of the author may not be used to endorse or promote products
+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+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 AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+IN NO EVENT SHALL THE COPYRIGHT HOLDER 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
diff --git a/README.md b/README.md
index 8d5093a..0e247d4 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[![Build status](https://ci.appveyor.com/api/projects/status/ft3167hf8yr2n5d3?svg=true)](https://ci.appveyor.com/project/Chris00/cppo-pnjtx)
+[![Build status](https://github.com/ocaml-community/cppo/workflows/Build/badge.svg?branch=master)](https://github.com/ocaml-community/cppo/actions?query=workflow:Build)
Cppo: cpp for OCaml
===================
@@ -13,6 +13,38 @@ Cppo is:
* reasonably fast
* simple to install and to maintain
+Meta
+----
+
+* Author: Martin Jambon
+* OCaml-community maintainers:
+ - Martin Jambon ([**@mjambon**](https://github.com/mjambon))
+ - Yishuai Li ([**@liyishuai**](https://github.com/liyishuai))
+* License: [BSD 3-Clause "New" or "Revised" License](LICENSE.md)
+* Compatible OCaml versions: 4.02.3 or later
+* Additional dependencies:
+ - [Dune](https://dune.build) 1.10 or later
+ - [OCamlbuild](https://github.com/ocaml/ocamlbuild) and [Findlib](http://projects.camlcity.org/projects/findlib.html), for Ocamlbuild plugin
+
+Building and installation instructions
+--------------------------------------
+
+The easiest way to install the latest released version of cppo
+is via [OPAM](https://opam.ocaml.org/doc/Install.html):
+
+```shell
+opam install cppo
+```
+
+To instead build and install manually, do:
+
+``` shell
+git clone https://github.com/ocaml-community/cppo.git
+cd cppo
+make
+make install
+```
+
User guide
----------
diff --git a/cppo.opam b/cppo.opam
index ca016ff..885e52a 100644
--- a/cppo.opam
+++ b/cppo.opam
@@ -1,20 +1,19 @@
+# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
-maintainer: "martin@mjambon.com"
-authors: "Martin Jambon"
-license: "BSD-3-Clause"
-homepage: "https://github.com/ocaml-community/cppo"
-doc: "https://ocaml-community.github.io/cppo/"
-bug-reports: "https://github.com/ocaml-community/cppo/issues"
-depends: [
- "ocaml" {>= "4.02.3"}
- "dune" {>= "1.0"}
- "base-unix"
-]
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
["dune" "runtest" "-p" name "-j" jobs] {with-test}
+ ["dune" "build" "-p" name "@doc"] {with-doc}
+]
+maintainer: [
+ "Martin Jambon <martin@mjambon.com>" "Yishuai Li <yishuai@upenn.edu>"
]
+authors: ["Martin Jambon"]
+bug-reports: "https://github.com/ocaml-community/cppo/issues"
+homepage: "https://github.com/ocaml-community/cppo"
+doc: "https://ocaml-community.github.io/cppo"
+license: "BSD-3-Clause"
dev-repo: "git+https://github.com/ocaml-community/cppo.git"
synopsis: "Code preprocessor like cpp for OCaml"
description: """
@@ -28,3 +27,8 @@ Cppo is:
* reasonably fast
* simple to install and to maintain
"""
+depends: [
+ "ocaml" {>= "4.02.3"}
+ "dune" {>= "1.10"}
+ "base-unix"
+]
diff --git a/cppo_ocamlbuild.opam b/cppo_ocamlbuild.opam
index 96f1fdb..bb43c71 100644
--- a/cppo_ocamlbuild.opam
+++ b/cppo_ocamlbuild.opam
@@ -1,21 +1,19 @@
+# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
-maintainer: "martin@mjambon.com"
-authors: "Martin Jambon"
-license: "BSD-3-Clause"
-homepage: "https://github.com/ocaml-community/cppo"
-doc: "https://ocaml-community.github.io/cppo/"
-bug-reports: "https://github.com/ocaml-community/cppo/issues"
-depends: [
- "ocaml"
- "dune" {>= "1.0"}
- "ocamlbuild"
- "ocamlfind"
-]
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
["dune" "runtest" "-p" name "-j" jobs] {with-test}
+ ["dune" "build" "-p" name "@doc"] {with-doc}
+]
+maintainer: [
+ "Martin Jambon <martin@mjambon.com>" "Yishuai Li <yishuai@upenn.edu>"
]
+authors: ["Martin Jambon"]
+bug-reports: "https://github.com/ocaml-community/cppo/issues"
+homepage: "https://github.com/ocaml-community/cppo"
+doc: "https://ocaml-community.github.io/cppo"
+license: "BSD-3-Clause"
dev-repo: "git+https://github.com/ocaml-community/cppo.git"
synopsis: "Plugin to use cppo with ocamlbuild"
description: """
@@ -24,3 +22,9 @@ This ocamlbuild plugin lets you use cppo in ocamlbuild projects.
To use it, you can call ocamlbuild with the argument `-plugin-tag
package(cppo_ocamlbuild)` (only since ocaml 4.01 and cppo >= 0.9.4).
"""
+depends: [
+ "ocaml"
+ "dune" {>= "1.10"}
+ "ocamlbuild"
+ "ocamlfind"
+]
diff --git a/dune-project b/dune-project
index 902539e..074b20b 100644
--- a/dune-project
+++ b/dune-project
@@ -1,2 +1,44 @@
-(lang dune 1.0)
+(lang dune 1.10)
(name cppo)
+
+(generate_opam_files true)
+
+(source (github ocaml-community/cppo))
+(license BSD-3-Clause)
+(authors "Martin Jambon")
+(maintainers
+ "Martin Jambon <martin@mjambon.com>"
+ "Yishuai Li <yishuai@upenn.edu>")
+(documentation "https://ocaml-community.github.io/cppo")
+
+(package
+ (name cppo)
+ (depends
+ (ocaml (>= 4.02.3))
+ (dune (>= 1.10))
+ base-unix)
+ (synopsis "Code preprocessor like cpp for OCaml")
+ (description "Cppo is an equivalent of the C preprocessor for OCaml programs.
+It allows the definition of simple macros and file inclusion.
+
+Cppo is:
+
+* more OCaml-friendly than cpp
+* easy to learn without consulting a manual
+* reasonably fast
+* simple to install and to maintain
+"))
+
+(package
+ (name cppo_ocamlbuild)
+ (depends
+ ocaml
+ (dune (>= 1.10))
+ ocamlbuild
+ ocamlfind)
+ (synopsis "Plugin to use cppo with ocamlbuild")
+ (description "This ocamlbuild plugin lets you use cppo in ocamlbuild projects.
+
+To use it, you can call ocamlbuild with the argument `-plugin-tag
+package(cppo_ocamlbuild)` (only since ocaml 4.01 and cppo >= 0.9.4).
+"))
diff --git a/src/cppo_lexer.mll b/src/cppo_lexer.mll
index 93ae901..9e815b9 100644
--- a/src/cppo_lexer.mll
+++ b/src/cppo_lexer.mll
@@ -522,13 +522,9 @@ and string e = parse
| '\r'? '\n'
{
- if e.in_directive then
- lexer_error lexbuf "Unterminated string literal"
- else (
add e (lexeme lexbuf);
new_line e;
string e lexbuf
- )
}
| _ as c
diff --git a/test/dune b/test/dune
index 254e534..862beec 100644
--- a/test/dune
+++ b/test/dune
@@ -72,6 +72,17 @@
%{targets}
(run %{bin:cppo} -V X:123.05.2-alpha.1+foo-2.1 -V COQ:8.13+beta1 %{<}))))
+(rule
+ (targets test.out)
+ (deps
+ (:< test.cppo)
+ incl.cppo
+ incl2.cppo)
+ (action
+ (with-stdout-to
+ %{targets}
+ (run %{bin:cppo} %{<}))))
+
(alias
(name runtest)
(package cppo)
@@ -111,7 +122,8 @@
(alias
(name runtest)
(package cppo)
- (deps version.out))
+ (action
+ (diff version.ref version.out)))
(alias
(name runtest)
@@ -122,9 +134,5 @@
(alias
(name runtest)
(package cppo)
- (deps
- (:< test.cppo)
- incl.cppo
- incl2.cppo)
(action
- (ignore-stdout (run %{bin:cppo} %{<}))))
+ (diff test.ref test.out)))
diff --git a/test/test.cppo b/test/test.cppo
index 89756f7..9a259bc 100644
--- a/test/test.cppo
+++ b/test/test.cppo
@@ -37,8 +37,10 @@ failure
#define test_multiline \
"abc\
+ xyz
def" \
(* 123 \
+ 789
456 *)
test_multiline
@@ -73,7 +75,7 @@ obj
' (* lone single quote *)
#define one 1
-one is not 1
+one = 1
#undef x
#define x #
diff --git a/test/test.ref b/test/test.ref
new file mode 100644
index 0000000..bf7ec11
--- /dev/null
+++ b/test/test.ref
@@ -0,0 +1,142 @@
+# 1 "test.cppo"
+(* comment *)
+
+# 4 "test.cppo"
+f(1)
+# 6 "test.cppo"
+ 2+ 3.14
+# 8 "test.cppo"
+ 3+ 3.14
+
+# 13 "test.cppo"
+"g" is not defined
+
+# 18 "test.cppo"
+ b()
+
+# 20 "test.cppo"
+debug("a")
+debug("b")
+
+
+
+
+# 33 "test.cppo"
+success
+
+# 45 "test.cppo"
+
+"abc\
+ xyz
+ def"
+(* 123 \
+ 789
+ 456 *)
+
+# 48 "test.cppo"
+ "a" "b"
+
+# 51 "test.cppo"
+ aa ,bb 123
+
+# 54 "test.cppo"
+ , ) (
+
+# 56 "test.cppo"
+blah #define xyz
+
+# 63 "test.cppo"
+ _ _ (* the 2 underscores should be space-separated *)
+
+# 67 "test.cppo"
+ + + (* there should be some space between the pluses *)
+
+# 69 "test.cppo"
+(* (* nested comment with single single quote: ' *) "*)" *)
+
+# 72 "test.cppo"
+obj
+ # define
+# 73 "test.cppo"
+
+
+# 75 "test.cppo"
+' (* lone single quote *)
+
+# 78 "test.cppo"
+ 1
+# 78 "test.cppo"
+ = 1
+
+# 82 "test.cppo"
+ #
+# 82 "test.cppo"
+ is #
+
+# 98 "test.cppo"
+good maths
+
+
+
+
+# 117 "test.cppo"
+
+let g x =
+ printf "call %s\n%!" "g";
+ let y = g x in
+ printf "return %s\n%!" "g";
+ y
+;;
+
+
+# 124 "test.cppo"
+class foo () =
+object
+
+# 126 "test.cppo"
+
+ val mutable field_1 : int option
+ method get_field_1 = field_1
+ method set_field_1 x = field_1 <- Some x
+
+# 127 "test.cppo"
+
+ val mutable field_2 : string option
+ method get_field_2 = field_2
+ method set_field_2 x = field_2 <- Some x
+# 128 "test.cppo"
+end
+
+# 135 "test.cppo"
+
+ (if !debug then
+ eprintf "[debug] %s %i: " "test.cppo" 135 ;
+ eprintf "test1 %i %i" x y;
+ eprintf "\n")
+# 136 "test.cppo"
+
+ (if !debug then
+ eprintf "[debug] %s %i: " "test.cppo" 136 ;
+ eprintf "test2 %i" x;
+ eprintf "\n")
+
+# 1 "incl.cppo"
+included
+
+# 1 "incl2.cppo"
+ok
+# 139 "test.cppo"
+
+# 123456
+
+
+# 789 "test"
+# 1 "incl.cppo"
+included
+
+# 1 "incl2.cppo"
+ok
+
+
+# 793 "test"
+end
diff --git a/test/version.ref b/test/version.ref
new file mode 100644
index 0000000..0da340f
--- /dev/null
+++ b/test/version.ref
@@ -0,0 +1,37 @@
+
+# 5 "version.cppo"
+ Cape buffalos
+
+
+# 10 "version.cppo"
+ onion rings
+
+# 16 "version.cppo"
+major:
+# 16 "version.cppo"
+ 123
+# 17 "version.cppo"
+minor:
+# 17 "version.cppo"
+ 05
+# 18 "version.cppo"
+patch:
+# 18 "version.cppo"
+ 2
+
+
+# 21 "version.cppo"
+ prerelease:
+# 21 "version.cppo"
+ alpha.1
+
+
+# 27 "version.cppo"
+ build:
+# 27 "version.cppo"
+ foo-2.1
+
+# 32 "version.cppo"
+Coq:
+# 32 "version.cppo"
+ (8, 13, 0)