From 72680e073ec8591e73a790603990a008dc00fc3e Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Fri, 20 Sep 2024 11:06:05 -0500 Subject: [PATCH 1/8] chore(common): Windows CMake file collision --- .../amplify_db_common/windows/CMakeLists.txt | 79 ++++++++++--------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/packages/common/amplify_db_common/windows/CMakeLists.txt b/packages/common/amplify_db_common/windows/CMakeLists.txt index a5de5d3f88..4da745b029 100644 --- a/packages/common/amplify_db_common/windows/CMakeLists.txt +++ b/packages/common/amplify_db_common/windows/CMakeLists.txt @@ -21,7 +21,7 @@ add_library(${PLUGIN_NAME} SHARED ### # Essentially, the idea of this build script is to compile a sqlite3.dll -# and make Fluter bundle that with the final app. +# and make Flutter bundle that with the final app. # It looks like we can't avoid building a sqlite3_flutter_libs.dll too, # but that's not on me. @@ -34,57 +34,62 @@ target_include_directories(${PLUGIN_NAME} INTERFACE target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) include(FetchContent) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") # cmake 3.24.0 added the `DOWNLOAD_EXTRACT_TIMESTAMP` and prints an ugly warning when # the default is used, so override it to the recommended behavior. # We can't really ask users to use a cmake that recent, so there's this if here. FetchContent_Declare( sqlite3 - URL https://sqlite.org/2023/sqlite-autoconf-3430000.tar.gz + URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz DOWNLOAD_EXTRACT_TIMESTAMP NEW ) else() FetchContent_Declare( sqlite3 - URL https://sqlite.org/2023/sqlite-autoconf-3430000.tar.gz + URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz ) endif() -FetchContent_MakeAvailable(sqlite3) -add_library(sqlite3 SHARED "sqlite3_flutter.c") +# Only fetch and build sqlite3 if it hasn't been added yet +if (NOT TARGET sqlite3) + FetchContent_MakeAvailable(sqlite3) -target_include_directories(sqlite3 PRIVATE "${sqlite3_SOURCE_DIR}") -target_compile_options(sqlite3 PRIVATE "$<$>:-O2>" "/w") + add_library(sqlite3 SHARED "sqlite3_flutter.c") -# Note: Keep in sync with https://github.com/simolus3/sqlite-native-libraries/blob/master/sqlite3-native-library/cpp/CMakeLists.txt -target_compile_definitions(sqlite3 PRIVATE - SQLITE_ENABLE_FTS5 - SQLITE_ENABLE_RTREE - SQLITE_DQS=0 - SQLITE_DEFAULT_MEMSTATUS=0 - SQLITE_TEMP_STORE=2 - SQLITE_MAX_EXPR_DEPTH=0 - SQLITE_OMIT_AUTHORIZATION - SQLITE_OMIT_DECLTYPE - SQLITE_OMIT_DEPRECATED - SQLITE_OMIT_GET_TABLE - SQLITE_OMIT_LOAD_EXTENSION - SQLITE_OMIT_PROGRESS_CALLBACK - SQLITE_OMIT_SHARED_CACHE - SQLITE_OMIT_TCL_VARIABLE - SQLITE_OMIT_TRACE - SQLITE_USE_ALLOCA - SQLITE_UNTESTABLE - SQLITE_HAVE_ISNAN - SQLITE_HAVE_LOCALTIME_R - SQLITE_HAVE_LOCALTIME_S -) + target_include_directories(sqlite3 PRIVATE "${sqlite3_SOURCE_DIR}") + target_compile_options(sqlite3 PRIVATE "$<$>:-O2>" "/w") -# Ensure sqlite3 actually gets build -add_dependencies(${PLUGIN_NAME} sqlite3) + # Note: Keep in sync with https://github.com/simolus3/sqlite-native-libraries/blob/master/sqlite3-native-library/cpp/CMakeLists.txt + target_compile_definitions(sqlite3 PRIVATE + SQLITE_ENABLE_DBSTAT_VTAB + SQLITE_ENABLE_FTS5 + SQLITE_ENABLE_RTREE + SQLITE_DQS=0 + SQLITE_DEFAULT_MEMSTATUS=0 + SQLITE_TEMP_STORE=2 + SQLITE_MAX_EXPR_DEPTH=0 + SQLITE_STRICT_SUBTYPE=1 + SQLITE_OMIT_AUTHORIZATION + SQLITE_OMIT_DECLTYPE + SQLITE_OMIT_DEPRECATED + SQLITE_OMIT_PROGRESS_CALLBACK + SQLITE_OMIT_SHARED_CACHE + SQLITE_OMIT_TCL_VARIABLE + SQLITE_OMIT_TRACE + SQLITE_USE_ALLOCA + SQLITE_UNTESTABLE + SQLITE_HAVE_ISNAN + SQLITE_HAVE_LOCALTIME_R + SQLITE_HAVE_LOCALTIME_S + ) -# List of absolute paths to libraries that should be bundled with the plugin -set(amplify_db_common_bundled_libraries - "$" - PARENT_SCOPE -) + # Ensure sqlite3 actually gets built + add_dependencies(${PLUGIN_NAME} sqlite3) + + # List of absolute paths to libraries that should be bundled with the plugin + set(amplify_db_common_bundled_libraries + "$" + PARENT_SCOPE + ) +endif() From 5fcf84618174d3df81a1b7bd804b50bbf88a761f Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Fri, 20 Sep 2024 12:00:01 -0500 Subject: [PATCH 2/8] temp bump dep --- packages/common/amplify_db_common_dart/pubspec.yaml | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/common/amplify_db_common_dart/pubspec.yaml b/packages/common/amplify_db_common_dart/pubspec.yaml index 7ede684144..d6e0b887c1 100644 --- a/packages/common/amplify_db_common_dart/pubspec.yaml +++ b/packages/common/amplify_db_common_dart/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: drift: ">=2.18.0 <2.19.0" meta: ^1.7.0 path: ">=1.8.0 <2.0.0" - sqlite3: ">=2.0.0 <2.4.3" + sqlite3: ">=2.0.0 <2.4.7" dev_dependencies: amplify_lints: ">=3.1.0 <3.2.0" diff --git a/pubspec.yaml b/pubspec.yaml index 7038fca683..b4b41cd7bf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,7 +39,7 @@ dependencies: oauth2: ^2.0.2 package_info_plus: ^8.0.0 pigeon: ^11.0.0 - sqlite3: ">=2.0.0 <2.4.3" + sqlite3: ">=2.0.0 <2.4.7" source_gen: ^1.3.2 stack_trace: ^1.10.0 uuid: ">=3.0.6 <5.0.0" From cd79b00e8f28971dd1585e533faf1d73ff4c733a Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Fri, 20 Sep 2024 12:22:25 -0500 Subject: [PATCH 3/8] adjust conditional --- .../amplify_db_common/windows/CMakeLists.txt | 63 +++++++++---------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/packages/common/amplify_db_common/windows/CMakeLists.txt b/packages/common/amplify_db_common/windows/CMakeLists.txt index 4da745b029..6377002554 100644 --- a/packages/common/amplify_db_common/windows/CMakeLists.txt +++ b/packages/common/amplify_db_common/windows/CMakeLists.txt @@ -16,43 +16,42 @@ add_library(${PLUGIN_NAME} SHARED "amplify_db_common_plugin.cpp" ) -### +# ## # Below here, keep in sync with: https://github.com/simolus3/sqlite3.dart/blob/main/sqlite3_flutter_libs/windows/CMakeLists.txt -### +# ## -# Essentially, the idea of this build script is to compile a sqlite3.dll -# and make Flutter bundle that with the final app. -# It looks like we can't avoid building a sqlite3_flutter_libs.dll too, -# but that's not on me. - -apply_standard_settings(${PLUGIN_NAME}) -set_target_properties(${PLUGIN_NAME} PROPERTIES - CXX_VISIBILITY_PRESET hidden) -target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) -target_include_directories(${PLUGIN_NAME} INTERFACE - "${CMAKE_CURRENT_SOURCE_DIR}/include") -target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) +# Only fetch and build sqlite3 if it hasn't been added yet +if(NOT TARGET sqlite3) + # Essentially, the idea of this build script is to compile a sqlite3.dll + # and make Flutter bundle that with the final app. + # It looks like we can't avoid building a sqlite3_flutter_libs.dll too, + # but that's not on me. + apply_standard_settings(${PLUGIN_NAME}) + set_target_properties(${PLUGIN_NAME} PROPERTIES + CXX_VISIBILITY_PRESET hidden) + target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) + target_include_directories(${PLUGIN_NAME} INTERFACE + "${CMAKE_CURRENT_SOURCE_DIR}/include") + target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) -include(FetchContent) + include(FetchContent) -if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") - # cmake 3.24.0 added the `DOWNLOAD_EXTRACT_TIMESTAMP` and prints an ugly warning when - # the default is used, so override it to the recommended behavior. - # We can't really ask users to use a cmake that recent, so there's this if here. - FetchContent_Declare( - sqlite3 - URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz - DOWNLOAD_EXTRACT_TIMESTAMP NEW - ) -else() - FetchContent_Declare( - sqlite3 - URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz - ) -endif() + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") + # cmake 3.24.0 added the `DOWNLOAD_EXTRACT_TIMESTAMP` and prints an ugly warning when + # the default is used, so override it to the recommended behavior. + # We can't really ask users to use a cmake that recent, so there's this if here. + FetchContent_Declare( + sqlite3 + URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz + DOWNLOAD_EXTRACT_TIMESTAMP NEW + ) + else() + FetchContent_Declare( + sqlite3 + URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz + ) + endif() -# Only fetch and build sqlite3 if it hasn't been added yet -if (NOT TARGET sqlite3) FetchContent_MakeAvailable(sqlite3) add_library(sqlite3 SHARED "sqlite3_flutter.c") From 7572f75a0cd1722da209ebb5e5f8465f95b445b8 Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Fri, 20 Sep 2024 13:04:13 -0500 Subject: [PATCH 4/8] alias approach --- .../amplify_db_common/windows/CMakeLists.txt | 53 +++++++++---------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/packages/common/amplify_db_common/windows/CMakeLists.txt b/packages/common/amplify_db_common/windows/CMakeLists.txt index 6377002554..ee4dd682e9 100644 --- a/packages/common/amplify_db_common/windows/CMakeLists.txt +++ b/packages/common/amplify_db_common/windows/CMakeLists.txt @@ -20,26 +20,20 @@ add_library(${PLUGIN_NAME} SHARED # Below here, keep in sync with: https://github.com/simolus3/sqlite3.dart/blob/main/sqlite3_flutter_libs/windows/CMakeLists.txt # ## -# Only fetch and build sqlite3 if it hasn't been added yet -if(NOT TARGET sqlite3) - # Essentially, the idea of this build script is to compile a sqlite3.dll - # and make Flutter bundle that with the final app. - # It looks like we can't avoid building a sqlite3_flutter_libs.dll too, - # but that's not on me. - apply_standard_settings(${PLUGIN_NAME}) - set_target_properties(${PLUGIN_NAME} PROPERTIES - CXX_VISIBILITY_PRESET hidden) - target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) - target_include_directories(${PLUGIN_NAME} INTERFACE - "${CMAKE_CURRENT_SOURCE_DIR}/include") - target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) +# Apply standard settings for the plugin +apply_standard_settings(${PLUGIN_NAME}) +set_target_properties(${PLUGIN_NAME} PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) +target_include_directories(${PLUGIN_NAME} INTERFACE + "${CMAKE_CURRENT_SOURCE_DIR}/include") +target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) +# Check if the target 'sqlite3' already exists +if(NOT TARGET sqlite3_amplify_db_common) include(FetchContent) if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") - # cmake 3.24.0 added the `DOWNLOAD_EXTRACT_TIMESTAMP` and prints an ugly warning when - # the default is used, so override it to the recommended behavior. - # We can't really ask users to use a cmake that recent, so there's this if here. FetchContent_Declare( sqlite3 URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz @@ -54,13 +48,14 @@ if(NOT TARGET sqlite3) FetchContent_MakeAvailable(sqlite3) - add_library(sqlite3 SHARED "sqlite3_flutter.c") + # Create an alias for the sqlite3 library specifically for amplify_db_common + # Must be preserved to avoid collisions, ie consumer has a dependency on sqlite3 too + add_library(sqlite3_amplify_db_common SHARED "sqlite3_flutter.c") - target_include_directories(sqlite3 PRIVATE "${sqlite3_SOURCE_DIR}") - target_compile_options(sqlite3 PRIVATE "$<$>:-O2>" "/w") + target_include_directories(sqlite3_amplify_db_common PRIVATE "${sqlite3_SOURCE_DIR}") + target_compile_options(sqlite3_amplify_db_common PRIVATE "$<$>:-O2>" "/w") - # Note: Keep in sync with https://github.com/simolus3/sqlite-native-libraries/blob/master/sqlite3-native-library/cpp/CMakeLists.txt - target_compile_definitions(sqlite3 PRIVATE + target_compile_definitions(sqlite3_amplify_db_common PRIVATE SQLITE_ENABLE_DBSTAT_VTAB SQLITE_ENABLE_FTS5 SQLITE_ENABLE_RTREE @@ -82,13 +77,13 @@ if(NOT TARGET sqlite3) SQLITE_HAVE_LOCALTIME_R SQLITE_HAVE_LOCALTIME_S ) +endif() - # Ensure sqlite3 actually gets built - add_dependencies(${PLUGIN_NAME} sqlite3) +# Ensure sqlite3_amplify_db_common is used by the plugin +add_dependencies(${PLUGIN_NAME} sqlite3_amplify_db_common) - # List of absolute paths to libraries that should be bundled with the plugin - set(amplify_db_common_bundled_libraries - "$" - PARENT_SCOPE - ) -endif() +# List of absolute paths to libraries that should be bundled with the plugin +set(amplify_db_common_bundled_libraries + "$" + PARENT_SCOPE +) From 740e0083b404f7bc8af44790e6bb5992c515cdb2 Mon Sep 17 00:00:00 2001 From: equartey Date: Fri, 18 Oct 2024 11:04:11 -0500 Subject: [PATCH 5/8] test --- .../amplify_db_common/windows/CMakeLists.txt | 72 ------------------- 1 file changed, 72 deletions(-) diff --git a/packages/common/amplify_db_common/windows/CMakeLists.txt b/packages/common/amplify_db_common/windows/CMakeLists.txt index ee4dd682e9..7b379714d9 100644 --- a/packages/common/amplify_db_common/windows/CMakeLists.txt +++ b/packages/common/amplify_db_common/windows/CMakeLists.txt @@ -15,75 +15,3 @@ set(PLUGIN_NAME "amplify_db_common_plugin") add_library(${PLUGIN_NAME} SHARED "amplify_db_common_plugin.cpp" ) - -# ## -# Below here, keep in sync with: https://github.com/simolus3/sqlite3.dart/blob/main/sqlite3_flutter_libs/windows/CMakeLists.txt -# ## - -# Apply standard settings for the plugin -apply_standard_settings(${PLUGIN_NAME}) -set_target_properties(${PLUGIN_NAME} PROPERTIES - CXX_VISIBILITY_PRESET hidden) -target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) -target_include_directories(${PLUGIN_NAME} INTERFACE - "${CMAKE_CURRENT_SOURCE_DIR}/include") -target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) - -# Check if the target 'sqlite3' already exists -if(NOT TARGET sqlite3_amplify_db_common) - include(FetchContent) - - if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") - FetchContent_Declare( - sqlite3 - URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz - DOWNLOAD_EXTRACT_TIMESTAMP NEW - ) - else() - FetchContent_Declare( - sqlite3 - URL https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz - ) - endif() - - FetchContent_MakeAvailable(sqlite3) - - # Create an alias for the sqlite3 library specifically for amplify_db_common - # Must be preserved to avoid collisions, ie consumer has a dependency on sqlite3 too - add_library(sqlite3_amplify_db_common SHARED "sqlite3_flutter.c") - - target_include_directories(sqlite3_amplify_db_common PRIVATE "${sqlite3_SOURCE_DIR}") - target_compile_options(sqlite3_amplify_db_common PRIVATE "$<$>:-O2>" "/w") - - target_compile_definitions(sqlite3_amplify_db_common PRIVATE - SQLITE_ENABLE_DBSTAT_VTAB - SQLITE_ENABLE_FTS5 - SQLITE_ENABLE_RTREE - SQLITE_DQS=0 - SQLITE_DEFAULT_MEMSTATUS=0 - SQLITE_TEMP_STORE=2 - SQLITE_MAX_EXPR_DEPTH=0 - SQLITE_STRICT_SUBTYPE=1 - SQLITE_OMIT_AUTHORIZATION - SQLITE_OMIT_DECLTYPE - SQLITE_OMIT_DEPRECATED - SQLITE_OMIT_PROGRESS_CALLBACK - SQLITE_OMIT_SHARED_CACHE - SQLITE_OMIT_TCL_VARIABLE - SQLITE_OMIT_TRACE - SQLITE_USE_ALLOCA - SQLITE_UNTESTABLE - SQLITE_HAVE_ISNAN - SQLITE_HAVE_LOCALTIME_R - SQLITE_HAVE_LOCALTIME_S - ) -endif() - -# Ensure sqlite3_amplify_db_common is used by the plugin -add_dependencies(${PLUGIN_NAME} sqlite3_amplify_db_common) - -# List of absolute paths to libraries that should be bundled with the plugin -set(amplify_db_common_bundled_libraries - "$" - PARENT_SCOPE -) From 8dfbdcd3bdb80d9e10ab461437b9a1597e66655f Mon Sep 17 00:00:00 2001 From: equartey Date: Wed, 23 Oct 2024 12:28:49 -0500 Subject: [PATCH 6/8] test --- .../amplify_db_common/windows/CMakeLists.txt | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/packages/common/amplify_db_common/windows/CMakeLists.txt b/packages/common/amplify_db_common/windows/CMakeLists.txt index 7b379714d9..45eb154162 100644 --- a/packages/common/amplify_db_common/windows/CMakeLists.txt +++ b/packages/common/amplify_db_common/windows/CMakeLists.txt @@ -15,3 +15,90 @@ set(PLUGIN_NAME "amplify_db_common_plugin") add_library(${PLUGIN_NAME} SHARED "amplify_db_common_plugin.cpp" ) + +### +# Below here, keep in sync with: https://github.com/simolus3/sqlite3.dart/blob/main/sqlite3_flutter_libs/windows/CMakeLists.txt +### + +# Essentially, the idea of this build script is to compile a sqlite3.dll +# and make Fluter bundle that with the final app. +# It looks like we can't avoid building a sqlite3_flutter_libs.dll too, +# but that's not on me. + +apply_standard_settings(${PLUGIN_NAME}) +set_target_properties(${PLUGIN_NAME} PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) +target_include_directories(${PLUGIN_NAME} INTERFACE + "${CMAKE_CURRENT_SOURCE_DIR}/include") +target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) + +# Include FetchContent for sqlite3 if not already available. +include(FetchContent) + +# Only add the sqlite3 library if it hasn't been defined already. +if (NOT TARGET sqlite3) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") + FetchContent_Declare( + sqlite3 + URL https://sqlite.org/2023/sqlite-autoconf-3430000.tar.gz + DOWNLOAD_EXTRACT_TIMESTAMP NEW + ) + else() + FetchContent_Declare( + sqlite3 + URL https://sqlite.org/2023/sqlite-autoconf-3430000.tar.gz + ) + endif() + + FetchContent_MakeAvailable(sqlite3) + + # Define the sqlite3 library only if it wasn't already defined. + add_library(sqlite3 SHARED "sqlite3_flutter.c") + + # Configure sqlite3 compilation options. + target_include_directories(sqlite3 PRIVATE "${sqlite3_SOURCE_DIR}") + target_compile_options(sqlite3 PRIVATE "$<$>:-O2>" "/w") + + # Note: Keep in sync with https://github.com/simolus3/sqlite-native-libraries/blob/master/sqlite3-native-library/cpp/CMakeLists.txt + target_compile_definitions(sqlite3 PRIVATE + SQLITE_ENABLE_FTS5 + SQLITE_ENABLE_RTREE + SQLITE_DQS=0 + SQLITE_DEFAULT_MEMSTATUS=0 + SQLITE_TEMP_STORE=2 + SQLITE_MAX_EXPR_DEPTH=0 + SQLITE_OMIT_AUTHORIZATION + SQLITE_OMIT_DECLTYPE + SQLITE_OMIT_DEPRECATED + SQLITE_OMIT_GET_TABLE + SQLITE_OMIT_LOAD_EXTENSION + SQLITE_OMIT_PROGRESS_CALLBACK + SQLITE_OMIT_SHARED_CACHE + SQLITE_OMIT_TCL_VARIABLE + SQLITE_OMIT_TRACE + SQLITE_USE_ALLOCA + SQLITE_UNTESTABLE + SQLITE_HAVE_ISNAN + SQLITE_HAVE_LOCALTIME_R + SQLITE_HAVE_LOCALTIME_S + ) + + # Create an alias for this version of sqlite3 for your plugin's use. + add_library(sqlite3_amplify_db_common ALIAS sqlite3) +else() + # If sqlite3 already exists, create an alias for your plugin to avoid duplication. + add_library(sqlite3_amplify_db_common ALIAS sqlite3) +endif() + +# Link your plugin to the sqlite3 alias. +target_link_libraries(${PLUGIN_NAME} PRIVATE sqlite3_amplify_db_common) + +# Ensure sqlite3 actually gets built. +add_dependencies(${PLUGIN_NAME} sqlite3_amplify_db_common) + +# List of absolute paths to libraries that should be bundled with the plugin. +set(amplify_db_common_bundled_libraries + "$" + PARENT_SCOPE +) From cc6ba9d4a8128d5910f72b1ff8fd814a9dff9ec8 Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Thu, 24 Oct 2024 09:55:20 -0500 Subject: [PATCH 7/8] clean up comments --- .../amplify_db_common/windows/CMakeLists.txt | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/common/amplify_db_common/windows/CMakeLists.txt b/packages/common/amplify_db_common/windows/CMakeLists.txt index 45eb154162..b9788c4158 100644 --- a/packages/common/amplify_db_common/windows/CMakeLists.txt +++ b/packages/common/amplify_db_common/windows/CMakeLists.txt @@ -16,15 +16,14 @@ add_library(${PLUGIN_NAME} SHARED "amplify_db_common_plugin.cpp" ) -### +# ## # Below here, keep in sync with: https://github.com/simolus3/sqlite3.dart/blob/main/sqlite3_flutter_libs/windows/CMakeLists.txt -### +# ## # Essentially, the idea of this build script is to compile a sqlite3.dll # and make Fluter bundle that with the final app. # It looks like we can't avoid building a sqlite3_flutter_libs.dll too, # but that's not on me. - apply_standard_settings(${PLUGIN_NAME}) set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) @@ -33,12 +32,14 @@ target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) -# Include FetchContent for sqlite3 if not already available. include(FetchContent) # Only add the sqlite3 library if it hasn't been defined already. -if (NOT TARGET sqlite3) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") +if(NOT TARGET sqlite3) + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") + # cmake 3.24.0 added the `DOWNLOAD_EXTRACT_TIMESTAMP` and prints an ugly warning when + # the default is used, so override it to the recommended behavior. + # We can't really ask users to use a cmake that recent, so there's this if here. FetchContent_Declare( sqlite3 URL https://sqlite.org/2023/sqlite-autoconf-3430000.tar.gz @@ -55,8 +56,7 @@ if (NOT TARGET sqlite3) # Define the sqlite3 library only if it wasn't already defined. add_library(sqlite3 SHARED "sqlite3_flutter.c") - - # Configure sqlite3 compilation options. + target_include_directories(sqlite3 PRIVATE "${sqlite3_SOURCE_DIR}") target_compile_options(sqlite3 PRIVATE "$<$>:-O2>" "/w") @@ -83,18 +83,16 @@ if (NOT TARGET sqlite3) SQLITE_HAVE_LOCALTIME_R SQLITE_HAVE_LOCALTIME_S ) - - # Create an alias for this version of sqlite3 for your plugin's use. + + # Create an alias for this version of sqlite3. add_library(sqlite3_amplify_db_common ALIAS sqlite3) else() - # If sqlite3 already exists, create an alias for your plugin to avoid duplication. + # If sqlite3 already exists, create an alias for amplify plugin to avoid duplication. add_library(sqlite3_amplify_db_common ALIAS sqlite3) endif() -# Link your plugin to the sqlite3 alias. target_link_libraries(${PLUGIN_NAME} PRIVATE sqlite3_amplify_db_common) -# Ensure sqlite3 actually gets built. add_dependencies(${PLUGIN_NAME} sqlite3_amplify_db_common) # List of absolute paths to libraries that should be bundled with the plugin. From 638d7b1b45c1bf37334a6d2d71ae40bee43b9c88 Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Thu, 24 Oct 2024 09:57:47 -0500 Subject: [PATCH 8/8] Added sqlite3 dep for example app to verify fix --- packages/common/amplify_db_common/example/pubspec.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/common/amplify_db_common/example/pubspec.yaml b/packages/common/amplify_db_common/example/pubspec.yaml index 52a0bd554f..aee1e97d19 100644 --- a/packages/common/amplify_db_common/example/pubspec.yaml +++ b/packages/common/amplify_db_common/example/pubspec.yaml @@ -11,6 +11,10 @@ dependencies: drift: ">=2.18.0 <2.19.0" flutter: sdk: flutter + # Unused in example app, rather included to validate + # windows app will build when there is a downstream dependency on sqlite3 + # https://github.com/aws-amplify/amplify-flutter/issues/5477 + sqlite3: ">=2.0.0 <2.4.7" dev_dependencies: amplify_lints: ^2.0.0