Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/cpp-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ jobs:
# Run the build in the host OS default shell since Windows can't handle long path names in bash.
- name: Build desktop SDK
run: |
python scripts/gha/build_desktop.py --arch "${{ matrix.architecture }}" --config "${{ matrix.build_type }}" --msvc_runtime_library "${{ matrix.msvc_runtime }}" --linux_abi "${{ matrix.linux_abi }}" --build_dir out-sdk ${VERBOSE_FLAG} ${{ matrix.additional_build_flags }}
python scripts/gha/build_desktop.py --arch "${{ matrix.architecture }}" --config "${{ matrix.build_type }}" --msvc_runtime_library "${{ matrix.msvc_runtime }}" --linux_abi "${{ matrix.linux_abi }}" --build_dir out-sdk ${VERBOSE_FLAG} ${{ matrix.additional_build_flags }} --gha_build

- name: Archive SDK
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ jobs:
- name: Build SDK
shell: bash
run: |
python scripts/gha/build_desktop.py --build_tests --arch "${{ matrix.architecture }}" --config "${{ matrix.build_type }}" --msvc_runtime_library "${{ matrix.msvc_runtime }}"
python scripts/gha/build_desktop.py --build_tests --arch "${{ matrix.architecture }}" --config "${{ matrix.build_type }}" --msvc_runtime_library "${{ matrix.msvc_runtime }}" --gha_build

- name: Stats for ccache (mac and linux)
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
Expand Down
16 changes: 13 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,15 @@ option(FIREBASE_FORCE_FAKE_SECURE_STORAGE
option(FIREBASE_CPP_BUILD_PACKAGE
"Bundle the Firebase C++ libraries into a zip file." OFF)
option(FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD
"When building with Gradle, use the previously built libraries." OFF)
"When building with Gradle, use the previously built libraries." OFF)
option(FIREBASE_USE_BORINGSSL
"Build against BoringSSL instead of using your system's OpenSSL." OFF)
"Build against BoringSSL instead of using your system's OpenSSL." OFF)
option(FIREBASE_USE_LINUX_CXX11_ABI
"Build Linux SDK using the C++11 ABI instead of the legacy ABI." OFF)
"Build Linux SDK using the C++11 ABI instead of the legacy ABI." OFF)

# This should only be enabled by the GitHub Action build script.
option(FIREBASE_GITHUB_ACTION_BUILD
"Indicates that this build was created from a GitHub Action" OFF)

set(FIREBASE_ANDROID_STL "" CACHE STRING "STL implementation to use.")
if (NOT FIREBASE_ANDROID_STL STREQUAL "")
Expand Down Expand Up @@ -139,6 +143,12 @@ if(DESKTOP AND NOT MSVC AND NOT APPLE)
endif()
endif()

if(FIREBASE_GITHUB_ACTION_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFIREBASE_GITHUB_ACTION_BUILD=1")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFIREBASE_GITHUB_ACTION_BUILD=0")
endif()

# Set directories needed by the Firebase subprojects
# Directory to store generated files.
set(FIREBASE_GEN_FILE_DIR ${CMAKE_BINARY_DIR}/generated)
Expand Down
8 changes: 8 additions & 0 deletions app/src/app_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ const char* kCpuArchitecture = "x86";
#else
#error Unknown operating system.
#endif // Operating system

#if FIREBASE_GITHUB_ACTION_BUILD
const char* kBuildSource = "github_action_built";
#else
const char* kBuildSource = "custom_built";
#endif
// clang-format=on

const char* kApiClientHeader = "x-firebase-client";
Expand Down Expand Up @@ -303,6 +309,8 @@ App* AddApp(App* app, std::map<std::string, InitResult>* results) {
kCpuArchitecture);
App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX "-stl",
kCppRuntimeOrStl);
App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX "-buildsrc",
kBuildSource);
}
callback::Initialize();
AppCallback::NotifyAllAppCreated(app, results);
Expand Down
1 change: 1 addition & 0 deletions app/src/app_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace app_common {
extern const char* kOperatingSystem;
extern const char* kCppRuntimeOrStl;
extern const char* kCpuArchitecture;
extern const char* kBuildSource;

// Extended API client header for Google user agent strings.
extern const char* kApiClientHeader;
Expand Down
11 changes: 9 additions & 2 deletions scripts/gha/build_desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def install_cpp_dependencies_with_vcpkg(arch, msvc_runtime_library, cleanup=True

def cmake_configure(build_dir, arch, msvc_runtime_library='static', linux_abi='legacy',
build_tests=True, config=None, target_format=None,
use_openssl=False, disable_vcpkg=False, verbose=False):
use_openssl=False, disable_vcpkg=False, gha_build=False, verbose=False):
""" CMake configure.

If you are seeing problems when running this multiple times,
Expand All @@ -168,6 +168,8 @@ def cmake_configure(build_dir, arch, msvc_runtime_library='static', linux_abi='l
use_openssl (bool) : Use prebuilt OpenSSL library instead of using boringssl
downloaded and built during the cmake configure step.
disable_vcpkg (bool): If True, skip vcpkg and just use CMake for deps.
gha_build (bool): If True, this build will be marked as having been built
from GitHub, which is useful for metrics tracking.
verbose (bool): If True, enable verbose mode in the CMake file.
"""
cmd = ['cmake', '-S', '.', '-B', build_dir]
Expand Down Expand Up @@ -216,6 +218,10 @@ def cmake_configure(build_dir, arch, msvc_runtime_library='static', linux_abi='l
if not use_openssl:
cmd.append('-DFIREBASE_USE_BORINGSSL=ON')

# When building from GitHub Actions, this should always be set.
if gha_build:
cmd.append('-DFIREBASE_GITHUB_ACTION_BUILD=ON')

# Print out every command while building.
if verbose:
cmd.append('-DCMAKE_VERBOSE_MAKEFILE=1')
Expand Down Expand Up @@ -248,7 +254,7 @@ def main():
# CMake configure
cmake_configure(args.build_dir, args.arch, args.msvc_runtime_library, args.linux_abi,
args.build_tests, args.config, args.target_format,
args.use_openssl, args.disable_vcpkg, args.verbose)
args.use_openssl, args.disable_vcpkg, args.gha_build, args.verbose)

# CMake build
# cmake --build build -j 8
Expand Down Expand Up @@ -278,6 +284,7 @@ def parse_cmdline_args():
parser.add_argument('--target', nargs='+', help='A list of CMake build targets (eg: firebase_app firebase_auth)')
parser.add_argument('--target_format', default=None, help='(Mac only) whether to output frameworks (default) or libraries.')
parser.add_argument('--use_openssl', action='store_true', default=None, help='Use openssl for build instead of boringssl')
parser.add_argument('--gha_build', action='store_true', default=None, help='Set to true when building on GitHub, for metric tracking purposes')
args = parser.parse_args()
return args

Expand Down