shithub: dav1d

Download patch

ref: d1c56da1d1c65767924d6752e802380409a38d17
parent: 8e80f57c112e21f757e09401f566c89d424a31d6
author: Janne Grunau <janne-vlc@jannau.net>
date: Tue Feb 5 19:32:56 EST 2019

build: generate a installed version header for semantic versioning

Renames the current version function and define to dav1d_version_vcs()
and DAV1D_VERSION_VCS. Fixes #241.
The generated version.h is included as "dav1d/version.h" to avoid errors
with a stale include/version.h in a build dir.

--- a/include/dav1d/dav1d.h
+++ b/include/dav1d/dav1d.h
@@ -38,6 +38,7 @@
 #include "common.h"
 #include "picture.h"
 #include "data.h"
+#include "dav1d/version.h"
 
 typedef struct Dav1dContext Dav1dContext;
 typedef struct Dav1dRef Dav1dRef;
@@ -71,6 +72,16 @@
  * Get library version.
  */
 DAV1D_API const char *dav1d_version(void);
+
+/**
+ * Get library version based on version control system.
+ */
+DAV1D_API const char *dav1d_version_vcs(void);
+
+/**
+ * Get library version as unsigned int.
+ */
+DAV1D_API unsigned int dav1d_version_int(void);
 
 /**
  * Initialize settings to default values.
--- /dev/null
+++ b/include/dav1d/meson.build
@@ -1,0 +1,41 @@
+# Copyright © 2019, VideoLAN and dav1d authors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this
+#    list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+#    this list of conditions and the following disclaimer in the documentation
+#    and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# installed version.h header generation
+version_h_data = configuration_data()
+version_h_data.set('DAV1D_VERSION_MAJOR', dav1d_version_major)
+version_h_data.set('DAV1D_VERSION_MINOR', dav1d_version_minor)
+version_h_data.set('DAV1D_VERSION_PATCH', dav1d_version_revision)
+version_h_target = configure_file(input: 'version.h.in',
+                                  output: 'version.h',
+                                  configuration: version_h_data)
+
+# install headers
+install_headers('common.h',
+                'data.h',
+                'dav1d.h',
+                'headers.h',
+                'picture.h',
+                version_h_target,
+                subdir : 'dav1d')
--- /dev/null
+++ b/include/dav1d/version.h.in
@@ -1,0 +1,38 @@
+/*
+ * Copyright © 2019, VideoLAN and dav1d authors
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ *    list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DAV1D_VERSION_H
+#define DAV1D_VERSION_H
+
+#define DAV1D_VERSION_MAJOR @DAV1D_VERSION_MAJOR@
+#define DAV1D_VERSION_MINOR @DAV1D_VERSION_MINOR@
+#define DAV1D_VERSION_PATCH @DAV1D_VERSION_PATCH@
+
+#define DAV1D_VERSION "@DAV1D_VERSION_MAJOR@.@DAV1D_VERSION_MINOR@.@DAV1D_VERSION_PATCH@"
+
+#define DAV1D_VERSION_INT (@DAV1D_VERSION_MAJOR@ << 16 | @DAV1D_VERSION_MINOR@ << 8 | @DAV1D_VERSION_PATCH@)
+
+#endif /* DAV1D_VERSION_H */
--- a/include/meson.build
+++ b/include/meson.build
@@ -22,7 +22,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-# Revision file (version.h) generation
+# Revision file (vcs_version.h) generation
 dav1d_git_dir = join_paths(dav1d_src_root, '.git')
 rev_target = vcs_tag(command: [
         'git', '--git-dir', dav1d_git_dir,
@@ -29,9 +29,8 @@
         'describe', '--tags', '--long',
         '--match', '?.*.*', '--always'
     ],
-    input: 'version.h.in',
-    output: 'version.h'
+    input: 'vcs_version.h.in',
+    output: 'vcs_version.h'
 )
 
-# Install include/dav1d headers
-install_subdir('dav1d', install_dir: get_option('includedir'))
+subdir('dav1d')
--- /dev/null
+++ b/include/vcs_version.h.in
@@ -1,0 +1,2 @@
+/* auto-generated, do not edit */
+#define DAV1D_VERSION_VCS "@VCS_TAG@"
--- a/include/version.h.in
+++ /dev/null
@@ -1,2 +1,0 @@
-/* auto-generated, do not edit */
-#define DAV1D_VERSION "@VCS_TAG@"
--- a/src/lib.c
+++ b/src/lib.c
@@ -26,7 +26,7 @@
  */
 
 #include "config.h"
-#include "version.h"
+#include "vcs_version.h"
 
 #include <errno.h>
 #include <string.h>
@@ -54,6 +54,14 @@
 
 const char *dav1d_version(void) {
     return DAV1D_VERSION;
+}
+
+const char *dav1d_version_vcs(void) {
+    return DAV1D_VERSION_VCS;
+}
+
+unsigned int dav1d_version_int(void) {
+    return DAV1D_VERSION_INT;
 }
 
 void dav1d_default_settings(Dav1dSettings *const s) {
--- a/src/meson.build
+++ b/src/meson.build
@@ -172,7 +172,7 @@
 # Helper library for dav1d entrypoints
 libdav1d_entrypoints_objs = static_library('dav1d_entrypoint',
     libdav1d_entrypoints_sources,
-    rev_target,
+    rev_target, config_h_target,
 
     include_directories : dav1d_inc_dirs,
     dependencies: [stdatomic_dependency],
--- a/tools/dav1d.c
+++ b/tools/dav1d.c
@@ -26,7 +26,7 @@
  */
 
 #include "config.h"
-#include "version.h"
+#include "vcs_version.h"
 
 #include <assert.h>
 #include <errno.h>
@@ -40,7 +40,7 @@
 # include <io.h>
 #endif
 
-#include "dav1d/data.h"
+#include "dav1d/dav1d.h"
 
 #include "input/input.h"
 
@@ -73,11 +73,11 @@
     Dav1dContext *c;
     Dav1dData data;
     unsigned n_out = 0, total, fps[2];
-    const char *version = dav1d_version();
+    const char *version = dav1d_version_vcs();
 
-    if (strcmp(version, DAV1D_VERSION)) {
+    if (strcmp(version, DAV1D_VERSION_VCS)) {
         fprintf(stderr, "Version mismatch (library: %s, executable: %s)\n",
-                version, DAV1D_VERSION);
+                version, DAV1D_VERSION_VCS);
         return -1;
     }
 
@@ -100,7 +100,7 @@
     }
 
     if (!cli_settings.quiet)
-        fprintf(stderr, "dav1d %s - by VideoLAN\n", DAV1D_VERSION);
+        fprintf(stderr, "dav1d %s - by VideoLAN\n", dav1d_version_vcs());
 
     // skip frames until a sequence header is found
     if (cli_settings.skip) {
--- a/tools/dav1d_cli_parse.c
+++ b/tools/dav1d_cli_parse.c
@@ -263,7 +263,7 @@
                 !!parse_unsigned(optarg, ARG_ALL_LAYERS, argv[0]);
             break;
         case 'v':
-            fprintf(stderr, "%s\n", dav1d_version());
+            fprintf(stderr, "%s\n", dav1d_version_vcs());
             exit(0);
         case ARG_CPU_MASK:
             dav1d_set_cpu_flags_mask(parse_enum(optarg, cpu_mask_tbl,
--- a/tools/dav1d_cli_parse.h
+++ b/tools/dav1d_cli_parse.h
@@ -28,7 +28,7 @@
 #ifndef DAV1D_CLI_PARSE_H
 #define DAV1D_CLI_PARSE_H
 
-#include "dav1d.h"
+#include "dav1d/dav1d.h"
 
 typedef struct {
     const char *outputfile;