diff --git a/cmd/wuffs-c/internal/cgen/base/core-public.h b/cmd/wuffs-c/internal/cgen/base/core-public.h index f7229a92..c3c2b754 100644 --- a/cmd/wuffs-c/internal/cgen/base/core-public.h +++ b/cmd/wuffs-c/internal/cgen/base/core-public.h @@ -25,26 +25,27 @@ // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the -// middle 16 bits. The patch number is the low 16 bits. The version extension -// (such as "", "beta" or "rc.1") is part of the string representation (such as -// "1.2.3-beta") but not the uint64_t representation. +// middle 16 bits. The patch number is the low 16 bits. The pre-release label +// and build metadata are part of the string representation (such as +// "1.2.3-beta+456.20181231") but not the uint64_t representation. // -// WUFFS_VERSION_GIT_REV_LIST_COUNT is the number of commits in the repository -// used to build this library: the result of "git rev-list --count HEAD". -// Within each major.minor branch, this number should increase monotonically. +// WUFFS_VERSION_PRE_RELEASE_LABEL (such as "", "beta" or "rc.1") being +// non-empty denotes a developer preview, not a release version, and has no +// backwards or forwards compatibility guarantees. // -// All three of major, minor and patch being zero means that this is a -// work-in-progress version, not a release version, and has no backwards or -// forwards compatibility guarantees. +// WUFFS_VERSION_BUILD_METADATA_XXX, if non-zero, are the number of commits and +// the last commit date in the repository used to build this library. Within +// each major.minor branch, the commit count should increase monotonically. // // !! Some code generation programs can override WUFFS_VERSION. #define WUFFS_VERSION ((uint64_t)0) #define WUFFS_VERSION_MAJOR ((uint64_t)0) #define WUFFS_VERSION_MINOR ((uint64_t)0) #define WUFFS_VERSION_PATCH ((uint64_t)0) -#define WUFFS_VERSION_EXTENSION "" -#define WUFFS_VERSION_STRING "0.0.0" -#define WUFFS_VERSION_GIT_REV_LIST_COUNT 0 +#define WUFFS_VERSION_PRE_RELEASE_LABEL "work.in.progress" +#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 0 +#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 0 +#define WUFFS_VERSION_STRING "0.0.0+0.00000000" // Define WUFFS_CONFIG__STATIC_FUNCTIONS to make all of Wuffs' functions have // static storage. The motivation is discussed in the "ALLOW STATIC diff --git a/cmd/wuffs-c/internal/cgen/data.go b/cmd/wuffs-c/internal/cgen/data.go index a29aa432..96887632 100644 --- a/cmd/wuffs-c/internal/cgen/data.go +++ b/cmd/wuffs-c/internal/cgen/data.go @@ -57,10 +57,10 @@ const baseCorePrivateH = "" + "" const baseCorePublicH = "" + - "// Wuffs assumes that:\n// - converting a uint32_t to a size_t will never overflow.\n// - converting a size_t to a uint64_t will never overflow.\n#ifdef __WORDSIZE\n#if (__WORDSIZE != 32) && (__WORDSIZE != 64)\n#error \"Wuffs requires a word size of either 32 or 64 bits\"\n#endif\n#endif\n\n// WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/,\n// as a uint64_t. The major number is the high 32 bits. The minor number is the\n// middle 16 bits. The patch number is the low 16 bits. The version extension\n// (such as \"\", \"beta\" or \"rc.1\") is part of the string representation (such as\n// \"1.2.3-beta\") but not the uint64_t representation.\n//\n// WUFFS_VERSION_GIT_REV_LIST_COUNT is the number of commits in the repository\n// used to build this library: the result of \"git rev-list --count HEAD\".\n// Within each major.minor branch, this number should increase monotonically.\n//\n// All three of major, minor and patch being zero means that this is a\n// work-in-progress version, not a release version, and has no" + - " backwards or\n// forwards compatibility guarantees.\n//\n// !! Some code generation programs can override WUFFS_VERSION.\n#define WUFFS_VERSION ((uint64_t)0)\n#define WUFFS_VERSION_MAJOR ((uint64_t)0)\n#define WUFFS_VERSION_MINOR ((uint64_t)0)\n#define WUFFS_VERSION_PATCH ((uint64_t)0)\n#define WUFFS_VERSION_EXTENSION \"\"\n#define WUFFS_VERSION_STRING \"0.0.0\"\n#define WUFFS_VERSION_GIT_REV_LIST_COUNT 0\n\n// Define WUFFS_CONFIG__STATIC_FUNCTIONS to make all of Wuffs' functions have\n// static storage. The motivation is discussed in the \"ALLOW STATIC\n// IMPLEMENTATION\" section of\n// https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt\n#ifdef WUFFS_CONFIG__STATIC_FUNCTIONS\n#define WUFFS_BASE__MAYBE_STATIC static\n#else\n#define WUFFS_BASE__MAYBE_STATIC\n#endif\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define WUFFS_BASE__WARN_UNUSED_RESULT __attribute__((warn_unused_result))\n#else\n#define WUFFS_BASE__WARN_UNUSED_RESULT\n#endif\n\n// wuffs_base__empty_struct is used when a Wuffs function returns " + - "an empty\n// struct. In C, if a function f returns void, you can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g()\".\ntypedef struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__empty_struct;\n\n// wuffs_base__utility is a placeholder receiver type. It enables what Java\n// calls static methods, as opposed to regular methods.\ntypedef struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the size" + - "of a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__utility;\n\n" + + "// Wuffs assumes that:\n// - converting a uint32_t to a size_t will never overflow.\n// - converting a size_t to a uint64_t will never overflow.\n#ifdef __WORDSIZE\n#if (__WORDSIZE != 32) && (__WORDSIZE != 64)\n#error \"Wuffs requires a word size of either 32 or 64 bits\"\n#endif\n#endif\n\n// WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/,\n// as a uint64_t. The major number is the high 32 bits. The minor number is the\n// middle 16 bits. The patch number is the low 16 bits. The pre-release label\n// and build metadata are part of the string representation (such as\n// \"1.2.3-beta+456.20181231\") but not the uint64_t representation.\n//\n// WUFFS_VERSION_PRE_RELEASE_LABEL (such as \"\", \"beta\" or \"rc.1\") being\n// non-empty denotes a developer preview, not a release version, and has no\n// backwards or forwards compatibility guarantees.\n//\n// WUFFS_VERSION_BUILD_METADATA_XXX, if non-zero, are the number of commits and\n// the last commit date in the repository used to build this library. Within\n// eac" + + "h major.minor branch, the commit count should increase monotonically.\n//\n// !! Some code generation programs can override WUFFS_VERSION.\n#define WUFFS_VERSION ((uint64_t)0)\n#define WUFFS_VERSION_MAJOR ((uint64_t)0)\n#define WUFFS_VERSION_MINOR ((uint64_t)0)\n#define WUFFS_VERSION_PATCH ((uint64_t)0)\n#define WUFFS_VERSION_PRE_RELEASE_LABEL \"work.in.progress\"\n#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 0\n#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 0\n#define WUFFS_VERSION_STRING \"0.0.0+0.00000000\"\n\n// Define WUFFS_CONFIG__STATIC_FUNCTIONS to make all of Wuffs' functions have\n// static storage. The motivation is discussed in the \"ALLOW STATIC\n// IMPLEMENTATION\" section of\n// https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt\n#ifdef WUFFS_CONFIG__STATIC_FUNCTIONS\n#define WUFFS_BASE__MAYBE_STATIC static\n#else\n#define WUFFS_BASE__MAYBE_STATIC\n#endif\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define WUFFS_BASE__WARN_UNUSED_RESULT __attribute__((warn_unused_result))\n#else\n" + + "#define WUFFS_BASE__WARN_UNUSED_RESULT\n#endif\n\n// wuffs_base__empty_struct is used when a Wuffs function returns an empty\n// struct. In C, if a function f returns void, you can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g()\".\ntypedef struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__empty_struct;\n\n// wuffs_base__utility is a placeholder receiver type. It enables what Java\n// calls static methods, as opposed to regular methods.\ntypedef s" + + "truct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__utility;\n\n" + "" + "// --------\n\n// A status is either NULL (meaning OK) or a string message. That message is\n// human-readable, for programmers, but it is not for end users. It is not\n// localized, and does not contain additional contextual information such as a\n// source filename.\n//\n// Status strings are statically allocated and should never be free'd. They can\n// be compared by the == operator and not just by strcmp.\n//\n// Statuses come in four categories:\n// - OK: the request was completed, successfully.\n// - Warnings: the request was completed, unsuccessfully.\n// - Suspensions: the request was not completed, but can be re-tried.\n// - Errors: the request was not completed, permanently.\n//\n// When a function returns an incomplete status, a suspension means that that\n// function should be called again within a new context, such as after flushing\n// or re-filling an I/O buffer. An error means that an irrecoverable failure\n// state was reached.\ntypedef const char* wuffs_base__status;\n\n// !! INSERT wuffs_bas" + "e__status names.\n\nstatic inline bool //\nwuffs_base__status__is_complete(wuffs_base__status z) {\n return (z == NULL) || ((*z != '$') && (*z != '?'));\n}\n\nstatic inline bool //\nwuffs_base__status__is_error(wuffs_base__status z) {\n return z && (*z == '?');\n}\n\nstatic inline bool //\nwuffs_base__status__is_ok(wuffs_base__status z) {\n return z == NULL;\n}\n\nstatic inline bool //\nwuffs_base__status__is_suspension(wuffs_base__status z) {\n return z && (*z == '$');\n}\n\nstatic inline bool //\nwuffs_base__status__is_warning(wuffs_base__status z) {\n return z && (*z != '$') && (*z != '?');\n}\n\n" + diff --git a/cmd/wuffs-c/release.go b/cmd/wuffs-c/release.go index 2399ac90..08df418a 100644 --- a/cmd/wuffs-c/release.go +++ b/cmd/wuffs-c/release.go @@ -136,7 +136,7 @@ var ( grIncludeQuote = []byte("#include \"") grNN = []byte("\n\n") grVOverride = []byte("// !! Some code generation programs can override WUFFS_VERSION.\n") - grVEnd = []byte("#define WUFFS_VERSION_GIT_REV_LIST_COUNT 0") + grVEnd = []byte(`#define WUFFS_VERSION_STRING "0.0.0+0.00000000"`) grWmrAbove = []byte("// !! WUFFS MONOLITHIC RELEASE DISCARDS EVERYTHING ABOVE.\n") grWmrBelow = []byte("// !! WUFFS MONOLITHIC RELEASE DISCARDS EVERYTHING BELOW.\n") ) @@ -288,17 +288,29 @@ func (h *genReleaseHelper) substituteWuffsVersion(s []byte) ([]byte, error) { fmt.Fprintf(w, " based on revision\n// %s committed on %s", h.revision, h.commitDate) } + commitDate := "0" + if h.commitDate != "" { + commitDate = strings.Replace(h.commitDate, "-", "", -1) + } + + buildMetadata := "" + if h.gitRevListCount != 0 { + buildMetadata = fmt.Sprintf("+%d.%s", h.gitRevListCount, commitDate) + } + fmt.Fprintf(w, `. #define WUFFS_VERSION ((uint64_t)0x%016X) #define WUFFS_VERSION_MAJOR ((uint64_t)0x%08X) #define WUFFS_VERSION_MINOR ((uint64_t)0x%04X) #define WUFFS_VERSION_PATCH ((uint64_t)0x%04X) - #define WUFFS_VERSION_EXTENSION %q + #define WUFFS_VERSION_PRE_RELEASE_LABEL %q + #define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT %d + #define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE %s #define WUFFS_VERSION_STRING %q - #define WUFFS_VERSION_GIT_REV_LIST_COUNT %d `, h.version.Uint64(), h.version.Major, h.version.Minor, h.version.Patch, - h.version.Extension, h.version, h.gitRevListCount) + h.version.Extension, h.gitRevListCount, commitDate, + h.version.String()+buildMetadata) ret = append(ret, w.Bytes()...) ret = append(ret, s...) diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 2c1c3383..c8a9d4eb 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -41,26 +41,27 @@ extern "C" { // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the -// middle 16 bits. The patch number is the low 16 bits. The version extension -// (such as "", "beta" or "rc.1") is part of the string representation (such as -// "1.2.3-beta") but not the uint64_t representation. +// middle 16 bits. The patch number is the low 16 bits. The pre-release label +// and build metadata are part of the string representation (such as +// "1.2.3-beta+456.20181231") but not the uint64_t representation. // -// WUFFS_VERSION_GIT_REV_LIST_COUNT is the number of commits in the repository -// used to build this library: the result of "git rev-list --count HEAD". -// Within each major.minor branch, this number should increase monotonically. +// WUFFS_VERSION_PRE_RELEASE_LABEL (such as "", "beta" or "rc.1") being +// non-empty denotes a developer preview, not a release version, and has no +// backwards or forwards compatibility guarantees. // -// All three of major, minor and patch being zero means that this is a -// work-in-progress version, not a release version, and has no backwards or -// forwards compatibility guarantees. +// WUFFS_VERSION_BUILD_METADATA_XXX, if non-zero, are the number of commits and +// the last commit date in the repository used to build this library. Within +// each major.minor branch, the commit count should increase monotonically. // // !! Some code generation programs can override WUFFS_VERSION. #define WUFFS_VERSION ((uint64_t)0) #define WUFFS_VERSION_MAJOR ((uint64_t)0) #define WUFFS_VERSION_MINOR ((uint64_t)0) #define WUFFS_VERSION_PATCH ((uint64_t)0) -#define WUFFS_VERSION_EXTENSION "" -#define WUFFS_VERSION_STRING "0.0.0" -#define WUFFS_VERSION_GIT_REV_LIST_COUNT 0 +#define WUFFS_VERSION_PRE_RELEASE_LABEL "work.in.progress" +#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 0 +#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 0 +#define WUFFS_VERSION_STRING "0.0.0+0.00000000" // Define WUFFS_CONFIG__STATIC_FUNCTIONS to make all of Wuffs' functions have // static storage. The motivation is discussed in the "ALLOW STATIC