Skip to content

Commit

Permalink
bundle flutter_embedder.h with project
Browse files Browse the repository at this point in the history
- only way to ensure flutter-pi doesn't break with embedder API
  updates
- also, that's the whole benefit of the ABI-backwards compatibility
  of the embedder header
- don't download embedder header in CMakeLists.txt
- remove FLUTTER_EMBEDDER_HEADER option
  • Loading branch information
ardera committed May 13, 2023
1 parent def1681 commit 0e0889e
Show file tree
Hide file tree
Showing 3 changed files with 2,982 additions and 48 deletions.
49 changes: 1 addition & 48 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,53 +68,6 @@ set_property(CACHE FILESYSTEM_LAYOUT PROPERTY STRINGS ${FILESYSTEM_LAYOUTS})

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Download the flutter_embedder.h if it's not specified
if(NOT FLUTTER_EMBEDDER_HEADER)

include(FetchContent)

if(NOT FLUTTER_ENGINE_SHA)

if(NOT CHANNEL)
set(CHANNEL "stable" CACHE STRING "The flutter channel to be used for downloading the flutter_embedder.h header file. Choose: master, dev, beta, stable" FORCE)
message(STATUS "Flutter Channel not set, defaulting to stable")
endif()

message(STATUS "Flutter Channel ........ ${CHANNEL}")

FetchContent_Declare(engine-version
URL https://raw.githubusercontent.com/flutter/flutter/${CHANNEL}/bin/internal/engine.version
DOWNLOAD_NAME engine.version
DOWNLOAD_NO_EXTRACT TRUE
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}
)

FetchContent_GetProperties(engine-version)
if(NOT engine-version_POPULATED)
FetchContent_Populate(engine-version)
file(READ ${CMAKE_BINARY_DIR}/engine.version FLUTTER_ENGINE_SHA)
string(REPLACE "\n" "" FLUTTER_ENGINE_SHA ${FLUTTER_ENGINE_SHA})
else()
MESSAGE(FATAL "Unable to determine engine-version, please override FLUTTER_ENGINE_SHA")
endif()

endif()

message(STATUS "Engine SHA1 ............ ${FLUTTER_ENGINE_SHA}")

set(FLUTTER_EMBEDDER_HEADER ${CMAKE_BINARY_DIR}/flutter_embedder.h)

# Download and setup the flutter engine library header.
if(NOT EXISTS ${FLUTTER_EMBEDDER_HEADER})
file(DOWNLOAD
https://raw.githubusercontent.com/flutter/engine/${FLUTTER_ENGINE_SHA}/shell/platform/embedder/embedder.h
${FLUTTER_EMBEDDER_HEADER}
)
endif()
else()
message(STATUS "Flutter Header ......... ${FLUTTER_EMBEDDER_HEADER}")
endif()

include(ExternalProject)
include(CheckCCompilerFlag)

Expand Down Expand Up @@ -170,7 +123,7 @@ target_link_libraries(flutterpi_module PUBLIC
)

target_include_directories(flutterpi_module PUBLIC
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/third_party/flutter_embedder_header/include
${CMAKE_SOURCE_DIR}/src
)

Expand Down
1 change: 1 addition & 0 deletions third_party/flutter_embedder_header/engine.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d44b5a94c976fbb65815374f61ab5392a220b084
Loading

0 comments on commit 0e0889e

Please sign in to comment.