[MacPorts] #56377: Additions to the cargo PG for all cases

MacPorts noreply at macports.org
Sat Apr 28 15:42:59 UTC 2018


#56377: Additions to the cargo PG for all cases
-------------------------+-------------------------------------------------
 Reporter:               |      Owner:  (none)
  MarcusCalhoun-Lopez    |
     Type:  enhancement  |     Status:  new
 Priority:  Normal       |  Milestone:
Component:  ports        |    Version:
 Keywords:               |       Port:  ripgrep fd mesalink ​racer librsvg
                         |  cargo
-------------------------+-------------------------------------------------
 Currently, there seem to be six ports that use the [https://crates.io
 cargo build system]:
 * [https://github.com/macports/macports-
 ports/tree/master/textproc/ripgrep/Portfile ripgrep]
 * [https://github.com/macports/macports-
 ports/tree/master/sysutils/fd/Portfile fd]
 * [https://github.com/macports/macports-
 ports/tree/master/devel/mesalink/Portfile mesalink]
 * [https://github.com/macports/macports-
 ports/tree/master/devel/racer/Portfile racer]
 * [https://github.com/macports/macports-
 ports/tree/master/graphics/librsvg/Portfile librsvg]
 * [https://github.com/macports/macports-
 ports/tree/master/devel/cargo/Portfile cargo]

 Only ripgrep, fd, and mesalink use the [https://github.com/macports
 /macports-ports/blob/master/_resources/port1.0/group/cargo-1.0.tcl cargo
 PortGroup], while the last three probably should (see, e.g, this
 [https://trac.macports.org/ticket/56195 ticket] for cargo).

 Ports that do '''not''' use configure and call cargo directly in the build
 phase:
 * ripgrep
 * fd
 * racer
 * cargo

 Ports that use configure and make:
 * mesalink
 * librsvg

 One possible solution:
 {{{
 options cargo.direct_call
 default cargo.direct_call yes

 option_proc cargo.direct_call handle_cargo_direct_call
 proc handle_cargo_direct_call {option action {value ""}} {
     if {${action} eq "set" && ${value}} {
         global build.jobs

         use_configure       no

         build.cmd           cargo build
         build.target
         build.pre_args      --release --frozen -v -j${build.jobs}
         build.args

         # restore destroot.cmd
         default destroot.cmd {[portbuild::build_getmaketype]}
     }
 }
 }}}

 For the convenience of mesalink and librsvg, we might also consider
 removing
 {{{
 destroot {
     ui_error "No destroot phase in the Portfile!"
     ui_msg "Here is an example destroot phase:"
     ui_msg
     ui_msg "destroot {"
     ui_msg {    xinstall -m 755 ${worksrcpath}/target/release/${name}
 ${destroot}${prefix}/bin/}
     ui_msg {    xinstall -m 444 ${worksrcpath}/doc/${name}.1
 ${destroot}${prefix}/share/man/man1/}
     ui_msg "}"
     ui_msg
     ui_msg "Please check if there are additional files (configuration,
 documentation, etc.) that need to be installed."
     error "destroot phase not implemented"
 }
 }}}
 from the cargo PG.

 ----

 As a special case, librsvg seems to include its own crates, so the
 [https://github.com/macports/macports-
 ports/blob/e482f28f8bc97ed40b305739692115892346f7cc/_resources/port1.0/group/cargo-1.0.tcl#L151
 config file] causes an error.[[BR]]
 One possible solution:
 {{{
 options cargo.worksrcdir_crates
 default cargo.worksrcdir_crates no

 if {!${cargo.worksrcdir_crates}} {
 ...
 set conf [open "${cargo.home}/config" "w"]
 ...
 }
 }}}

 ----

 In order to respect {{{build_arch}}}, we would need to set
 {{{CARGO_BUILD_TARGET}}}.[[BR]]
 This has the unfortunate consequence of changing the directly where the
 binary is built:
 * ripgrep : {{{${worksrcpath}/target/release/rg}}} -->
 {{{${worksrcpath}/target/$(CARGO_BUILD_TARGET)/release/rg}}}
 * fd: {{{${worksrcpath}/target/release/fd}}} -->
 {{{${worksrcpath}/target/release/$(CARGO_BUILD_TARGET)/fd}}}
 * mesalink: {{{configure.args-append --enable-
 rusthost=\$CARGO_BUILD_TARGET}}}
 * racer:
 {{{${worksrcpath}/target/release/racer}}}-->{{{${worksrcpath}/target/$(CARGO_BUILD_TARGET)/release/racer}}}
 * librsvg: [https://github.com/macports/macports-
 ports/blob/master/graphics/librsvg/files/patch-configure-
 rust_target_subdir.diff patchfile]
 * cargo: {{{${worksrcpath}/target/release/cargo}}} -->
 {{{${worksrcpath}/target/\$(CARGO_BUILD_TARGET)/release/cargo}}}

 ----

 In order to support universal builds, we would have to use the
 [https://github.com/macports/macports-
 ports/blob/master/_resources/port1.0/group/muniversal-1.0.tcl muniversal
 PG].[[BR]]
 However, a shortcoming of muniversal is that it
 [https://lists.macports.org/pipermail/macports-dev/2018-April/038639.html
 does not allow destroot in the Portfile].[[BR]]
 So ripgrep, fd, racer, and cargo would have to be changed to use a
 Makefile for installation.[[BR]]
 This may be too much of a maintenance headache.

 ----

 Minor issue: if cargo is going to use the cargo PG, then the dependency
 will have to change.[[BR]]
 One possible solution:
 {{{
 if {${subport} ne "cargo-bootstrap" && ${subport} ne "cargo-stage1" &&
 ${subport} ne "cargo"} {
     depends_build-append port:cargo
     # do not force all Portfiles to switch from depends_build to
 depends_build-append
     proc cargo.add_dependencies {} {
         depends_build-delete port:cargo
         depends_build-append port:cargo
     }
     port::register_callback cargo.add_dependencies
 }
 }}}
 The existence of {{{cargo-bootstrap}}} and {{{cargo-stage1}}} subports
 assumes the inclusion of parts of the patch from
 [https://trac.macports.org/ticket/56195 56195].

 ----

 Minor issue: the libssh2-sys crate (used by cargo) has an annoying issue
 with header files.[[BR]]
 One possible solution:
 {{{
         foreach {cname cversion chksum} ${cargo.crates} {
             # the libssh2-sys crate requires the header files from
             #    a version of libssh2 that has not been released
             #    (e.g. channel.c uses the error code
 LIBSSH2_ERROR_CHANNEL_WINDOW_FULL)
             # make sure these header files are found properly
             if {${cname} eq "libssh2-sys"} {
                 foreach f [glob -tail -directory
 ${cargo.home}/macports/libssh2-sys-${cversion}/libssh2/include/ *.h] {
                     ln -s ../include/${f}
 ${cargo.home}/macports/libssh2-sys-${cversion}/libssh2/src/
                 }
             }
         }
 }}}
 However, it is not at all clear that this is of general enough use to
 belong in the cargo PG.

 ----

 Minor issue: if cargo is to use the cargo PG, it will have to change
 {{{build.cmd}}} to some prebuilt cargo.[[BR]]
 Such a change will be slightly easier if
 {{{
 build.cmd           cargo build
 build.target
 }}}
 becomes
 {{{
 build.cmd           cargo
 build.target        build
 }}}
 .

-- 
Ticket URL: <https://trac.macports.org/ticket/56377>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list