1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
# A build system class for handling ocaml-dune based projects.
#
# Copyright: © 2023 Stéphane Glondu
# License: GPL-2+
package Debian::Debhelper::Buildsystem::ocaml_dune;
use strict;
use warnings;
use parent qw(Debian::Debhelper::Buildsystem);
use Config;
sub DESCRIPTION {
"OCaml Dune";
}
sub new {
my $class = shift;
my $this = $class->SUPER::new(@_);
return $this;
}
sub check_auto_buildable {
my ( $this, $step ) = @_;
return -e $this->get_sourcepath("debian/debian-dune");
}
sub get_dune_package_names {
my $this = shift;
my @names;
open( FH, "<", $this->get_sourcepath("debian/debian-dune") );
while (<FH>) {
chomp;
push( @names, $_ );
}
close(FH);
return @names;
}
sub get_dune_package_name_list {
my $this = shift;
return join( ",", $this->get_dune_package_names() );
}
sub get_dune_parallel {
my $this = shift;
my $parallel = $this->get_parallel();
my @result;
if ( $parallel > 0 ) {
push( @result, "-j" );
push( @result, $parallel );
}
return @result;
}
sub build {
my $this = shift;
$this->doit_in_sourcedir( "dune", "build", $this->get_dune_parallel(),
"-p", $this->get_dune_package_name_list(), @_ );
}
sub test {
my $this = shift;
$this->doit_in_sourcedir( "dune", "runtest", $this->get_dune_parallel(),
"-p", $this->get_dune_package_name_list() );
}
sub install {
my $this = shift;
my $ocaml_stdlib_dir = `ocamlc -where`;
chomp($ocaml_stdlib_dir);
$this->doit_in_sourcedir( "dune", "install", "--destdir=debian/tmp",
"--prefix=/usr", "--libdir=$ocaml_stdlib_dir",
$this->get_dune_package_names() );
}
sub clean {
my $this = shift;
$this->doit_in_sourcedir( "dune", "clean" );
}
1
|