Skip to content

Commit dbee74d

Browse files
coadofacebook-github-bot
authored andcommitted
Set hermes release version (facebook#1791)
Summary: This diff sets version in `CMakeLists.txt` to `1.0.0` and configures build to pass `-DHERMES_RELEASE_VERSION=for RN ${hermesReleaseVersion}` where `hermesReleaseVersion` is of type `<date>.0.0`. Differential Revision: D82313203
1 parent 5b91d78 commit dbee74d

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ endif()
6565
# - npm/package.json
6666
# - hermes-engine.podspec
6767
project(Hermes
68-
VERSION 0.12.0
68+
VERSION 1.0.0
6969
LANGUAGES C CXX)
7070

7171
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")

android/build-logic/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
plugins { `kotlin-dsl` }
8+
plugins {
9+
`kotlin-dsl`
10+
kotlin("plugin.serialization") version "2.2.0"
11+
}
12+
13+
dependencies { implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0") }
914

1015
repositories {
1116
mavenCentral()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.hermes.helpers.internal
9+
10+
import java.io.File
11+
import kotlinx.serialization.*
12+
import kotlinx.serialization.json.*
13+
import org.gradle.api.Project
14+
15+
@Serializable @JsonIgnoreUnknownKeys data class PackageJson(val version: String)
16+
17+
class SerializeHermesCompilerPackageJson(project: Project) {
18+
private val serializedPackageJson = run {
19+
val packageJsonFile = File(project.rootDir.parentFile, "npm/hermes-compiler/package.json")
20+
if (!packageJsonFile.exists()) {
21+
throw IllegalStateException("package.json file not found at $packageJsonFile")
22+
}
23+
Json.decodeFromString<PackageJson>(packageJsonFile.readText())
24+
}
25+
26+
val hermesReleaseVersion = serializedPackageJson.version
27+
}

android/build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
import com.facebook.hermes.helpers.internal.SerializeHermesCompilerPackageJson
89
import com.facebook.hermes.tasks.internal.CustomExecTask
910
import org.apache.tools.ant.taskdefs.condition.Os
1011

@@ -21,6 +22,8 @@ group = "com.facebook.hermes"
2122

2223
version = project.findProperty("VERSION_NAME")?.toString()!!
2324

25+
val hermesReleaseVersion = SerializeHermesCompilerPackageJson(project).hermesReleaseVersion
26+
2427
val cmakeVersion = System.getenv("CMAKE_VERSION") ?: libs.versions.cmake.get()
2528
val cmakePath = "${getSDKPath()}/cmake/$cmakeVersion"
2629
val cmakeBinaryPath = "${cmakePath}/bin/cmake"
@@ -222,7 +225,7 @@ android {
222225
"-DIMPORT_HOST_COMPILERS=${File(hermesBuildDir, "ImportHostCompilers.cmake").toString()}",
223226
"-DJSI_DIR=${jsiDir}",
224227
"-DHERMES_BUILD_SHARED_JSI=True",
225-
// "-DHERMES_RELEASE_VERSION=for RN ${version}",
228+
"-DHERMES_RELEASE_VERSION=for RN ${hermesReleaseVersion}",
226229
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True",
227230
// We intentionally build Hermes with Intl support only. This is to simplify
228231
// the build setup and to avoid overcomplicating the build-type matrix.

utils/build-apple-framework-rn.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ IMPORT_HERMESC_PATH=${HERMES_OVERRIDE_HERMESC_PATH:-$PWD/build_host_hermesc/Impo
1313
BUILD_TYPE=${BUILD_TYPE:-Debug}
1414

1515
HERMES_PATH="$CURR_SCRIPT_DIR/.."
16+
HERMES_COMPILER_PACKAGE_PATH="$HERMES_PATH/npm/hermes-compiler"
1617

1718
NUM_CORES=$(sysctl -n hw.ncpu)
1819

@@ -43,6 +44,24 @@ function get_mac_deployment_target {
4344
use_env_var "${MAC_DEPLOYMENT_TARGET}" "MAC_DEPLOYMENT_TARGET"
4445
}
4546

47+
function get_release_version {
48+
local package_json_path="$HERMES_COMPILER_PACKAGE_PATH/package.json"
49+
if [[ -f "$package_json_path" ]]; then
50+
local version
51+
version=$(node -e "console.log(JSON.parse(require('fs').readFileSync('$package_json_path', 'utf8')).version)" 2>/dev/null)
52+
if [[ -n "$version" ]]; then
53+
echo "$version"
54+
return
55+
else
56+
echo >&2 "Error: Failed to read version from $package_json_path"
57+
exit 1
58+
fi
59+
else
60+
echo >&2 "Error: Package file not found at $package_json_path"
61+
exit 1
62+
fi
63+
}
64+
4665
# Build host hermes compiler for internal bytecode
4766
function build_host_hermesc {
4867
echo "Building hermesc"
@@ -98,6 +117,7 @@ function configure_apple_framework {
98117
-DCMAKE_C_FLAGS:STRING="-gdwarf" \
99118
-DIMPORT_HOST_COMPILERS:PATH="$IMPORT_HERMESC_PATH" \
100119
-DJSI_DIR="$JSI_PATH" \
120+
-DHERMES_RELEASE_VERSION="for RN $(get_release_version)" \
101121
-DCMAKE_BUILD_TYPE="$cmake_build_type" \
102122
$boost_context_flag
103123
popd > /dev/null || exit 1

0 commit comments

Comments
 (0)