mirror of
https://github.com/xcat2/xNBA.git
synced 2024-11-22 17:41:55 +00:00
[efi] Tidy up output of EFI header import script
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
03b1020acc
commit
bf2b1c8e47
@ -1,3 +1,6 @@
|
||||
#ifndef _IPXE_EFI_PROCESSOR_BIND_H
|
||||
#define _IPXE_EFI_PROCESSOR_BIND_H
|
||||
|
||||
/*
|
||||
* EFI header files rely on having the CPU architecture directory
|
||||
* present in the search path in order to pick up ProcessorBind.h. We
|
||||
@ -12,3 +15,5 @@
|
||||
#if __x86_64__
|
||||
#include <ipxe/efi/X64/ProcessorBind.h>
|
||||
#endif
|
||||
|
||||
#endif /* _IPXE_EFI_PROCESSOR_BIND_H */
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef _EFI_H
|
||||
#define _EFI_H
|
||||
#ifndef _IPXE_EFI_H
|
||||
#define _IPXE_EFI_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
@ -142,4 +142,4 @@ extern EFI_STATUS efi_init ( EFI_HANDLE image_handle,
|
||||
EFI_SYSTEM_TABLE *systab );
|
||||
extern int efi_snp_install ( void );
|
||||
|
||||
#endif /* _EFI_H */
|
||||
#endif /* _IPXE_EFI_H */
|
||||
|
@ -1,28 +1,58 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
=head1 NAME
|
||||
|
||||
import.pl
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
import.pl [options] /path/to/edk2/edk2
|
||||
|
||||
Options:
|
||||
|
||||
-h,--help Display brief help message
|
||||
-v,--verbose Increase verbosity
|
||||
-q,--quiet Decrease verbosity
|
||||
|
||||
=cut
|
||||
|
||||
use File::Spec::Functions qw ( :ALL );
|
||||
use File::Find;
|
||||
use File::Path;
|
||||
use Getopt::Long;
|
||||
use Pod::Usage;
|
||||
use FindBin;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $verbosity = 0;
|
||||
|
||||
sub try_import_file {
|
||||
my $ipxedir = shift;
|
||||
my $edktop = shift;
|
||||
my $edkdirs = shift;
|
||||
my $filename = shift;
|
||||
|
||||
# Skip everything except headers
|
||||
return unless $filename =~ /\.h$/;
|
||||
print "$filename...";
|
||||
|
||||
( undef, undef, my $basename ) = splitpath ( $filename );
|
||||
# Skip files that are iPXE native headers
|
||||
my $outfile = catfile ( $ipxedir, $filename );
|
||||
if ( -s $outfile ) {
|
||||
open my $outfh, "<$outfile" or die "Could not open $outfile: $!\n";
|
||||
my $line = <$outfh>;
|
||||
close $outfh;
|
||||
chomp $line;
|
||||
return if $line =~ /^\#ifndef\s+_IPXE_\S+_H$/;
|
||||
}
|
||||
|
||||
# Search for importable header
|
||||
foreach my $edkdir ( @$edkdirs ) {
|
||||
my $infile = catfile ( $edkdir, $filename );
|
||||
my $infile = catfile ( $edktop, $edkdir, $filename );
|
||||
if ( -e $infile ) {
|
||||
# We have found a matching source file - import it
|
||||
print "$infile\n";
|
||||
print "$filename <- ".catfile ( $edkdir, $filename )."\n"
|
||||
if $verbosity >= 1;
|
||||
open my $infh, "<$infile" or die "Could not open $infile: $!\n";
|
||||
( undef, my $outdir, undef ) = splitpath ( $outfile );
|
||||
mkpath ( $outdir );
|
||||
@ -61,33 +91,44 @@ sub try_import_file {
|
||||
# Recurse to handle any included files that we don't already have
|
||||
foreach my $dependency ( @dependencies ) {
|
||||
if ( ! -e catfile ( $ipxedir, $dependency ) ) {
|
||||
print "...following dependency on $dependency\n";
|
||||
try_import_file ( $ipxedir, $edkdirs, $dependency );
|
||||
print "...following dependency on $dependency\n" if $verbosity >= 1;
|
||||
try_import_file ( $ipxedir, $edktop, $edkdirs, $dependency );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
print "no equivalent found\n";
|
||||
die "$filename has no equivalent in $edktop\n";
|
||||
}
|
||||
|
||||
# Identify edk import directories
|
||||
die "Syntax $0 /path/to/edk2/edk2\n" unless @ARGV == 1;
|
||||
# Parse command-line options
|
||||
Getopt::Long::Configure ( 'bundling', 'auto_abbrev' );
|
||||
GetOptions (
|
||||
'verbose|v+' => sub { $verbosity++; },
|
||||
'quiet|q+' => sub { $verbosity--; },
|
||||
'help|h' => sub { pod2usage ( 1 ); },
|
||||
) or die "Could not parse command-line options\n";
|
||||
pod2usage ( 1 ) unless @ARGV == 1;
|
||||
my $edktop = shift;
|
||||
die "Directory \"$edktop\" does not appear to contain the EFI EDK2\n"
|
||||
unless -e catfile ( $edktop, "MdePkg" );
|
||||
my $edkdirs = [ catfile ( $edktop, "MdePkg/Include" ),
|
||||
catfile ( $edktop, "IntelFrameworkPkg/Include" ) ];
|
||||
|
||||
# Identify edk import directories
|
||||
my $edkdirs = [ "MdePkg/Include", "IntelFrameworkPkg/Include" ];
|
||||
foreach my $edkdir ( @$edkdirs ) {
|
||||
die "Directory \"$edktop\" does not appear to contain the EFI EDK2 "
|
||||
."(missing \"$edkdir\")\n" unless -d catdir ( $edktop, $edkdir );
|
||||
}
|
||||
|
||||
# Identify iPXE EFI includes directory
|
||||
my $ipxedir = $FindBin::Bin;
|
||||
die "Directory \"$ipxedir\" does not appear to contain the iPXE EFI includes\n"
|
||||
unless -e catfile ( $ipxedir, "../../../include/ipxe/efi" );
|
||||
|
||||
print "Importing EFI headers into $ipxedir\nfrom ";
|
||||
print join ( "\n and ", @$edkdirs )."\n";
|
||||
if ( $verbosity >= 1 ) {
|
||||
print "Importing EFI headers into $ipxedir\nfrom ";
|
||||
print join ( "\n and ", map { catdir ( $edktop, $_ ) } @$edkdirs )."\n";
|
||||
}
|
||||
|
||||
# Import headers
|
||||
find ( { wanted => sub {
|
||||
try_import_file ( $ipxedir, $edkdirs, abs2rel ( $_, $ipxedir ) );
|
||||
try_import_file ( $ipxedir, $edktop, $edkdirs, abs2rel ( $_, $ipxedir ) );
|
||||
}, no_chdir => 1 }, $ipxedir );
|
||||
|
Loading…
Reference in New Issue
Block a user