@@ -45,6 +45,8 @@ struct gcc_base_context;
enum gcc_base_api_version
{
GCC_FE_VERSION_0 = 0,
+
+ /* Parameter verbose has been moved from compile to set_arguments. */
GCC_FE_VERSION_1 = 1,
};
@@ -71,14 +73,15 @@ struct gcc_base_vtable
The arguments are copied by GCC. ARGV need not be
NULL-terminated. The arguments must be set separately for each
compilation; that is, after a compile is requested, the
- previously-set arguments cannot be reused.
+ previously-set arguments cannot be reused. VERBOSE can be set
+ to cause GCC to print some information as it works.
This returns NULL on success. On failure, returns a malloc()d
error message. The caller is responsible for freeing it. */
char *(*set_arguments) (struct gcc_base_context *self,
const char *triplet_regexp,
- int argc, char **argv);
+ int argc, char **argv, int /* bool */ verbose);
/* Set the file name of the program to compile. The string is
copied by the method implementation, but the caller must
@@ -95,13 +98,10 @@ struct gcc_base_vtable
void *datum);
/* Perform the compilation. FILENAME is the name of the resulting
- object file. VERBOSE can be set to cause GCC to print some
- information as it works. Returns true on success, false on
- error. */
+ object file. Returns true on success, false on error. */
int /* bool */ (*compile) (struct gcc_base_context *self,
- const char *filename,
- int /* bool */ verbose);
+ const char *filename);
/* Destroy this object. */
@@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see
#include "xregex.h"
#include "findcomp.hh"
#include "compiler-name.h"
+#include "intl.h"
struct libcc1;
@@ -66,6 +67,9 @@ struct libcc1 : public gcc_c_context
std::vector<std::string> args;
std::string source_file;
+
+ /* Non-zero as an equivalent to gcc driver option "-v". */
+ bool verbose;
};
// A local subclass of connection that holds a back-pointer to the
@@ -97,7 +101,8 @@ libcc1::libcc1 (const gcc_base_vtable *v,
print_function (NULL),
print_datum (NULL),
args (),
- source_file ()
+ source_file (),
+ verbose (false)
{
base.ops = v;
c_ops = cv;
@@ -309,13 +314,19 @@ make_regexp (const char *triplet_regexp, const char *compiler)
static char *
libcc1_set_arguments (struct gcc_base_context *s,
const char *triplet_regexp,
- int argc, char **argv)
+ int argc, char **argv, int verbose)
{
libcc1 *self = (libcc1 *) s;
regex_t triplet;
int code;
+ self->verbose = verbose != 0;
+
std::string rx = make_regexp (triplet_regexp, COMPILER_NAME);
+ // Simulate fnotice by fprintf.
+ if (self->verbose)
+ fprintf (stderr, _("searching for compiler matching regex %s\n"),
+ rx.c_str());
code = regcomp (&triplet, rx.c_str (), REG_EXTENDED | REG_NOSUB);
if (code != 0)
{
@@ -341,6 +352,8 @@ libcc1_set_arguments (struct gcc_base_context *s,
(char *) NULL);
}
regfree (&triplet);
+ if (self->verbose)
+ fprintf (stderr, _("found compiler %s\n"), compiler.c_str());
self->args.push_back (compiler);
@@ -434,8 +447,7 @@ fork_exec (libcc1 *self, char **argv, int spair_fds[2], int stderr_fds[2])
static int
libcc1_compile (struct gcc_base_context *s,
- const char *filename,
- int verbose)
+ const char *filename)
{
libcc1 *self = (libcc1 *) s;
@@ -466,7 +478,7 @@ libcc1_compile (struct gcc_base_context *s,
self->args.push_back ("-c");
self->args.push_back ("-o");
self->args.push_back (filename);
- if (verbose)
+ if (self->verbose)
self->args.push_back ("-v");
self->connection = new libcc1_connection (fds[0], stderr_fds[0], self);