OLD | NEW |
| (Empty) |
1 # A debhelper build system class for handling SCons based projects. | |
2 # Extended for Chrome OS (cross-compiling support, parallel builds). | |
3 # | |
4 # Copyright: © 2009 Luca Falavigna | |
5 # Copyright: © 2009 The Chromium OS Authors. | |
6 # License: GPL-2+ | |
7 | |
8 package Debian::Debhelper::Buildsystem::scons_chromeos; | |
9 | |
10 use strict; | |
11 use File::Path; | |
12 use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value); | |
13 use base 'Debian::Debhelper::Buildsystem'; | |
14 | |
15 sub DESCRIPTION { | |
16 "SCons, extended for Chrome OS (Sconstruct)" | |
17 } | |
18 | |
19 sub check_auto_buildable { | |
20 my $this=shift; | |
21 if (-e $this->get_sourcepath("SConstruct.chromiumos")) { | |
22 return -e $this->get_sourcepath("SConstruct.chromiumos"); | |
23 } elsif (-e $this->get_sourcepath("SConstruct")) { | |
24 return -e $this->get_sourcepath("SConstruct"); | |
25 } elsif (-e $this->get_sourcepath("Sconstruct")) { | |
26 return -e $this->get_sourcepath("Sconstruct"); | |
27 } elsif (-e $this->get_sourcepath("sconstruct")) { | |
28 return -e $this->get_sourcepath("sconstruct"); | |
29 } | |
30 } | |
31 | |
32 sub new { | |
33 my $class=shift; | |
34 my $this=$class->SUPER::new(@_); | |
35 $this->enforce_in_source_building(); | |
36 return $this; | |
37 } | |
38 | |
39 my %toolchain = ( | |
40 CC => 'gcc', | |
41 CXX => 'g++', | |
42 AR => 'ar', | |
43 RANLIB => 'ranlib', | |
44 LD => 'ld', | |
45 NM => 'nm', | |
46 ); | |
47 | |
48 sub do_scons { | |
49 my $this=shift; | |
50 | |
51 my @opts; | |
52 if (-e $this->get_sourcepath("SConstruct.chromiumos")) { | |
53 push @opts, "-f", "SConstruct.chromiumos"; | |
54 } | |
55 return $this->doit_in_sourcedir("scons", @opts, @_); | |
56 } | |
57 | |
58 sub build { | |
59 my $this=shift; | |
60 | |
61 my $deb_build_gnu_type=dpkg_architecture_value("DEB_BUILD_GNU_TYPE"); | |
62 my $deb_host_gnu_type=dpkg_architecture_value("DEB_HOST_GNU_TYPE"); | |
63 if ($deb_build_gnu_type eq $deb_host_gnu_type) { | |
64 for my $tool (keys %toolchain) { | |
65 $ENV{$tool}=$toolchain{$tool}; | |
66 } | |
67 } else { | |
68 for my $tool (keys %toolchain) { | |
69 $ENV{$tool}="$deb_host_gnu_type-$toolchain{$tool}"; | |
70 } | |
71 } | |
72 | |
73 my @opts; | |
74 open NUM_JOBS, '-|', | |
75 "grep processor /proc/cpuinfo | awk '{a++} END {print a}'"; | |
76 my $num_jobs = <NUM_JOBS>; | |
77 chomp $num_jobs; | |
78 close NUM_JOBS; | |
79 if ($num_jobs ne '') { | |
80 push @opts, "-j$num_jobs"; | |
81 } | |
82 | |
83 $this->do_scons(@opts, @_); | |
84 } | |
85 | |
86 sub clean { | |
87 my $this=shift; | |
88 $this->do_scons("-c", @_); | |
89 unlink($this->get_buildpath(".sconsign.dblite")); | |
90 rmtree($this->get_buildpath(".sconf_temp")); | |
91 } | |
92 | |
93 1 | |
OLD | NEW |