Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kudo committed Nov 26, 2024
1 parent b010e05 commit 21b1ee8
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 10 deletions.
16 changes: 10 additions & 6 deletions lib/jsc-android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
project(jsc-android)

add_library(jsclib SHARED IMPORTED GLOBAL)
add_library(jsc SHARED empty.cpp)

set_target_properties(jsclib
PROPERTIES
IMPORTED_LOCATION
"${PREBUILT_LIBS_DIR}/${ANDROID_ABI}/libjsc.so")
set(OUTPUT_SRC "${PREBUILT_LIBS_DIR}/${ANDROID_ABI}/libjsc.so")
set(OUTPUT_DST "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libjsc.so")

add_library(jsc SHARED empty.cpp)
add_custom_command(
TARGET jsc POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${OUTPUT_SRC}
${OUTPUT_DST}
COMMENT "Overwriting ${OUTPUT_SRC} to ${OUTPUT_DST}"
)
1 change: 0 additions & 1 deletion lib/jsc-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ android {

prefab {
jsc {
headerOnly true
headers file(headersDir).absolutePath
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"web": {
"favicon": "./assets/favicon.png"
},
"jsEngine": "jsc"
"jsEngine": "jsc",
"plugins": ["./plugins/withJscAndroid"]
}
}
3 changes: 1 addition & 2 deletions test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"start": "expo start",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web",
"postinstall": "rm -rf node_modules/jsc-android/dist && cd node_modules/jsc-android && ln -s ../../../dist"
"web": "expo start --web"
},
"dependencies": {
"expo": "~52.0.7",
Expand Down
45 changes: 45 additions & 0 deletions test/plugins/withJscAndroid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const assert = require('assert');
const { withProjectBuildGradle } = require('expo/config-plugins');

const withJscAndroidProjectBuildGradle = (config) => {
return withProjectBuildGradle(config, (config) => {
assert(config.modResults.language === 'groovy');
if (!config.modResults.contents.match(/\/\/ Local dist maven repo/)) {
const mavenRepo = `
maven {
// Local dist maven repo
url('../../dist')
}`;
config.modResults.contents = config.modResults.contents.replace(
/^(allprojects \{[\s\S]+?repositories \{)/gm,
`$1${mavenRepo}`
);
}

if (
!config.modResults.contents.match(
/io\.github\.react-native-community:jsc-android:/
)
) {
config.modResults.contents += `
allprojects {
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute(module('org.webkit:android-jsc'))
.using(module('io.github.react-native-community:jsc-android:+'))
}
}
}
`;
}

return config;
});
};

const withJscAndroid = (config) => {
config = withJscAndroidProjectBuildGradle(config);
return config;
};

module.exports = withJscAndroid;

0 comments on commit 21b1ee8

Please # to comment.