[FFmpeg-devel] [PATCH] Keep including the full version.h when headers are included externally

Martin Storsjö martin at martin.st
Fri Mar 18 10:15:21 EET 2022


This avoids unnecessary churn and build breakage for users, by
making sure the whole version.h is included like it has been so far,
while keeping the benefit of not needing to rebuild most files in
the ffmpeg tree on minor/micro bumps.
---
Surprisingly many downstream users do seem to rely on the version
defines.
---
 doc/APIchanges             | 9 ++-------
 libavcodec/avcodec.h       | 6 ++++++
 libavdevice/avdevice.h     | 6 ++++++
 libavfilter/avfilter.h     | 6 ++++++
 libavformat/avformat.h     | 6 ++++++
 libpostproc/postprocess.h  | 6 ++++++
 libswresample/swresample.h | 6 ++++++
 libswscale/swscale.h       | 6 ++++++
 8 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 7b324f48fa..41662da84f 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,15 +14,10 @@ libavutil:     2021-04-27
 
 API changes, most recent first:
 
-2022-03-16 - xxxxxxxxxx - all libraries - version.h, version_major.h
-  No longer implicitly include lib<name>/version.h in lib<name>/<name>.h.
-  Users who depend on defines from these files (LIB<name>_VERSION*,
-  LIB<name>_IDENT) must explicitly include these headers instead of
-  relying on them being included implicitly.
+2022-03-16 - xxxxxxxxxx - all libraries - version_major.h
   Add lib<name>/version_major.h as new installed headers, which only
   contain the major version number (and corresponding API deprecation
-  defines). These headers are still implicitly included from the
-  library main headers.
+  defines).
 
 2022-03-10 - xxxxxxxxxx - lavu 57.23.100 - cpu.h
   Add AV_CPU_FLAG_AVX512ICL.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index c6512f12c4..4dae23d06e 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -44,6 +44,12 @@
 #include "defs.h"
 #include "packet.h"
 #include "version_major.h"
+#ifndef HAVE_AV_CONFIG_H
+/* When included as part of the ffmpeg build, only include the major version
+ * to avoid unnecessary rebuilds. When included externally, keep including
+ * the full version information. */
+#include "version.h"
+#endif
 
 /**
  * @defgroup libavc libavcodec
diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
index 6de0e33819..0b32e59fed 100644
--- a/libavdevice/avdevice.h
+++ b/libavdevice/avdevice.h
@@ -20,6 +20,12 @@
 #define AVDEVICE_AVDEVICE_H
 
 #include "version_major.h"
+#ifndef HAVE_AV_CONFIG_H
+/* When included as part of the ffmpeg build, only include the major version
+ * to avoid unnecessary rebuilds. When included externally, keep including
+ * the full version information. */
+#include "version.h"
+#endif
 
 /**
  * @file
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 3fb41d777c..2e8197c9a6 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -48,6 +48,12 @@
 #include "libavutil/rational.h"
 
 #include "libavfilter/version_major.h"
+#ifndef HAVE_AV_CONFIG_H
+/* When included as part of the ffmpeg build, only include the major version
+ * to avoid unnecessary rebuilds. When included externally, keep including
+ * the full version information. */
+#include "libavfilter/version.h"
+#endif
 
 /**
  * Return the LIBAVFILTER_VERSION_INT constant.
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 03df76af92..f12fa7d904 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -320,6 +320,12 @@
 
 #include "avio.h"
 #include "libavformat/version_major.h"
+#ifndef HAVE_AV_CONFIG_H
+/* When included as part of the ffmpeg build, only include the major version
+ * to avoid unnecessary rebuilds. When included externally, keep including
+ * the full version information. */
+#include "libavformat/version.h"
+#endif
 
 struct AVFormatContext;
 struct AVStream;
diff --git a/libpostproc/postprocess.h b/libpostproc/postprocess.h
index cf4e78c83a..5decb7e8a9 100644
--- a/libpostproc/postprocess.h
+++ b/libpostproc/postprocess.h
@@ -35,6 +35,12 @@
  */
 
 #include "libpostproc/version_major.h"
+#ifndef HAVE_AV_CONFIG_H
+/* When included as part of the ffmpeg build, only include the major version
+ * to avoid unnecessary rebuilds. When included externally, keep including
+ * the full version information. */
+#include "libpostproc/version.h"
+#endif
 
 /**
  * Return the LIBPOSTPROC_VERSION_INT constant.
diff --git a/libswresample/swresample.h b/libswresample/swresample.h
index 2c4eb3562d..26d42fab8d 100644
--- a/libswresample/swresample.h
+++ b/libswresample/swresample.h
@@ -126,6 +126,12 @@
 #include "libavutil/samplefmt.h"
 
 #include "libswresample/version_major.h"
+#ifndef HAVE_AV_CONFIG_H
+/* When included as part of the ffmpeg build, only include the major version
+ * to avoid unnecessary rebuilds. When included externally, keep including
+ * the full version information. */
+#include "libswresample/version.h"
+#endif
 
 /**
  * @name Option constants
diff --git a/libswscale/swscale.h b/libswscale/swscale.h
index 07c69e1ae7..3ebf7c698d 100644
--- a/libswscale/swscale.h
+++ b/libswscale/swscale.h
@@ -34,6 +34,12 @@
 #include "libavutil/log.h"
 #include "libavutil/pixfmt.h"
 #include "version_major.h"
+#ifndef HAVE_AV_CONFIG_H
+/* When included as part of the ffmpeg build, only include the major version
+ * to avoid unnecessary rebuilds. When included externally, keep including
+ * the full version information. */
+#include "version.h"
+#endif
 
 /**
  * @defgroup libsws libswscale
-- 
2.32.0 (Apple Git-132)



More information about the ffmpeg-devel mailing list