Skip to content

Commit

Permalink
Fix bug that prevented ast.h being made on msys2/mingw
Browse files Browse the repository at this point in the history
Alexander Sivitilli is using AST on windows, building with msys2 and
mingw. Mingw requires header files to be included using relative paths,
but the old makeh script used absolute paths, and so failed to find the
included files. makeh now uses relative paths.
  • Loading branch information
dsberry committed May 26, 2020
1 parent 76647bc commit d24e3df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
6 changes: 5 additions & 1 deletion ast_cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#
# The name of the CPP processor is substituted in by the ./configure script,
# based on the result of the AC_PROG_CPP test.
#
# The first (and only) argument for this script should be the path to
# the directory containing the header files. This is passed to the C
# pre-processor using the -I option.

cat >/tmp/ast_cpp_$$.c
@CPP@ /tmp/ast_cpp_$$.c
@CPP@ /tmp/ast_cpp_$$.c -I$1
rm -f /tmp/ast_cpp_$$.c
15 changes: 11 additions & 4 deletions makeh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
# Include the process ID in the name of the temporary directory and
# file, so that simultaneous invocations of this script do not trample
# all over each other.
# 25-MAY-2020 (DSB):
# Previously, the temporary .c file included the header files using an
# absolute file path in each "#include" statement. But this does not
# work on mingw, which can only include header files using relative
# paths. So now each "#include" statement uses a relative path, and the
# appropriate parent directory is specified using the "-I" option when
# running the C pre-processor within the ast_cpp script.
#-

( $#ARGV >= 0 ) || Usage();
Expand Down Expand Up @@ -84,15 +91,15 @@ foreach $file ( @ARGV ) {

# Open a pipe to a script (in the current directory) which runs the C
# preprocessor and direct its output to a scratch file.
open( CC, "| ./ast_cpp >/tmp/ast-$$.h" ) ||
open( CC, "| ./ast_cpp $tmpdir >/tmp/ast-$$.h" ) ||
die "Can't open pipe to C preprocessor (cpp)";

if ( $need_config_h ) {
# Include this directory's config.h, unescaped, in the output. We
# need to pay attention to the values in this file, but don't want
# them unexpanded in the final ast.h.
chomp($cwd = `pwd`);
print(CC "#include \"$cwd/config.h\"\n");
system("cp ./config.h $tmpdir/config.h");
print(CC "#include \"config.h\"\n");
}

# Before including each file, write an underlined heading in the form of
Expand All @@ -110,7 +117,7 @@ foreach $file ( @ARGV ) {
# preprocesses) each of the temporary files created above in turn.
$tmp_file = $file;
$tmp_file =~ s|^.*/||;
printf(CC "#include \"%s/%s\"\n", $tmpdir, $tmp_file);
printf(CC "#include \"%s\"\n", $tmp_file);
};

# Close the pipe to cpp.
Expand Down

0 comments on commit d24e3df

Please sign in to comment.