Line 33... |
Line 33... |
#include "diagnostic.h"
|
#include "diagnostic.h"
|
|
|
#include "../../libcpp/internal.h"
|
#include "../../libcpp/internal.h"
|
#include "cpp.h"
|
#include "cpp.h"
|
#include "incpath.h"
|
#include "incpath.h"
|
|
#include "mkdeps.h"
|
|
|
#ifndef TARGET_OS_CPP_BUILTINS
|
#ifndef TARGET_OS_CPP_BUILTINS
|
# define TARGET_OS_CPP_BUILTINS()
|
# define TARGET_OS_CPP_BUILTINS()
|
#endif
|
#endif
|
|
|
Line 82... |
Line 83... |
int dump_includes; /* -dI */
|
int dump_includes; /* -dI */
|
int working_directory; /* -fworking-directory */
|
int working_directory; /* -fworking-directory */
|
int no_predefined; /* -undef */
|
int no_predefined; /* -undef */
|
int standard_include_paths; /* -nostdinc */
|
int standard_include_paths; /* -nostdinc */
|
int verbose; /* -v */
|
int verbose; /* -v */
|
|
int deps; /* -M */
|
|
int deps_skip_system; /* -MM */
|
|
const char *deps_filename; /* -M[M]D */
|
|
const char *deps_filename_user; /* -MF <arg> */
|
|
int deps_missing_are_generated; /* -MG */
|
|
int deps_phony; /* -MP */
|
|
|
const char *multilib; /* -imultilib <dir> */
|
const char *multilib; /* -imultilib <dir> */
|
const char *prefix; /* -iprefix <dir> */
|
const char *prefix; /* -iprefix <dir> */
|
const char *sysroot; /* -isysroot <dir> */
|
const char *sysroot; /* -isysroot <dir> */
|
|
|
Line 268... |
Line 275... |
gfc_cpp_preprocess_only (void)
|
gfc_cpp_preprocess_only (void)
|
{
|
{
|
return gfc_cpp_option.preprocess_only;
|
return gfc_cpp_option.preprocess_only;
|
}
|
}
|
|
|
|
bool
|
|
gfc_cpp_makedep (void)
|
|
{
|
|
return gfc_cpp_option.deps;
|
|
}
|
|
|
|
void
|
|
gfc_cpp_add_dep (const char *name, bool system)
|
|
{
|
|
if (!gfc_cpp_option.deps_skip_system || !system)
|
|
deps_add_dep (cpp_get_deps (cpp_in), name);
|
|
}
|
|
|
|
void
|
|
gfc_cpp_add_target (const char *name)
|
|
{
|
|
deps_add_target (cpp_get_deps (cpp_in), name, 0);
|
|
}
|
|
|
|
|
const char *
|
const char *
|
gfc_cpp_temporary_file (void)
|
gfc_cpp_temporary_file (void)
|
{
|
{
|
return gfc_cpp_option.temporary_filename;
|
return gfc_cpp_option.temporary_filename;
|
}
|
}
|
Line 297... |
Line 324... |
gfc_cpp_option.dump_includes = 0;
|
gfc_cpp_option.dump_includes = 0;
|
gfc_cpp_option.working_directory = -1;
|
gfc_cpp_option.working_directory = -1;
|
gfc_cpp_option.no_predefined = 0;
|
gfc_cpp_option.no_predefined = 0;
|
gfc_cpp_option.standard_include_paths = 1;
|
gfc_cpp_option.standard_include_paths = 1;
|
gfc_cpp_option.verbose = 0;
|
gfc_cpp_option.verbose = 0;
|
|
gfc_cpp_option.deps = 0;
|
|
gfc_cpp_option.deps_skip_system = 0;
|
|
gfc_cpp_option.deps_phony = 0;
|
|
gfc_cpp_option.deps_missing_are_generated = 0;
|
|
gfc_cpp_option.deps_filename = NULL;
|
|
gfc_cpp_option.deps_filename_user = NULL;
|
|
|
gfc_cpp_option.multilib = NULL;
|
gfc_cpp_option.multilib = NULL;
|
gfc_cpp_option.prefix = NULL;
|
gfc_cpp_option.prefix = NULL;
|
gfc_cpp_option.sysroot = NULL;
|
gfc_cpp_option.sysroot = NULL;
|
|
|
Line 412... |
Line 445... |
|
|
case OPT_H:
|
case OPT_H:
|
gfc_cpp_option.print_include_names = 1;
|
gfc_cpp_option.print_include_names = 1;
|
break;
|
break;
|
|
|
|
case OPT_MM:
|
|
gfc_cpp_option.deps_skip_system = 1;
|
|
/* fall through */
|
|
|
|
case OPT_M:
|
|
gfc_cpp_option.deps = 1;
|
|
break;
|
|
|
|
case OPT_MMD:
|
|
gfc_cpp_option.deps_skip_system = 1;
|
|
/* fall through */
|
|
|
|
case OPT_MD:
|
|
gfc_cpp_option.deps = 1;
|
|
gfc_cpp_option.deps_filename = arg;
|
|
break;
|
|
|
|
case OPT_MF:
|
|
/* If specified multiple times, last one wins. */
|
|
gfc_cpp_option.deps_filename_user = arg;
|
|
break;
|
|
|
|
case OPT_MG:
|
|
gfc_cpp_option.deps_missing_are_generated = 1;
|
|
break;
|
|
|
|
case OPT_MP:
|
|
gfc_cpp_option.deps_phony = 1;
|
|
break;
|
|
|
|
case OPT_MQ:
|
|
case OPT_MT:
|
|
gfc_cpp_option.deferred_opt[gfc_cpp_option.deferred_opt_count].code = code;
|
|
gfc_cpp_option.deferred_opt[gfc_cpp_option.deferred_opt_count].arg = arg;
|
|
gfc_cpp_option.deferred_opt_count++;
|
|
break;
|
|
|
case OPT_P:
|
case OPT_P:
|
gfc_cpp_option.no_line_commands = 1;
|
gfc_cpp_option.no_line_commands = 1;
|
break;
|
break;
|
}
|
}
|
|
|
Line 428... |
Line 498... |
{
|
{
|
/* Any preprocessing-related option without '-cpp' is considered
|
/* Any preprocessing-related option without '-cpp' is considered
|
an error. */
|
an error. */
|
if (!gfc_cpp_enabled ()
|
if (!gfc_cpp_enabled ()
|
&& (gfc_cpp_preprocess_only ()
|
&& (gfc_cpp_preprocess_only ()
|
|
|| gfc_cpp_makedep ()
|
|| !gfc_cpp_option.discard_comments
|
|| !gfc_cpp_option.discard_comments
|
|| !gfc_cpp_option.discard_comments_in_macro_exp
|
|| !gfc_cpp_option.discard_comments_in_macro_exp
|
|| gfc_cpp_option.print_include_names
|
|| gfc_cpp_option.print_include_names
|
|| gfc_cpp_option.no_line_commands
|
|| gfc_cpp_option.no_line_commands
|
|| gfc_cpp_option.dump_macros
|
|| gfc_cpp_option.dump_macros
|
Line 460... |
Line 531... |
cpp_option->discard_comments = gfc_cpp_option.discard_comments;
|
cpp_option->discard_comments = gfc_cpp_option.discard_comments;
|
cpp_option->discard_comments_in_macro_exp = gfc_cpp_option.discard_comments_in_macro_exp;
|
cpp_option->discard_comments_in_macro_exp = gfc_cpp_option.discard_comments_in_macro_exp;
|
cpp_option->print_include_names = gfc_cpp_option.print_include_names;
|
cpp_option->print_include_names = gfc_cpp_option.print_include_names;
|
cpp_option->preprocessed = gfc_option.flag_preprocessed;
|
cpp_option->preprocessed = gfc_option.flag_preprocessed;
|
|
|
|
if (gfc_cpp_makedep ())
|
|
{
|
|
cpp_option->deps.style = DEPS_USER;
|
|
cpp_option->deps.phony_targets = gfc_cpp_option.deps_phony;
|
|
cpp_option->deps.missing_files = gfc_cpp_option.deps_missing_are_generated;
|
|
|
|
/* -MF <arg> overrides -M[M]D. */
|
|
if (gfc_cpp_option.deps_filename_user)
|
|
gfc_cpp_option.deps_filename = gfc_cpp_option.deps_filename_user;
|
|
}
|
|
|
if (gfc_cpp_option.working_directory == -1)
|
if (gfc_cpp_option.working_directory == -1)
|
gfc_cpp_option.working_directory = (debug_info_level != DINFO_LEVEL_NONE);
|
gfc_cpp_option.working_directory = (debug_info_level != DINFO_LEVEL_NONE);
|
|
|
cpp_post_options (cpp_in);
|
cpp_post_options (cpp_in);
|
|
|
Line 569... |
Line 651... |
if (opt->arg[0] == '-')
|
if (opt->arg[0] == '-')
|
cpp_unassert (cpp_in, opt->arg + 1);
|
cpp_unassert (cpp_in, opt->arg + 1);
|
else
|
else
|
cpp_assert (cpp_in, opt->arg);
|
cpp_assert (cpp_in, opt->arg);
|
}
|
}
|
|
else if (opt->code == OPT_MT || opt->code == OPT_MQ)
|
|
deps_add_target (cpp_get_deps (cpp_in),
|
|
opt->arg, opt->code == OPT_MQ);
|
}
|
}
|
|
|
if (gfc_cpp_option.working_directory
|
if (gfc_cpp_option.working_directory
|
&& gfc_cpp_option.preprocess_only && !gfc_cpp_option.no_line_commands)
|
&& gfc_cpp_option.preprocess_only && !gfc_cpp_option.no_line_commands)
|
pp_dir_change (cpp_in, get_src_pwd ());
|
pp_dir_change (cpp_in, get_src_pwd ());
|
Line 612... |
Line 697... |
gfc_cpp_done (void)
|
gfc_cpp_done (void)
|
{
|
{
|
if (!gfc_cpp_enabled ())
|
if (!gfc_cpp_enabled ())
|
return;
|
return;
|
|
|
/* TODO: if dependency tracking was enabled, call
|
gcc_assert (cpp_in);
|
cpp_finish() here to write dependencies.
|
|
|
|
Use cpp_get_deps() to access the current source's
|
if (gfc_cpp_makedep ())
|
dependencies during parsing. Add dependencies using
|
{
|
the mkdeps-interface (defined in libcpp). */
|
if (gfc_cpp_option.deps_filename)
|
|
{
|
|
FILE *f = fopen (gfc_cpp_option.deps_filename, "w");
|
|
if (f)
|
|
{
|
|
cpp_finish (cpp_in, f);
|
|
fclose (f);
|
|
}
|
|
else
|
|
gfc_fatal_error ("opening output file %s: %s",
|
|
gfc_cpp_option.deps_filename,
|
|
xstrerror (errno));
|
|
}
|
|
else
|
|
cpp_finish (cpp_in, stdout);
|
|
}
|
|
|
gcc_assert (cpp_in);
|
|
cpp_undef_all (cpp_in);
|
cpp_undef_all (cpp_in);
|
cpp_clear_file_cache (cpp_in);
|
cpp_clear_file_cache (cpp_in);
|
}
|
}
|
|
|
/* PATH must be malloc-ed and NULL-terminated. */
|
/* PATH must be malloc-ed and NULL-terminated. */
|