From 969c49a1b15ba8c1036cb6fc8790f40702b734b1 Mon Sep 17 00:00:00 2001 From: canxin <69547456+canxin121@users.noreply.github.com> Date: Wed, 3 Apr 2024 19:52:27 +0800 Subject: [PATCH] fix insufficient sh permissions (#65) Origin issue: https://github.com/fzyzcjy/flutter_rust_bridge/issues/1840 Origin pr: https://github.com/fzyzcjy/flutter_rust_bridge/pull/1842 Simple problem description: if you create a new flutter_rust project in windows, the sh script is automatically created, but the executable permissions cannot be set. When moving this project to macOS and executing `flutter build ios` to build ipa files the process crashes due to insufficient sh script permissions. This permission problem can be circumvented by `sh script.sh` rather than `script.sh` As verified by Github Action's macOS Runner, the modified cargokit works fine for building ipa apps using the flutter_rust project created on windows. [Action Link](https://github.com/canxin121/new_app_test/actions/runs/8466294309) --- build_pod.sh | 2 +- cmake/cargokit.cmake | 4 +++- gradle/plugin.gradle | 8 +++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/build_pod.sh b/build_pod.sh index 379b9c6..ed0e0d9 100755 --- a/build_pod.sh +++ b/build_pod.sh @@ -49,7 +49,7 @@ do fi done -"$BASEDIR/run_build_tool.sh" build-pod "$@" +sh "$BASEDIR/run_build_tool.sh" build-pod "$@" # Make a symlink from built framework to phony file, which will be used as input to # build script. This should force rebuild (podspec currently doesn't support alwaysOutOfDate diff --git a/cmake/cargokit.cmake b/cmake/cargokit.cmake index 8832600..ddd05df 100644 --- a/cmake/cargokit.cmake +++ b/cmake/cargokit.cmake @@ -50,6 +50,7 @@ function(apply_cargokit target manifest_dir lib_name any_symbol_name) else() set(SCRIPT_EXTENSION ".sh") set(IMPORT_LIB_EXTENSION "") + execute_process(COMMAND chmod +x "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}") endif() # Using generators in custom command is only supported in CMake 3.20+ @@ -75,6 +76,7 @@ function(apply_cargokit target manifest_dir lib_name any_symbol_name) ) endif() + set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/_phony_" PROPERTIES SYMBOLIC TRUE) if (TARGET ${target}) @@ -94,4 +96,4 @@ function(apply_cargokit target manifest_dir lib_name any_symbol_name) # Allow adding the output library to plugin bundled libraries set("${target}_cargokit_lib" ${OUTPUT_LIB} PARENT_SCOPE) -endfunction() \ No newline at end of file +endfunction() diff --git a/gradle/plugin.gradle b/gradle/plugin.gradle index a9a6ec7..12c49f1 100644 --- a/gradle/plugin.gradle +++ b/gradle/plugin.gradle @@ -55,7 +55,13 @@ abstract class CargoKitBuildTask extends DefaultTask { def manifestDir = Paths.get(project.buildscript.sourceFile.parent, project.cargokit.manifestDir) def rootProjectDir = project.rootProject.projectDir - + + if (!Os.isFamily(Os.FAMILY_WINDOWS)) { + project.exec { + commandLine 'chmod', '+x', path + } + } + project.exec { executable path args "build-gradle"