Jeremy Evans <jer...@openbsd.org> writes:

> The commonmarker gem recently changed the backend they were using from a
> C-based one (libcmark-gfm), to a Rust-based one (comrak).  This required
> a significant amount of work to get it to continue to build, because:
>
> * cargo wants to download the crates at runtime, and the way the cargo
>   module wants to handle this doesn't work for the gem case.
>
> * There is a dummy cargo.toml file shipped in top level folder, but it
>   is not the one used for building.

you could tell devel/cargo which Cargo.toml to use using:
  MODCARGO_CARGOTOML = ${WRKSRC}/shomewhere/Cargo.toml

> * One crate needs a source file that doesn't appear to ship in the crate
>   (or the cargo module removes it).

yes, the cargo module removes the sources fixes for several crates, when
the usual purpose is to build a library from source whereas it is
present in the ports tree.

if you only need the oniguruma library, you could just add:
  LIB_DEPENDS += textproc/oniguruma
  WANTLIB += onig

the onig_sys crate will first looks at pkg-config to search it (and try
to build it if not present).

if you need more than the library, you could opt-in to not remove the
source files using:
  MODCARGO_CRATES_KEEP += onig_sys

> * The cargo module needs to modification (extra variable) to build this,
>   because either it or the ruby module puts the downloaded crates in a
>   different location than expected.

> To get around the last issue, I added MODCARGO_CRATE_EXTRACTDIR to the
> cargo module.  No backwards-incompatible changes for other ports
> using the cargo module.

I would like to properly understand the issue first. specially as you
are also redefining lot of paths to have things properly working
(MODCARGO_VENDOR_DIR and .cargo/config file generation).

I will take a look at it.

> This also required a new dependency, ruby-rb_sys, which will likely
> be used by any future Rust-based Ruby ports.  Hopefully, the work
> required to get this port updated will make it easier to get other
> Rust-based Ruby ports working, should they show up.
>
> This is my first time working on a port using Rust.  Maybe there is an
> easier way or I'm doing something wrong.

The MODCARGO_CRATES lines could go inside an external "crates.inc" file
and do a .include "crates.inc" in the Makefile. it is usually simpler
for updating the port.

$ make modcargo-gen-crates > crates.inc

please also re-run the crates.inc generation (after the "make makesum"),
to have proper licenses information in the file, using

$ make modcargo-gen-crates-licenses > crates.inc

> The use of Rust will probably knock out a few platforms. However, this
> is a leaf port, so the affect on ports will be minimal.
>
> Tested on amd64.
>
> OKs for:
>
> * cargo module change
> * import ruby-rb_sys dependency
> * commonmarker update
>
> Thanks,
> Jeremy
>

Thanks.
-- 
Sebastien Marie

Reply via email to