Making a portfile from a cmake based project

Mojca Miklavec mojca at macports.org
Sat Feb 27 09:13:48 PST 2016


On 27 February 2016 at 17:52, Manu N wrote:
> Hello again,
> here's my current Portfile, located in a local portfile repository
> ~/ports/audio/libebur128
>
> # $Id$
> PortSystem          1.0
> PortGroup           github 1.0
> github.setup        jiixyj libebur128 1.1.0 v
> github.tarball_from releases

I'm not sure if this is needed. I left it out in the experiment (and
as a consequence had to change the shasums).

> PortGroup           cmake 1.0
> cmake.out_of_source yes
> name                libebur128
> version             1.1.0

No need to repeat name and version. They are set by github.setup already.

> categories          audio
> platforms           darwin
> maintainers         audionuma \
>                     gmail.com:audionuma

The maintainer audionuma would be a synonym for
audionuma at macports.org. Since you probably don't have an account /
commit rights yet, you only need the second address and potentially
openmaintainer as well.

> description         loudness measure according to EBU R128
> long_description    loudness measure according to EBU R128

In this case you can use
long_description ${description}

> homepage            https://github.com/jiixyj/libebur128
> master_sites        https://github.com/jiixyj/libebur128

No need. Both are set by github.setup already.

> checksums               rmd160  2eb66acfd34557f66961e34b21fefa126fabb889 \
>                         sha256
> c60e78f4bfda387a0895c64a4fc9850445e3a4425cc98f9140885966ce17c1d1
> depends_lib        port:speex-devel

I was unable to use that because I already had "speex" installed. I
removed -devel and it seemed to work.

> OK.
> Added a github.tarball_from releases command as there is a release on
> github.

I'm not sure when this is needed.

> Nevertheless, I had to manually add the  libebur128-1.1.0.tar.gz file into
> the /opt/local/var/macports/distfiles/libebur128 directory to have the
> installation work, otherwise `port` was searching for the archive in it's
> usual online repositories. Is that the expected behavior ?

The port certainly has to be fetched from somewhere.

I removed github.tarball_from and this is what I get:

> sudo port -v destroot libebur128
--->  Computing dependencies for libebur128.
--->  Fetching distfiles for libebur128
--->  libebur128-1.1.0.tar.gz doesn't seem to exist in
/opt/local/var/macports/distfiles/libebur128
--->  Attempting to fetch libebur128-1.1.0.tar.gz from
http://distfiles.macports.org/libebur128
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
--->  Attempting to fetch libebur128-1.1.0.tar.gz from
http://lil.fr.distfiles.macports.org/libebur128
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
--->  Attempting to fetch libebur128-1.1.0.tar.gz from
http://fco.it.distfiles.macports.org/mirrors/macports-distfiles/libebur128
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
--->  Attempting to fetch libebur128-1.1.0.tar.gz from
http://mse.uk.distfiles.macports.org/sites/distfiles.macports.org/libebur128
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   276    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
--->  Attempting to fetch libebur128-1.1.0.tar.gz from
http://nue.de.distfiles.macports.org/macports/distfiles/libebur128
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
--->  Attempting to fetch libebur128-1.1.0.tar.gz from
http://osl.no.distfiles.macports.org/libebur128
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
--->  Attempting to fetch libebur128-1.1.0.tar.gz from
https://github.com/jiixyj/libebur128/tarball/v1.1.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19333    0 19333    0     0   9094      0 --:--:--  0:00:02 --:--:-- 71339


>> This is basically all you need. If you want to switch some features
>> on/off, you could do something like
>>
>> configure.args-append -DENABLE_TESTS=ON
>>
>
> Now, if I add the following lines to the Portfile (at the end)
>
> variant with_tests description {Build tests suite} {
>   configure.args-append -DENABLE_TESTS=ON
> }
>
> and run
>
> port variants libebur128
>
> the result is :
>
> libebur128 has the variants:
>    debug: Enable debug binaries
>    universal: Build for multiple architectures
>
> So it seems that my with_tests variant is not found.

Maybe you have an old index. It works for me:

> port variants libebur128
libebur128 has the variants:
   debug: Enable debug binaries
   universal: Build for multiple architectures
   with_tests: Build tests suite


This would be my proposal based on yours:

# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil;
c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id$
PortSystem          1.0
PortGroup           github 1.0
PortGroup           cmake 1.0

github.setup        jiixyj libebur128 1.1.0 v
categories          audio
platforms           darwin
license             MIT
maintainers         gmail.com:audionuma openmaintainer
description         loudness measure according to EBU R128
long_description    ${description}

checksums           rmd160  cb08401693d25a74d584cb8aaa85c1847634b200 \
                    sha256
1de69d2ee9a5a94c5333dafdacc9c0fed26a5b540bf8fbe9a2c7c7557658c182

# some additional code is needed to make it work with both
depends_lib         port:speex
#depends_lib        port:speex-devel

cmake.out_of_source yes

As far as the tests are concerned: MacPorts offers some functionality
to run the tests (like "sudo port test libebur128"), but I would have
to check how to properly implement that.

Mojca


More information about the macports-dev mailing list