Skip to content

Conversation

@smondet
Copy link
Contributor

@smondet smondet commented Mar 7, 2025

Cf. issue #412

PR checklist

  • New code has tests to catch future regressions
  • Documentation is up-to-date
  • CHANGES.md is up-to-date

@smondet smondet marked this pull request as ready for review March 7, 2025 15:46
@smondet
Copy link
Contributor Author

smondet commented Mar 7, 2025

 $ dune exec atdgen/bin/ag_main.exe -- --help | head -n 20
Generate OCaml code offering:         
  * OCaml type definitions translated from ATD file (-t)
  * serializers and deserializers for Biniou (-b)
  * serializers and deserializers for JSON (-j)
  * record-creating functions supporting default fields (-v)
  * user-specified data validators (-v)

Recommended usage: _build/default/atdgen/bin/ag_main.exe (-t|-b|-j|-v|-dep|-list|-mel) example.atd

Some options are deprecated. Use the environment variable `ATDGEN_FAIL_DEPRECATED_OPTIONS=true`
to make their use fail and hence help clean-up your build scripts.

  -type-conv 
    GEN1,GEN2,...
         Insert 'with GEN1, GEN2, ...' after OCaml type definitions for the
         type-conv preprocessor
    
  -deriving-conv 
    GEN1,GEN2,...
         Insert '[@@deriving GEN1,GEN2,...]' after OCaml type definitions for

@smondet
Copy link
Contributor Author

smondet commented Mar 7, 2025

Building the repo with export ATDGEN_FAIL_DEPRECATED_OPTIONS=true for now gives:

File "atdgen/test/dune", line 93, characters 0-232:
93 | (rule
94 |  (targets test_ambiguous_record_j.ml test_ambiguous_record_j.mli)
95 |  (deps    test_ambiguous_record.atd)
96 |  (action
97 |   (run %{bin:atdgen} -json -j-gen-modules -o test_ambiguous_record_j -open Test_ambiguous_record_t -ntd %{deps})))
Error: option "-json" is forbidden.
File "atdgen/test/dune", line 117, characters 0-197:
117 | (rule
118 |  (targets test_polymorphic_wrap_j.ml test_polymorphic_wrap_j.mli)
119 |  (deps    test_polymorphic_wrap.atd)
120 |  (action
121 |   (run %{bin:atdgen} -json -j-gen-modules -o test_polymorphic_wrap_j %{deps})))
Error: option "-json" is forbidden.
File "atdgen/test/dune", line 163, characters 0-139:
163 | (rule
164 |  (targets testjstd_j.ml testjstd_j.mli)
165 |  (deps    test.atd)
166 |  (action  (run %{bin:atdgen} -extend Test test.atd -json -o testjstd_j)))
Error: option "-json" is forbidden.
File "atdgen/test/dune", line 178, characters 0-128:
178 | (rule
179 |  (targets testv.ml testv.mli)
180 |  (deps    test.atd)
181 |  (action  (run %{bin:atdgen} -validate -extend Test test.atd -o testv)))
Error: option "-validate" is forbidden.
File "atdgen/test/dune", line 31, characters 0-256:
31 | (rule
32 |  (targets testj.ml testj.mli)
33 |  (deps    (:atd test.atd) test.ml test.mli)
34 |  (action
35 |   (run
36 |    %{bin:atdgen} -json -extend Test -j-custom-fields
37 |    "fun loc s -> Printf.eprintf \"Warning: skipping field %s (def: %s)\n\" s loc"
38 |    %{atd}
39 |     -o testj)))
Error: option "-json" is forbidden.

Copy link
Collaborator

@mjambon mjambon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you!

@smondet
Copy link
Contributor Author

smondet commented Mar 10, 2025

@mjambon should we do anything special with PRs that target the "3.0" major version (ie breaking changes we may not want in a minor release)?

@mjambon mjambon mentioned this pull request Sep 22, 2025
@mjambon
Copy link
Collaborator

mjambon commented Sep 22, 2025

@smondet sorry I forgot to follow up. We should edit dune-project with a version constraint on yojson 3 where needed (at least on atdgen-runtime). The opam files will be derived from it.

ocaml-ci fails because it uses the latest yojson (3) which is allowed by the current version constraint. I'm not sure why our own CI succeeds. I guess we should also make it use yojson 3 and not bother supporting yojson 2 any longer (except for security patches if ever needed).

@kit-ty-kate is asking for a yojson3-compatible release at #431

@barracuda156
Copy link

@smondet sorry I forgot to follow up. We should edit dune-project with a version constraint on yojson 3 where needed (at least on atdgen-runtime).

@mjambon That does not fix the issue for dependents, unfortunately, since two versions of yojson are in conflict (cannot be active simultaneously), so even if I add yojson2 for compatibility (to be used with atd and its dependents), for example, lab app will pull in both:

Last login: Wed Oct 15 04:15:51 on ttys002
% port rdeps ocaml-lab
The following ports are dependencies of ocaml-lab @0.1.8_0:
  ocaml-dune
    ocaml-findlib
      ocaml
        xz
          gettext
            ncurses
            gettext-tools-libs
              libiconv
                autoconf
                  xz-bootstrap
                  m4-bootstrap
                automake
                gperf
              libtextstyle
              gettext-runtime
  ocaml-cmdliner
  ocaml-cohttp-lwt-unix
    ocaml-http
    ocaml-logs
      ocaml-topkg
        ocaml-ocamlbuild
        opam
          gpatch
      ocaml-fmt
      ocaml-js_of_ocaml
        ocaml-ppxlib
          ocaml-compiler-libs
          ocaml-ppx_derivers
          ocaml-sexplib0
          ocaml-stdlib-shims
        ocaml-js_of_ocaml-compiler
          ocaml-menhir
            ocaml-menhirSdk
            ocaml-menhirLib
            ocaml-coq-menhirlib
          ocaml-sedlex
            ocaml-gen
              ocaml-seq
          ocaml-yojson
      ocaml-lwt
        ocaml-cppo
        ocaml-dune-configurator
          ocaml-csexp
        ocaml-ocplib-endian
    ocaml-ppx_sexp_conv
      ocaml-base
    ocaml-cohttp
      ocaml-base64
      ocaml-re
        ocaml-ounit
          ocaml-ounit2
        ocaml-ppx_expect
          ocaml-ppx_here
          ocaml-ppx_inline_test
            ocaml-time_now
              ocaml-jane-street-headers
              ocaml-jst-config
                ocaml-ppx_assert
                  ocaml-ppx_cold
                  ocaml-ppx_compare
              ocaml-ppx_base
                ocaml-ppx_enumerate
                ocaml-ppx_globalize
                ocaml-ppx_hash
              ocaml-ppx_optcomp
                ocaml-stdio
      ocaml-stringext
      ocaml-uri
        ocaml-angstrom
          ocaml-bigstringaf
      ocaml-uri-sexp
    ocaml-cohttp-lwt
      ocaml-ipaddr
        ocaml-domain-name
        ocaml-macaddr
    ocaml-conduit-lwt
      ocaml-conduit
        ocaml-astring
        ocaml-ipaddr-sexp
    ocaml-conduit-lwt-unix
      ocaml-ca-certs
        ocaml-bos
          ocaml-fpath
          ocaml-rresult
        ocaml-digestif
          ocaml-eqaf
        ocaml-mirage-crypto
        ocaml-ohex
        ocaml-ptime
        ocaml-x509
          ocaml-asn1-combinators
          ocaml-gmap
          ocaml-kdf
          ocaml-mirage-crypto-ec
            ocaml-mirage-crypto-rng
              ocaml-duration
          ocaml-mirage-crypto-pk
            pkgconfig
            gmp
              m4
            ocaml-zarith
              perl5
                perl5.34
                  db48
                  gdbm
                    readline
      ocaml-lwt_ssl
        ocaml-ssl
          openssl3
            zlib
      ocaml-tls-lwt
        ocaml-tls
    ocaml-magic-mime
  ocaml-gitlab-unix
    ocaml-gitlab
      ocaml-atdgen
        ocaml-yojson2
        ocaml-atd
          ocaml-easy-format
        ocaml-atdgen-runtime
          ocaml-biniou
            ocaml-camlp-streams
      ocaml-ISO8601
  ocaml-otoml
    ocaml-uutf
  groff
    texinfo
      help2man
        p5.34-locale-gettext
      libunistring
        libtool
    ghostscript
      fontconfig
        python313
          bzip2
          expat
          libedit
          libffi
            dejagnu
              expect
                tcl
          mpdecimal
          openssl
          sqlite3
          python_select-313
            python_select
          python3_select-313
            python3_select
        freetype
          brotli
            cmake-bootstrap
          libpng
      jbig2dec
      lcms2
        libjpeg-turbo
          cmake
            curl
              nghttp2
              libidn2
              libpsl
                python310
                  python_select-310
                  python3_select-310
              curl-ca-bundle
                unzip
              zstd
                lz4
            libarchive
              libb2
              libxml2
                icu
              lzo2
          nasm
        tiff
          lerc
          libdeflate
      libidn
      libpaper
      openjpeg
        jbigkit
      xorg-libXext
        xorg-util-macros
        xorg-libX11
          xorg-xtrans
          xorg-xorgproto
          xorg-libXdmcp
          xorg-libXau
          xorg-libxcb
            xorg-xcb-proto
      xorg-libXt
        xmlto
          docbook-xml
            xmlcatmgr
            docbook-xml-4.1.2
              docbook-xml-4.2
            docbook-xml-4.3
            docbook-xml-4.4
            docbook-xml-4.5
            docbook-xml-5.0
          docbook-xsl-nons
          libxslt
          util-linux
          fop
          libpaper-utils
          w3m
            boehmgc
        xorg-libsm
          xorg-libice
    psutils
    netpbm
      jasper
      libnetpbm
    uchardet
    urw-fonts

Which won’t work, of course.

@glondu
Copy link

glondu commented Oct 22, 2025

I didn't look the changes in details, but could -j-std be kept, even if it becomes the default? It would ease things for codebases that want to be compatible with both versions.

@kit-ty-kate
Copy link
Contributor

I didn't look the changes in details, but could -j-std be kept, even if it becomes the default? It would ease things for codebases that want to be compatible with both versions.

As far as i understand the code, i believe this is what this PR does already. The option is kept and doesn't do anything unless ATDGEN_FAIL_DEPRECATED_OPTIONS=true is set. I think this is quite reasonable.

@mjambon
Copy link
Collaborator

mjambon commented Dec 9, 2025

I'm going to merge this. The tests pass with yojson 2.0.2. They still fail with yojson 3.0.0 but this isn't new and there's a version constraint in the relevant opam file ensuring the use of yojson 2. I'll try to fix the compatibility with yojson 3.0.0 in another PR.

@mjambon mjambon force-pushed the smondet-20250307-remove-j-std-i412 branch from 8340908 to bd4916f Compare December 9, 2025 02:07
@mjambon mjambon merged commit ffbefb7 into master Dec 9, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants