Skip to content

Commit c0b8ad5

Browse files
authored
feat(core): add support for Windows via Firebase C++ desktop SDK (#10496)
* feat: integration of C++ desktop SDK * add windows * add windows * add windows * add windows * right position for google service file * add windows * feat: integration of C++ desktop SDK * add windows * add windows * add windows * add windows * right position for google service file * add windows * feat(core, windows): add windows support to firebase_core * feat(core, windows): update pigeon * feat(core, windows): update pigeon * feat(core, windows): update pigeon * feat(core, windows): update pigeon * feat: merge with main package * add intializeApp * initalizeCore * ready windows * feat: integration of C++ desktop SDK * add windows * add windows * add windows * add windows * right position for google service file * add windows * add windows * add windows * add windows * feat(core, windows): add windows support to firebase_core * feat(core, windows): update pigeon * feat(core, windows): update pigeon * feat(core, windows): update pigeon * feat(core, windows): update pigeon * feat: merge with main package * add intializeApp * initalizeCore * ready windows * app host * add licence headers * format * format * formatting ui * formatting ui * formatting ui * feat: automatically download the C++ SDK * feat: auto download of the sdk * tests working * ci: windows ci * ci: windows * ci: tests * remove old desktop service files * add licence * remove comment * remove file * add generated files
1 parent a3b9673 commit c0b8ad5

File tree

70 files changed

+3978
-387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3978
-387
lines changed

Diff for: .github/workflows/e2e_tests.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,32 @@ jobs:
295295
--driver=test_driver/integration_test.dart \
296296
--target=integration_test/e2e_test.dart \
297297
--dart-define=CI=true
298+
299+
windows:
300+
runs-on: windows-latest
301+
timeout-minutes: 45
302+
steps:
303+
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
304+
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
305+
name: Install Node.js 16
306+
with:
307+
node-version: "16"
308+
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d
309+
with:
310+
channel: 'stable'
311+
cache: true
312+
- uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a
313+
with:
314+
run-bootstrap: false
315+
melos-version: '3.0.0'
316+
- name: "Bootstrap package"
317+
run: melos bootstrap --scope tests
318+
- name: "Install Tools"
319+
run: |
320+
npm install -g firebase-tools
321+
- name: Start Firebase Emulator
322+
run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh
323+
- name: "E2E Tests"
324+
working-directory: tests
325+
run: |
326+
flutter test .\integration_test\e2e_test.dart -d windows

Diff for: packages/firebase_core/firebase_core/android/src/main/java/io/flutter/plugins/firebase/core/GeneratedAndroidFirebaseCore.java

+113-121
Large diffs are not rendered by default.
+22-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
# This file tracks properties of this Flutter project.
22
# Used by Flutter tool to assess capabilities and perform upgrades etc.
33
#
4-
# This file should be version controlled and should not be manually edited.
4+
# This file should be version controlled.
55

66
version:
7-
revision: f139b11009aeb8ed2a3a3aa8b0066e482709dde3
7+
revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
88
channel: stable
99

1010
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
17+
base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
18+
- platform: windows
19+
create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
20+
base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'

Diff for: packages/firebase_core/firebase_core/example/lib/firebase_options.dart

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class DefaultFirebaseOptions {
3030
return ios;
3131
case TargetPlatform.macOS:
3232
return macos;
33+
// TODO(Lyokone): Remove when FlutterFire CLI updated
34+
case TargetPlatform.windows:
35+
return android;
3336
default:
3437
throw UnsupportedError(
3538
'DefaultFirebaseOptions are not supported for this platform.',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
flutter/ephemeral/
2+
3+
# Visual Studio user-specific files.
4+
*.suo
5+
*.user
6+
*.userosscache
7+
*.sln.docstates
8+
9+
# Visual Studio build-related files.
10+
x64/
11+
x86/
12+
13+
# Visual Studio cache files
14+
# files ending in .cache can be ignored
15+
*.[Cc]ache
16+
# but keep track of directories ending in .cache
17+
!*.[Cc]ache/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Project-level configuration.
2+
cmake_minimum_required(VERSION 3.14)
3+
project(firebase_core_example LANGUAGES CXX)
4+
5+
# The name of the executable created for the application. Change this to change
6+
# the on-disk name of your application.
7+
set(BINARY_NAME "firebase_core_example")
8+
9+
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
10+
# versions of CMake.
11+
cmake_policy(SET CMP0063 NEW)
12+
13+
# Define build configuration option.
14+
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
15+
if(IS_MULTICONFIG)
16+
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
17+
CACHE STRING "" FORCE)
18+
else()
19+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
20+
set(CMAKE_BUILD_TYPE "Debug" CACHE
21+
STRING "Flutter build mode" FORCE)
22+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
23+
"Debug" "Profile" "Release")
24+
endif()
25+
endif()
26+
# Define settings for the Profile build mode.
27+
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
28+
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
29+
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
30+
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
31+
32+
# Use Unicode for all projects.
33+
add_definitions(-DUNICODE -D_UNICODE)
34+
35+
# Compilation settings that should be applied to most targets.
36+
#
37+
# Be cautious about adding new options here, as plugins use this function by
38+
# default. In most cases, you should add new options to specific targets instead
39+
# of modifying this function.
40+
function(APPLY_STANDARD_SETTINGS TARGET)
41+
target_compile_features(${TARGET} PUBLIC cxx_std_17)
42+
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
43+
target_compile_options(${TARGET} PRIVATE /EHsc)
44+
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
45+
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
46+
endfunction()
47+
48+
# Flutter library and tool build rules.
49+
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
50+
add_subdirectory(${FLUTTER_MANAGED_DIR})
51+
52+
# Application build; see runner/CMakeLists.txt.
53+
add_subdirectory("runner")
54+
55+
# Generated plugin build rules, which manage building the plugins and adding
56+
# them to the application.
57+
include(flutter/generated_plugins.cmake)
58+
59+
60+
# === Installation ===
61+
# Support files are copied into place next to the executable, so that it can
62+
# run in place. This is done instead of making a separate bundle (as on Linux)
63+
# so that building and running from within Visual Studio will work.
64+
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
65+
# Make the "install" step default, as it's required to run.
66+
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
67+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
68+
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
69+
endif()
70+
71+
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
72+
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
73+
74+
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
75+
COMPONENT Runtime)
76+
77+
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
78+
COMPONENT Runtime)
79+
80+
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
81+
COMPONENT Runtime)
82+
83+
if(PLUGIN_BUNDLED_LIBRARIES)
84+
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
85+
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
86+
COMPONENT Runtime)
87+
endif()
88+
89+
# Fully re-copy the assets directory on each build to avoid having stale files
90+
# from a previous install.
91+
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
92+
install(CODE "
93+
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
94+
" COMPONENT Runtime)
95+
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
96+
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
97+
98+
# Install the AOT library on non-Debug builds only.
99+
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
100+
CONFIGURATIONS Profile;Release
101+
COMPONENT Runtime)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# This file controls Flutter-level build steps. It should not be edited.
2+
cmake_minimum_required(VERSION 3.14)
3+
4+
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5+
6+
# Configuration provided via flutter tool.
7+
include(${EPHEMERAL_DIR}/generated_config.cmake)
8+
9+
# TODO: Move the rest of this into files in ephemeral. See
10+
# https://github.com/flutter/flutter/issues/57146.
11+
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
12+
13+
# === Flutter Library ===
14+
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
15+
16+
# Published to parent scope for install step.
17+
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
18+
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
19+
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
20+
set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
21+
22+
list(APPEND FLUTTER_LIBRARY_HEADERS
23+
"flutter_export.h"
24+
"flutter_windows.h"
25+
"flutter_messenger.h"
26+
"flutter_plugin_registrar.h"
27+
"flutter_texture_registrar.h"
28+
)
29+
list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
30+
add_library(flutter INTERFACE)
31+
target_include_directories(flutter INTERFACE
32+
"${EPHEMERAL_DIR}"
33+
)
34+
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
35+
add_dependencies(flutter flutter_assemble)
36+
37+
# === Wrapper ===
38+
list(APPEND CPP_WRAPPER_SOURCES_CORE
39+
"core_implementations.cc"
40+
"standard_codec.cc"
41+
)
42+
list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
43+
list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
44+
"plugin_registrar.cc"
45+
)
46+
list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
47+
list(APPEND CPP_WRAPPER_SOURCES_APP
48+
"flutter_engine.cc"
49+
"flutter_view_controller.cc"
50+
)
51+
list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
52+
53+
# Wrapper sources needed for a plugin.
54+
add_library(flutter_wrapper_plugin STATIC
55+
${CPP_WRAPPER_SOURCES_CORE}
56+
${CPP_WRAPPER_SOURCES_PLUGIN}
57+
)
58+
apply_standard_settings(flutter_wrapper_plugin)
59+
set_target_properties(flutter_wrapper_plugin PROPERTIES
60+
POSITION_INDEPENDENT_CODE ON)
61+
set_target_properties(flutter_wrapper_plugin PROPERTIES
62+
CXX_VISIBILITY_PRESET hidden)
63+
target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
64+
target_include_directories(flutter_wrapper_plugin PUBLIC
65+
"${WRAPPER_ROOT}/include"
66+
)
67+
add_dependencies(flutter_wrapper_plugin flutter_assemble)
68+
69+
# Wrapper sources needed for the runner.
70+
add_library(flutter_wrapper_app STATIC
71+
${CPP_WRAPPER_SOURCES_CORE}
72+
${CPP_WRAPPER_SOURCES_APP}
73+
)
74+
apply_standard_settings(flutter_wrapper_app)
75+
target_link_libraries(flutter_wrapper_app PUBLIC flutter)
76+
target_include_directories(flutter_wrapper_app PUBLIC
77+
"${WRAPPER_ROOT}/include"
78+
)
79+
add_dependencies(flutter_wrapper_app flutter_assemble)
80+
81+
# === Flutter tool backend ===
82+
# _phony_ is a non-existent file to force this command to run every time,
83+
# since currently there's no way to get a full input/output list from the
84+
# flutter tool.
85+
set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
86+
set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
87+
add_custom_command(
88+
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
89+
${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
90+
${CPP_WRAPPER_SOURCES_APP}
91+
${PHONY_OUTPUT}
92+
COMMAND ${CMAKE_COMMAND} -E env
93+
${FLUTTER_TOOL_ENVIRONMENT}
94+
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
95+
windows-x64 $<CONFIG>
96+
VERBATIM
97+
)
98+
add_custom_target(flutter_assemble DEPENDS
99+
"${FLUTTER_LIBRARY}"
100+
${FLUTTER_LIBRARY_HEADERS}
101+
${CPP_WRAPPER_SOURCES_CORE}
102+
${CPP_WRAPPER_SOURCES_PLUGIN}
103+
${CPP_WRAPPER_SOURCES_APP}
104+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
// clang-format off
6+
7+
#include "generated_plugin_registrant.h"
8+
9+
#include <firebase_core/firebase_core_plugin_c_api.h>
10+
11+
void RegisterPlugins(flutter::PluginRegistry* registry) {
12+
FirebaseCorePluginCApiRegisterWithRegistrar(
13+
registry->GetRegistrarForPlugin("FirebaseCorePluginCApi"));
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
// clang-format off
6+
7+
#ifndef GENERATED_PLUGIN_REGISTRANT_
8+
#define GENERATED_PLUGIN_REGISTRANT_
9+
10+
#include <flutter/plugin_registry.h>
11+
12+
// Registers Flutter plugins.
13+
void RegisterPlugins(flutter::PluginRegistry* registry);
14+
15+
#endif // GENERATED_PLUGIN_REGISTRANT_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# Generated file, do not edit.
3+
#
4+
5+
list(APPEND FLUTTER_PLUGIN_LIST
6+
firebase_core
7+
)
8+
9+
list(APPEND FLUTTER_FFI_PLUGIN_LIST
10+
)
11+
12+
set(PLUGIN_BUNDLED_LIBRARIES)
13+
14+
foreach(plugin ${FLUTTER_PLUGIN_LIST})
15+
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
16+
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
17+
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
18+
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
19+
endforeach(plugin)
20+
21+
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22+
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
23+
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24+
endforeach(ffi_plugin)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(runner LANGUAGES CXX)
3+
4+
# Define the application target. To change its name, change BINARY_NAME in the
5+
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
6+
# work.
7+
#
8+
# Any new source files that you add to the application should be added here.
9+
add_executable(${BINARY_NAME} WIN32
10+
"flutter_window.cpp"
11+
"main.cpp"
12+
"utils.cpp"
13+
"win32_window.cpp"
14+
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
15+
"Runner.rc"
16+
"runner.exe.manifest"
17+
)
18+
19+
# Apply the standard set of build settings. This can be removed for applications
20+
# that need different build settings.
21+
apply_standard_settings(${BINARY_NAME})
22+
23+
# Add preprocessor definitions for the build version.
24+
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
25+
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
26+
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
27+
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
28+
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
29+
30+
# Disable Windows macros that collide with C++ standard library functions.
31+
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
32+
33+
# Add dependency libraries and include directories. Add any application-specific
34+
# dependencies here.
35+
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
36+
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
37+
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
38+
39+
# Run the Flutter tool portions of the build. This must not be removed.
40+
add_dependencies(${BINARY_NAME} flutter_assemble)

0 commit comments

Comments
 (0)