Browse Source

[efi] Tidy up output of EFI header import script

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
bf2b1c8e47
3 changed files with 65 additions and 19 deletions
  1. 5
    0
      src/include/ipxe/efi/ProcessorBind.h
  2. 3
    3
      src/include/ipxe/efi/efi.h
  3. 57
    16
      src/include/ipxe/efi/import.pl

+ 5
- 0
src/include/ipxe/efi/ProcessorBind.h View File

1
+#ifndef _IPXE_EFI_PROCESSOR_BIND_H
2
+#define _IPXE_EFI_PROCESSOR_BIND_H
3
+
1
 /*
4
 /*
2
  * EFI header files rely on having the CPU architecture directory
5
  * EFI header files rely on having the CPU architecture directory
3
  * present in the search path in order to pick up ProcessorBind.h.  We
6
  * present in the search path in order to pick up ProcessorBind.h.  We
12
 #if __x86_64__
15
 #if __x86_64__
13
 #include <ipxe/efi/X64/ProcessorBind.h>
16
 #include <ipxe/efi/X64/ProcessorBind.h>
14
 #endif
17
 #endif
18
+
19
+#endif /* _IPXE_EFI_PROCESSOR_BIND_H */

+ 3
- 3
src/include/ipxe/efi/efi.h View File

1
-#ifndef _EFI_H
2
-#define _EFI_H
1
+#ifndef _IPXE_EFI_H
2
+#define _IPXE_EFI_H
3
 
3
 
4
 /** @file
4
 /** @file
5
  *
5
  *
142
 			     EFI_SYSTEM_TABLE *systab );
142
 			     EFI_SYSTEM_TABLE *systab );
143
 extern int efi_snp_install ( void );
143
 extern int efi_snp_install ( void );
144
 
144
 
145
-#endif /* _EFI_H */
145
+#endif /* _IPXE_EFI_H */

+ 57
- 16
src/include/ipxe/efi/import.pl View File

1
 #!/usr/bin/perl -w
1
 #!/usr/bin/perl -w
2
 
2
 
3
+=head1 NAME
4
+
5
+import.pl
6
+
7
+=head1 SYNOPSIS
8
+
9
+import.pl [options] /path/to/edk2/edk2
10
+
11
+Options:
12
+
13
+    -h,--help		Display brief help message
14
+    -v,--verbose	Increase verbosity
15
+    -q,--quiet		Decrease verbosity
16
+
17
+=cut
18
+
3
 use File::Spec::Functions qw ( :ALL );
19
 use File::Spec::Functions qw ( :ALL );
4
 use File::Find;
20
 use File::Find;
5
 use File::Path;
21
 use File::Path;
22
+use Getopt::Long;
23
+use Pod::Usage;
6
 use FindBin;
24
 use FindBin;
7
 use strict;
25
 use strict;
8
 use warnings;
26
 use warnings;
9
 
27
 
28
+my $verbosity = 0;
29
+
10
 sub try_import_file {
30
 sub try_import_file {
11
   my $ipxedir = shift;
31
   my $ipxedir = shift;
32
+  my $edktop = shift;
12
   my $edkdirs = shift;
33
   my $edkdirs = shift;
13
   my $filename = shift;
34
   my $filename = shift;
14
 
35
 
15
   # Skip everything except headers
36
   # Skip everything except headers
16
   return unless $filename =~ /\.h$/;
37
   return unless $filename =~ /\.h$/;
17
-  print "$filename...";
18
 
38
 
19
-  ( undef, undef, my $basename ) = splitpath ( $filename );
39
+  # Skip files that are iPXE native headers
20
   my $outfile = catfile ( $ipxedir, $filename );
40
   my $outfile = catfile ( $ipxedir, $filename );
41
+  if ( -s $outfile ) {
42
+    open my $outfh, "<$outfile" or die "Could not open $outfile: $!\n";
43
+    my $line = <$outfh>;
44
+    close $outfh;
45
+    chomp $line;
46
+    return if $line =~ /^\#ifndef\s+_IPXE_\S+_H$/;
47
+  }
48
+
49
+  # Search for importable header
21
   foreach my $edkdir ( @$edkdirs ) {
50
   foreach my $edkdir ( @$edkdirs ) {
22
-    my $infile = catfile ( $edkdir, $filename );
51
+    my $infile = catfile ( $edktop, $edkdir, $filename );
23
     if ( -e $infile ) {
52
     if ( -e $infile ) {
24
       # We have found a matching source file - import it
53
       # We have found a matching source file - import it
25
-      print "$infile\n";
54
+      print "$filename <- ".catfile ( $edkdir, $filename )."\n"
55
+	  if $verbosity >= 1;
26
       open my $infh, "<$infile" or die "Could not open $infile: $!\n";
56
       open my $infh, "<$infile" or die "Could not open $infile: $!\n";
27
       ( undef, my $outdir, undef ) = splitpath ( $outfile );
57
       ( undef, my $outdir, undef ) = splitpath ( $outfile );
28
       mkpath ( $outdir );
58
       mkpath ( $outdir );
61
       # Recurse to handle any included files that we don't already have
91
       # Recurse to handle any included files that we don't already have
62
       foreach my $dependency ( @dependencies ) {
92
       foreach my $dependency ( @dependencies ) {
63
 	if ( ! -e catfile ( $ipxedir, $dependency ) ) {
93
 	if ( ! -e catfile ( $ipxedir, $dependency ) ) {
64
-	  print "...following dependency on $dependency\n";
65
-	  try_import_file ( $ipxedir, $edkdirs, $dependency );
94
+	  print "...following dependency on $dependency\n" if $verbosity >= 1;
95
+	  try_import_file ( $ipxedir, $edktop, $edkdirs, $dependency );
66
 	}
96
 	}
67
       }
97
       }
68
       return;
98
       return;
69
     }
99
     }
70
   }
100
   }
71
-  print "no equivalent found\n";
101
+  die "$filename has no equivalent in $edktop\n";
72
 }
102
 }
73
 
103
 
74
-# Identify edk import directories
75
-die "Syntax $0 /path/to/edk2/edk2\n" unless @ARGV == 1;
104
+# Parse command-line options
105
+Getopt::Long::Configure ( 'bundling', 'auto_abbrev' );
106
+GetOptions (
107
+  'verbose|v+' => sub { $verbosity++; },
108
+  'quiet|q+' => sub { $verbosity--; },
109
+  'help|h' => sub { pod2usage ( 1 ); },
110
+) or die "Could not parse command-line options\n";
111
+pod2usage ( 1 ) unless @ARGV == 1;
76
 my $edktop = shift;
112
 my $edktop = shift;
77
-die "Directory \"$edktop\" does not appear to contain the EFI EDK2\n"
78
-    unless -e catfile ( $edktop, "MdePkg" );
79
-my $edkdirs = [ catfile ( $edktop, "MdePkg/Include" ),
80
-		catfile ( $edktop, "IntelFrameworkPkg/Include" ) ];
113
+
114
+# Identify edk import directories
115
+my $edkdirs = [ "MdePkg/Include", "IntelFrameworkPkg/Include" ];
116
+foreach my $edkdir ( @$edkdirs ) {
117
+  die "Directory \"$edktop\" does not appear to contain the EFI EDK2 "
118
+      ."(missing \"$edkdir\")\n" unless -d catdir ( $edktop, $edkdir );
119
+}
81
 
120
 
82
 # Identify iPXE EFI includes directory
121
 # Identify iPXE EFI includes directory
83
 my $ipxedir = $FindBin::Bin;
122
 my $ipxedir = $FindBin::Bin;
84
 die "Directory \"$ipxedir\" does not appear to contain the iPXE EFI includes\n"
123
 die "Directory \"$ipxedir\" does not appear to contain the iPXE EFI includes\n"
85
     unless -e catfile ( $ipxedir, "../../../include/ipxe/efi" );
124
     unless -e catfile ( $ipxedir, "../../../include/ipxe/efi" );
86
 
125
 
87
-print "Importing EFI headers into $ipxedir\nfrom ";
88
-print join ( "\n and ", @$edkdirs )."\n";
126
+if ( $verbosity >= 1 ) {
127
+  print "Importing EFI headers into $ipxedir\nfrom ";
128
+  print join ( "\n and ", map { catdir ( $edktop, $_ ) } @$edkdirs )."\n";
129
+}
89
 
130
 
90
 # Import headers
131
 # Import headers
91
 find ( { wanted => sub {
132
 find ( { wanted => sub {
92
-  try_import_file ( $ipxedir, $edkdirs, abs2rel ( $_, $ipxedir ) );
133
+  try_import_file ( $ipxedir, $edktop, $edkdirs, abs2rel ( $_, $ipxedir ) );
93
 }, no_chdir => 1 }, $ipxedir );
134
 }, no_chdir => 1 }, $ipxedir );

Loading…
Cancel
Save