mirror of
https://github.com/reactos/ccache.git
synced 2024-10-06 16:43:26 +00:00
config: Use sloppiness from conf struct
This commit is contained in:
parent
da63d7d3f5
commit
adba0503b6
54
ccache.c
54
ccache.c
@ -124,9 +124,6 @@ static char *manifest_path;
|
||||
*/
|
||||
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.
|
||||
@ -341,7 +338,7 @@ remember_include_file(char *path, size_t path_len, struct mdfour *cpp_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;
|
||||
@ -373,7 +370,7 @@ remember_include_file(char *path, size_t path_len, struct mdfour *cpp_hash)
|
||||
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;
|
||||
@ -970,7 +967,7 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
|
||||
}
|
||||
|
||||
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
|
||||
@ -981,7 +978,7 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
@ -994,7 +991,7 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
|
||||
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 {
|
||||
@ -1600,7 +1597,7 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_args,
|
||||
|
||||
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");
|
||||
@ -1849,7 +1846,6 @@ cc_reset(void)
|
||||
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;
|
||||
}
|
||||
@ -1864,36 +1860,6 @@ cc_reset(void)
|
||||
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
|
||||
@ -1945,7 +1911,13 @@ ccache(int argc, char *argv[])
|
||||
|
||||
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());
|
||||
|
16
hashutil.c
16
hashutil.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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
|
||||
@ -104,16 +104,16 @@ check_for_temporal_macros(const char *str, size_t len)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ hash_source_code_string(
|
||||
* 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;
|
||||
@ -171,7 +171,7 @@ hash_source_code_file(struct mdfour *hash, const char *path)
|
||||
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;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef HASHUTIL_H
|
||||
#define HASHUTIL_H
|
||||
|
||||
#include "conf.h"
|
||||
#include "mdfour.h"
|
||||
#include <inttypes.h>
|
||||
|
||||
@ -21,8 +22,10 @@ int file_hashes_equal(struct file_hash *fh1, struct file_hash *fh2);
|
||||
#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,
|
||||
|
10
manifest.c
10
manifest.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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
|
||||
@ -344,7 +344,7 @@ error:
|
||||
}
|
||||
|
||||
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;
|
||||
@ -359,7 +359,7 @@ verify_object(struct manifest *mf, struct object *obj,
|
||||
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);
|
||||
@ -523,7 +523,7 @@ add_object_entry(struct manifest *mf,
|
||||
* 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;
|
||||
@ -554,7 +554,7 @@ manifest_get(const char *manifest_path)
|
||||
|
||||
/* 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;
|
||||
|
@ -1,10 +1,11 @@
|
||||
#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);
|
||||
|
Loading…
Reference in New Issue
Block a user