Skip to content

Commit 53b96ac

Browse files
refactor ABICompCheck to use nested configuration for binaries and flags, use config opts from config, remove some duplicate code
1 parent ab4aaab commit 53b96ac

2 files changed

Lines changed: 51 additions & 70 deletions

File tree

PGBuild/Modules/ABICompCheck.pm

Lines changed: 42 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ sub setup
5252
$abi_compare_root = "$buildroot/abicheck";
5353
}
5454

55-
my $binaries_rel_path = $conf->{binaries_rel_path}
55+
my $binaries_rel_path = $conf->{abi_comp_check}->{binaries_rel_path}
5656
|| {
5757
'postgres' => 'bin/postgres',
5858
'ecpg' => 'bin/ecpg',
5959
'libpq.so' => 'lib/libpq.so',
6060
};
6161

62-
my $abidw_flags_list = $conf->{abidw_flags_list}
62+
my $abidw_flags_list = $conf->{abi_comp_check}->{abidw_flags_list}
6363
|| [
6464
'--drop-undefined-syms', '--no-architecture', '--no-comp-dir-path',
6565
'--no-elf-needed', '--no-show-locs', '--type-id-style',
@@ -240,24 +240,31 @@ sub _log_command_output
240240

241241
sub _configure_make_and_build
242242
{
243-
my ($self, $commit_hash) = @_; # Added $commit_hash argument
243+
my ($self, $commit_hash) = @_;
244244
my $abi_compare_root = $self->{abi_compare_root};
245-
my $clone_name = $self->{clone_name};
246-
my $log_dir = "$abi_compare_root/logs/$commit_hash";
247-
my $make = $self->{bfconf}->{make};
248-
my $make_jobs = $self->{bfconf}->{make_jobs};
249245
print time_str(),
250246
"Configuring, making, and installing for commit $commit_hash in ",
251247
__PACKAGE__, "\n"
252248
if $verbose;
253249

254-
chdir "$abi_compare_root/$clone_name"
250+
chdir $abi_compare_root . '/' . $self->{clone_name}
255251
or die
256-
"Cannot change to PostgreSQL source directory: $abi_compare_root/$clone_name for commit $commit_hash";
252+
"Cannot change to PostgreSQL source directory: $abi_compare_root/$self->{clone_name} for commit $commit_hash";
253+
254+
my $log_dir = "$abi_compare_root/logs/$commit_hash";
255+
my $make = $self->{bfconf}->{make};
256+
my $make_jobs = $self->{bfconf}->{make_jobs};
257+
my $config_opts = $self->{bfconf}->{config_opts} || [];
258+
259+
if (! grep { $_ eq '--enable-debug' } @$config_opts)
260+
{
261+
push @$config_opts, '--enable-debug';
262+
}
263+
my $configure_options = join(' ', @$config_opts);
257264

258-
_log_command_output($self,
259-
qq{./configure --enable-debug --prefix=$abi_compare_root/install/},
260-
$log_dir, 'configure');
265+
my $cmdd=qq{./configure $configure_options --prefix=$abi_compare_root/install/};
266+
267+
_log_command_output($self, $cmdd, $log_dir, 'configure');
261268
my $make_cmd = $make;
262269
$make_cmd = "$make -j $make_jobs"
263270
if ($make_jobs > 1);
@@ -271,8 +278,7 @@ sub _configure_make_and_build
271278
sub _generate_abidw_xml
272279
{
273280
my $self = shift;
274-
my $abidw_flags_list = $self->{abidw_flags_list};
275-
my $abidw_flags_str = join(' ', @$abidw_flags_list);
281+
my $abidw_flags_str = join ' ', @{ $self->{abidw_flags_list} };
276282
my $commit_hash = shift;
277283

278284
print time_str(), "Generating ABIDW XML for commit $commit_hash in ",
@@ -302,68 +308,41 @@ sub _generate_abidw_xml
302308
}
303309

304310
my @targets_to_process = ();
305-
foreach my $target_name (keys %$binaries_rel_path)
311+
while (my ($target_name, $rel_path) = each %{ $binaries_rel_path })
306312
{
307-
my $input_path = "$install_dir/$binaries_rel_path->{$target_name}";
313+
my $input_path = "$install_dir/$rel_path";
308314
my $output_file = "$commit_xml_dir/$target_name.abi";
309315

310-
if (-e $input_path)
311-
{
312-
push @targets_to_process,
313-
{
314-
name => $target_name,
315-
input_path => $input_path,
316-
output_file => $output_file,
317-
};
318-
}
319-
else
320-
{
321-
print time_str(),
322-
"Warning: Input file '$input_path' for $target_name not found. Skipping ABI generation for this target (commit $commit_hash).\n"
323-
if $verbose;
324-
}
325-
}
326-
327-
if (!@targets_to_process)
328-
{
329-
die "No valid targets found for ABI generation in commit $commit_hash.";
330-
}
331-
332-
foreach my $target (@targets_to_process)
333-
{
334-
my $target_name = $target->{name};
335-
my $input_file_path = $target->{input_path};
336-
my $output_abi_file = $target->{output_file};
337-
338-
unless (-e $input_file_path && -f $input_file_path)
316+
if (-e $input_path && -f $input_path)
339317
{
340-
print time_str(),
341-
"Warning: Input file '$input_file_path' for $target_name not found or is not a regular file. Skipping ABI generation for this target (commit $commit_hash).\n"
342-
if $verbose;
343-
next;
344-
}
345-
346-
my $cmd =
347-
qq{abidw --out-file "$output_abi_file" "$input_file_path" $abidw_flags_str};
348-
print time_str(), "Executing: $cmd\n" if $verbose;
318+
my $cmd = qq{abidw --out-file "$output_file" "$input_path" $abidw_flags_str};
319+
print time_str(), "Executing: $cmd\n" if $verbose;
349320

350-
my @abidw_log = run_log($cmd);
351-
my $exit_status = $? >> 8;
321+
my @abidw_log = run_log($cmd);
322+
my $exit_status = $? >> 8;
352323

353-
print_logs(\@abidw_log);
324+
print_logs(\@abidw_log);
354325

355-
if ($exit_status)
356-
{
357-
die
358-
"abidw failed for $target_name (from $input_file_path) with status $exit_status. Commit: $commit_hash";
326+
if ($exit_status)
327+
{
328+
die
329+
"abidw failed for $target_name (from $input_path) with status $exit_status. Commit: $commit_hash";
330+
}
331+
else
332+
{
333+
print time_str(),
334+
"Successfully generated ABI XML for $target_name to $output_file\n"
335+
if $verbose;
336+
}
359337
}
360338
else
361339
{
362340
print time_str(),
363-
"Successfully generated ABI XML for $target_name to $output_abi_file\n"
341+
"Warning: Input file '$input_path' for $target_name not found. Skipping ABI generation for this target (commit $commit_hash).\n"
364342
if $verbose;
365343
}
366344
}
345+
367346
return;
368347
}
369348

@@ -551,14 +530,7 @@ sub print_logs
551530
{
552531
my ($logss) = @_;
553532

554-
if (@$logss)
555-
{
556-
print "ABICompCheck:";
557-
foreach my $line (@$logss)
558-
{
559-
print $line;
560-
}
561-
}
533+
print "ABICompCheck: ", @$logss if @$logss;
562534
}
563535

564536
sub install

build-farm.conf.sample

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,15 @@ my $confdir = File::Spec->rel2abs(File::Basename::dirname(__FILE__));
416416
# },
417417
},
418418
419+
abi_comp_check => {
420+
# binaries_rel_path => {
421+
# 'postgres' => 'bin/postgres'
422+
# },
423+
# abidw_flags_list => [
424+
# '--drop-undefined-syms'
425+
# ]
426+
}
427+
419428
);
420429
421430

0 commit comments

Comments
 (0)