mirror of
https://github.com/wgh136/flutter_qjs.git
synced 2025-09-27 21:37:24 +00:00
ios build without cmake
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -8,4 +8,4 @@ build/
|
|||||||
.idea/
|
.idea/
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
|
|
||||||
publish.cmd
|
ios/cxx
|
||||||
|
22
README.md
22
README.md
@@ -142,25 +142,3 @@ try {
|
|||||||
Method `close` can destroy quickjs runtime that can be recreated again if you call `evaluate`.
|
Method `close` can destroy quickjs runtime that can be recreated again if you call `evaluate`.
|
||||||
|
|
||||||
[This example](example/lib/main.dart) contains a complete demonstration on how to use this plugin.
|
[This example](example/lib/main.dart) contains a complete demonstration on how to use this plugin.
|
||||||
|
|
||||||
## For macOS & iOS developer
|
|
||||||
|
|
||||||
I am new to Xcode and iOS developing, and I cannot find a better way to support both simulators and real devices without combining the binary frameworks. To reduce build size, change the `s.vendored_frameworks` in `ios/flutter_qjs.podspec` to the specific framework.
|
|
||||||
|
|
||||||
For simulator, use:
|
|
||||||
|
|
||||||
```podspec
|
|
||||||
s.vendored_frameworks = `build/Debug-iphonesimulator/ffiquickjs.framework`
|
|
||||||
```
|
|
||||||
|
|
||||||
For real device, use:
|
|
||||||
|
|
||||||
```podspec
|
|
||||||
s.vendored_frameworks = `build/Debug-iphoneos/ffiquickjs.framework`
|
|
||||||
```
|
|
||||||
|
|
||||||
Two additional notes:
|
|
||||||
|
|
||||||
1. quickjs built with `release` config has bug in resolving `Promise`. Please let me know if you know the solution.
|
|
||||||
|
|
||||||
2. `ios/make.sh` limits the build architectures to avoid combining conflicts. Change the `make.sh` to support another architectures.
|
|
12
example/android/app/src/main/res/drawable-v21/launch_background.xml
Executable file
12
example/android/app/src/main/res/drawable-v21/launch_background.xml
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Modify this file to customize your launch splash screen -->
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="?android:colorBackground" />
|
||||||
|
|
||||||
|
<!-- You can insert your own image assets here -->
|
||||||
|
<!-- <item>
|
||||||
|
<bitmap
|
||||||
|
android:gravity="center"
|
||||||
|
android:src="@mipmap/launch_image" />
|
||||||
|
</item> -->
|
||||||
|
</layer-list>
|
@@ -14,9 +14,9 @@ EXTERNAL SOURCES:
|
|||||||
:path: ".symlinks/plugins/flutter_qjs/ios"
|
:path: ".symlinks/plugins/flutter_qjs/ios"
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
|
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
|
||||||
flutter_qjs: 351b608d97711c8939aaba405af874e593ec2cb0
|
flutter_qjs: 9bb46bb262be81b7c50e4a1a117d5a602d69691f
|
||||||
|
|
||||||
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
|
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
|
||||||
|
|
||||||
COCOAPODS: 1.9.3
|
COCOAPODS: 1.10.1
|
||||||
|
@@ -253,17 +253,12 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
);
|
);
|
||||||
inputPaths = (
|
inputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||||
"${PODS_ROOT}/../Flutter/Flutter.framework",
|
|
||||||
"${PODS_ROOT}/../.symlinks/plugins/flutter_qjs/ios/build/ffiquickjs.framework",
|
|
||||||
"${BUILT_PRODUCTS_DIR}/flutter_qjs/flutter_qjs.framework",
|
|
||||||
);
|
);
|
||||||
name = "[CP] Embed Pods Frameworks";
|
name = "[CP] Embed Pods Frameworks";
|
||||||
outputPaths = (
|
outputFileListPaths = (
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ffiquickjs.framework",
|
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_qjs.framework",
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
|
0
ios/.gitignore
vendored
Normal file → Executable file
0
ios/.gitignore
vendored
Normal file → Executable file
0
ios/Assets/.gitkeep
Normal file → Executable file
0
ios/Assets/.gitkeep
Normal file → Executable file
@@ -1,24 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
|
|
||||||
project(ffiquickjs LANGUAGES CXX)
|
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_SOURCE_DIR}/../cxx/quickjs.cmake")
|
|
||||||
|
|
||||||
add_library(ffiquickjs SHARED ${CXX_LIB_DIR}/ffi.cpp)
|
|
||||||
target_link_libraries(ffiquickjs PRIVATE quickjs)
|
|
||||||
|
|
||||||
set_target_properties(ffiquickjs PROPERTIES
|
|
||||||
FRAMEWORK TRUE
|
|
||||||
FRAMEWORK_VERSION A
|
|
||||||
MACOSX_FRAMEWORK_IDENTIFIER soko.ekibun.ffiquickjs
|
|
||||||
# MACOSX_FRAMEWORK_INFO_PLIST Info.plist
|
|
||||||
# "current version" in semantic format in Mach-O binary file
|
|
||||||
VERSION 1.0.0
|
|
||||||
# "compatibility version" in semantic format in Mach-O binary file
|
|
||||||
SOVERSION 1.0.0
|
|
||||||
MACOSX_FRAMEWORK_BUNDLE_VERSION 100
|
|
||||||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING 100
|
|
||||||
XCODE_ATTRIBUTE_DYLIB_INSTALL_NAME_BASE "@rpath"
|
|
||||||
PUBLIC_HEADER ffi.h
|
|
||||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Apple Development"
|
|
||||||
# RESOURCE "${RESOURCE_FILES}"
|
|
||||||
)
|
|
@@ -13,14 +13,14 @@ This plugin is a simple js engine for flutter using the `quickjs` project. Plugi
|
|||||||
s.license = { :file => '../LICENSE' }
|
s.license = { :file => '../LICENSE' }
|
||||||
s.author = { 'ekibun' => 'soekibun@gmail.com' }
|
s.author = { 'ekibun' => 'soekibun@gmail.com' }
|
||||||
s.source = { :path => '.' }
|
s.source = { :path => '.' }
|
||||||
s.source_files = 'Classes/**/*'
|
s.compiler_flags = '-DDUMP_LEAKS'
|
||||||
|
s.source_files = ['Classes/**/*', 'cxx/*']
|
||||||
|
s.public_header_files = 'Classes/**/*.h'
|
||||||
s.dependency 'Flutter'
|
s.dependency 'Flutter'
|
||||||
s.platform = :ios, '8.0'
|
s.platform = :ios, '8.0'
|
||||||
|
|
||||||
# Flutter.framework does not contain a i386 slice.
|
# Flutter.framework does not contain a i386 slice.
|
||||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
|
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
|
||||||
s.vendored_frameworks = 'build/ffiquickjs.framework'
|
s.prepare_command = 'sh pre.sh'
|
||||||
s.static_framework = false
|
|
||||||
s.prepare_command = 'sh make.sh'
|
|
||||||
s.swift_version = '5.0'
|
s.swift_version = '5.0'
|
||||||
end
|
end
|
||||||
|
22
ios/make.sh
22
ios/make.sh
@@ -1,22 +0,0 @@
|
|||||||
###
|
|
||||||
# @Description:
|
|
||||||
# @Author: ekibun
|
|
||||||
# @Date: 2020-09-24 00:50:13
|
|
||||||
# @LastEditors: ekibun
|
|
||||||
# @LastEditTime: 2020-09-24 00:51:43
|
|
||||||
###
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
|
|
||||||
cmake .. -G Xcode \
|
|
||||||
-DCMAKE_SYSTEM_NAME=iOS \
|
|
||||||
-DCMAKE_IOS_INSTALL_COMBINED=true \
|
|
||||||
-DCMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=NO
|
|
||||||
cmake --build . --config Debug -- -arch arm64
|
|
||||||
cmake --build . --config Debug -- -sdk iphonesimulator -arch x86_64
|
|
||||||
|
|
||||||
mkdir ffiquickjs.framework
|
|
||||||
lipo -create 'Debug-iphoneos/ffiquickjs.framework/ffiquickjs' 'Debug-iphonesimulator/ffiquickjs.framework/ffiquickjs' -output 'ffiquickjs.framework/ffiquickjs'
|
|
||||||
cp -f 'Debug-iphoneos/ffiquickjs.framework/Info.plist' 'ffiquickjs.framework/Info.plist'
|
|
||||||
|
|
||||||
cd ..
|
|
33
ios/pre.sh
Normal file
33
ios/pre.sh
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
if [ -d "./cxx/" ];then
|
||||||
|
rm -r ./cxx
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir ./cxx
|
||||||
|
|
||||||
|
sed 's/\#include \"quickjs\/quickjs.h\"/\#include \"quickjs.h\"/g' ../cxx/ffi.h > ./cxx/ffi.h
|
||||||
|
cp ../cxx/ffi.cpp ./cxx/ffi.cpp
|
||||||
|
|
||||||
|
quickjs_version=$(cat ../cxx/quickjs/VERSION)
|
||||||
|
|
||||||
|
sed '1i\
|
||||||
|
\#define CONFIG_VERSION \"'$quickjs_version'\"\
|
||||||
|
' ../cxx/quickjs/quickjs.c > ./cxx/quickjs.c
|
||||||
|
|
||||||
|
quickjs_src=(
|
||||||
|
"list.h"
|
||||||
|
"cutils.c"
|
||||||
|
"libregexp.c"
|
||||||
|
"libunicode.c"
|
||||||
|
"cutils.h"
|
||||||
|
"libregexp.h"
|
||||||
|
"libunicode.h"
|
||||||
|
"quickjs.h"
|
||||||
|
"quickjs-atom.h"
|
||||||
|
"quickjs-opcode.h"
|
||||||
|
"libregexp-opcode.h"
|
||||||
|
"libunicode-table.h"
|
||||||
|
)
|
||||||
|
for item in ${quickjs_src[*]}
|
||||||
|
do
|
||||||
|
cp ../cxx/quickjs/$item ./cxx/$item
|
||||||
|
done
|
@@ -59,8 +59,6 @@ final DynamicLibrary qjsLib = Platform.environment['FLUTTER_TEST'] == 'true'
|
|||||||
? DynamicLibrary.open("flutter_qjs_plugin.dll")
|
? DynamicLibrary.open("flutter_qjs_plugin.dll")
|
||||||
: Platform.isAndroid
|
: Platform.isAndroid
|
||||||
? DynamicLibrary.open("libqjs.so")
|
? DynamicLibrary.open("libqjs.so")
|
||||||
: Platform.isIOS
|
|
||||||
? DynamicLibrary.open("ffiquickjs.framework/ffiquickjs")
|
|
||||||
: DynamicLibrary.process());
|
: DynamicLibrary.process());
|
||||||
|
|
||||||
/// JSValue *jsThrowInternalError(JSContext *ctx, char *message)
|
/// JSValue *jsThrowInternalError(JSContext *ctx, char *message)
|
||||||
|
Reference in New Issue
Block a user