Skip to content

Commit

Permalink
cmake: we now use flutter engine from our 3rdparty
Browse files Browse the repository at this point in the history
No longer needed to have env variables pointing to a local
flutter which needed to exist somewhere else.

download_engine.sh now detects which flutter version you need
and downloads it.
  • Loading branch information
iamsergio committed Jan 10, 2025
1 parent 994eaf4 commit 295bd9c
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 271 deletions.
63 changes: 0 additions & 63 deletions .devcontainer/Dockerfile

This file was deleted.

39 changes: 0 additions & 39 deletions .devcontainer/devcontainer.json

This file was deleted.

71 changes: 0 additions & 71 deletions .github/docker/Dockerfile

This file was deleted.

5 changes: 0 additions & 5 deletions .github/docker/compose.yml

This file was deleted.

35 changes: 21 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,37 @@ jobs:
fail-fast: true
matrix:
os:
- self-hosted
# - windows-latest
# - macos-latest
- ubuntu-24.04

steps:
- uses: actions/checkout@v4
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
fetch-depth: 0

- name: Install ninja-build tool (must be after Qt due PATH changes)
if: ${{ runner.os == 'Windows' }}
uses: turtlesec-no/get-ninja@main

- name: Make sure MSVC is found when Ninja generator is in use
if: ${{ runner.os == 'Windows' }}
uses: ilammy/msvc-dev-cmd@v1
version: 6.6.0
cache: true

- name: Checkout qt-embedder
uses: actions/checkout@v4
with:
submodules: true

- name: Install clang
run: sudo apt-get update && sudo apt-get install -y clang ninja-build

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable

- name: Download flutter engine
run: sh download_engine.sh
env:
GH_TOKEN: ${{ github.token }}

- name: Configure project
run: cmake -S . -B ./build-dev --preset dev

- name: Build Project ${{ matrix.preset.build_preset_arg }}
- name: Build Project
run: cmake --build ./build-dev

- name: Build example
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ compile_commands.json
.cache/
/examples/default_counter_app/linux/flutter/generated_plugins.cmake
/examples/default_counter_app/windows/flutter/generated_plugins.cmake
libflutter_engine.so
2 changes: 1 addition & 1 deletion 3rdparty/flutter
Submodule flutter updated 1706 files
71 changes: 27 additions & 44 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,29 @@ set(CMAKE_INCLUDE_CURRENT_DIRS ON)

find_package(Qt6 6.6 NO_MODULE REQUIRED COMPONENTS Widgets OpenGL)

if(NOT DEFINED ENV{FLUTTER_ENGINE_FOLDER})
message(FATAL_ERROR "Point env var FLUTTER_ENGINE_FOLDER to engine folder")
endif()

if(MSVC)
# Windows is not tested, this probably doesn't work
set(FLUTTER_ENGINE_LIBRARY flutter_engine.lib)
else()
if(EXISTS "$ENV{FLUTTER_ENGINE_FOLDER}/rel/")
if(QT_EMBEDDER_AOT)
set(FLUTTER_ENGINE_LIBRARY
rel/libflutter_engine.${CMAKE_SHARED_LIBRARY_SUFFIX})
else()
set(FLUTTER_ENGINE_LIBRARY
dbg_unopt/libflutter_engine.${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()
set(FLUTTER_ENGINE_INCLUDE_DIR $ENV{FLUTTER_ENGINE_FOLDER})
if(QT_EMBEDDER_AOT)
set(FLUTTER_ENGINE_LIBRARY
${CMAKE_SOURCE_DIR}/engine_binaries/rel/libflutter_engine${CMAKE_SHARED_LIBRARY_SUFFIX}
)
else()
if(APPLE)
set(BUILD_FOLDER_NAME host_debug_unopt_arm64)
else()
set(BUILD_FOLDER_NAME host_debug_unopt)
endif()

set(FLUTTER_ENGINE_LIBRARY
../out/${BUILD_FOLDER_NAME}/libflutter_engine${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_SOURCE_DIR}/engine_binaries/dbg_unopt/libflutter_engine${CMAKE_SHARED_LIBRARY_SUFFIX}
)
set(FLUTTER_ENGINE_INCLUDE_DIR
$ENV{FLUTTER_ENGINE_FOLDER}/../out/${BUILD_FOLDER_NAME})
endif()
endif()

message(
"FLUTTER_ENGINE_LIBRARY=$ENV{FLUTTER_ENGINE_FOLDER}/${FLUTTER_ENGINE_LIBRARY}"
)
message("FLUTTER_ENGINE_LIBRARY=${FLUTTER_ENGINE_LIBRARY}}")

include_directories(${FLUTTER_ENGINE_INCLUDE_DIR})
if(NOT EXISTS ${FLUTTER_ENGINE_LIBRARY})
message(
FATAL_ERROR
"Could not find ${FLUTTER_ENGINE_LIBRARY}. Did you run dowload_engine.sh ?"
)
endif()

if(ENABLE_ASAN)
add_compile_options(-fsanitize=address -fsanitize=undefined)
Expand All @@ -62,31 +49,27 @@ endif()

add_library(
flutter_common_client_wrapper STATIC
$ENV{FLUTTER_ENGINE_FOLDER}/shell/platform/common/client_wrapper/plugin_registrar.cc
$ENV{FLUTTER_ENGINE_FOLDER}/shell/platform/common/client_wrapper/core_implementations.cc
$ENV{FLUTTER_ENGINE_FOLDER}/shell/platform/common/client_wrapper/standard_codec.cc
$ENV{FLUTTER_ENGINE_FOLDER}/shell/platform/common/client_wrapper/engine_method_result.cc
$ENV{FLUTTER_ENGINE_FOLDER}/shell/platform/common/client_wrapper/engine_method_result.cc
$ENV{FLUTTER_ENGINE_FOLDER}/shell/platform/common/incoming_message_dispatcher.cc
)
3rdparty/flutter/shell/platform/common/client_wrapper/plugin_registrar.cc
3rdparty/flutter/shell/platform/common/client_wrapper/core_implementations.cc
3rdparty/flutter/shell/platform/common/client_wrapper/standard_codec.cc
3rdparty/flutter/shell/platform/common/client_wrapper/engine_method_result.cc
3rdparty/flutter/shell/platform/common/client_wrapper/engine_method_result.cc
3rdparty/flutter/shell/platform/common/incoming_message_dispatcher.cc)

target_include_directories(
flutter_common_client_wrapper
PUBLIC
"$ENV{FLUTTER_ENGINE_FOLDER}/shell/platform/common/public"
$ENV{FLUTTER_ENGINE_FOLDER}/shell/platform/embedder/
$ENV{FLUTTER_ENGINE_FOLDER}/shell/platform/common
$ENV{FLUTTER_ENGINE_FOLDER}/shell/platform/common/client_wrapper
$ENV{FLUTTER_ENGINE_FOLDER}/shell/platform/common/client_wrapper/include/
"$ENV{FLUTTER_ENGINE_FOLDER}/..")
PUBLIC 3rdparty/flutter/shell/platform/common/public
3rdparty/flutter/shell/platform/embedder/
3rdparty/flutter/shell/platform/common
3rdparty/flutter/shell/platform/common/client_wrapper
3rdparty/flutter/shell/platform/common/client_wrapper/include/
3rdparty/flutter/..)

add_executable(qtembedder main.cpp src/Embedder.cpp src/FlutterWindow.cpp
src/3rdparty/flutter/glfw_shell.cpp)

target_link_libraries(
qtembedder Qt6::Widgets Qt6::OpenGL Qt6::GuiPrivate
$ENV{FLUTTER_ENGINE_FOLDER}/${FLUTTER_ENGINE_LIBRARY}
flutter_common_client_wrapper)
target_link_libraries(qtembedder Qt6::Widgets Qt6::OpenGL Qt6::GuiPrivate
${FLUTTER_ENGINE_LIBRARY} flutter_common_client_wrapper)

if(NOT APPLE)
target_link_libraries(qtembedder EGL)
Expand Down
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ Can be used to launch a 100% flutter app or to integrate flutter into an existin

## Instructions

Install `ms-vscode-remote.remote-containers` extension in vscode and open the `.devcontainer`.

Build the embedder.

Build the example by running `build_example.sh`.

Run the example:
`./build-dev/qtembedder -m -e examples/default_counter_app`

```bash
git submodule update --init
cmake --preset=dev
cmake --build build-dev
build_example.sh
build-dev/qtembedder -m -e examples/default_counter_app
```

## Licensing

Expand Down
3 changes: 1 addition & 2 deletions build_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ else
fi

cd examples/default_counter_app && flutter pub get && \
echo "FLUTTER_HOST=${FLUTTER_HOST} ; FLUTTER_ENGINE_FOLDER=${FLUTTER_ENGINE_FOLDER} ; FLUTTER_ARCH=${FLUTTER_ARCH}"
flutter build ${FLUTTER_HOST} --debug --local-engine-src-path=$FLUTTER_ENGINE_FOLDER/.. --local-engine=host_debug_unopt${FLUTTER_ARCH} --local-engine-host=host_debug_unopt${FLUTTER_ARCH}
flutter build ${FLUTTER_HOST} --debug
Loading

0 comments on commit 295bd9c

Please sign in to comment.