Loading...
--- Libc/Libc-825.25/xcodescripts/generate_features.pl
+++ Libc/Libc-1669.40.2/xcodescripts/generate_features.pl
@@ -1,8 +1,4 @@
#!/usr/bin/perl
-
-if ($ENV{"ACTION"} eq "installhdrs") {
- exit 0;
-}
# Generates the libc-features.h files used to control #ifdef behaviour in Libc
use warnings;
@@ -23,15 +19,19 @@
{
# set ENV{"CURRENT_ARCH"} so we can predicate on it
$ENV{"CURRENT_ARCH"} = $arch;
-
- my $platformName = $ENV{"PLATFORM_NAME"};
- $platformName = "iphoneos" if ($platformName eq "iphonesimulator");
-
+
+ my $platformName = $ENV{"VARIANT_PLATFORM_NAME"};
+ $platformName =~ s/simulator/os/;
+
+ # Try to find a platform+arch config file. If not found, try just
+ # a platform config file.
+ my $platformArchPath = $ENV{"SRCROOT"} . "/Platforms/" . $platformName . "/Makefile." . $arch . ".inc";
my $platformPath = $ENV{"SRCROOT"} . "/Platforms/" . $platformName . "/Makefile.inc";
+
my $featuresHeaderDir = $ENV{"DERIVED_FILES_DIR"}."/".$arch;
my $featuresHeader = $featuresHeaderDir."/libc-features.h";
- open FEATURESFILE, "<$platformPath" or die "Unable to open: $platformPath";
+ open FEATURESFILE, "<$platformArchPath" or open FEATURESFILE, "<$platformPath" or die "Unable to open: $platformArchPath nor $platformPath";
my %features = ();
my $skip = 0;
@@ -51,7 +51,7 @@
my $regex = $2;
$nested++;
- if ($ENV{$envvar} !~ /$regex/) {
+ if (!defined($ENV{$envvar}) || ($ENV{$envvar} !~ /$regex/)) {
$skip += 1;
}
}
@@ -80,10 +80,11 @@
elsif ($unifdef == 1) {
# assume FEATURE_BLOCKS was on by default
$unifdefs{"UNIFDEF_BLOCKS"} = 1;
+ $unifdefs{"UNIFDEF_DRIVERKIT"} = defined($ENV{"DRIVERKITSDK"});
$unifdefs{"UNIFDEF_LEGACY_64_APIS"} = defined($features{"FEATURE_LEGACY_64_APIS"});
$unifdefs{"UNIFDEF_LEGACY_RUNE_APIS"} = defined($features{"FEATURE_LEGACY_RUNE_APIS"});
$unifdefs{"UNIFDEF_LEGACY_UTMP_APIS"} = defined($features{"FEATURE_LEGACY_UTMP_APIS"});
- $unifdefs{"UNIFDEF_MOVE_LOCALTIME"} = defined($features{"FEATURE_MOVE_LOCALTIME"});
+ $unifdefs{"UNIFDEF_POSIX_ILP32_ALLOW"} = defined($features{"FEATURE_POSIX_ILP32_ALLOW"});
my $output = "";
for my $d (keys %unifdefs) {
@@ -97,10 +98,14 @@
elsif ($unifdef == 0) {
# If we touch this file on every build, then every other iterative build in Xcode will rebuild *everything*
- my $platform_mtime = (stat($platformPath))[9];
+ my $platform_mtime = (stat($platformArchPath))[9];
+ if (!defined($platform_mtime)) {
+ # try the other one
+ $platform_mtime = (stat($platformPath))[9];
+ }
my $header_mtime = (stat($featuresHeader))[9];
- if ($header_mtime > $platform_mtime) {
+ if (defined($header_mtime) && defined($platform_mtime) && ($header_mtime > $platform_mtime)) {
exit 0;
}
@@ -123,6 +128,9 @@
my $shortarch = $arch;
$shortarch =~ s/armv\d+[a-z]?/arm/g;
+ # map all arm64 subtypes to arm64
+ $shortarch =~ s/arm64[_a-z0-9]*/arm64/g;
+
printf HEADER "#if !defined(__".$shortarch."__)\n";
printf HEADER "#error Mismatched libc-features.h architecture\n";
printf HEADER "#endif\n\n";
@@ -143,12 +151,6 @@
printf HEADER "#define UNIFDEF_LEGACY_UTMP_APIS 1\n";
} else {
printf HEADER "/* #undef UNIFDEF_LEGACY_UTMP_APIS */\n";
- }
-
- if (defined($features{"FEATURE_MOVE_LOCALTIME"})) {
- printf HEADER "#define UNIFDEF_MOVE_LOCALTIME 1\n";
- } else {
- printf HEADER "/* #undef UNIFDEF_MOVE_LOCALTIME */\n";
}
if (defined($features{"FEATURE_ONLY_1050_VARIANTS"})) {
@@ -187,12 +189,6 @@
printf HEADER "/* #undef __APPLE_PR3417676_HACK__ */\n";
}
- if (defined($features{"FEATURE_PATCH_5243343"})) {
- printf HEADER "#define PR_5243343 1\n";
- } else {
- printf HEADER "/* #undef PR_5243343 */\n";
- }
-
if (defined($features{"FEATURE_PLOCKSTAT"})) {
printf HEADER "#define PLOCKSTAT 1\n";
} else {
@@ -205,16 +201,22 @@
printf HEADER "/* #undef NOTIFY_TZ */\n";
}
- if (defined($features{"FEATURE_NO_LIBCRASHREPORTERCLIENT"})) {
- printf HEADER "#define LIBC_NO_LIBCRASHREPORTERCLIENT 1\n";
- } else {
- printf HEADER "/* #undef LIBC_NO_LIBCRASHREPORTERCLIENT */\n";
- }
-
- if (defined($features{"FEATURE_MEMORYSTATUS"})) {
- printf HEADER "#define CONFIG_MEMORYSTATUS 1\n";
- } else {
- printf HEADER "/* #undef CONFIG_MEMORYSTATUS */\n";
+ if (defined($features{"FEATURE_SMALL_STDIOBUF"})) {
+ printf HEADER "#define FEATURE_SMALL_STDIOBUF 1\n";
+ } else {
+ printf HEADER "/* #undef FEATURE_SMALL_STDIOBUF */\n";
+ }
+
+ if (defined($features{"FEATURE_XPRINTF_PERF"})) {
+ printf HEADER "#define XPRINTF_PERF 1\n";
+ } else {
+ printf HEADER "/* #undef XPRINTF_PERF */\n";
+ }
+
+ if (defined($features{"FEATURE_SIGNAL_RESTRICTION"})) {
+ printf HEADER "#define FEATURE_SIGNAL_RESTRICTION 1\n";
+ } else {
+ printf HEADER "/* #undef FEATURE_SIGNAL_RESTRICTION */\n";
}
printf HEADER "#endif // _LIBC_FEATURES_H_\n";