// Find the real compiler. We just search the PATH to find an executable of the
// same name that isn't a link to ourselves.
static void
-find_compiler(const Context& ctx, char** argv)
+find_compiler(const Context& ctx, const char* const* argv)
{
// We might be being invoked like "ccache gcc -c foo.c".
std::string base(Util::base_name(argv[0]));
// Initialize ccache, must be called once before anything else is run.
static Context&
-initialize(int argc, char* argv[])
+initialize(int argc, const char* const* argv)
{
// This object is placed onto the heap so it is available in exit functions
// which run after main(). It is cleaned up by the last exit function.
fmt::print("({}) {} = {}\n", origin, key, value);
}
-static int cache_compilation(int argc, char* argv[]);
-static enum stats do_cache_compilation(Context& ctx, char* argv[]);
+static int cache_compilation(int argc, const char* const* argv);
+static enum stats do_cache_compilation(Context& ctx, const char* const* argv);
// The entry point when invoked to cache a compilation.
static int
-cache_compilation(int argc, char* argv[])
+cache_compilation(int argc, const char* const* argv)
{
#ifndef _WIN32
set_up_signal_handlers();
}
static enum stats
-do_cache_compilation(Context& ctx, char* argv[])
+do_cache_compilation(Context& ctx, const char* const* argv)
{
if (ctx.actual_cwd.empty()) {
cc_log("Unable to determine current working directory: %s",
// The main program when not doing a compile.
static int
-handle_main_options(int argc, char* argv[])
+handle_main_options(int argc, const char* const* argv)
{
enum longopts {
DUMP_MANIFEST,
(void)ctx;
int c;
- while ((c = getopt_long(argc, argv, "cCk:hF:M:po:sVxX:z", options, nullptr))
+ while ((c = getopt_long(argc,
+ const_cast<char* const*>(argv),
+ "cCk:hF:M:po:sVxX:z",
+ options,
+ nullptr))
!= -1) {
switch (c) {
case DUMP_MANIFEST:
return 0;
}
-int ccache_main(int argc, char* argv[]);
+int ccache_main(int argc, const char* const* argv);
int
-ccache_main(int argc, char* argv[])
+ccache_main(int argc, const char* const* argv)
{
try {
// Check if we are being invoked as "ccache".
#ifdef _WIN32
int
-execute(char** argv, int fd_out, int fd_err, pid_t* /*pid*/)
+execute(const char* const* argv, int fd_out, int fd_err, pid_t* /*pid*/)
{
return win32execute(argv[0], argv, 1, fd_out, fd_err);
}
// Re-create a win32 command line string based on **argv.
// http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
char*
-win32argvtos(char* prefix, char** argv, int* length)
+win32argvtos(const char* prefix, const char* const* argv, int* length)
{
int i = 0;
int k = 0;
- char* arg = prefix ? prefix : argv[i++];
+ const char* arg = prefix ? prefix : argv[i++];
do {
int bs = 0;
for (int j = 0; arg[j]; j++) {
}
char*
-win32getshell(char* path)
+win32getshell(const char* path)
{
char* path_env;
char* sh = NULL;
}
int
-win32execute(
- char* path, char** argv, int doreturn, int fd_stdout, int fd_stderr)
+win32execute(const char* path,
+ const char* const* argv,
+ int doreturn,
+ int fd_stdout,
+ int fd_stderr)
{
PROCESS_INFORMATION pi;
memset(&pi, 0x00, sizeof(pi));
// Execute a compiler backend, capturing all output to the given paths the full
// path to the compiler to run is in argv[0].
int
-execute(char** argv, int fd_out, int fd_err, pid_t* pid)
+execute(const char* const* argv, int fd_out, int fd_err, pid_t* pid)
{
cc_log_argv("Executing ", argv);
close(fd_out);
dup2(fd_err, 2);
close(fd_err);
- x_exit(execv(argv[0], argv));
+ x_exit(execv(argv[0], const_cast<char* const*>(argv)));
}
close(fd_out);
}
void
-print_command(FILE* fp, char** argv)
+print_command(FILE* fp, const char* const* argv)
{
for (int i = 0; argv[i]; i++) {
fprintf(fp, "%s%s", (i == 0) ? "" : " ", argv[i]);
struct Context;
-int execute(char** argv, int fd_out, int fd_err, pid_t* pid);
+int execute(const char* const* argv, int fd_out, int fd_err, pid_t* pid);
char*
find_executable(const Context& ctx, const char* name, const char* exclude_name);
char* find_executable_in_path(const char* name,
const char* exclude_name,
const char* path);
-void print_command(FILE* fp, char** argv);
+void print_command(FILE* fp, const char* const* argv);
char* format_command(const char* const* argv);
// Log an executed command to the CCACHE_LOGFILE location.
void
-cc_log_argv(const char* prefix, char** argv)
+cc_log_argv(const char* prefix, const char* const* argv)
{
if (!(debug_log_buffer || logfile || use_syslog)) {
return;
void init_log(const Config& config);
void cc_log(const char* format, ...) ATTR_FORMAT(printf, 1, 2);
void cc_bulklog(const char* format, ...) ATTR_FORMAT(printf, 1, 2);
-void cc_log_argv(const char* prefix, char** argv);
+void cc_log_argv(const char* prefix, const char* const* argv);
void cc_dump_debug_log_buffer(const char* path);
-// Copyright (C) 2010-2016 Joel Rosdahl and other contributors
+// Copyright (C) 2010-2020 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
// this program; if not, write to the Free Software Foundation, Inc., 51
// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-int
-ccache_main(int argc, char *argv[]);
+int ccache_main(int argc, const char* const* argv);
int
-main(int argc, char *argv[])
+main(int argc, char* const* argv)
{
- return ccache_main(argc, argv);
+ return ccache_main(argc, argv);
}
#endif
#ifdef _WIN32
-char* win32argvtos(char* prefix, char** argv, int* length);
-char* win32getshell(char* path);
-int win32execute(
- char* path, char** argv, int doreturn, int fd_stdout, int fd_stderr);
+char* win32argvtos(const char* prefix, const char* const* argv, int* length);
+char* win32getshell(const char* path);
+int win32execute(const char* path,
+ const char* const* argv,
+ int doreturn,
+ int fd_stdout,
+ int fd_stderr);
void add_exe_ext_if_no_to_fullpath(char* full_path_win_ext,
size_t max_size,
const char* ext,