~ubuntu-branches/ubuntu/oneiric/javatools/oneiric

« back to all changes in this revision

Viewing changes to jh_compilefeatures

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Johnson, Niels Thykier, Matthew Johnson
  • Date: 2010-03-30 00:11:37 UTC
  • mfrom: (6.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100330001137-ihh6lyi8omhx6dun
Tags: 0.30
[ Niels Thykier ]
* Added myself to uploaders.
* Created debhelper-like scripts for building eclipse features and
  added a dh7 sequence.
* Added Vcs-* fields.
* Replaced references to "dh_clean -k" with "dh_prep" in the tutorial.
  (Closes: #571097)
* Added DM-Upload-Allowed.
* Bumped Standards-Version to 3.8.4 - no changes required.

[ Matthew Johnson ]
* Make it a 3.0 (native) package

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
=head1 NAME
 
4
 
 
5
jh_compilefeatures - Compiles eclipse features using pde-build.
 
6
 
 
7
=cut
 
8
 
 
9
use strict;
 
10
use Cwd;
 
11
use Debian::Debhelper::Dh_Lib;
 
12
 
 
13
=head1 SYNOPSIS
 
14
 
 
15
B<jh_compilefeatures> [S<I<debhelper options>>] [S<I<options>>] [B<--pde-build-dir=>I<dir>] [S<I<feature [...]>>]
 
16
 
 
17
=head1 DESCRIPTION
 
18
 
 
19
jh_compilefeatures is a javahelper program that handles compiling
 
20
features using pde-build. These features can be specified either in
 
21
debian/eclipse.features or via command-line.
 
22
 
 
23
jh_compilefeatures uses debhelper behind the scenes and are therefore
 
24
subject to the compat level (e.g. when parsing the eclipse.features file).
 
25
 
 
26
When specifying the dependencies for a feature, jh_compilefeatures will
 
27
see if this feature has just been compiled and will use the dependency
 
28
if it is among the results. This can be used together with
 
29
debian/eclipse.features. 
 
30
 
 
31
Dependencies are always resolved by first checking if it is a recently
 
32
built feature and if not, then the system installed eclipse's dropins
 
33
folders will be checked.
 
34
 
 
35
Currently jh_compilefeatures do not clean up between builds, which means
 
36
the dependencies for previous builds are present for the current build.
 
37
Nevertheless, do not rely on this, as this behavior is subject to change.
 
38
 
 
39
Note: jh_compilefeatures will I<not> rearrange the build order for you
 
40
in order to do this.
 
41
 
 
42
Note: that jh_compilefeatures will not error out if it cannot find a
 
43
missing dependency. This is due to the underlying builder being unable
 
44
to detect this.
 
45
 
 
46
=head1 FILES
 
47
 
 
48
=over 4
 
49
 
 
50
=item debian/eclipse.features
 
51
 
 
52
List the eclipse features to compile and their dependencies. The first
 
53
item on the line is the feature to compile and the following items
 
54
are considered dependencies.
 
55
 
 
56
A dependency can either be a dropins folder or a previous built feature.
 
57
jh_compilefeatures will find it as long as it is installed in the system
 
58
eclipse's dropins folder or it has just been compiled.
 
59
 
 
60
=back
 
61
 
 
62
=head1 OPTIONS
 
63
 
 
64
=over 4
 
65
 
 
66
=item B<--pde-build-dir=dir>
 
67
 
 
68
Specifies the directory from where pde-build is to be run. Defauls to
 
69
"debian/.eclipse_build".
 
70
 
 
71
=item B<--feature-deps=deps>
 
72
 
 
73
A space separated list of dependencies. These dependencies will be used
 
74
to compile all features passed by command-line. Features read from
 
75
debian/eclipse.features are unaffected by this.
 
76
 
 
77
=item B<--build-opts=args>
 
78
 
 
79
Pass args to the underlying builder. These options are passed to all
 
80
features built.
 
81
 
 
82
This defaults to "-DjavacTarget=1.5 -DjavacSource=1.5" if not set.
 
83
This can be disabled by passing the empty string.
 
84
 
 
85
=item B<--jvm-args=args>
 
86
 
 
87
Pass args to the JVM. These options are passed to all
 
88
features built.
 
89
 
 
90
=item B<--orbit-dir=dir>
 
91
 
 
92
Specifies where the Orbit dependencies can be found. This is only needed
 
93
if the orbit dir is in an unusual location.
 
94
 
 
95
=item B<--pde-build=cmd>
 
96
 
 
97
Use a non-standard pde-build command to compile the features.
 
98
 
 
99
=item B<--pde-args=args>
 
100
 
 
101
Passes args directly to pde-build. Note, jh_compilefeatures have
 
102
specialised options for some of pde-build options and these should
 
103
be used whenever possible.
 
104
 
 
105
These options are passed to all features built.
 
106
 
 
107
=item B<--ignore-java-home>
 
108
 
 
109
Skip the check of JAVA_HOME. Since the underlying builder uses ant
 
110
(and therefore java), the build should ensure it always uses the
 
111
expected java implementation.
 
112
 
 
113
Use this if you (for whatever reason) need to declare the specific
 
114
java implementation without being able to use JAVA_HOME.
 
115
 
 
116
Note: You still have to tell the underlying builder which java to
 
117
use.
 
118
 
 
119
=back
 
120
 
 
121
=cut
 
122
 
 
123
my $pdebdir = undef;
 
124
my $ffile = 'debian/eclipse.features';
 
125
my @features = ();
 
126
my $fdeps = "";
 
127
my $orbitdir = undef;
 
128
my $pdebcmd = undef;
 
129
my $bopts = undef;
 
130
my $pdeargs = "";
 
131
my $jvmargs = "";
 
132
my $ignoreJH = 0;
 
133
init(options => {
 
134
    'pde-build-dir=s' => \$pdebdir,
 
135
    'feature-deps=s' => \$fdeps,
 
136
    'orbit-dir=s' => \$orbitdir,
 
137
    'pde-build=s' => \$pdebcmd,
 
138
    'build-opts=s' => \$bopts,
 
139
    'pde-args=s' => \$pdeargs,
 
140
    'jvm-args=s' => \$jvmargs,
 
141
    'ignore-java-home' => \$ignoreJH,
 
142
});
 
143
 
 
144
error("pde-build uses ant, therefore JAVA_HOME must be set.") unless(($ENV{'JAVA_HOME'}//'') ne '' or $ignoreJH);
 
145
 
 
146
# Use default value if none are given.
 
147
$pdebdir = 'debian/.eclipse-build' unless(defined($pdebdir));
 
148
$pdebdir =~ s@/*$@@; # remove trailing slash, looks better.
 
149
 
 
150
$orbitdir = "$pdebdir/orbitdeps" unless(defined($orbitdir));
 
151
 
 
152
$pdebcmd = '/usr/lib/eclipse/buildscripts/pde-build' unless(defined($pdebcmd));
 
153
 
 
154
$bopts = '-DjavacTarget=1.5 -DjavacSource=1.5' unless(defined($bopts));
 
155
 
 
156
$orbitdir = Cwd::abs_path($orbitdir) unless($orbitdir =~ m@^/@);
 
157
 
 
158
if( -e $ffile){
 
159
    @features = filedoublearray($ffile);
 
160
}
 
161
 
 
162
error("$pdebdir does not exist") if(scalar(@ARGV) + scalar(@features) > 0 && ! -d $pdebdir);
 
163
 
 
164
foreach my $arg (@ARGV){
 
165
    compile($arg, split(/\s+/, $fdeps));
 
166
}
 
167
 
 
168
foreach my $feat (@features){
 
169
    compile(@$feat);
 
170
}
 
171
 
 
172
exit(0);
 
173
 
 
174
sub compile{
 
175
    my $feat = shift;
 
176
    my @args = ();
 
177
    my @deps = ();
 
178
    DEP_LOOP: foreach my $d (@_){
 
179
        # Check if we just built this feature.
 
180
        foreach my $s qw(. .zip .ZIP) {
 
181
            my $zip = "$pdebdir/$d$s";
 
182
            if( -e $zip ){
 
183
                installZippedFeature($zip, "$pdebdir/build/SDK");
 
184
                next DEP_LOOP;
 
185
            }
 
186
        }
 
187
        push(@deps, $d);
 
188
    }
 
189
    push(@args, "-o", escape_shell($orbitdir)) if(defined($orbitdir) && -d $orbitdir);
 
190
    push(@args, "-j", escape_shell($jvmargs)) if($jvmargs ne '');
 
191
    push(@args, "-a", escape_shell($bopts)) if($bopts ne '');
 
192
    push(@args, "-d", escape_shell(@deps)) if(scalar(@deps) > 0);
 
193
    push(@args, $pdeargs);
 
194
    complex_doit("cd", $pdebdir , "&&", $pdebcmd, @args, "-f", $feat);
 
195
}
 
196
 
 
197
=head1 EXAMPLE
 
198
 
 
199
A sample debian/eclipse.features
 
200
 
 
201
  org.eclipse.tm.terminal emf
 
202
  org.eclipse.rse.sdk
 
203
 
 
204
org.eclipse.tm.terminal depends on "emf", which is expected to be found in
 
205
eclipse's dropins folder. org.eclipse.rse.sdk on the other hand has no
 
206
dependencies beyond the eclipse platform.
 
207
 
 
208
If needed you can also specify a previously built feature as a dependency:
 
209
 
 
210
  org.eclipse.some.feature
 
211
  org.eclipse.another.feature org.eclipse.some.feature rse
 
212
 
 
213
Here org.eclipse.another.feature depends org.eclipse.some.feature, which was
 
214
just built and also rse, which is expected to be in system installed eclipse's
 
215
dropins.
 
216
 
 
217
=head1 SEE ALSO
 
218
 
 
219
L<debhelper(7)>
 
220
 
 
221
This program is a part of javahelper and uses debhelper as backend. There are
 
222
also tutorials in /usr/share/javahelper.
 
223
 
 
224
=head1 AUTHOR
 
225
 
 
226
Niels Thykier <niels@thykier.net>
 
227
 
 
228
=head1 COPYRIGHT AND LICENSE
 
229
 
 
230
Copyright 2010 by Niels Thykier
 
231
 
 
232
This tool is free software; you may redistribute it and/or modify
 
233
it under the terms of GNU GPL 2.
 
234
 
 
235
=cut