mirror of
https://github.com/wgh136/flutter_qjs.git
synced 2025-09-27 05:27:23 +00:00
remove C++ std limitation for linux and android
This commit is contained in:
9
.vscode/c_cpp_properties.json
vendored
9
.vscode/c_cpp_properties.json
vendored
@@ -23,9 +23,8 @@
|
|||||||
"C:/Users/ekibun/AppData/Local/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include"
|
"C:/Users/ekibun/AppData/Local/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include"
|
||||||
],
|
],
|
||||||
"defines": [
|
"defines": [
|
||||||
"_DEBUG",
|
"__ANDROID__",
|
||||||
"UNICODE",
|
"__LINUX__"
|
||||||
"_UNICODE"
|
|
||||||
],
|
],
|
||||||
"windowsSdkVersion": "10.0.18362.0",
|
"windowsSdkVersion": "10.0.18362.0",
|
||||||
"compilerPath": "C:/Users/ekibun/AppData/Local/Android/Sdk/cmake/3.10.2.4988404/bin/cmake.exe",
|
"compilerPath": "C:/Users/ekibun/AppData/Local/Android/Sdk/cmake/3.10.2.4988404/bin/cmake.exe",
|
||||||
@@ -41,9 +40,7 @@
|
|||||||
"/usr/include/**"
|
"/usr/include/**"
|
||||||
],
|
],
|
||||||
"defines": [
|
"defines": [
|
||||||
"_DEBUG",
|
"__LINUX__"
|
||||||
"UNICODE",
|
|
||||||
"_UNICODE"
|
|
||||||
],
|
],
|
||||||
"windowsSdkVersion": "10.0.18362.0",
|
"windowsSdkVersion": "10.0.18362.0",
|
||||||
"compilerPath": "/usr/bin/clang++",
|
"compilerPath": "/usr/bin/clang++",
|
||||||
|
@@ -3,8 +3,12 @@
|
|||||||
* @Author: ekibun
|
* @Author: ekibun
|
||||||
* @Date: 2020-08-08 08:16:50
|
* @Date: 2020-08-08 08:16:50
|
||||||
* @LastEditors: ekibun
|
* @LastEditors: ekibun
|
||||||
* @LastEditTime: 2020-08-25 18:12:51
|
* @LastEditTime: 2020-08-26 23:37:16
|
||||||
-->
|
-->
|
||||||
|
## 0.0.4
|
||||||
|
|
||||||
|
* remove C++ std limitation for linux and android.
|
||||||
|
|
||||||
## 0.0.3
|
## 0.0.3
|
||||||
|
|
||||||
* fix js memory leak.
|
* fix js memory leak.
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* @Author: ekibun
|
* @Author: ekibun
|
||||||
* @Date: 2020-08-08 08:16:50
|
* @Date: 2020-08-08 08:16:50
|
||||||
* @LastEditors: ekibun
|
* @LastEditors: ekibun
|
||||||
* @LastEditTime: 2020-08-20 13:58:47
|
* @LastEditTime: 2020-08-26 23:02:05
|
||||||
-->
|
-->
|
||||||
# flutter_qjs
|
# flutter_qjs
|
||||||
|
|
||||||
@@ -76,6 +76,3 @@ try {
|
|||||||
```
|
```
|
||||||
|
|
||||||
[This example](example/lib/test.dart) contains a complete demonstration on how to use this plugin.
|
[This example](example/lib/test.dart) contains a complete demonstration on how to use this plugin.
|
||||||
|
|
||||||
**notice:**
|
|
||||||
To use this plugin in Linux desktop application, you must change `cxx_std_14` to `cxx_std_17` in your project's `CMakeLists.txt`.
|
|
@@ -33,11 +33,6 @@ android {
|
|||||||
}
|
}
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
externalNativeBuild {
|
|
||||||
cmake {
|
|
||||||
cppFlags "-std=c++17"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
lintOptions {
|
lintOptions {
|
||||||
disable 'InvalidPackage'
|
disable 'InvalidPackage'
|
||||||
|
@@ -30,6 +30,7 @@ target_sources(${JNI_LIB_NAME} PUBLIC
|
|||||||
${QUICK_JS_LIB_DIR}/libunicode.c
|
${QUICK_JS_LIB_DIR}/libunicode.c
|
||||||
${QUICK_JS_LIB_DIR}/quickjs.c
|
${QUICK_JS_LIB_DIR}/quickjs.c
|
||||||
)
|
)
|
||||||
|
target_compile_features(${JNI_LIB_NAME} PUBLIC cxx_std_17)
|
||||||
|
|
||||||
# Searches for a specified prebuilt library and stores the path as a
|
# Searches for a specified prebuilt library and stores the path as a
|
||||||
# variable. Because CMake includes system libraries in the search path by
|
# variable. Because CMake includes system libraries in the search path by
|
||||||
|
@@ -29,7 +29,6 @@ class FlutterQjsPlugin: FlutterPlugin, MethodCallHandler {
|
|||||||
override fun onMethodCall(call: MethodCall, result: Result) {
|
override fun onMethodCall(call: MethodCall, result: Result) {
|
||||||
if (call.method == "createEngine") {
|
if (call.method == "createEngine") {
|
||||||
val engine: Long = JniBridge.instance.createEngine(channelwrapper)
|
val engine: Long = JniBridge.instance.createEngine(channelwrapper)
|
||||||
println(engine)
|
|
||||||
result.success(engine)
|
result.success(engine)
|
||||||
} else if (call.method == "evaluate") {
|
} else if (call.method == "evaluate") {
|
||||||
val engine: Long = call.argument<Long>("engine")!!
|
val engine: Long = call.argument<Long>("engine")!!
|
||||||
@@ -43,7 +42,6 @@ class FlutterQjsPlugin: FlutterPlugin, MethodCallHandler {
|
|||||||
JniBridge.instance.call(engine, function, args, ResultWrapper(handler, result))
|
JniBridge.instance.call(engine, function, args, ResultWrapper(handler, result))
|
||||||
} else if (call.method == "close") {
|
} else if (call.method == "close") {
|
||||||
val engine: Long = call.arguments<Long>()
|
val engine: Long = call.arguments<Long>()
|
||||||
println(engine)
|
|
||||||
JniBridge.instance.close(engine)
|
JniBridge.instance.close(engine)
|
||||||
result.success(null)
|
result.success(null)
|
||||||
} else {
|
} else {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* @Author: ekibun
|
* @Author: ekibun
|
||||||
* @Date: 2020-08-08 10:30:59
|
* @Date: 2020-08-08 10:30:59
|
||||||
* @LastEditors: ekibun
|
* @LastEditors: ekibun
|
||||||
* @LastEditTime: 2020-08-20 11:11:30
|
* @LastEditTime: 2020-08-26 23:35:20
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@@ -53,7 +53,8 @@ namespace qjs
|
|||||||
|
|
||||||
void handleException(qjs::Value exc)
|
void handleException(qjs::Value exc)
|
||||||
{
|
{
|
||||||
std::cout << getStackTrack(exc) << std::endl;
|
printf("%s", getStackTrack(exc).c_str());
|
||||||
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -125,7 +126,7 @@ namespace qjs
|
|||||||
if (err <= 0)
|
if (err <= 0)
|
||||||
{
|
{
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
std::cout << getStackTrack(ctx.getException()) << std::endl;
|
handleException(ctx.getException());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,12 +37,6 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
|
||||||
#include <android/log.h>
|
|
||||||
#undef printf
|
|
||||||
#define printf(...) __android_log_print(ANDROID_LOG_INFO, "qjs", __VA_ARGS__)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
|
|
||||||
@@ -1704,7 +1698,7 @@ static inline size_t js_def_malloc_usable_size(void *ptr)
|
|||||||
return malloc_size(ptr);
|
return malloc_size(ptr);
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
return _msize(ptr);
|
return _msize(ptr);
|
||||||
#elif defined(EMSCRIPTEN)
|
#elif defined(EMSCRIPTEN) || defined(__ANDROID__)
|
||||||
return 0;
|
return 0;
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
return malloc_usable_size(ptr);
|
return malloc_usable_size(ptr);
|
||||||
@@ -1778,7 +1772,7 @@ static const JSMallocFunctions def_malloc_funcs = {
|
|||||||
malloc_size,
|
malloc_size,
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
(size_t (*)(const void *))_msize,
|
(size_t (*)(const void *))_msize,
|
||||||
#elif defined(EMSCRIPTEN)
|
#elif defined(EMSCRIPTEN) || defined(__ANDROID__)
|
||||||
NULL,
|
NULL,
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
(size_t (*)(const void *))malloc_usable_size,
|
(size_t (*)(const void *))malloc_usable_size,
|
||||||
|
@@ -28,6 +28,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
#include <android/log.h>
|
||||||
|
#define printf(...) __android_log_print(ANDROID_LOG_INFO, "qjs", __VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>android</name>
|
|
||||||
<comment>Project android created by Buildship.</comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
@@ -1,13 +0,0 @@
|
|||||||
arguments=
|
|
||||||
auto.sync=false
|
|
||||||
build.scans.enabled=false
|
|
||||||
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
|
||||||
connection.project.dir=
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
gradle.user.home=
|
|
||||||
java.home=C\:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2019.3.2/jbr
|
|
||||||
jvm.arguments=
|
|
||||||
offline.mode=false
|
|
||||||
override.workspace.settings=true
|
|
||||||
show.console.view=true
|
|
||||||
show.executions.view=true
|
|
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
|
||||||
<classpathentry kind="output" path="bin/default"/>
|
|
||||||
</classpath>
|
|
@@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>app</name>
|
|
||||||
<comment>Project app created by Buildship.</comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
@@ -1,2 +0,0 @@
|
|||||||
connection.project.dir=..
|
|
||||||
eclipse.preferences.version=1
|
|
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
|
|||||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 29
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
@@ -40,7 +40,7 @@ android {
|
|||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId "soko.ekibun.example"
|
applicationId "soko.ekibun.example"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 28
|
targetSdkVersion 29
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +0,0 @@
|
|||||||
package soko.ekibun.flutter_qjs_example
|
|
||||||
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
|
||||||
|
|
||||||
class MainActivity: FlutterActivity() {
|
|
||||||
}
|
|
@@ -1,4 +1,4 @@
|
|||||||
org.gradle.jvmargs=-Xmx1536M
|
org.gradle.jvmargs=-Xmx1536M
|
||||||
android.enableR8=true
|
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
|
android.enableR8=true
|
||||||
|
@@ -18,7 +18,7 @@ endif()
|
|||||||
|
|
||||||
# Compilation settings that should be applied to most targets.
|
# Compilation settings that should be applied to most targets.
|
||||||
function(APPLY_STANDARD_SETTINGS TARGET)
|
function(APPLY_STANDARD_SETTINGS TARGET)
|
||||||
target_compile_features(${TARGET} PUBLIC cxx_std_17)
|
target_compile_features(${TARGET} PUBLIC cxx_std_14)
|
||||||
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
|
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
|
||||||
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
|
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
|
||||||
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
|
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
|
||||||
|
@@ -75,7 +75,7 @@ packages:
|
|||||||
path: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "0.0.3"
|
version: "0.0.4"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* @Author: ekibun
|
* @Author: ekibun
|
||||||
* @Date: 2020-08-08 08:29:09
|
* @Date: 2020-08-08 08:29:09
|
||||||
* @LastEditors: ekibun
|
* @LastEditors: ekibun
|
||||||
* @LastEditTime: 2020-08-20 14:43:40
|
* @LastEditTime: 2020-08-26 23:11:10
|
||||||
*/
|
*/
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
@@ -24,7 +24,6 @@ class FlutterJs {
|
|||||||
_ensureEngine() async {
|
_ensureEngine() async {
|
||||||
if (_engine == null) {
|
if (_engine == null) {
|
||||||
_engine = await _FlutterJs.instance._channel.invokeMethod("createEngine");
|
_engine = await _FlutterJs.instance._channel.invokeMethod("createEngine");
|
||||||
print(_engine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,6 +22,7 @@ add_library(${PLUGIN_NAME} SHARED
|
|||||||
)
|
)
|
||||||
|
|
||||||
apply_standard_settings(${PLUGIN_NAME})
|
apply_standard_settings(${PLUGIN_NAME})
|
||||||
|
target_compile_features(${PLUGIN_NAME} PUBLIC cxx_std_17)
|
||||||
set_target_properties(${PLUGIN_NAME} PROPERTIES
|
set_target_properties(${PLUGIN_NAME} PROPERTIES
|
||||||
CXX_VISIBILITY_PRESET hidden)
|
CXX_VISIBILITY_PRESET hidden)
|
||||||
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
|
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
name: flutter_qjs
|
name: flutter_qjs
|
||||||
description: This plugin is a simple js engine for flutter using the `quickjs` project. Plugin currently supports Windows, Linux, and Android.
|
description: This plugin is a simple js engine for flutter using the `quickjs` project. Plugin currently supports Windows, Linux, and Android.
|
||||||
version: 0.0.3
|
version: 0.0.4
|
||||||
homepage: https://github.com/ekibun/flutter_qjs
|
homepage: https://github.com/ekibun/flutter_qjs
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
Reference in New Issue
Block a user