dart-lang / pub

The pub command line tool
https://dart.dev/tools/pub/cmd
BSD 3-Clause "New" or "Revised" License
1.04k stars 228 forks source link

FFI Flutter plugins not supported for locally hosted pub #2885

Closed ErrApparent closed 1 year ago

ErrApparent commented 3 years ago

Problem

If a Flutter plugin utilizing C interop is published to a locally hosted repository, the Flutter build process breaks when using said package in another project. This is a result of locally hosted pub-cache directories containing "%" in the path, and Ninja not being able to handle "%".

Proposed solution

As far as I can tell, the usage of "%" in the pub-cache hosted directory formatting is compartmentalized to _urlToDirectory and _directoryToUrl in hosted.dart. Hopefully, there is an alternative Ninja-compatible formatting that the current implementation could be replaced with that wouldn't interfere with anything else.

sigurdm commented 3 years ago

Is this a bug in Ninja? Could this be solved by better quoting of file names in the ninja script.

I would like to understand this better. Could point to or write a small reproduction of the issue?

ErrApparent commented 3 years ago

@sigurdm Really the only evidence I have of that Ninja can't handle "%" in paths is from this so post.

The "depfile has multiple output paths" doesn't make sense in this context, so I'm assuming it is the result of the "%" confusion.

I don't really know Gradle well (been pretty anti-Java since it's inception). So, my ability to track down the exact source of the issue has involved some guesswork. I'm sure you'd be much more capable than me. I'll try to put a simple reproduction together and point to it in the next few days.

In the mean time, here's the output:

FAILURE: Build failed with an exception.

* What went wrong: Execution failed for task ':native_string_extensions:externalNativeBuildDebug'. > Build command failed. Error while executing process /home/jed/Android/Sdk/cmake/3.10.2.4988404/bin/ninja with arguments {-C /home/jed/.pub-cache/hosted/localhost%588089/native_string_extensions-0.0.1/android/.cxx/cmake/debug/armeabi-v7a native_string_extensions} ninja: Entering directory `/home/jed/.pub-cache/hosted/localhost%588089/native_string_extensions-0.0.1/android/.cxx/cmake/debug/armeabi-v7a' [1/2] Building C object 'CMakeFiles/native_string_extensions.dir/home/jed/.pub-cache/hosted/localhost%588089/native_string_extensions-0.0.1/ios/Classes/native_string_extensions.c.o' FAILED: CMakeFiles/native_string_extensions.dir/home/jed/.pub-cache/hosted/localhost%588089/native_string_extensions-0.0.1/ios/Classes/native_string_extensions.c.o /home/jed/Android/Sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi16 --gcc-toolchain=/home/jed/Android/Sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/jed/Android/Sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Dnative_string_extensions_EXPORTS -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -O0 -fno-limit-debug-info -fPIC -MD -MT 'CMakeFiles/native_string_extensions.dir/home/jed/.pub-cache/hosted/localhost%588089/native_string_extensions-0.0.1/ios/Classes/native_string_extensions.c.o' -MF CMakeFiles/native_string_extensions.dir/home/jed/.pub-cache/hosted/localhost%588089/native_string_extensions-0.0.1/ios/Classes/native_string_extensions.c.o.d -o 'CMakeFiles/native_string_extensions.dir/home/jed/.pub-cache/hosted/localhost%588089/native_string_extensions-0.0.1/ios/Classes/native_string_extensions.c.o' -c '/home/jed/.pub-cache/hosted/localhost%588089/native_string_extensions-0.0.1/ios/Classes/native_string_extensions.c' depfile has multiple output paths ninja: build stopped: subcommand failed.

sigurdm commented 1 year ago

Closing, as I believe this is not a pub issue.