From 9215e15d91208248b815465f03c19c1e72d281fa Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Wed, 10 Aug 2022 09:23:09 -0700 Subject: [PATCH] Add FLUTTER_DEPRECATED macro and flutter_macros.h (flutter/engine#35293) Adds a new header, flutter_macros.h which includes a FLUTTER_DEPRECATED macro that can be used to mark deprecated API as such, with a hopefully-informative message, ideally describing the expected removal version and any migration tips. This will need to be #included in flutter_windows.h and flutter_linux.h, but prior to doing so, we'll need to update the engine recipe to bundle the new header, here: https://flutter.googlesource.com/recipes/+/refs/heads/main/recipes/engine/engine.py#1457 No tests since this adds a compiler macro that will be used for future C/C++ API deprecation once the above recipe change has landed; specifically: FlutterDesktopEngineProcessMessages. Related: https://github.com/flutter/flutter/issues/93537 --- .../ci/licenses_golden/licenses_flutter | 1 + .../flutter/shell/platform/common/BUILD.gn | 1 + .../platform/common/public/flutter_macros.h | 24 +++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 engine/src/flutter/shell/platform/common/public/flutter_macros.h diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index 8386fee41b0..aa5c6a0a1cf 100644 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -1675,6 +1675,7 @@ FILE: ../../../flutter/shell/platform/common/path_utils.h FILE: ../../../flutter/shell/platform/common/path_utils_unittests.cc FILE: ../../../flutter/shell/platform/common/platform_provided_menu.h FILE: ../../../flutter/shell/platform/common/public/flutter_export.h +FILE: ../../../flutter/shell/platform/common/public/flutter_macros.h FILE: ../../../flutter/shell/platform/common/public/flutter_messenger.h FILE: ../../../flutter/shell/platform/common/public/flutter_plugin_registrar.h FILE: ../../../flutter/shell/platform/common/public/flutter_texture_registrar.h diff --git a/engine/src/flutter/shell/platform/common/BUILD.gn b/engine/src/flutter/shell/platform/common/BUILD.gn index 24d450cdb94..571ee50765d 100644 --- a/engine/src/flutter/shell/platform/common/BUILD.gn +++ b/engine/src/flutter/shell/platform/common/BUILD.gn @@ -11,6 +11,7 @@ config("desktop_library_implementation") { _public_headers = [ "public/flutter_export.h", + "public/flutter_macros.h", "public/flutter_messenger.h", "public/flutter_plugin_registrar.h", "public/flutter_texture_registrar.h", diff --git a/engine/src/flutter/shell/platform/common/public/flutter_macros.h b/engine/src/flutter/shell/platform/common/public/flutter_macros.h new file mode 100644 index 00000000000..7b60cb488b0 --- /dev/null +++ b/engine/src/flutter/shell/platform/common/public/flutter_macros.h @@ -0,0 +1,24 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_MACROS_H_ +#define FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_MACROS_H_ + +#ifdef FLUTTER_DESKTOP_LIBRARY + +// Do not add deprecation annotations when building the library. +#define FLUTTER_DEPRECATED(message) + +#else // FLUTTER_DESKTOP_LIBRARY + +// Add deprecation warning for users of the library. +#ifdef _WIN32 +#define FLUTTER_DEPRECATED(message) __declspec(deprecated(message)) +#else +#define FLUTTER_DEPRECATED(message) __attribute__((deprecated(message))) +#endif + +#endif // FLUTTER_DESKTOP_LIBRARY + +#endif // FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_MACROS_H_