|
@@ -494,10 +494,28 @@ int main(int argc, char **argv)
|
|
|
|
|
|
exec_args = args;
|
|
exec_args = args;
|
|
#ifdef BR_CCACHE
|
|
#ifdef BR_CCACHE
|
|
- /* If BR2_USE_CCACHE is not defined, or its value is not 1,
|
|
|
|
- * skip the ccache call */
|
|
|
|
|
|
+ /* If BR2_USE_CCACHE is set and its value is 1, enable ccache
|
|
|
|
+ * usage */
|
|
char *br_use_ccache = getenv("BR2_USE_CCACHE");
|
|
char *br_use_ccache = getenv("BR2_USE_CCACHE");
|
|
- if (!br_use_ccache || strncmp(br_use_ccache, "1", strlen("1")))
|
|
|
|
|
|
+ bool ccache_enabled = br_use_ccache && !strncmp(br_use_ccache, "1", strlen("1"));
|
|
|
|
+
|
|
|
|
+ if (ccache_enabled) {
|
|
|
|
+#ifdef BR_CCACHE_HASH
|
|
|
|
+ /* Allow compilercheck to be overridden through the environment */
|
|
|
|
+ if (setenv("CCACHE_COMPILERCHECK", "string:" BR_CCACHE_HASH, 0)) {
|
|
|
|
+ perror(__FILE__ ": Failed to set CCACHE_COMPILERCHECK");
|
|
|
|
+ return 3;
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+#ifdef BR_CCACHE_BASEDIR
|
|
|
|
+ /* Allow compilercheck to be overridden through the environment */
|
|
|
|
+ if (setenv("CCACHE_BASEDIR", BR_CCACHE_BASEDIR, 0)) {
|
|
|
|
+ perror(__FILE__ ": Failed to set CCACHE_BASEDIR");
|
|
|
|
+ return 3;
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+ } else
|
|
|
|
+ /* ccache is disabled, skip it */
|
|
exec_args++;
|
|
exec_args++;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -505,12 +523,14 @@ int main(int argc, char **argv)
|
|
if (debug > 0) {
|
|
if (debug > 0) {
|
|
fprintf(stderr, "Toolchain wrapper executing:");
|
|
fprintf(stderr, "Toolchain wrapper executing:");
|
|
#ifdef BR_CCACHE_HASH
|
|
#ifdef BR_CCACHE_HASH
|
|
- fprintf(stderr, "%sCCACHE_COMPILERCHECK='string:" BR_CCACHE_HASH "'",
|
|
|
|
- (debug == 2) ? "\n " : " ");
|
|
|
|
|
|
+ if (ccache_enabled)
|
|
|
|
+ fprintf(stderr, "%sCCACHE_COMPILERCHECK='string:" BR_CCACHE_HASH "'",
|
|
|
|
+ (debug == 2) ? "\n " : " ");
|
|
#endif
|
|
#endif
|
|
#ifdef BR_CCACHE_BASEDIR
|
|
#ifdef BR_CCACHE_BASEDIR
|
|
- fprintf(stderr, "%sCCACHE_BASEDIR='" BR_CCACHE_BASEDIR "'",
|
|
|
|
- (debug == 2) ? "\n " : " ");
|
|
|
|
|
|
+ if (ccache_enabled)
|
|
|
|
+ fprintf(stderr, "%sCCACHE_BASEDIR='" BR_CCACHE_BASEDIR "'",
|
|
|
|
+ (debug == 2) ? "\n " : " ");
|
|
#endif
|
|
#endif
|
|
for (i = 0; exec_args[i]; i++)
|
|
for (i = 0; exec_args[i]; i++)
|
|
fprintf(stderr, "%s'%s'",
|
|
fprintf(stderr, "%s'%s'",
|
|
@@ -518,21 +538,6 @@ int main(int argc, char **argv)
|
|
fprintf(stderr, "\n");
|
|
fprintf(stderr, "\n");
|
|
}
|
|
}
|
|
|
|
|
|
-#ifdef BR_CCACHE_HASH
|
|
|
|
- /* Allow compilercheck to be overridden through the environment */
|
|
|
|
- if (setenv("CCACHE_COMPILERCHECK", "string:" BR_CCACHE_HASH, 0)) {
|
|
|
|
- perror(__FILE__ ": Failed to set CCACHE_COMPILERCHECK");
|
|
|
|
- return 3;
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
-#ifdef BR_CCACHE_BASEDIR
|
|
|
|
- /* Allow compilercheck to be overridden through the environment */
|
|
|
|
- if (setenv("CCACHE_BASEDIR", BR_CCACHE_BASEDIR, 0)) {
|
|
|
|
- perror(__FILE__ ": Failed to set CCACHE_BASEDIR");
|
|
|
|
- return 3;
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
if (execv(exec_args[0], exec_args))
|
|
if (execv(exec_args[0], exec_args))
|
|
perror(path);
|
|
perror(path);
|
|
|
|
|