Support API versioning in platform-specific headers (see #3836)

- Exclude platform-specific includes (anything in < >) from the
  clang preprocessor by using `!defined(GENERATING_CEF_API_HASH)`
  in CEF header files.
- Define "target platforms" by passing platform- and architecture-
  specific ifdefs to the clang preprocessor. Grep for `defined(OS_`
  to identify headers that require target platform processing, and
  then process for each target as the platform-specific API hash
  contribution.
- Delete the univeral hash which is no longer a useful concept.
This commit is contained in:
Nik Pavlov
2025-02-25 11:43:44 -05:00
committed by Marshall Greenblatt
parent 8ddb1bffbb
commit fdd36e8461
22 changed files with 922 additions and 550 deletions

View File

@@ -77,19 +77,15 @@
#endif
#endif
#define _CEF_AH_PASTE(a, b, c) a##_##b##_##c
#define _CEF_AH_EVAL(a, b, c) _CEF_AH_PASTE(a, b, c)
#define _CEF_AH_DECLARE(version, suffix) \
_CEF_AH_EVAL(CEF_API_HASH, version, suffix)
#define _CEF_AH_PASTE(a, b) a##_##b
#define _CEF_AH_EVAL(a, b) _CEF_AH_PASTE(a, b)
#define _CEF_AH_DECLARE(version) _CEF_AH_EVAL(CEF_API_HASH, version)
// API hashes for the selected CEF_API_VERSION. API hashes are created for
// each version by analyzing CEF header files for C API type definitions. The
// hash value will change when header files are modified in a way that may
// cause binary incompatibility with other builds. The universal hash value
// will change if any platform is affected whereas the platform hash values
// will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL _CEF_AH_DECLARE(CEF_API_VERSION, UNIVERSAL)
#define CEF_API_HASH_PLATFORM _CEF_AH_DECLARE(CEF_API_VERSION, PLATFORM)
// cause binary incompatibility with other builds.
#define CEF_API_HASH_PLATFORM _CEF_AH_DECLARE(CEF_API_VERSION)
#if defined(BUILDING_CEF_SHARED)
@@ -132,7 +128,7 @@ extern "C" {
/// parameter describes which hash value will be returned:
///
/// 0 - CEF_API_HASH_PLATFORM
/// 1 - CEF_API_HASH_UNIVERSAL
/// 1 - CEF_API_HASH_UNIVERSAL (deprecated, same as CEF_API_HASH_PLATFORM)
/// 2 - CEF_COMMIT_HASH (from cef_version.h)
///
CEF_EXPORT const char* cef_api_hash(int version, int entry);

View File

@@ -31,8 +31,11 @@
#define CEF_INCLUDE_CEF_BASE_H_
#pragma once
#include "include/base/cef_atomic_ref_count.h"
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#include "include/base/cef_atomic_ref_count.h"
#include "include/base/cef_macros.h"
// Bring in common C++ type definitions used by CEF consumers.

View File

@@ -31,7 +31,10 @@
#define CEF_INCLUDE_CEF_SANDBOX_MAC_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#include "include/internal/cef_export.h"
#if defined(OS_MAC)

View File

@@ -31,7 +31,9 @@
#define CEF_INCLUDE_CEF_SANDBOX_WIN_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#if defined(OS_WIN)

View File

@@ -31,7 +31,9 @@
#define CEF_INCLUDE_INTERNAL_CEF_APP_WIN_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#if defined(OS_WIN)

View File

@@ -32,7 +32,9 @@
#define CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#if defined(COMPILER_MSVC)

View File

@@ -31,12 +31,14 @@
#define CEF_INCLUDE_INTERNAL_CEF_THREAD_INTERNAL_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#if defined(OS_WIN)
#include <windows.h>
#elif defined(OS_POSIX)
#include <pthread.h>
#include <unistd.h>
#endif
#endif
#include "include/internal/cef_export.h"

View File

@@ -35,8 +35,11 @@
extern "C" {
#endif
#include <stdint.h>
#if !defined(GENERATING_CEF_API_HASH)
#include <time.h>
#endif
#include <stdint.h>
#include "include/internal/cef_export.h"

View File

@@ -31,15 +31,12 @@
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#if defined(OS_LINUX)
#if defined(CEF_X11)
typedef union _XEvent XEvent;
typedef struct _XDisplay XDisplay;
#endif
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
#include "include/internal/cef_types_color.h"
@@ -47,17 +44,6 @@ typedef struct _XDisplay XDisplay;
#include "include/internal/cef_types_osr.h"
#include "include/internal/cef_types_runtime.h"
// Handle types.
#if defined(CEF_X11)
#define cef_cursor_handle_t unsigned long
#define cef_event_handle_t XEvent*
#else
#define cef_cursor_handle_t void*
#define cef_event_handle_t void*
#endif
#define cef_window_handle_t unsigned long
#define kNullCursorHandle 0
#define kNullEventHandle NULL
#define kNullWindowHandle 0
@@ -66,6 +52,20 @@ typedef struct _XDisplay XDisplay;
extern "C" {
#endif
#if defined(CEF_X11)
typedef union _XEvent XEvent;
typedef struct _XDisplay XDisplay;
// Handle types.
typedef unsigned long cef_cursor_handle_t;
typedef XEvent* cef_event_handle_t;
#else
typedef void* cef_cursor_handle_t;
typedef void* cef_event_handle_t;
#endif
typedef unsigned long cef_window_handle_t;
///
/// Return the singleton X11 display shared with Chromium. The display is not
/// thread-safe and must only be accessed on the browser process UI thread.

View File

@@ -31,7 +31,9 @@
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#if defined(OS_MAC)
#include "include/internal/cef_string.h"
@@ -40,16 +42,6 @@
#include "include/internal/cef_types_osr.h"
#include "include/internal/cef_types_runtime.h"
// Handle types.
// Actually NSCursor*
#define cef_cursor_handle_t void*
// Acutally NSEvent*
#define cef_event_handle_t void*
// Actually NSView*
#define cef_window_handle_t void*
// Actually IOSurface*
#define cef_shared_texture_handle_t void*
#define kNullCursorHandle NULL
#define kNullEventHandle NULL
#define kNullWindowHandle NULL
@@ -78,6 +70,16 @@
extern "C" {
#endif
// Handle types.
// Actually NSCursor*
typedef void* cef_cursor_handle_t;
// Actually NSEvent*
typedef void* cef_event_handle_t;
// Actually NSView*
typedef void* cef_window_handle_t;
// Actually IOSurface*
typedef void* cef_shared_texture_handle_t;
///
/// Structure representing CefExecuteProcess arguments.
///

View File

@@ -31,10 +31,15 @@
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_
#pragma once
#if !defined(GENERATING_CEF_API_HASH)
#include "include/base/cef_build.h"
#endif
#if defined(OS_WIN)
#if !defined(GENERATING_CEF_API_HASH)
#include <windows.h>
#endif
#include "include/internal/cef_string.h"
#include "include/internal/cef_types_color.h"
@@ -42,12 +47,6 @@
#include "include/internal/cef_types_osr.h"
#include "include/internal/cef_types_runtime.h"
// Handle types.
#define cef_cursor_handle_t HCURSOR
#define cef_event_handle_t MSG*
#define cef_window_handle_t HWND
#define cef_shared_texture_handle_t HANDLE
#define kNullCursorHandle NULL
#define kNullEventHandle NULL
#define kNullWindowHandle NULL
@@ -56,6 +55,12 @@
extern "C" {
#endif
// Handle types.
typedef HCURSOR cef_cursor_handle_t;
typedef MSG* cef_event_handle_t;
typedef HWND cef_window_handle_t;
typedef HANDLE cef_shared_texture_handle_t;
///
/// Structure representing CefExecuteProcess arguments.
///