ref: 9bcde4d6e90488b0808f599d80715cfebc70fb9a
parent: e802a58426b982f88d2dba72fb6762d1ae2ed8f8
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Mar 8 21:12:37 EDT 2015
Put a version in the usefile. Give an error instead of a crash on version changes.
--- a/myrbuild/myrbuild.c
+++ b/myrbuild/myrbuild.c
@@ -240,6 +240,8 @@
use = openlib(lib);
if (fgetc(use) != 'U')
fail(1, "library \"%s\" has corrupt or invalid usefile.\n", lib);
+ if (rdint(use) != 0)
+ fail(1, "library '%s' has usefile out of date", lib);
/* we don't care about the usefile's name */
free(rdstr(use));
while (fgetc(use) == 'L') {
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -4,6 +4,8 @@
# define FATAL
#endif
+#define Useversion 0
+
typedef uint8_t byte;
typedef unsigned int uint;
typedef unsigned long ulong;
--- a/parse/use.c
+++ b/parse/use.c
@@ -819,6 +819,10 @@
tydedup = mkht(tdhash, tdeq);
if (fgetc(f) != 'U')
return 0;
+ if (rdint(f) != Useversion) {
+ fprintf(stderr, "usefile version mismatch. try rebuilding your deps.\n");
+ return 0;
+ }
pkg = rdstr(f);
/* if the package names match up, or the usefile has no declared
* package, then we simply add to the current stab. Otherwise,
@@ -959,6 +963,7 @@
/* usefile name */
wrbyte(f, 'U');
+ wrint(f, Useversion); /* use version */
if (st->_name)
wrstr(f, st->_name);
else