*/
static time_t time_of_compilation;
-/* Bitmask of SLOPPY_*. */
-unsigned sloppiness = 0;
-
/*
* Files included by the preprocessor and their hashes/sizes. Key: file path.
* Value: struct file_hash.
}
/* Let's hash the include file. */
- if (!(sloppiness & SLOPPY_INCLUDE_FILE_MTIME)
+ if (!(conf->sloppiness & SLOPPY_INCLUDE_FILE_MTIME)
&& st.st_mtime >= time_of_compilation) {
cc_log("Include file %s too new", path);
goto failure;
size = 0;
}
- result = hash_source_code_string(&fhash, source, size, path);
+ result = hash_source_code_string(conf, &fhash, source, size, path);
if (result & HASH_SOURCE_CODE_ERROR
|| result & HASH_SOURCE_CODE_FOUND_TIME) {
goto failure;
}
if (direct_mode) {
- if (!(sloppiness & SLOPPY_FILE_MACRO)) {
+ if (!(conf->sloppiness & SLOPPY_FILE_MACRO)) {
/*
* The source code file or an include file may contain
* __FILE__, so make sure that the hash is unique for
}
hash_delimiter(hash, "sourcecode");
- result = hash_source_code_file(hash, input_file);
+ result = hash_source_code_file(conf, hash, input_file);
if (result & HASH_SOURCE_CODE_ERROR) {
failed();
}
manifest_path = get_path_in_cache(manifest_name, ".manifest");
free(manifest_name);
cc_log("Looking for object file hash in %s", manifest_path);
- object_hash = manifest_get(manifest_path);
+ object_hash = manifest_get(conf, manifest_path);
if (object_hash) {
cc_log("Got object file hash from manifest");
} else {
if (found_pch || found_fpch_preprocess) {
using_precompiled_header = true;
- if (!(sloppiness & SLOPPY_TIME_MACROS)) {
+ if (!(conf->sloppiness & SLOPPY_TIME_MACROS)) {
cc_log("You have to specify \"time_macros\" sloppiness when using"
" precompiled headers to get direct hits");
cc_log("Disabling direct mode");
free(cached_dep); cached_dep = NULL;
free(manifest_path); manifest_path = NULL;
time_of_compilation = 0;
- sloppiness = false;
if (included_files) {
hashtable_destroy(included_files, 1); included_files = NULL;
}
initialize();
}
-static unsigned
-parse_sloppiness(char *p)
-{
- unsigned result = 0;
- char *word, *q, *saveptr = NULL;
-
- if (!p) {
- return result;
- }
- p = x_strdup(p);
- q = p;
- while ((word = strtok_r(q, ", ", &saveptr))) {
- if (str_eq(word, "file_macro")) {
- cc_log("Being sloppy about __FILE__");
- result |= SLOPPY_FILE_MACRO;
- }
- if (str_eq(word, "include_file_mtime")) {
- cc_log("Being sloppy about include file mtime");
- result |= SLOPPY_INCLUDE_FILE_MTIME;
- }
- if (str_eq(word, "time_macros")) {
- cc_log("Being sloppy about __DATE__ and __TIME__");
- result |= SLOPPY_TIME_MACROS;
- }
- q = NULL;
- }
- free(p);
- return result;
-}
-
/* Make a copy of stderr that will not be cached, so things like
distcc can send networking errors to it. */
static void
find_compiler(argc, argv);
- sloppiness = parse_sloppiness(getenv("CCACHE_SLOPPINESS"));
+ if (conf->sloppiness & SLOPPY_FILE_MACRO) {
+ cc_log("Being sloppy about __FILE__");
+ } else if (conf->sloppiness & SLOPPY_INCLUDE_FILE_MTIME) {
+ cc_log("Being sloppy about include file mtime");
+ } else if (conf->sloppiness & SLOPPY_TIME_MACROS) {
+ cc_log("Being sloppy about __DATE__ and __TIME__");
+ }
cc_log_argv("Command line: ", argv);
cc_log("Hostname: %s", get_hostname());
/*
- * Copyright (C) 2009-2010 Joel Rosdahl
+ * Copyright (C) 2009-2011 Joel Rosdahl
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
*/
int
hash_source_code_string(
- struct mdfour *hash, const char *str, size_t len, const char *path)
+ struct conf *conf, struct mdfour *hash, const char *str, size_t len,
+ const char *path)
{
int result = HASH_SOURCE_CODE_OK;
- extern unsigned sloppiness;
/*
- * Check for __DATE__ and __TIME__ if the sloppiness argument tells us
- * we have to.
+ * Check for __DATE__ and __TIME__ if the sloppiness configuration tells us
+ * we should.
*/
- if (!(sloppiness & SLOPPY_TIME_MACROS)) {
+ if (!(conf->sloppiness & SLOPPY_TIME_MACROS)) {
result |= check_for_temporal_macros(str, len);
}
* results.
*/
int
-hash_source_code_file(struct mdfour *hash, const char *path)
+hash_source_code_file(struct conf *conf, struct mdfour *hash, const char *path)
{
char *data;
size_t size;
if (!read_file(path, 0, &data, &size)) {
return HASH_SOURCE_CODE_ERROR;
}
- result = hash_source_code_string(hash, data, size, path);
+ result = hash_source_code_string(conf, hash, data, size, path);
free(data);
return result;
}
#ifndef HASHUTIL_H
#define HASHUTIL_H
+#include "conf.h"
#include "mdfour.h"
#include <inttypes.h>
#define HASH_SOURCE_CODE_FOUND_TIME 4
int hash_source_code_string(
- struct mdfour *hash, const char *str, size_t len, const char *path);
-int hash_source_code_file(struct mdfour *hash, const char *path);
+ struct conf *conf, struct mdfour *hash, const char *str, size_t len,
+ const char *path);
+int hash_source_code_file(
+ struct conf *conf, struct mdfour *hash, const char *path);
bool hash_command_output(struct mdfour *hash, const char *command,
const char *compiler);
bool hash_multicommand_output(struct mdfour *hash, const char *command,
/*
- * Copyright (C) 2009-2010 Joel Rosdahl
+ * Copyright (C) 2009-2011 Joel Rosdahl
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
}
static int
-verify_object(struct manifest *mf, struct object *obj,
+verify_object(struct conf *conf, struct manifest *mf, struct object *obj,
struct hashtable *hashed_files)
{
uint32_t i;
if (!actual) {
actual = x_malloc(sizeof(*actual));
hash_start(&hash);
- result = hash_source_code_file(&hash, mf->files[fi->index]);
+ result = hash_source_code_file(conf, &hash, mf->files[fi->index]);
if (result & HASH_SOURCE_CODE_ERROR) {
cc_log("Failed hashing %s", mf->files[fi->index]);
free(actual);
* on failure.
*/
struct file_hash *
-manifest_get(const char *manifest_path)
+manifest_get(struct conf *conf, const char *manifest_path)
{
int fd;
gzFile f = NULL;
/* Check newest object first since it's a bit more likely to match. */
for (i = mf->n_objects; i > 0; i--) {
- if (verify_object(mf, &mf->objects[i - 1], hashed_files)) {
+ if (verify_object(conf, mf, &mf->objects[i - 1], hashed_files)) {
fh = x_malloc(sizeof(*fh));
*fh = mf->objects[i - 1].hash;
goto out;
#ifndef MANIFEST_H
#define MANIFEST_H
+#include "conf.h"
#include "hashutil.h"
#include "hashtable.h"
-struct file_hash *manifest_get(const char *manifest_path);
+struct file_hash *manifest_get(struct conf *conf, const char *manifest_path);
bool manifest_put(const char *manifest_path, struct file_hash *object_hash,
struct hashtable *included_files);
bool manifest_dump(const char *manifest_path, FILE *stream);