Skip to content

win32: check if CCHOME is correctly set #20111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion win32/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,8 @@ CFG_VARS = \
"LINK_FLAGS=$(subst ",\",$(LINK_FLAGS))"\
"optimize=$(subst ",\",$(OPTIMIZE))" \
"ARCHPREFIX=$(ARCHPREFIX)" \
"WIN64=$(WIN64)"
"WIN64=$(WIN64)" \
"SKIP_CCHOME_CHECK=$(SKIP_CCHOME_CHECK)"

#
# Top targets
Expand Down
3 changes: 2 additions & 1 deletion win32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,8 @@ CFG_VARS = \
"default_inc_excludes_dot=$(DEFAULT_INC_EXCLUDES_DOT)" \
"LINK_FLAGS=$(LINK_FLAGS:"=\")" \
"optimize=$(OPTIMIZE:"=\")" \
"WIN64=$(WIN64)"
"WIN64=$(WIN64)" \
"SKIP_CCHOME_CHECK=$(SKIP_CCHOME_CHECK)"

#
# Top targets
Expand Down
32 changes: 31 additions & 1 deletion win32/config_sh.PL
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,32 @@ sub mungepath {
$p =~ s/[ ;]+$//;
$p =~ s/'/"/g;
my @p = map { $_ = "\"$_\"" if /\s/ and !/^".*"$/; $_ } split /;/, $p;
return join(' ', @p);
return wantarray ? @p : join(' ', @p);
}

# check that the directories in the provided var exist
sub check_path {
my $opt = shift;
my $p = shift;
my @paths = mungepath($p);
my $header_seen = 0;
foreach my $path (@paths) {
$path =~ s/^"(.*)"$/$1/;
next, if -d $path;

if (not $header_seen++) {
print STDERR "'$opt' contains the following non-existing paths:\n";
}
print STDERR "\t$path\n";
}
if ($header_seen) {
print STDERR <<EOF;
Did you provide a correct value for the 'CCHOME' option?

(This check can be skipped by using the SKIP_CCHOME_CHECK=1 option)
EOF
exit 1;
}
}

# generate an array of option strings from command-line args
Expand Down Expand Up @@ -112,6 +137,11 @@ if (!$opt{cf_email}) {
}
$opt{usemymalloc} = 'y' if $opt{d_mymalloc} eq 'define';

unless ($opt{SKIP_CCHOME_CHECK}) {
check_path('CCLIBDIR', $opt{libpth});
check_path('CCINCDIR', $opt{incpath});
}

$opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth};
$opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath};

Expand Down