Skip to content

Remove protobuf and nanopb setup #968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
26 changes: 0 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -472,32 +472,6 @@ if(DESKTOP)
endif()
endif()

if(DESKTOP)
if(FIRESTORE_USE_EXTERNAL_CMAKE_BUILD)
# The Firestore build includes protobuf and nanopb already
list(APPEND CMAKE_MODULE_PATH ${NANOPB_SOURCE_DIR}/extra)
find_package(Nanopb)

set(PROTOBUF_FOUND ON)
else()
find_package(Protobuf)
if (PROTOBUF_FOUND)
# NanoPB requires Protobuf to be present, so only add it if it was found.
add_external_library(nanopb)

# NanoPB has a FindNanopb which defines the function to generate files,
# so add it to the module path, and use that.
list(APPEND CMAKE_MODULE_PATH ${NANOPB_SOURCE_DIR}/extra)
find_package(Nanopb)

target_compile_definitions(
protobuf-nanopb-static
PUBLIC -DPB_FIELD_32BIT -DPB_ENABLE_MALLOC
)
endif()
endif()
endif()

if(DESKTOP AND NOT CMAKE_CROSSCOMPILING)
# Desktop platforms do not need to declare this dependency, as they will build
# flatc correctly when needed.
Expand Down
23 changes: 2 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,44 +60,25 @@ required packages:

* python -m ensurepip --default-pip
* python -m pip install --user absl-py
* python -m pip install --user protobuf

### Prerequisites for Desktop
The following prerequisites are required when building the libraries for
desktop platforms.

- [OpenSSL](https://www.openssl.org/), needed for Realtime Database and Cloud Firestore
- [Protobuf](https://github.com/protocolbuffers/protobuf/blob/master/src/README.md),
needed for Remote Config

### Prerequisites for Windows
Prebuilt packages for openssl can be found using google and if CMake fails to
find the install path use the command line option
**-DOPENSSL_ROOT_DIR=[Open SSL Dir]**.

Since there are no prebuilt packages for protobuf, getting it working on Windows
is a little tricky. The following steps can be used as a guide:

* Download source [zip from github](https://github.com/protocolbuffers/protobuf/releases/download/v3.9.2/protobuf-all-3.9.2.zip).
* Extract source and open command prompt to root folder
* Make new folder **vsprojects**
* CD to **vsprojects**
* run cmake: **cmake ..\cmake -Dprotobuf_BUILD_TESTS=OFF -A Win32**
* Build solution
* Add command line define to firebase cmake command (see below)
**-DPROTOBUF_SRC_ROOT_FOLDER=[Source Root Folder]**

Note: For x64 builds folder needs to be **vsprojects\x64** and change **Win32**
in cmake command to **x64**
**-DOPENSSL_ROOT_DIR=[Open SSL Dir]**. d

### Prerequisites for Mac
Home brew can be used to install required dependencies:

```bash
# https://github.com/protocolbuffers/protobuf/blob/master/kokoro/macos/prepare_build_macos_rc#L20
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
source $HOME/.rvm/scripts/rvm
brew install cmake protobuf python3
brew install cmake python3
sudo chown -R $(whoami) /usr/local
```

Expand Down
4 changes: 2 additions & 2 deletions build_scripts/android/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if [[ -z $(which python) ]]; then
exit 1
else
updated_pip=0
if ! $(echo "import absl"$'\n'"import google.protobuf" | python - 2> /dev/null); then
if ! $(echo "import absl"$'\n' | python - 2> /dev/null); then
echo "Installing python packages."
set -x
# On Windows bash shell, sudo doesn't exist
Expand All @@ -50,7 +50,7 @@ else
else
python -m pip install --upgrade pip
fi
pip install absl-py protobuf
pip install absl-py
set +x
fi
fi
Expand Down
4 changes: 2 additions & 2 deletions build_scripts/tvos/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ if [[ -z $(which python) ]]; then
exit 1
else
updated_pip=0
if ! $(echo "import absl"$'\n'"import google.protobuf" | python - 2> /dev/null); then
if ! $(echo "import absl"$'\n' | python - 2> /dev/null); then
echo "Installing python packages."
set -x
sudo python -m pip install --upgrade pip
pip install absl-py protobuf
pip install absl-py
set +x
fi
fi
Expand Down
1 change: 0 additions & 1 deletion cmake/external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ if (${FIREBASE_EXTERNAL_PLATFORM} STREQUAL "DESKTOP")
include(curl)
include(libuv)
include(leveldb)
include(nanopb)
include(uWebSockets)
include(zlib)
endif()
Expand Down
37 changes: 0 additions & 37 deletions cmake/external/nanopb.cmake

This file was deleted.

8 changes: 0 additions & 8 deletions cmake/external_rules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ function(download_external_sources)
set(external_platform "DESKTOP")
endif()

# When building with Firestore, use the NanoPB source from that instead.
if(FIREBASE_INCLUDE_FIRESTORE)
set(FIRESTORE_BINARY_DIR ${PROJECT_BINARY_DIR}/external/src/firestore-build)
set(NANOPB_SOURCE_DIR ${FIRESTORE_BINARY_DIR}/external/src/nanopb)
endif()

# Set variables to indicate if local versions of third party libraries should
# be used instead of downloading them.
function(check_use_local_directory NAME)
Expand All @@ -56,7 +50,6 @@ function(download_external_sources)
check_use_local_directory(CURL)
check_use_local_directory(FLATBUFFERS)
check_use_local_directory(LIBUV)
check_use_local_directory(NANOPB)
check_use_local_directory(UWEBSOCKETS)
check_use_local_directory(ZLIB)
check_use_local_directory(FIREBASE_IOS_SDK)
Expand Down Expand Up @@ -91,7 +84,6 @@ function(download_external_sources)
-DDOWNLOAD_FLATBUFFERS=${DOWNLOAD_FLATBUFFERS}
-DDOWNLOAD_GOOGLETEST=${FIREBASE_DOWNLOAD_GTEST}
-DDOWNLOAD_LIBUV=${DOWNLOAD_LIBUV}
-DDOWNLOAD_NANOPB=${DOWNLOAD_NANOPB}
-DDOWNLOAD_UWEBSOCKETS=${DOWNLOAD_UWEBSOCKETS}
-DDOWNLOAD_ZLIB=${DOWNLOAD_ZLIB}
-DDOWNLOAD_FIREBASE_IOS_SDK=${DOWNLOAD_FIREBASE_IOS_SDK}
Expand Down
45 changes: 17 additions & 28 deletions remote_config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,23 @@ set(android_SRCS
set(ios_SRCS
src/ios/remote_config_ios.mm)

if (NOT PROTOBUF_FOUND)
# Only log a message if building for Desktop, since mobile doesn't care.
if (NOT ANDROID AND NOT IOS)
message(FATAL_ERROR "Unable to find Protobuf, which is needed for Remote \
Configs's desktop implementation. Install Protobuf and add it to \
your PATH, or set the CMake option FIREBASE_INCLUDE_REMOTE_CONFIG \
to OFF to disable the firebase_remote_config build target.")
endif()
else()
set(desktop_SRCS
${PROTO_SRCS}
${PROTO_HDRS}
${request_resource_source}
${request_resource_header}
${response_resource_source}
${response_resource_header}
${FIREBASE_GEN_FILE_DIR}/remote_config/request_generated.h
${FIREBASE_GEN_FILE_DIR}/remote_config/response_generated.h
src/desktop/rest.cc
src/desktop/config_data.cc
src/desktop/file_manager.cc
src/desktop/metadata.cc
src/desktop/notification_channel.cc
src/desktop/remote_config_desktop.cc
src/desktop/remote_config_request.cc
src/desktop/remote_config_response.cc
)
endif()
# Source files used by the desktop implementation.
set(desktop_SRCS
${request_resource_source}
${request_resource_header}
${response_resource_source}
${response_resource_header}
${FIREBASE_GEN_FILE_DIR}/remote_config/request_generated.h
${FIREBASE_GEN_FILE_DIR}/remote_config/response_generated.h
src/desktop/rest.cc
src/desktop/config_data.cc
src/desktop/file_manager.cc
src/desktop/metadata.cc
src/desktop/notification_channel.cc
src/desktop/remote_config_desktop.cc
src/desktop/remote_config_request.cc
src/desktop/remote_config_response.cc
)

if(ANDROID)
set(remote_config_platform_SRCS
Expand Down