Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/firebase_core/firebase_core/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ list(APPEND PLUGIN_SOURCES
"firebase_core_plugin.h"
"messages.g.cpp"
"messages.g.h"
"firebase_plugin_registry.cpp"
)

# Read version from pubspec.yaml
Expand All @@ -89,6 +90,7 @@ include_directories(${CMAKE_BINARY_DIR}/generated/)
# on PLUGIN_NAME above).
add_library(${PLUGIN_NAME} STATIC
"include/firebase_core/firebase_core_plugin_c_api.h"
"include/firebase_core/firebase_plugin_registry.h"
"firebase_core_plugin_c_api.cpp"
${PLUGIN_SOURCES}
${CMAKE_BINARY_DIR}/generated/firebase_core/plugin_version.h
Expand Down Expand Up @@ -120,7 +122,7 @@ add_subdirectory(${FIREBASE_CPP_SDK_DIR} bin/ EXCLUDE_FROM_ALL)
target_include_directories(${PLUGIN_NAME} INTERFACE
"${FIREBASE_CPP_SDK_DIR}/include")

set(FIREBASE_RELEASE_PATH_LIBS firebase_app firebase_auth firebase_storage firebase_firestore)
set(FIREBASE_RELEASE_PATH_LIBS firebase_app firebase_auth firebase_storage firebase_firestore firebase_remote_config)
foreach(firebase_lib IN ITEMS ${FIREBASE_RELEASE_PATH_LIBS})
get_target_property(firebase_lib_path ${firebase_lib} IMPORTED_LOCATION)
string(REPLACE "Debug" "Release" firebase_lib_release_path ${firebase_lib_path})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <flutter/method_channel.h>
#include <flutter/plugin_registrar_windows.h>
#include <flutter/standard_method_codec.h>
#include "include/firebase_core/firebase_plugin_registry.h"

#include <future>
#include <iostream>
Expand Down Expand Up @@ -95,7 +96,17 @@ CoreFirebaseOptions optionsFromFIROptions(const firebase::AppOptions &options) {

// Convert a firebase::App to CoreInitializeResponse
CoreInitializeResponse AppToCoreInitializeResponse(const App &app) {

auto firebaseRegistry = FirebasePluginRegistry::GetInstance();
std::vector<std::shared_ptr<FlutterFirebasePlugin>>& values = firebaseRegistry->p_constants();

flutter::EncodableMap plugin_constants;

for (const std::shared_ptr<FlutterFirebasePlugin> &val: values) {
flutter::EncodableMap constants = val->get_plugin_constants(app);
plugin_constants[flutter::EncodableValue(val->plugin_name().c_str())] = flutter::EncodableValue(constants);
}

CoreInitializeResponse response = CoreInitializeResponse(
app.name(), optionsFromFIROptions(app.options()), plugin_constants);
return response;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2025, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

#include "include/firebase_core/firebase_plugin_registry.h"
#include "firebase/app.h"

extern firebase_core_windows::FirebasePluginRegistry* registry_instance_ = nullptr;

namespace firebase_core_windows {

FirebasePluginRegistry* FirebasePluginRegistry::GetInstance() {
if (registry_instance_ == nullptr) {
registry_instance_ = new FirebasePluginRegistry();
}

return registry_instance_;
}

void FirebasePluginRegistry::put_plugin_ref(std::shared_ptr<FlutterFirebasePlugin> plugin) {
this->pConstants_.push_back(plugin);
}

std::vector<std::shared_ptr<FlutterFirebasePlugin>>& FirebasePluginRegistry::p_constants() {
return pConstants_;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2025, the Chromium project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*/

#ifndef FLUTTER_FIREBASE_PLUGIN_REGISTRY_H
#define FLUTTER_FIREBASE_PLUGIN_REGISTRY_H

#ifdef BUILDING_SHARED_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif

#include "../../messages.g.h"
#include "firebase/app.h"
#include <string>
#include <map>
#include "flutter_firebase_plugin.h"
#include <mutex>
#include <memory>
#include <time.h>
#include <vector>

namespace firebase_core_windows {

class FirebasePluginRegistry {
public:

static FirebasePluginRegistry *GetInstance();

void put_plugin_ref(std::shared_ptr <FlutterFirebasePlugin>);

std::vector <std::shared_ptr<FlutterFirebasePlugin>> &p_constants();

std::string app_name;

private:
FirebasePluginRegistry() {
pConstants_ = {};
}
std::vector <std::shared_ptr<FlutterFirebasePlugin>> pConstants_;
friend class FirebaseCorePlugin;
};

}
#endif //FLUTTER_FIREBASE_PLUGIN_REGISTRY_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2025, the Chromium project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*/


#ifndef FLUTTER_FIREBASE_PLUGIN_H
#define FLUTTER_FIREBASE_PLUGIN_H

#include <string>
#include <flutter/encodable_value.h>
#include "firebase/app.h"

namespace firebase_core_windows {

class FlutterFirebasePlugin {
public:
virtual std::string plugin_name() = 0;
virtual flutter::EncodableMap get_plugin_constants(const ::firebase::App&) = 0;
};
}

#endif //FLUTTER_FIREBASE_PLUGIN_H
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ class DefaultFirebaseOptions {
case TargetPlatform.macOS:
return macos;
case TargetPlatform.windows:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for windows - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
return android;
case TargetPlatform.linux:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for linux - '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class _HomePageState extends State<HomePage> {
onPressed: () async {
final FirebaseRemoteConfig remoteConfig =
FirebaseRemoteConfig.instance;
// await remoteConfig.ensureInitialized();
await remoteConfig.setConfigSettings(
RemoteConfigSettings(
fetchTimeout: const Duration(seconds: 10),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
flutter/ephemeral/

# Visual Studio user-specific files.
*.suo
*.user
*.userosscache
*.sln.docstates

# Visual Studio build-related files.
x64/
x86/

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Project-level configuration.
cmake_minimum_required(VERSION 3.14)
project(firebase_core_example LANGUAGES CXX)

# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "firebase_remote_config_example")

# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(SET CMP0063 NEW)

# Define build configuration option.
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(IS_MULTICONFIG)
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
CACHE STRING "" FORCE)
else()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
endif()
# Define settings for the Profile build mode.
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")

# Use Unicode for all projects.
add_definitions(-DUNICODE -D_UNICODE)

# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_17)
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
target_compile_options(${TARGET} PRIVATE /EHsc)
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
endfunction()

# Flutter library and tool build rules.
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR})

# Application build; see runner/CMakeLists.txt.
add_subdirectory("runner")

# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)


# === Installation ===
# Support files are copied into place next to the executable, so that it can
# run in place. This is done instead of making a separate bundle (as on Linux)
# so that building and running from within Visual Studio will work.
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
# Make the "install" step default, as it's required to run.
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()

set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")

install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)

install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)

install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)

if(PLUGIN_BUNDLED_LIBRARIES)
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()

# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)

# Install the AOT library on non-Debug builds only.
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
CONFIGURATIONS Profile;Release
COMPONENT Runtime)
Loading