react-native-macos/ReactCommon/cxxreact/ReactNativeVersion.h

25 строки
499 B
C
Исходник Обычный вид История

Stamp React Native Version Into C++ Code (#28036) Summary: The PlatformConstants native module exposes the ability to query the React Native version used to build native code. This is managed on iOS and Android by a version bumping script, which replaces module code based on a template. It is currently difficult to accurately determine this version for out-of-tree C++ platforms (I.e. React Native Windows). The version of upstream react-native we resolve to is ultimately dependent on the version of react-native chosen a peer dependency, which is not neccesarily constant given a build of react-native-windows. We could try to hack around this, and make our native build try to reason about the resolved pacakge for react-native using a lockfile, but a much cleaner solution is to embed version into C++ code, similar to what is done for Android and iOS. This change does that, adding a header with React Native version and updating the build stamping script to write to it. Usage sample: ```c++ constants["reactNativeVersion"] = folly::dynamic::object(); constants["reactNativeVersion"]["major"] = ReactNativeVersion.Major; constants["reactNativeVersion"]["minor"] = ReactNativeVersion.Minor; constants["reactNativeVersion"]["patch"] = ReactNativeVersion.Patch; ``` ## Changelog [General] [Added] - Stamp React Native Version Into C++ Code Pull Request resolved: https://github.com/facebook/react-native/pull/28036 Test Plan: Validated that the bumping script will accurately update the header, can compile under both MSVC and Clang. Differential Revision: D19865992 Pulled By: hramos fbshipit-source-id: 9e0b8e9519015bb62c60b9935a234cd367a1926a
2020-02-27 17:38:53 +03:00
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
Stamp React Native Version Into C++ Code (#28036) Summary: The PlatformConstants native module exposes the ability to query the React Native version used to build native code. This is managed on iOS and Android by a version bumping script, which replaces module code based on a template. It is currently difficult to accurately determine this version for out-of-tree C++ platforms (I.e. React Native Windows). The version of upstream react-native we resolve to is ultimately dependent on the version of react-native chosen a peer dependency, which is not neccesarily constant given a build of react-native-windows. We could try to hack around this, and make our native build try to reason about the resolved pacakge for react-native using a lockfile, but a much cleaner solution is to embed version into C++ code, similar to what is done for Android and iOS. This change does that, adding a header with React Native version and updating the build stamping script to write to it. Usage sample: ```c++ constants["reactNativeVersion"] = folly::dynamic::object(); constants["reactNativeVersion"]["major"] = ReactNativeVersion.Major; constants["reactNativeVersion"]["minor"] = ReactNativeVersion.Minor; constants["reactNativeVersion"]["patch"] = ReactNativeVersion.Patch; ``` ## Changelog [General] [Added] - Stamp React Native Version Into C++ Code Pull Request resolved: https://github.com/facebook/react-native/pull/28036 Test Plan: Validated that the bumping script will accurately update the header, can compile under both MSVC and Clang. Differential Revision: D19865992 Pulled By: hramos fbshipit-source-id: 9e0b8e9519015bb62c60b9935a234cd367a1926a
2020-02-27 17:38:53 +03:00
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated by scripts/set-rn-version.js
Stamp React Native Version Into C++ Code (#28036) Summary: The PlatformConstants native module exposes the ability to query the React Native version used to build native code. This is managed on iOS and Android by a version bumping script, which replaces module code based on a template. It is currently difficult to accurately determine this version for out-of-tree C++ platforms (I.e. React Native Windows). The version of upstream react-native we resolve to is ultimately dependent on the version of react-native chosen a peer dependency, which is not neccesarily constant given a build of react-native-windows. We could try to hack around this, and make our native build try to reason about the resolved pacakge for react-native using a lockfile, but a much cleaner solution is to embed version into C++ code, similar to what is done for Android and iOS. This change does that, adding a header with React Native version and updating the build stamping script to write to it. Usage sample: ```c++ constants["reactNativeVersion"] = folly::dynamic::object(); constants["reactNativeVersion"]["major"] = ReactNativeVersion.Major; constants["reactNativeVersion"]["minor"] = ReactNativeVersion.Minor; constants["reactNativeVersion"]["patch"] = ReactNativeVersion.Patch; ``` ## Changelog [General] [Added] - Stamp React Native Version Into C++ Code Pull Request resolved: https://github.com/facebook/react-native/pull/28036 Test Plan: Validated that the bumping script will accurately update the header, can compile under both MSVC and Clang. Differential Revision: D19865992 Pulled By: hramos fbshipit-source-id: 9e0b8e9519015bb62c60b9935a234cd367a1926a
2020-02-27 17:38:53 +03:00
*/
#pragma once
#include <cstdint>
#include <string_view>
namespace facebook::react {
constexpr struct {
int32_t Major = 1000;
Stamp React Native Version Into C++ Code (#28036) Summary: The PlatformConstants native module exposes the ability to query the React Native version used to build native code. This is managed on iOS and Android by a version bumping script, which replaces module code based on a template. It is currently difficult to accurately determine this version for out-of-tree C++ platforms (I.e. React Native Windows). The version of upstream react-native we resolve to is ultimately dependent on the version of react-native chosen a peer dependency, which is not neccesarily constant given a build of react-native-windows. We could try to hack around this, and make our native build try to reason about the resolved pacakge for react-native using a lockfile, but a much cleaner solution is to embed version into C++ code, similar to what is done for Android and iOS. This change does that, adding a header with React Native version and updating the build stamping script to write to it. Usage sample: ```c++ constants["reactNativeVersion"] = folly::dynamic::object(); constants["reactNativeVersion"]["major"] = ReactNativeVersion.Major; constants["reactNativeVersion"]["minor"] = ReactNativeVersion.Minor; constants["reactNativeVersion"]["patch"] = ReactNativeVersion.Patch; ``` ## Changelog [General] [Added] - Stamp React Native Version Into C++ Code Pull Request resolved: https://github.com/facebook/react-native/pull/28036 Test Plan: Validated that the bumping script will accurately update the header, can compile under both MSVC and Clang. Differential Revision: D19865992 Pulled By: hramos fbshipit-source-id: 9e0b8e9519015bb62c60b9935a234cd367a1926a
2020-02-27 17:38:53 +03:00
int32_t Minor = 0;
int32_t Patch = 0;
std::string_view Prerelease = "";
} ReactNativeVersion;
} // namespace facebook::react