Skip to content

Commit b010e05

Browse files
committed
feat: add prefab support
1 parent 4a89838 commit b010e05

File tree

12 files changed

+161
-84
lines changed

12 files changed

+161
-84
lines changed

.github/workflows/build_and_test.yml

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12+
env:
13+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }}
14+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGNING_PASSWORD }}
1215

1316
steps:
1417
- uses: actions/checkout@v4

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package-lock.json
2020
bin/
2121
gen/
2222
out/
23+
.cxx/
2324

2425
# Gradle files
2526
.gradle/

lib/android-jsc/build.gradle

-65
This file was deleted.

lib/cppruntime/build.gradle

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ apply plugin: 'maven-publish'
33

44
def distDir = project.findProperty("distDir") ?: ""
55
def jniLibsDir = project.findProperty("jniLibsDir") ?: ""
6-
def revision = project.findProperty("revision") ?: "".replaceAll("\\s", "")
6+
def version = project.findProperty("version") ?: "".replaceAll("\\s", "")
77

88
if (!distDir) throw new RuntimeException("expecting --project-prop distDir=??? but was empty")
99
if (!jniLibsDir) throw new RuntimeException("expecting --project-prop jniLibsDir=??? but was empty")
10-
if (!revision) throw new RuntimeException("expecting --project-prop revision=??? but was empty")
10+
if (!version) throw new RuntimeException("expecting --project-prop version=??? but was empty")
1111

1212
android {
13-
namespace 'org.webkit.androidjsc_cppruntime'
13+
namespace 'io.github.react_native_community.jscandroid_cppruntime'
1414
compileSdkVersion 35
1515

1616
defaultConfig {
@@ -34,17 +34,17 @@ android {
3434

3535
dependencies {}
3636

37-
project.group = "org.webkit"
38-
project.version = "r${revision}"
37+
project.group = "io.github.react-native-community"
38+
project.version = "${version}"
3939

4040
afterEvaluate {
4141
publishing {
4242
publications {
4343
release(MavenPublication) {
4444
from components.release
4545
pom {
46-
name = "android-jsc"
47-
artifactId = "android-jsc-cppruntime"
46+
name = "jsc-android"
47+
artifactId = "jsc-android-cppruntime"
4848
packaging = "aar"
4949
}
5050
}
File renamed without changes.

lib/jsc-android/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
set(CMAKE_VERBOSE_MAKEFILE on)
3+
project(jsc-android)
4+
5+
add_library(jsclib SHARED IMPORTED GLOBAL)
6+
7+
set_target_properties(jsclib
8+
PROPERTIES
9+
IMPORTED_LOCATION
10+
"${PREBUILT_LIBS_DIR}/${ANDROID_ABI}/libjsc.so")
11+
12+
add_library(jsc SHARED empty.cpp)

lib/jsc-android/build.gradle

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'maven-publish'
3+
apply plugin: 'signing'
4+
5+
def distDir = project.findProperty("distDir") ?: ""
6+
def jniLibsDir = project.findProperty("jniLibsDir") ?: ""
7+
def headersDir = project.findProperty("headersDir") ?: "${distDir}/include"
8+
def version = project.findProperty("version") ?: "".replaceAll("\\s", "")
9+
def i18n = project.findProperty("i18n") ?: ""
10+
11+
def signingKey = project.findProperty('signingKey')
12+
def signingPassword = project.findProperty('signingPassword')
13+
14+
if (!distDir) throw new RuntimeException("expecting --project-prop distDir=??? but was empty")
15+
if (!jniLibsDir) throw new RuntimeException("expecting --project-prop jniLibsDir=??? but was empty")
16+
if (!version) throw new RuntimeException("expecting --project-prop version=??? but was empty")
17+
if (!i18n) throw new RuntimeException("expecting --project-prop i18n=??? but was empty")
18+
19+
android {
20+
namespace 'io.github.react_native_community.jscandroid'
21+
compileSdkVersion 35
22+
23+
defaultConfig {
24+
minSdkVersion 24
25+
targetSdkVersion 34
26+
versionCode 1
27+
versionName "1.0"
28+
29+
externalNativeBuild {
30+
cmake {
31+
arguments '-DANDROID_STL=c++_shared',
32+
"-DPREBUILT_LIBS_DIR=${jniLibsDir}"
33+
targets 'jsc'
34+
}
35+
}
36+
}
37+
38+
externalNativeBuild {
39+
cmake {
40+
path 'CMakeLists.txt'
41+
}
42+
}
43+
44+
packagingOptions {
45+
doNotStrip '**/libjsc.so'
46+
pickFirst '**/libjsc.so'
47+
48+
excludes += [
49+
'**/libc++_shared.so',
50+
]
51+
}
52+
53+
buildFeatures {
54+
prefabPublishing true
55+
}
56+
57+
prefab {
58+
jsc {
59+
headerOnly true
60+
headers file(headersDir).absolutePath
61+
}
62+
}
63+
64+
publishing {
65+
singleVariant("release") {
66+
}
67+
}
68+
}
69+
70+
dependencies {}
71+
72+
project.group = "io.github.react-native-community"
73+
def artifactName = Boolean.valueOf(i18n) ? "jsc-android-intl" : "jsc-android"
74+
project.version = "${version}"
75+
76+
afterEvaluate {
77+
publishing {
78+
publications {
79+
release(MavenPublication) {
80+
from components.release
81+
pom {
82+
name = artifactName
83+
artifactId = artifactName
84+
description = 'Pre-build version of JavaScriptCore to be used by React Native apps'
85+
url = 'https://github.com/react-native-community/jsc-android-buildscripts'
86+
87+
developers {
88+
developer {
89+
id = 'react-native-community'
90+
name = 'React Native Community'
91+
}
92+
}
93+
94+
licenses {
95+
license {
96+
name = 'BSD-2-Clause'
97+
url = 'https://github.com/react-native-community/jsc-android-buildscripts/blob/main/LICENSE'
98+
distribution = 'repo'
99+
}
100+
}
101+
102+
scm {
103+
url = 'https://github.com/react-native-community/jsc-android-buildscripts.git'
104+
connection = 'scm:git:https://github.com/react-native-community/jsc-android-buildscripts.git'
105+
developerConnection = 'scm:git:[email protected]:react-native-community/jsc-android-buildscripts.git'
106+
}
107+
}
108+
}
109+
}
110+
111+
repositories {
112+
maven {
113+
url = "file://${distDir}"
114+
}
115+
}
116+
117+
if (signingKey && signingPassword) {
118+
signing {
119+
useInMemoryPgpKeys(signingKey, signingPassword)
120+
sign publishing.publications.release
121+
}
122+
}
123+
}
124+
}

lib/jsc-android/empty.cpp

Whitespace-only changes.

lib/settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
rootProject.name = 'JavaScriptCore Lib'
22

3-
include ':android-jsc'
3+
include ':jsc-android'
44
include ':cppruntime'

measure/android/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ext {
66
JSC_VERSION = jscAAR ? file(file(jscAAR).getParent()).getName() : ""
77

88
def i18nProp = project.findProperty("i18n")
9-
JSC_NAME = Boolean.valueOf(i18nProp) ? "android-jsc-intl" : "android-jsc"
9+
JSC_NAME = Boolean.valueOf(i18nProp) ? "jsc-android-intl" : "jsc-android"
1010

1111
isIDE = System.getProperties()['idea.platform.prefix'] != null
1212
}
@@ -18,7 +18,7 @@ if (!isIDE && JSC_VERSION) {
1818
configurations.all {
1919
resolutionStrategy {
2020
eachDependency { DependencyResolveDetails details ->
21-
if (details.requested.name == 'android-jsc') {
21+
if (details.requested.name == 'jsc-android') {
2222
details.useTarget group: details.requested.group, name: JSC_NAME, version: JSC_VERSION
2323
}
2424
}
@@ -43,7 +43,7 @@ buildscript {
4343

4444
allprojects {
4545
repositories {
46-
// this tells gradle where android-jsc resides
46+
// this tells gradle where jsc-android resides
4747
maven {
4848
url JSC_DIR
4949
}

scripts/start.sh

+10-8
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@ createAAR() {
7979
local distDir=$2
8080
local jniLibsDir=$3
8181
local i18n=$4
82+
local headersDir=${distDir}/include
8283
printf "\n\n\t\t===================== create aar :${target}: =====================\n\n"
8384
cd $ROOTDIR/lib
8485
./gradlew clean :${target}:publish \
8586
--project-prop distDir="${distDir}" \
8687
--project-prop jniLibsDir="${jniLibsDir}" \
87-
--project-prop revision="$REVISION" \
88+
--project-prop headersDir="${headersDir}" \
89+
--project-prop version="${npm_package_version}" \
8890
--project-prop i18n="${i18n}"
8991
cd $ROOTDIR
9092
}
@@ -104,19 +106,19 @@ export I18N=true
104106
prep
105107
compile
106108

107-
export DISTDIR=${ROOTDIR}/dist
108109
printf "\n\n\t\t===================== create stripped distributions =====================\n\n"
109-
createAAR "android-jsc" ${DISTDIR} ${INSTALL_DIR_I18N_false} "false"
110-
createAAR "android-jsc" ${DISTDIR} ${INSTALL_DIR_I18N_true} "true"
111-
createAAR "cppruntime" ${DISTDIR} ${INSTALL_CPPRUNTIME_DIR} "false"
110+
export DISTDIR=${ROOTDIR}/dist
112111
copyHeaders ${DISTDIR}
112+
createAAR "jsc-android" ${DISTDIR} ${INSTALL_DIR_I18N_false} "false"
113+
createAAR "jsc-android" ${DISTDIR} ${INSTALL_DIR_I18N_true} "true"
114+
createAAR "cppruntime" ${DISTDIR} ${INSTALL_CPPRUNTIME_DIR} "false"
113115

114116
printf "\n\n\t\t===================== create unstripped distributions =====================\n\n"
115117
export DISTDIR=${ROOTDIR}/dist.unstripped
116-
createAAR "android-jsc" ${DISTDIR} ${INSTALL_UNSTRIPPED_DIR_I18N_false} "false"
117-
createAAR "android-jsc" ${DISTDIR} ${INSTALL_UNSTRIPPED_DIR_I18N_true} "true"
118-
createAAR "cppruntime" ${DISTDIR} ${INSTALL_CPPRUNTIME_DIR} "false"
119118
copyHeaders ${DISTDIR}
119+
createAAR "jsc-android" ${DISTDIR} ${INSTALL_UNSTRIPPED_DIR_I18N_false} "false"
120+
createAAR "jsc-android" ${DISTDIR} ${INSTALL_UNSTRIPPED_DIR_I18N_true} "true"
121+
createAAR "cppruntime" ${DISTDIR} ${INSTALL_CPPRUNTIME_DIR} "false"
120122

121123
npm run info
122124

0 commit comments

Comments
 (0)