File: soong.pm

package info (click to toggle)
mini-soong 0.20201028
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 84 kB
  • sloc: python: 514; perl: 67; makefile: 2
file content (100 lines) | stat: -rw-r--r-- 2,449 bytes parent folder | download
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# A debhelper build system class for handling simple soong-based projects.
# It uses mini-soong, a Python re-implementation of a minimal Soong subset.
#
# Copyright: © 2008 Joey Hess
#            © 2008-2009 Modestas Vainius
#            © 2020 Andrej Shadura
#
# SPDX-License-Identifier: GPL-2+
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later
# version.

package Debian::Debhelper::Buildsystem::soong;

use strict;
use Debian::Debhelper::Dh_Lib qw(compat escape_shell clean_jobserver_makeflags gain_root_cmd dpkg_architecture_value);
use base 'Debian::Debhelper::Buildsystem::makefile';

sub DESCRIPTION {
	"mini-Soong"
}

sub clean {
	my $this=shift;
	if (-e $this->get_buildpath("soong.mk")) {
		$this->SUPER::clean(@_);
	}
	$this->doit_in_builddir('rm', '-f', 'soong.mk');
}

sub configure {
	my $this=shift;

	$this->mkdir_builddir();

	my $builddir = $this->get_builddir();

	my @opts;
	if (-e $this->get_buildpath("Android.bp")) {
		push @opts, "-o";
		push @opts, "soong.mk";
	}
	$this->doit_in_builddir("mini-soong", @opts, @_);
}

sub do_make {
	my $this=shift;

	# Avoid possible warnings about unavailable jobserver,
	# and force make to start a new jobserver.
	clean_jobserver_makeflags();

	my @opts;
	push @opts, "-f";
	push @opts, "soong.mk";
	my $prefix = "/usr";
	push @opts, "prefix=${prefix}";
	push @opts, "mandir=${prefix}/share/man";
	push @opts, "infodir=${prefix}/share/info";
	push @opts, "sysconfdir=/etc";
	my $multiarch=dpkg_architecture_value("DEB_HOST_MULTIARCH");
	if (defined $multiarch) {
		push @opts, "libdir=${prefix}/lib/$multiarch";
		push @opts, "libexecdir=${prefix}/lib/$multiarch" if compat(11);
	}
	else {
		push @opts, "libexecdir=${prefix}/lib" if compat(11);
	}

	my @root_cmd;
	if (exists($this->{_run_make_as_root}) and $this->{_run_make_as_root}) {
		@root_cmd = gain_root_cmd();
	}
	$this->doit_in_builddir(@root_cmd, $this->{makecmd}, @opts, @_);
}

sub exists_make_target {
	my $this=shift;
	return $this->SUPER::exists_make_target(@_, "-f", "soong.mk");
}

sub check_auto_buildable {
	my $this=shift;
	my ($step)=@_;

	return 0 unless -e $this->get_sourcepath("Android.bp");
	return 1;
}

sub new {
	my $class=shift;
	my $this=$class->SUPER::new(@_);
	$this->{makecmd} = "make";
	return $this;
}

1