Commit f5ea10a5 authored by DEANTONI Julien's avatar DEANTONI Julien

...

parent 6a72ab14
#! /usr/bin/perl -w
#*******************************************************************************
# Copyright (c) 2017 I3S laboratory, INRIA and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# I3S laboratory and INRIA Kairos - initial API and implementation
#*******************************************************************************
use strict;
use File::Find;
sub checkBuildPropertiesFile ($$) {
my ($file, $isAfeature) = @_;
my %properties = readBuildPropertiesFile($file);
my @diagnostics = ();
# ensure that bin.includes contains . unless if is a feature
if ( (defined($isAfeature) && ! $isAfeature) && exists $properties{"bin.includes"} && defined $properties{"bin.includes"} ) {
my @binIncludes = @{ $properties{"bin.includes"} };
unless ("." ~~ @binIncludes) {
push @diagnostics, "bin.includes does not contain '.'";
}
}
return @diagnostics;
}
sub printDiagnostics {
my ($file, @diags) = @_;
unless ($#diags) {
print $file, ":\n";
for (@diags) {
print "\t", $_, "\n";
}
}
}
sub readBuildPropertiesFile {
my $filename = shift;
my $FH;
my $line;
my %content = ();
my $needjoin = 0;
my $property;
open(FH, $filename) || die ("Cannot open file", $filename);
while ($line = <FH>) {
if ($line =~ /^(\w+\.[\w\.]+)\s*=\s*(.+)$/) {
$property = $1;
my $value = $2;
chop $value if ($value =~ /\r$/);
$needjoin = ($value =~ /\\$/);
$value =~ s/\\$// if $needjoin;
#print "parsed: ", $property, "='", $value, "'\n";
#print "needjoin=", $needjoin, "\n";
my @values = split(',', $value);
#print "values=", join('|', @values), "\n";
$content{$property} = [ @values ];
}
elsif ($needjoin && $line =~ /^\s+(.+)$/) {
my $value = $1;
chop $value if ($value =~ /\r$/);
$needjoin = ($value =~ /\\$/);
$value =~ s/\\$// if $needjoin;
#print "continuation: ", $value, "\n";
push @{ $content{$property} }, split(',', $value);
}
}
close FH;
return %content;
}
for (@ARGV) {
my $arg = $_;
if (-f $arg) {
my @diagnostics = checkBuildPropertiesFile($arg, 0);
printDiagnostics($arg, @diagnostics);
}
elsif (-d $arg) {
find sub {
# the subroutine does a chdir(), we just need to check the existence of a feature.xml file
my $isAfeature = 0;
$isAfeature = ( -e "feature.xml");
if (-f $_ && $_ eq "build.properties") {
my @diagnostics = checkBuildPropertiesFile($_, $isAfeature);
printDiagnostics($File::Find::name, @diagnostics);
}
}, $arg;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment