diff --git a/.github/workflows/build_example.yaml b/.github/workflows/build_example.yaml new file mode 100644 index 00000000..53577080 --- /dev/null +++ b/.github/workflows/build_example.yaml @@ -0,0 +1,101 @@ +name: build examples + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + build-windows: + name: build-windows + runs-on: windows-latest + + steps: + - uses: subosito/flutter-action@v2 + with: + # flutter-version: '3.16.9' + channel: "stable" + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '11' + - name: build + run: | + cd example + flutter build windows + flutter build apk --release --target-platform android-arm64,android-arm,android-x64 --split-per-abi + build-ubuntu: + name: build-ubuntu + runs-on: ubuntu-latest + + steps: + - uses: subosito/flutter-action@v2 + with: + # flutter-version: '3.16.9' + channel: "stable" + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '11' + - name: setup + run: | + sudo apt-get update + sudo apt-get install -y curl git wget python3 unzip build-essential \ + libgtk-3-dev ffmpeg libavcodec-dev \ + cmake ninja-build nasm libavformat-dev libavutil-dev \ + libswscale-dev libgflags-dev \ + libjpeg-dev libpng-dev libtiff-dev python3-pip + - name: build + run: | + cd example + flutter build linux + flutter build apk --release --target-platform android-arm64,android-arm,android-x64 --split-per-abi + build-macos: + name: build-macos + runs-on: macos-13 + steps: + - uses: subosito/flutter-action@v2 + with: + # flutter-version: '3.16.9' + channel: "stable" + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '11' + - name: build + run: | + cd example + flutter build macos + flutter build apk --release --target-platform android-arm64,android-arm,android-x64 --split-per-abi + flutter build ios --release --no-codesign + build-macos-arm: + name: build-macos-arm + runs-on: macos-14 + steps: + - uses: subosito/flutter-action@v2 + with: + # flutter-version: '3.16.9' + channel: "stable" + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '11' + - name: build + run: | + cd example + flutter build macos + flutter build apk --release --target-platform android-arm64,android-arm,android-x64 --split-per-abi + flutter build ios --release --no-codesign diff --git a/README.md b/README.md index e56559c6..b36cc391 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,18 @@ OpenCV Bindings for Dart Language.

> [!IMPORTANT] -> Please use v0.3.0 and later version, usage: +> Please use `v0.3.0` and later version +> +> For `v1.0.5` and later, setup is no longer needed, the prebuilt libs will be downloaded from releases +> automatically, some notes: +> +> 1. iOS: default target architecture is `arm64`, if you need to run on `x64`(ios simulator), please +> set `OPENCV_DART_ARCH` to `x64`, e.g., `export OPENCV_DART_ARCH=x64` +> 2. Android: all supported ABIs (`x86_64` `arm64-v8a` `armeabi-v7a`) will be downloaded, if you want +> to reduce the app size, please add `--split-per-abi` to the `flutter build` command, e.g., `flutter build apk --release --target-platform android-arm64,android-x64 --split-per-abi`, otherwise, all `.so` will +> be packaged to app. +> +> For `v1.0.4` and below, make sure run the following setup commands before running your app: > > 1. `flutter pub add opencv_dart` or `dart pub add opencv_dart` > 2. `dart run opencv_dart:setup --arch ` @@ -148,7 +159,7 @@ void main() { #### Flutter -see [example](https://github.com/rainyl/opencv_dart/tree/native-assets/example) +see [example](https://github.com/rainyl/opencv_dart/tree/main/example) More examples are on the way... diff --git a/android/build.gradle b/android/build.gradle index 5fac1088..a0a7e534 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,3 @@ -// The Android Gradle Plugin builds the native code with the Android NDK. - group 'dev.rainyl.opencv_dart' version '1.0' @@ -33,9 +31,8 @@ android { // to bump the version in their app. compileSdk 33 - // Use the NDK version - // declared in /android/app/build.gradle file of the Flutter project. - // Replace it with a version number if this plugin requires a specfic NDK version. + // Use the NDK version declared in /android/app/build.gradle file of the Flutter project. + // Replace it with a version number if this plugin requires a specific NDK version. // (e.g. ndkVersion "23.1.7779620") ndkVersion android.ndkVersion @@ -63,3 +60,40 @@ android { minSdkVersion 19 } } + +// 'dart' and 'dart.bat' both exists on windwos, the former is a bash script and won't work +// correctly on windows, so use `dart.bat` +def dartCmd = "dart" +def currentOS = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem +if(currentOS.isWindows()){ + dartCmd = "dart.bat" +} + +task runOpenCVSetup(type: Exec) { + // Set working directory to the parent directory of the root directory + workingDir rootDir.parentFile + commandLine dartCmd, 'run', 'opencv_dart:setup', 'android', '--arch', 'x86_64' + doFirst { + println "Running OpenCV setup for x86_64 in ${workingDir}" + } +} + +task runOpenCVSetupArm64(type: Exec) { + // Set working directory to the parent directory of the root directory + workingDir rootDir.parentFile + commandLine dartCmd, 'run', 'opencv_dart:setup', 'android', '--arch', 'arm64-v8a' + doFirst { + println "Running OpenCV setup for arm64-v8a in ${workingDir}" + } +} + +task runOpenCVSetupArmeabi(type: Exec) { + // Set working directory to the parent directory of the root directory + workingDir rootDir.parentFile + commandLine dartCmd, 'run', 'opencv_dart:setup', 'android', '--arch', 'armeabi-v7a' + doFirst { + println "Running OpenCV setup for armeabi-v7a in ${workingDir}" + } +} + +preBuild.dependsOn runOpenCVSetup, runOpenCVSetupArm64, runOpenCVSetupArmeabi diff --git a/bin/setup_commands.dart b/bin/setup_commands.dart index 1f334245..5db0869e 100644 --- a/bin/setup_commands.dart +++ b/bin/setup_commands.dart @@ -106,6 +106,18 @@ abstract class BaseSetupCommand extends Command { if (!Directory(extractPath).existsSync()) { Directory(extractPath).createSync(recursive: true); } + // Check if libs already existed, avoid double-extract + if (Directory(extractPath) + .listSync() + .map((e) => + e.path.endsWith(".so") || + e.path.endsWith(".dll") || + e.path.endsWith(".dylib") || + e.path.endsWith(".framework")) + .any((e) => e)) { + print("Libs already exists in $extractPath, Skipping..."); + return; + } print("Extracting to $extractPath"); final tarBytes = GZipDecoder().decodeBytes(saveFile.readAsBytesSync()); final archive = TarDecoder().decodeBytes(tarBytes); diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index 592ceee8..ec97fc6f 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 592ceee8..c4855bfe 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Podfile b/example/ios/Podfile new file mode 100644 index 00000000..d97f17e2 --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock new file mode 100644 index 00000000..f4d18c18 --- /dev/null +++ b/example/ios/Podfile.lock @@ -0,0 +1,28 @@ +PODS: + - Flutter (1.0.0) + - image_picker_ios (0.0.1): + - Flutter + - opencv_dart (0.0.1): + - Flutter + +DEPENDENCIES: + - Flutter (from `Flutter`) + - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) + - opencv_dart (from `.symlinks/plugins/opencv_dart/ios`) + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + image_picker_ios: + :path: ".symlinks/plugins/image_picker_ios/ios" + opencv_dart: + :path: ".symlinks/plugins/opencv_dart/ios" + +SPEC CHECKSUMS: + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 + image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1 + opencv_dart: 818b078a7168d455a7b84e1b1a0f444835ad666b + +PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796 + +COCOAPODS: 1.15.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index ae8e0791..c2799ab1 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -10,10 +10,12 @@ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 4CFCAD823EC8F0F4D5E6657E /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A4613ED73D45D8C920A7A0 /* Pods_RunnerTests.framework */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + DF5C25F974F6CC2C13B84B38 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8C5FEA70103218433955AC4 /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -40,14 +42,18 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 067E2E19AA6262406BB058D8 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 15A4613ED73D45D8C920A7A0 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 784CD811C2E3900D1A86E3CB /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7DDA84E97C856E03F69E4076 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -55,6 +61,10 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A66259C121F79FED86ADBFDB /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + A8F3A3595A9EBE92FDD6CD8D /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; + C8C5FEA70103218433955AC4 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + E7386E133BD416EAC7801C77 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -62,6 +72,15 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DF5C25F974F6CC2C13B84B38 /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F1EA7FE63D3C6BDB03714A6A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4CFCAD823EC8F0F4D5E6657E /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -76,6 +95,15 @@ path = RunnerTests; sourceTree = ""; }; + 3FEB229357D7587F84CD4759 /* Frameworks */ = { + isa = PBXGroup; + children = ( + C8C5FEA70103218433955AC4 /* Pods_Runner.framework */, + 15A4613ED73D45D8C920A7A0 /* Pods_RunnerTests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -94,6 +122,8 @@ 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, 331C8082294A63A400263BE5 /* RunnerTests */, + C30E14C8B3D8D114E25F00E6 /* Pods */, + 3FEB229357D7587F84CD4759 /* Frameworks */, ); sourceTree = ""; }; @@ -121,6 +151,20 @@ path = Runner; sourceTree = ""; }; + C30E14C8B3D8D114E25F00E6 /* Pods */ = { + isa = PBXGroup; + children = ( + 784CD811C2E3900D1A86E3CB /* Pods-Runner.debug.xcconfig */, + A66259C121F79FED86ADBFDB /* Pods-Runner.release.xcconfig */, + E7386E133BD416EAC7801C77 /* Pods-Runner.profile.xcconfig */, + 067E2E19AA6262406BB058D8 /* Pods-RunnerTests.debug.xcconfig */, + A8F3A3595A9EBE92FDD6CD8D /* Pods-RunnerTests.release.xcconfig */, + 7DDA84E97C856E03F69E4076 /* Pods-RunnerTests.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -128,8 +172,10 @@ isa = PBXNativeTarget; buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( + 825D881618B368D1B780564C /* [CP] Check Pods Manifest.lock */, 331C807D294A63A400263BE5 /* Sources */, 331C807F294A63A400263BE5 /* Resources */, + F1EA7FE63D3C6BDB03714A6A /* Frameworks */, ); buildRules = ( ); @@ -145,12 +191,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + C24101EF42F16AB2A61EBA61 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + AF389F3AE13FC17748F4A47A /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -238,6 +286,28 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 825D881618B368D1B780564C /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -253,6 +323,45 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + AF389F3AE13FC17748F4A47A /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + C24101EF42F16AB2A61EBA61 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -378,6 +487,7 @@ }; 331C8088294A63A400263BE5 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 067E2E19AA6262406BB058D8 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -395,6 +505,7 @@ }; 331C8089294A63A400263BE5 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = A8F3A3595A9EBE92FDD6CD8D /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -410,6 +521,7 @@ }; 331C808A294A63A400263BE5 /* Profile */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 7DDA84E97C856E03F69E4076 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; diff --git a/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a16..21a3cc14 100644 --- a/example/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/example/macos/Flutter/Flutter-Debug.xcconfig b/example/macos/Flutter/Flutter-Debug.xcconfig index c2efd0b6..4b81f9b2 100644 --- a/example/macos/Flutter/Flutter-Debug.xcconfig +++ b/example/macos/Flutter/Flutter-Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/example/macos/Flutter/Flutter-Release.xcconfig b/example/macos/Flutter/Flutter-Release.xcconfig index c2efd0b6..5caa9d15 100644 --- a/example/macos/Flutter/Flutter-Release.xcconfig +++ b/example/macos/Flutter/Flutter-Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/example/macos/Podfile b/example/macos/Podfile new file mode 100644 index 00000000..c795730d --- /dev/null +++ b/example/macos/Podfile @@ -0,0 +1,43 @@ +platform :osx, '10.14' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock new file mode 100644 index 00000000..16eb2301 --- /dev/null +++ b/example/macos/Podfile.lock @@ -0,0 +1,28 @@ +PODS: + - file_selector_macos (0.0.1): + - FlutterMacOS + - FlutterMacOS (1.0.0) + - opencv_dart (0.0.1): + - FlutterMacOS + +DEPENDENCIES: + - file_selector_macos (from `Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos`) + - FlutterMacOS (from `Flutter/ephemeral`) + - opencv_dart (from `Flutter/ephemeral/.symlinks/plugins/opencv_dart/macos`) + +EXTERNAL SOURCES: + file_selector_macos: + :path: Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos + FlutterMacOS: + :path: Flutter/ephemeral + opencv_dart: + :path: Flutter/ephemeral/.symlinks/plugins/opencv_dart/macos + +SPEC CHECKSUMS: + file_selector_macos: 54fdab7caa3ac3fc43c9fac4d7d8d231277f8cf2 + FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 + opencv_dart: 5970f8f91dc9666bc2082a53a538646d767e91ae + +PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 + +COCOAPODS: 1.15.2 diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj index 75daf03c..14c0906a 100644 --- a/example/macos/Runner.xcodeproj/project.pbxproj +++ b/example/macos/Runner.xcodeproj/project.pbxproj @@ -27,6 +27,8 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + DCFC2E127B9EF1F2204AB818 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 654596FE695EC3DCFED818BE /* Pods_Runner.framework */; }; + FA6EB657139E7F78347AE9FB /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ACB9F0B90590C36E43ED715D /* Pods_RunnerTests.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -60,11 +62,13 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 05EA5A4FC174F659E0F8044C /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + 28CF2AEF0D9D6DD70279F70A /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; - 33CC10ED2044A3C60003C045 /* opencv_dart_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "opencv_dart_example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10ED2044A3C60003C045 /* opencv_dart_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = opencv_dart_example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; @@ -76,8 +80,14 @@ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 5F575DB152AA0E496226DCF5 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; + 654596FE695EC3DCFED818BE /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 8479B48E7B210163B17FA742 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 9549B18450D49F6E814A1B53 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; + ACB9F0B90590C36E43ED715D /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DBB74CB371D8EA070063B99E /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -85,6 +95,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + FA6EB657139E7F78347AE9FB /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -92,6 +103,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DCFC2E127B9EF1F2204AB818 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -125,6 +137,7 @@ 331C80D6294CF71000263BE5 /* RunnerTests */, 33CC10EE2044A3C60003C045 /* Products */, D73912EC22F37F3D000D13A0 /* Frameworks */, + 607375F7BBF92453D6A82FF6 /* Pods */, ); sourceTree = ""; }; @@ -172,9 +185,25 @@ path = Runner; sourceTree = ""; }; + 607375F7BBF92453D6A82FF6 /* Pods */ = { + isa = PBXGroup; + children = ( + 8479B48E7B210163B17FA742 /* Pods-Runner.debug.xcconfig */, + 05EA5A4FC174F659E0F8044C /* Pods-Runner.release.xcconfig */, + 28CF2AEF0D9D6DD70279F70A /* Pods-Runner.profile.xcconfig */, + 9549B18450D49F6E814A1B53 /* Pods-RunnerTests.debug.xcconfig */, + DBB74CB371D8EA070063B99E /* Pods-RunnerTests.release.xcconfig */, + 5F575DB152AA0E496226DCF5 /* Pods-RunnerTests.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; D73912EC22F37F3D000D13A0 /* Frameworks */ = { isa = PBXGroup; children = ( + 654596FE695EC3DCFED818BE /* Pods_Runner.framework */, + ACB9F0B90590C36E43ED715D /* Pods_RunnerTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -186,6 +215,7 @@ isa = PBXNativeTarget; buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( + 814F1C305CA506DD176467C4 /* [CP] Check Pods Manifest.lock */, 331C80D1294CF70F00263BE5 /* Sources */, 331C80D2294CF70F00263BE5 /* Frameworks */, 331C80D3294CF70F00263BE5 /* Resources */, @@ -204,11 +234,13 @@ isa = PBXNativeTarget; buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + BD5E97794BFC96A5802B0CBD /* [CP] Check Pods Manifest.lock */, 33CC10E92044A3C60003C045 /* Sources */, 33CC10EA2044A3C60003C045 /* Frameworks */, 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, + A8E67AA0D8A94CB2BD6AC81C /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -329,6 +361,67 @@ shellPath = /bin/sh; shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; + 814F1C305CA506DD176467C4 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + A8E67AA0D8A94CB2BD6AC81C /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + BD5E97794BFC96A5802B0CBD /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -380,6 +473,7 @@ /* Begin XCBuildConfiguration section */ 331C80DB294CF71000263BE5 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 9549B18450D49F6E814A1B53 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; @@ -394,6 +488,7 @@ }; 331C80DC294CF71000263BE5 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DBB74CB371D8EA070063B99E /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; @@ -408,6 +503,7 @@ }; 331C80DD294CF71000263BE5 /* Profile */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 5F575DB152AA0E496226DCF5 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; diff --git a/example/macos/Runner.xcworkspace/contents.xcworkspacedata b/example/macos/Runner.xcworkspace/contents.xcworkspacedata index 1d526a16..21a3cc14 100644 --- a/example/macos/Runner.xcworkspace/contents.xcworkspacedata +++ b/example/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/ios/Makefile b/ios/Makefile new file mode 100644 index 00000000..6efa429c --- /dev/null +++ b/ios/Makefile @@ -0,0 +1,26 @@ +# Define the platform and architecture +OPENCV_DART_ARCH ?= arm64 # Default architecture is arm64 if not specified +VALID_ARCHS := x64 arm64 + +# Dart command +DART_CMD := dart run opencv_dart:setup + +# Function to check if a value is in a list +check_in_list = $(filter $(1),$(2)) + +# Get the parent directory of the current working directory +PARENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))).. +SETUP_CMD := cd $(PARENT_DIR) && $(DART_CMD) + +.PHONY: setup + +setup: + @echo "Auto-selected architecture: $(OPENCV_DART_ARCH)" + @echo "You can override this by setting the OPENCV_DART_ARCH environment variable. Valid options: x64, arm64" +ifeq ($(call check_in_list,$(OPENCV_DART_ARCH),$(VALID_ARCHS)),) + @echo "Unsupported architecture: $(OPENCV_DART_ARCH). Valid options are: x64, arm64" + @exit 1 +else + @echo "Running setup with architecture: $(OPENCV_DART_ARCH)" + @$(SETUP_CMD) ios --arch $(OPENCV_DART_ARCH) +endif diff --git a/ios/opencv_dart.podspec b/ios/opencv_dart.podspec index 3be0599e..38fb8dc1 100644 --- a/ios/opencv_dart.podspec +++ b/ios/opencv_dart.podspec @@ -3,6 +3,8 @@ # Run `pod lib lint opencv_dart.podspec` to validate before publishing. # Pod::Spec.new do |s| + system("make setup") + s.name = 'opencv_dart' s.version = '0.0.1' s.summary = 'OpenCV bindings for Dart.' diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index 49c218d0..cc62b11e 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -7,11 +7,33 @@ cmake_minimum_required(VERSION 3.10) set(PROJECT_NAME "opencv_dart") project(${PROJECT_NAME} LANGUAGES CXX) +# Define default architecture +set(OPENCV_DART_ARCH "x64") + +# Print messages +message(STATUS "Auto-selected architecture: ${OPENCV_DART_ARCH}") +message(STATUS "Running setup with architecture: ${OPENCV_DART_ARCH}") + +# Get the parent directory of the current working directory +get_filename_component(PARENT_DIR ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) + +# Run Dart command +find_program(DART_PATH dart) +message(STATUS "${PROJECT_NAME} using dart from: ${DART_PATH}") +execute_process( + COMMAND ${DART_PATH} run opencv_dart:setup linux --arch ${OPENCV_DART_ARCH} + TIMEOUT 120 + WORKING_DIRECTORY ${PARENT_DIR} +) + # Invoke the build for native code shared with the other target platforms. # This can be changed to accommodate different builds. # add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") file(GLOB opencv_dart_libs "${CMAKE_CURRENT_SOURCE_DIR}/*.so") +if(NOT opencv_dart_libs) + message(FATAL_ERROR "${PROJECT_NAME} setup failed: not found any .so in ${CMAKE_CURRENT_SOURCE_DIR}") +endif() # List of absolute paths to libraries that should be bundled with the plugin. # This list could contain prebuilt libraries, or libraries created by an diff --git a/macos/Makefile b/macos/Makefile new file mode 100644 index 00000000..b9620cde --- /dev/null +++ b/macos/Makefile @@ -0,0 +1,33 @@ +# Define the platform and architecture +PLATFORM := $(shell uname) +OPENCV_DART_ARCH := $(shell uname -m) + +# MacOS specific architectures +MACOS_ARCHS := x64 arm64 + +# Dart command +DART_CMD := dart run opencv_dart:setup + +# Function to check if a value is in a list +check_in_list = $(filter $(1),$(2)) + +# Get the parent directory of the current working directory +PARENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))).. +SETUP_CMD := cd $(PARENT_DIR) && $(DART_CMD) + +.PHONY: setup + +setup: +ifeq ($(PLATFORM),Darwin) + @echo "Detected macOS platform" +ifeq ($(call check_in_list,$(OPENCV_DART_ARCH),$(MACOS_ARCHS)),) + @echo "Unsupported architecture for macOS: $(OPENCV_DART_ARCH)" + @exit 1 +else + @echo "Running setup for macOS with architecture: $(OPENCV_DART_ARCH)" + @$(SETUP_CMD) macos --arch $(OPENCV_DART_ARCH) +endif +else + @echo "This setup only runs on macOS" + @exit 1 +endif diff --git a/macos/opencv_dart.podspec b/macos/opencv_dart.podspec index f27a29f0..d09790ab 100644 --- a/macos/opencv_dart.podspec +++ b/macos/opencv_dart.podspec @@ -3,25 +3,27 @@ # Run `pod lib lint opencv_dart.podspec` to validate before publishing. # Pod::Spec.new do |s| - s.name = 'opencv_dart' - s.version = '0.0.1' - s.summary = 'OpenCV bindings for Dart.' - s.description = <<-DESC -OpenCV bindings for Dart. - DESC - s.homepage = 'https://github.com/rainyl/opencv_dart' - s.license = { :file => '../LICENSE' } - s.author = { 'Rainyl' => 'rainyliusy3@gmail.com' } + system("make setup") + + s.name = 'opencv_dart' + s.version = '0.0.1' + s.summary = 'OpenCV bindings for Dart.' + s.description = <<-DESC + OpenCV bindings for Dart. + DESC + s.homepage = 'https://github.com/rainyl/opencv_dart' + s.license = { :file => '../LICENSE' } + s.author = { 'Rainyl' => 'rainyliusy3@gmail.com' } # This will ensure the source files in Classes/ are included in the native # builds of apps using this FFI plugin. Podspec does not support relative # paths, so Classes contains a forwarder C file that relatively imports # `../src/*` so that the C sources can be shared among all target platforms. - s.source = { :path => '.' } - # s.source_files = 'Classes/**/*' + s.source = { :path => '.' } + # s.source_files = 'Classes/**/*' s.dependency 'FlutterMacOS' s.vendored_libraries = '*.dylib' - s.platform = :osx, '10.11' + s.platform = :osx, '10.11' s.static_framework = true s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } s.swift_version = '5.0' diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index 455a268c..a34a1932 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -8,6 +8,25 @@ cmake_minimum_required(VERSION 3.14) set(PROJECT_NAME "opencv_dart") project(${PROJECT_NAME} LANGUAGES CXX) +# Define default architecture +set(OPENCV_DART_ARCH "x64") + +# Print messages +message(STATUS "Auto-selected architecture: ${OPENCV_DART_ARCH}") +message(STATUS "Running setup with architecture: ${OPENCV_DART_ARCH}") + +# Get the parent directory of the current working directory +get_filename_component(PARENT_DIR ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) + +# Run Dart command +find_program(DART_PATH dart.bat) + +execute_process( + COMMAND ${DART_PATH} run opencv_dart:setup windows -a ${OPENCV_DART_ARCH} + TIMEOUT 120 + WORKING_DIRECTORY ${PARENT_DIR} +) + # Invoke the build for native code shared with the other target platforms. # This can be changed to accommodate different builds. # add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") @@ -16,6 +35,9 @@ project(${PROJECT_NAME} LANGUAGES CXX) # This list could contain prebuilt libraries, or libraries created by an # external build triggered from this build file. file(GLOB opencv_dart_libs "${CMAKE_CURRENT_SOURCE_DIR}/*.dll") +if(NOT opencv_dart_libs) + message(FATAL_ERROR "${PROJECT_NAME} setup failed: not found any dll in ${CMAKE_CURRENT_SOURCE_DIR}") +endif() set(opencv_dart_bundled_libraries # Defined in ../src/CMakeLists.txt.