Created
December 8, 2024 07:52
-
-
Save ntfargo/3f0b776c76f0850d17dcf465539d2b0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub createForwardingHeadersForFramework { | |
my $targetDirectory = File::Spec->catfile($outputDirectory, $framework); | |
mkpath($targetDirectory); | |
foreach my $header (@frameworkHeaders) { | |
my $headerName = basename($header); | |
# Find all headers with the same name | |
my @headers = grep($_ =~ "/$headerName\$", @frameworkHeaders); | |
if (@headers > 1) { | |
# Prioritize gtk headers if building for gtk | |
if (grep($_ eq "gtk", @platform)) { | |
@headers = grep($_ =~ "/gtk/", @headers); | |
if (@headers == 1) { | |
# Found exactly one gtk header, proceed with it | |
$header = $headers[0]; | |
} else { | |
print("ERROR: Multiple or no gtk headers found for $headerName:\n"); | |
foreach (@headers) { print " - $_\n" }; | |
die(); | |
} | |
} else { | |
print("ERROR: Can't create $headerName forwarding header, because there are more headers with the same name:\n"); | |
foreach (@headers) { print " - $_\n" }; | |
die(); | |
} | |
} | |
my $forwardingHeaderPath = File::Spec->catfile($targetDirectory, $headerName); | |
my $expectedIncludeStatement = "#include \"$framework/$header\""; | |
my $foundIncludeStatement = 0; | |
$foundIncludeStatement = <EXISTING_HEADER> if open(EXISTING_HEADER, "<$forwardingHeaderPath"); | |
chomp($foundIncludeStatement); | |
if (! $foundIncludeStatement || $foundIncludeStatement ne $expectedIncludeStatement) { | |
print "[Creating forwarding header for $framework/$header]\n" if $verbose; | |
open(FORWARDING_HEADER, ">$forwardingHeaderPath") or die "Could not open $forwardingHeaderPath."; | |
print FORWARDING_HEADER "$expectedIncludeStatement\n"; | |
close(FORWARDING_HEADER); | |
} | |
close(EXISTING_HEADER); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment