Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 29 additions & 15 deletions meta/ancestry.pl
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,27 @@

my %options = ();

getopts("dsASlDH:", \%options);
use Getopt::Long qw(GetOptions Configure);
Configure(qw(no_ignore_case));

our $optionPrintDebug = 1 if defined $options{d};
our $optionDisableAspell = 1 if defined $options{A};
our $optionUseXmlSimple = 1 if defined $options{s};
our $optionDisableStyleCheck = 1 if defined $options{S};
our $optionShowLogCaller = 1 if defined $options{l};
our $optionDumpHistoryFile = 1 if defined $options{D};
our $optionHistoryFile = $options{H} if defined $options{H};
my ($optionPrintDebug, $optionDisableAspell, $optionUseXmlSimple,
$optionDisableStyleCheck, $optionShowLogCaller, $optionDumpHistoryFile,
$optionHistoryFile, $mydir);

my @mycommits;

GetOptions(
'd|debug' => \$optionPrintDebug,
'A|no-aspell' => \$optionDisableAspell,
's|xmlsimple' => \$optionUseXmlSimple,
'S|no-style' => \$optionDisableStyleCheck,
'l|show-caller' => \$optionShowLogCaller,
'D|dump-history' => \$optionDumpHistoryFile,
'H|history-file=s' => \$optionHistoryFile,

'dir=s' => \$mydir, # Directory to process, e.g. inc or meta (default: inc)
'commits=s{,}' => \@mycommits, # --commits c1 c2 c3 ...
) or die "Usage: $0 [opts] --dir <dir> --commits <c1> [c2 ...]\n";

$SIG{__DIE__} = sub
{
Expand Down Expand Up @@ -127,13 +139,15 @@ sub ProcessHeaders
{
my $commit = shift;

my @headers = GetHeaderFiles("temp/commit-$commit/inc");
my $dir = defined($mydir) ? $mydir : 'inc';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this check done here fir inc/meta switch? why then mydirisadded if that directory is given from command line? should it alwys be command line ? and maybe add t hen check here if the dir dont exists then exit(1) ?

my $path = "temp/commit-$commit/$dir";

my @headers = GetHeaderFiles($path);

for my $header (@headers)
{
LogDebug "Processing $header";

ProcessSingleHeader "temp/commit-$commit/inc/$header";
LogDebug "Processing $path/$header";
ProcessSingleHeader "$path/$header";
}
}

Expand Down Expand Up @@ -245,7 +259,7 @@ sub CleanData
LogInfo "loaded history from $optionHistoryFile";
}

for my $commit (@ARGV)
for my $commit (@mycommits)
{
# reset

Expand All @@ -264,15 +278,15 @@ sub CleanData

ExitOnErrorsOrWarnings();

if (defined $optionDumpHistoryFile and (scalar @ARGV > 0))
if (defined $optionDumpHistoryFile and (scalar @mycommits > 0))
{
$Data::Dumper::Indent = 0;

my $history = Data::Dumper->Dump([\%HISTORY],[qw/*HISTORY/]);

$history =~ s/ //g;

my $lastCommit = $ARGV[-1];
my $lastCommit = $mycommits[-1];

WriteFile("ancestry.$lastCommit.history", $history);

Expand Down
27 changes: 22 additions & 5 deletions meta/checkancestry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,18 @@ function create_temp_dir()

function checkout_inc_directories()
{
echo "git checkout work tree commits:" $LIST
echo "git checkout work tree commits:" $LIST_INC

for commit in $LIST
for commit in $LIST_INC
do
#echo working on commit $commit

mkdir temp/commit-$commit
mkdir temp/commit-$commit/inc
mkdir temp/commit-$commit/meta

git --work-tree=temp/commit-$commit checkout $commit inc 2>/dev/null
git --work-tree=temp/commit-$commit checkout $commit meta 2>/dev/null

done
}
Expand All @@ -101,12 +103,21 @@ function create_commit_list()

echo "git rev list from $begin to $end"

LIST=$(git rev-list --ancestry-path ${begin}^..${end} | xargs -n 1 git rev-parse --short | tac)
local FULL_LIST=$(git rev-list --ancestry-path ${begin}^..${end} | xargs -n 1 git rev-parse --short | tac)

local skip_begin=$3
local skip_end=$4
local SKIP_LIST=$(git rev-list --ancestry-path ${skip_begin}^..${skip_end} | xargs -n 1 git rev-parse --short | tac)

LIST_INC=$FULL_LIST
LIST_META=$(grep -vxFf <(echo "$SKIP_LIST") <<< "$FULL_LIST")

}

function check_enum_history()
{
perl ancestry.pl -H "ancestry.1f2bca1.history" $LIST
perl ancestry.pl -H "ancestry.1f2bca1.history" --dir "inc" --commits $LIST_INC
perl ancestry.pl -H "ancestry.1f2bca1.history" --dir "meta" --commits $LIST_META
Comment on lines +119 to +120
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is executed twice? since normally history file is based on entire include files, this will basically split it to 2 entries, what i meant in my comment previously to add explicit skip for commits for meta directory inside ancesry.pl file not checkancestry.sh, this will work what you implemented, but it will not generate histroy file for meta directory, with your approach you would need 2 files with histrou, one for inc one for meta

}

#
Expand All @@ -123,11 +134,17 @@ function check_enum_history()

BEGIN_COMMIT=3132018 # from this commit we are backward compatible
BEGIN_COMMIT=1f2bca1 # to this commit we have history file

# commits from skip_begin to skip_end are skipped from backward compatibility check
# due to a regression in meta directory which was earlier excluded from this check
SKIP_BEGIN=401bd1f
SKIP_END=77578c8
Comment thread
kcudnik marked this conversation as resolved.

END_COMMIT=HEAD

clean_temp_dir
create_temp_dir
create_commit_list $BEGIN_COMMIT $END_COMMIT
create_commit_list $BEGIN_COMMIT $END_COMMIT $SKIP_BEGIN $SKIP_END
checkout_inc_directories
check_enum_history
clean_temp_dir
6 changes: 5 additions & 1 deletion meta/checkenumlock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ rm -rf $TEMP_DIR

mkdir $TEMP_DIR

git --work-tree=$TEMP_DIR/ checkout origin/master inc experimental
git --work-tree=$TEMP_DIR/ checkout origin/master inc experimental meta

echo "Checking for possible enum values shift (current branch vs origin/master) ..."

./checkheaders.pl -s ../inc/ $TEMP_DIR/inc/

./checkheaders.pl -s ../meta/ $TEMP_DIR/meta/

./checkheaders.pl -s ../experimental/ $TEMP_DIR/experimental/

rm -rf $TEMP_DIR
20 changes: 18 additions & 2 deletions meta/checkheaders.pl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ sub GetEnums

for my $file (@files)
{
next if $file eq "saimetadata.h";

my $data = ReadHeaderFile("$dir/$file");

my %en = FilterEnums($data, "$dir/$file");
Expand All @@ -122,7 +124,21 @@ sub ConstructSource

my $source = "#include <stdio.h>\n";

$source .= "#include \"$dir/sai.h\"\n";
$source .= "#include \"$dir/../inc/sai.h\"\n";

if( ! -e "$dir/sai.h") {

my @files = GetHeaderFiles $dir;

for my $file (@files)
{
if ($file =~ /\.h$/)
{
$source .= "#include \"$dir/$file\"\n";
}
}
}

$source .="int main() { ";

for my $en (sort keys %enums)
Expand All @@ -149,7 +165,7 @@ sub GetValues

my ($fhb, $bin) = tempfile( SUFFIX => '.bin', UNLINK => 1 );

system("gcc $src -I. -I '$dir'/../experimental -I '$dir/../custom/' -I '$dir' -o $bin") == 0 or die "gcc failed! $!";
system("gcc $src -I. -I '$dir'/../experimental -I '$dir/../custom/' -I '$dir/../inc/' -I '$dir' -o $bin") == 0 or die "gcc failed! $!";
Comment thread
tjchadaga marked this conversation as resolved.
Comment thread
tjchadaga marked this conversation as resolved.

close $fhs;
close $fhb;
Expand Down
Loading