Skip to content

Commit 21b1ee8

Browse files
committed
fix
1 parent b010e05 commit 21b1ee8

File tree

5 files changed

+58
-10
lines changed

5 files changed

+58
-10
lines changed

lib/jsc-android/CMakeLists.txt

+10-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ cmake_minimum_required(VERSION 3.13)
22
set(CMAKE_VERBOSE_MAKEFILE on)
33
project(jsc-android)
44

5-
add_library(jsclib SHARED IMPORTED GLOBAL)
5+
add_library(jsc SHARED empty.cpp)
66

7-
set_target_properties(jsclib
8-
PROPERTIES
9-
IMPORTED_LOCATION
10-
"${PREBUILT_LIBS_DIR}/${ANDROID_ABI}/libjsc.so")
7+
set(OUTPUT_SRC "${PREBUILT_LIBS_DIR}/${ANDROID_ABI}/libjsc.so")
8+
set(OUTPUT_DST "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libjsc.so")
119

12-
add_library(jsc SHARED empty.cpp)
10+
add_custom_command(
11+
TARGET jsc POST_BUILD
12+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
13+
${OUTPUT_SRC}
14+
${OUTPUT_DST}
15+
COMMENT "Overwriting ${OUTPUT_SRC} to ${OUTPUT_DST}"
16+
)

lib/jsc-android/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ android {
5656

5757
prefab {
5858
jsc {
59-
headerOnly true
6059
headers file(headersDir).absolutePath
6160
}
6261
}

test/app.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"web": {
2727
"favicon": "./assets/favicon.png"
2828
},
29-
"jsEngine": "jsc"
29+
"jsEngine": "jsc",
30+
"plugins": ["./plugins/withJscAndroid"]
3031
}
3132
}

test/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"start": "expo start",
77
"android": "expo run:android",
88
"ios": "expo run:ios",
9-
"web": "expo start --web",
10-
"postinstall": "rm -rf node_modules/jsc-android/dist && cd node_modules/jsc-android && ln -s ../../../dist"
9+
"web": "expo start --web"
1110
},
1211
"dependencies": {
1312
"expo": "~52.0.7",

test/plugins/withJscAndroid.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const assert = require('assert');
2+
const { withProjectBuildGradle } = require('expo/config-plugins');
3+
4+
const withJscAndroidProjectBuildGradle = (config) => {
5+
return withProjectBuildGradle(config, (config) => {
6+
assert(config.modResults.language === 'groovy');
7+
if (!config.modResults.contents.match(/\/\/ Local dist maven repo/)) {
8+
const mavenRepo = `
9+
maven {
10+
// Local dist maven repo
11+
url('../../dist')
12+
}`;
13+
config.modResults.contents = config.modResults.contents.replace(
14+
/^(allprojects \{[\s\S]+?repositories \{)/gm,
15+
`$1${mavenRepo}`
16+
);
17+
}
18+
19+
if (
20+
!config.modResults.contents.match(
21+
/io\.github\.react-native-community:jsc-android:/
22+
)
23+
) {
24+
config.modResults.contents += `
25+
allprojects {
26+
configurations.all {
27+
resolutionStrategy.dependencySubstitution {
28+
substitute(module('org.webkit:android-jsc'))
29+
.using(module('io.github.react-native-community:jsc-android:+'))
30+
}
31+
}
32+
}
33+
`;
34+
}
35+
36+
return config;
37+
});
38+
};
39+
40+
const withJscAndroid = (config) => {
41+
config = withJscAndroidProjectBuildGradle(config);
42+
return config;
43+
};
44+
45+
module.exports = withJscAndroid;

0 commit comments

Comments
 (0)