diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2003-08-05 21:15:57 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@gcc.gnu.org> | 2003-08-05 21:15:57 +0000 |
commit | b20d9f0c07107060fe1873ee33e40b83ba425d12 (patch) | |
tree | b7f8db5c8aee0a49ffa5b4f9b148561a8a68a233 /gcc/toplev.c | |
parent | 1260d70fb61e50255cf7f185efff31f568a7049c (diff) | |
download | gcc-b20d9f0c07107060fe1873ee33e40b83ba425d12.zip gcc-b20d9f0c07107060fe1873ee33e40b83ba425d12.tar.gz gcc-b20d9f0c07107060fe1873ee33e40b83ba425d12.tar.bz2 |
c.opt: Introduce -fworking-directory.
* c.opt: Introduce -fworking-directory.
* doc/cpp.texi, doc/invoke.texi, doc/cppopts.texi: Document it.
* c-common.h (flag_working_directory): Declare.
* c-common.c (flag_working_directory): Define.
* c-opts.c (c_common_handle_options): Set it.
(sanitize_cpp_opts): Set...
* cpplib.h (struct cpp_options): ... working_directory option.
(struct cpp_callbacks): Add dir_change.
* cppinit.c (read_original_filename): Call...
(read_original_directory): New. Look for # 1 "directory//"
and process it.
(cpp_read_main_file): Call dir_change callback if working_directory
option is set.
* gcc.c (cpp_unique_options): Pass -g*.
* c-lex.c (cb_dir_change): New.
(init_c_lex): Set dir_change callback.
* toplev.c (src_pwd): New static variable.
(set_src_pwd, get_src_pwd): New functions.
* toplev.h (get_src_pwd, set_src_pwd): Declare.
* dbxout.c (dbxout_init): Call get_src_pwd() instead of getpwd().
* dwarf2out.c (gen_compile_unit_die): Likewise.
* dwarfout.c (output_compile_unit_die, dwarfout_init): Likewise.
From-SVN: r70189
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r-- | gcc/toplev.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c index 1e57877..73d459a 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1219,6 +1219,41 @@ FILE *aux_info_file; FILE *rtl_dump_file = NULL; FILE *cgraph_dump_file = NULL; +/* The current working directory of a translation. It's generally the + directory from which compilation was initiated, but a preprocessed + file may specify the original directory in which it was + created. */ + +static const char *src_pwd; + +/* Initialize src_pwd with the given string, and return true. If it + was already initialized, return false. As a special case, it may + be called with a NULL argument to test whether src_pwd has NOT been + initialized yet. */ + +bool +set_src_pwd (const char *pwd) +{ + if (src_pwd) + return false; + + src_pwd = xstrdup (pwd); + return true; +} + +/* Return the directory from which the translation unit was initiated, + in case set_src_pwd() was not called before to assign it a + different value. */ + +const char * +get_src_pwd (void) +{ + if (! src_pwd) + src_pwd = getpwd (); + + return src_pwd; +} + /* Set up a default flag_random_seed and local_tick, unless the user already specified one. */ |