Sunday, September 13, 2026

Re: devel/dune: missing rdep on devel/git

On Sun, 13 Sep 2026, Christopher Zimmermann wrote: > .cmx, .cmxa, .cmxs and .a with the same basename as coresponding .cmxa > are only built on native archs. They go into PFRAG.native. The .cmxs > into PFRAG.dynlink-native, but this at the moment makes do difference since > there is no native no-dynlink architecture. I decided to try to automate "make plist" for ocaml since I keep getting it wrong when I do it by hand. The stubs for ocaml files are already there so it looks like someone already planned to do this at some point. Only the redistribute method implementations are missing. This diff implements logic from chrisz@ by putting native files into PFRAG.native, cmxs files into PFRAG.dynlink-native and adds the required fragment links automatically. I tested this on devel/dune and it resulted in what I think are the correct PLIST and PFRAG files. Some of the other ocaml ports can probably benefit from being checked against this revised script. ok? Index: update-plist =================================================================== RCS file: /cvs/ports/infrastructure/bin/update-plist,v diff -u -p -u -r1.217 update-plist --- update-plist 6 Jul 2026 08:12:40 -0000 1.217 +++ update-plist 13 Sep 2026 22:08:57 -0000 @@ -731,6 +731,27 @@ sub check_suffix($self, $state) package OpenBSD::PackingElement::File::Ocaml; our @ISA = qw(OpenBSD::PackingElement::File); +sub ocaml_pfrag($o, $p, $frag) +{ + my $base = $p->{tracker}->default->name; + $base =~ s/PFRAG\./PFRAG.$frag-/ or + $base =~ s/PLIST/PFRAG.$frag/; + return $base; +} + +# .cmx/.cmxa/paired .a and .o are native-only +sub redistribute($o, $p) +{ + return if $o->{DONT}; + my $native = $o->ocaml_pfrag($p, 'native'); + if (defined $o->{file} && $o->{file} =~ /PFRAG\./ + && $o->{file} ne $o->ocaml_pfrag($p, 'dynlink-native')) { + $p->{tracker}->file($o->{file})->add($o); + } else { + $p->{tracker}->file($native)->add($o); + } +} + package OpenBSD::PackingElement::File::Ocaml::Cmx; our @ISA = qw(OpenBSD::PackingElement::File::Ocaml); package OpenBSD::PackingElement::File::Ocaml::Cmxa; @@ -739,9 +760,23 @@ package OpenBSD::PackingElement::File::O our @ISA = qw(OpenBSD::PackingElement::File::Ocaml); package OpenBSD::PackingElement::File::Ocaml::o; our @ISA = qw(OpenBSD::PackingElement::File::Ocaml); + package OpenBSD::PackingElement::File::Ocaml::Cmxs; our @ISA = qw(OpenBSD::PackingElement::File::Ocaml); +# .cmxs requires dynlink +sub redistribute($o, $p) +{ + return if $o->{DONT}; + my $dynlink = $o->ocaml_pfrag($p, 'dynlink-native'); + if (defined $o->{file} && $o->{file} =~ /PFRAG\./ + && $o->{file} ne $o->ocaml_pfrag($p, 'native')) { + $p->{tracker}->file($o->{file})->add($o); + } else { + $p->{tracker}->file($dynlink)->add($o); + } +} + package OpenBSD::PackingElement::LoginClass; our @ISA = qw(OpenBSD::PackingElement::File); @@ -1249,6 +1284,46 @@ sub log_variables($self, $s) } } +sub _has_frag_link($tf, $frag_name) +{ + for my $item (@{$tf->{items}}) { + return 1 if ref($item) eq 'OpenBSD::PackingElement::Fragment' + && $item->{name} eq $frag_name; + } + return 0; +} + +# inject missing fragment links for any OCaml PFRAG that was populated +sub ensure_ocaml_links($self, $p) +{ + my $tracker = $p->{tracker}; + my $known = $tracker->{known}; + for my $plist_path (@{$p->{base_plists}}) { + my $native_path = $plist_path; + $native_path =~ s/PFRAG\./PFRAG.native-/ or + $native_path =~ s/PLIST/PFRAG.native/; + my $dynlink_path = $native_path; + $dynlink_path =~ s/PFRAG\./PFRAG.dynlink-/; + + next unless exists $known->{$native_path} + || exists $known->{$dynlink_path}; + + my $tf_plist = $tracker->file($plist_path); + unless (_has_frag_link($tf_plist, 'native')) { + $tf_plist->add(bless {name => 'native'}, + 'OpenBSD::PackingElement::Fragment'); + } + + next unless exists $known->{$dynlink_path}; + + my $tf_native = $tracker->file($native_path); + unless (_has_frag_link($tf_native, 'dynlink')) { + $tf_native->add(bless {name => 'dynlink'}, + 'OpenBSD::PackingElement::Fragment'); + } + } +} + sub write_new_files($self) { for my $p (@{$self->{lists}}) { @@ -1256,6 +1331,7 @@ sub write_new_files($self) $p->{tracker} = OpenBSD::TrackFile->new($p->{base_plists}[-1], $self->{state}{extnew}); $p->nlist->redistribute($p); + $self->ensure_ocaml_links($p); $p->{tracker}->write_all($p); $self->log_variables($p->subst);

No comments:

Post a Comment