Commit d1c56da1 authored by Janne Grunau's avatar Janne Grunau

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.
parent 8e80f57c
......@@ -38,6 +38,7 @@ extern "C" {
#include "common.h"
#include "picture.h"
#include "data.h"
#include "dav1d/version.h"
typedef struct Dav1dContext Dav1dContext;
typedef struct Dav1dRef Dav1dRef;
......@@ -72,6 +73,16 @@ typedef struct Dav1dSettings {
*/
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.
*
......
# 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')
/*
* 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 */
......@@ -22,16 +22,15 @@
# (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,
'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')
/* auto-generated, do not edit */
#define DAV1D_VERSION "@VCS_TAG@"
#define DAV1D_VERSION_VCS "@VCS_TAG@"
......@@ -26,7 +26,7 @@
*/
#include "config.h"
#include "version.h"
#include "vcs_version.h"
#include <errno.h>
#include <string.h>
......@@ -56,6 +56,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) {
s->n_frame_threads = 1;
s->n_tile_threads = 1;
......
......@@ -172,7 +172,7 @@ endif
# 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],
......
......@@ -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 @@ int main(const int argc, char *const *const argv) {
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 @@ int main(const int argc, char *const *const argv) {
}
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) {
......
......@@ -263,7 +263,7 @@ void parse(const int argc, char *const *const argv,
!!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,
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment