diff mbox

[PATCH/RFC] Optionally remove use of __DATE__ and __TIME__ when building.

Message ID 20140226164116.00b83d74@notabene.brown
State Superseded
Headers show

Commit Message

NeilBrown Feb. 26, 2014, 5:41 a.m. UTC
Use of __DATE__ and __TIME__ makes it impossible to recompile after
possibly changing context and see the context made any real change in
the resulting build.
The Open Build Service can do this (to optimise rebuilds) and so
discourages the use of __DATE__ and __TIME__

This patch makes it easy to disable the use of __DATE__ and __TIME__
in src/fedfsd/main.c by setting CPPFLAGS.

Possibly a ./configure option should be created instead.

Signed-off-by: NeilBrown <neilb@suse.de>

Comments

Chuck Lever Feb. 26, 2014, 5:55 a.m. UTC | #1
I might prefer setting the build date in configure.ac, or removing these in favor of simply using VERSION by itself.

--
Chuck Lever

> On Feb 25, 2014, at 9:41 PM, NeilBrown <neilb@suse.de> wrote:
> 
> 
> 
> Use of __DATE__ and __TIME__ makes it impossible to recompile after
> possibly changing context and see the context made any real change in
> the resulting build.
> The Open Build Service can do this (to optimise rebuilds) and so
> discourages the use of __DATE__ and __TIME__
> 
> This patch makes it easy to disable the use of __DATE__ and __TIME__
> in src/fedfsd/main.c by setting CPPFLAGS.
> 
> Possibly a ./configure option should be created instead.
> 
> Signed-off-by: NeilBrown <neilb@suse.de>
> 
> diff --git a/src/fedfsd/main.c b/src/fedfsd/main.c
> index f6ca61f7d6e8..edf96c90577a 100644
> --- a/src/fedfsd/main.c
> +++ b/src/fedfsd/main.c
> @@ -165,8 +165,12 @@ int main(int argc, char **argv)
>            break;
>        case '?':
>            fprintf(stderr, "Version " VERSION
> -                    ", built on %s at %s\n\n",
> -                    __DATE__, __TIME__);
> +                #ifndef NO_DATE_TIME
> +                    ", built on " __DATE__
> +                    " at " __TIME __
> +                #endif
> +                    "\n\n"
> +                );
>            fedfsd_usage(progname);
>            break;
>        case 'o':
> @@ -230,8 +234,11 @@ int main(int argc, char **argv)
>        }
>    }
> 
> -    xlog(L_NOTICE, "Version " VERSION " (built %s at %s) starting",
> -            __DATE__, __TIME__);
> +    xlog(L_NOTICE, "Version " VERSION
> +         #ifndef NO_DATE_TIME
> +         " (built " __DATE__ " at " __TIME__ ")"
> +         #endif
> +         " starting");
> 
>    if (!fedfsd_set_up_authenticators())
>        exit(EXIT_FAILURE);
> _______________________________________________
> fedfs-utils-devel mailing list
> fedfs-utils-devel@oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/fedfs-utils-devel
Chuck Lever Feb. 26, 2014, 2:32 p.m. UTC | #2
> On Feb 25, 2014, at 9:55 PM, Chuck Lever <chuck.lever@oracle.com> wrote:
> 
> I might prefer setting the build date in configure.ac, or removing these in favor of simply using VERSION by itself.

Yeah, the latter is fine.  Can you send a patch that does this, and cite the rationale below in the patch description?

> 
> --
> Chuck Lever
> 
>> On Feb 25, 2014, at 9:41 PM, NeilBrown <neilb@suse.de> wrote:
>> 
>> 
>> 
>> Use of __DATE__ and __TIME__ makes it impossible to recompile after
>> possibly changing context and see the context made any real change in
>> the resulting build.
>> The Open Build Service can do this (to optimise rebuilds) and so
>> discourages the use of __DATE__ and __TIME__
>> 
>> This patch makes it easy to disable the use of __DATE__ and __TIME__
>> in src/fedfsd/main.c by setting CPPFLAGS.
>> 
>> Possibly a ./configure option should be created instead.
>> 
>> Signed-off-by: NeilBrown <neilb@suse.de>
>> 
>> diff --git a/src/fedfsd/main.c b/src/fedfsd/main.c
>> index f6ca61f7d6e8..edf96c90577a 100644
>> --- a/src/fedfsd/main.c
>> +++ b/src/fedfsd/main.c
>> @@ -165,8 +165,12 @@ int main(int argc, char **argv)
>>           break;
>>       case '?':
>>           fprintf(stderr, "Version " VERSION
>> -                    ", built on %s at %s\n\n",
>> -                    __DATE__, __TIME__);
>> +                #ifndef NO_DATE_TIME
>> +                    ", built on " __DATE__
>> +                    " at " __TIME __
>> +                #endif
>> +                    "\n\n"
>> +                );
>>           fedfsd_usage(progname);
>>           break;
>>       case 'o':
>> @@ -230,8 +234,11 @@ int main(int argc, char **argv)
>>       }
>>   }
>> 
>> -    xlog(L_NOTICE, "Version " VERSION " (built %s at %s) starting",
>> -            __DATE__, __TIME__);
>> +    xlog(L_NOTICE, "Version " VERSION
>> +         #ifndef NO_DATE_TIME
>> +         " (built " __DATE__ " at " __TIME__ ")"
>> +         #endif
>> +         " starting");
>> 
>>   if (!fedfsd_set_up_authenticators())
>>       exit(EXIT_FAILURE);
>> _______________________________________________
>> fedfs-utils-devel mailing list
>> fedfs-utils-devel@oss.oracle.com
>> https://oss.oracle.com/mailman/listinfo/fedfs-utils-devel
> 
> _______________________________________________
> fedfs-utils-devel mailing list
> fedfs-utils-devel@oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/fedfs-utils-devel
diff mbox

Patch

diff --git a/src/fedfsd/main.c b/src/fedfsd/main.c
index f6ca61f7d6e8..edf96c90577a 100644
--- a/src/fedfsd/main.c
+++ b/src/fedfsd/main.c
@@ -165,8 +165,12 @@  int main(int argc, char **argv)
 			break;
 		case '?':
 			fprintf(stderr, "Version " VERSION
-					", built on %s at %s\n\n",
-					__DATE__, __TIME__);
+				#ifndef NO_DATE_TIME
+					", built on " __DATE__
+					" at " __TIME __
+				#endif
+					"\n\n"
+				);
 			fedfsd_usage(progname);
 			break;
 		case 'o':
@@ -230,8 +234,11 @@  int main(int argc, char **argv)
 		}
 	}
 
-	xlog(L_NOTICE, "Version " VERSION " (built %s at %s) starting",
-			__DATE__, __TIME__);
+	xlog(L_NOTICE, "Version " VERSION
+	     #ifndef NO_DATE_TIME
+	     " (built " __DATE__ " at " __TIME__ ")"
+	     #endif
+	     " starting");
 
 	if (!fedfsd_set_up_authenticators())
 		exit(EXIT_FAILURE);