Skip to content

Commit 6c9d947

Browse files
authored
Feature/support x86 md python build scripts (#172)
* removed whitespaces * support for msvc runtime and x86 * copy custom triplets before using vcpkg * adding set of predefined vcpkg configs * catch vcpkg errors * passing required argument to function * cleanup packages directory after vcpkg build * adding /md,/mt and x86 to desktop workflow * temporarily switching on workflow for push event. * install python on x64 only and vcpkg cache key updated Python 3.7 does not exist on linux x86. Use x64 for Python regardless of architecture. * install x86 linux libs before building for x86 * fixed function name * removing call to apt python module * reorganized vcpkg files for customized data * pointing to newly organized vcpkg custom data copying over custom triplets and toolchains to vcpkg fixed paths to response files * fixed path to relocated response files * using shutil.copy instead of shutil.copyfile * fixed copy of custom vcpkg data * install support infrastructure for x86 linux install all required x86 libs for cross compiling on x64 hosts use a separate cmake toolchain for linux x86 * disable unit tests for x86 * fix toolchain file name * respecting config flag in cmake build Some multi-config generators specify the config (Release vs Debug) during cmake build and not cmake configure. * reverting temp change to run workflow on push * script to inspect built libraries * added windows support * more changes for finding arch from windows libs * inspect msvc_runtime_linkage * added cmd line flags * refactored code to support verbose and summarized output * support for * in library filter cmd line flag * pretty print summary table * add msvc runtime to headers * added an option to cleanup temp data * alphabetic import of modules * added google copyright and module docstring * added windows example to docstring * removed cleanup flag and added docstrings. * fixed some docstrings * adding new python inspection script and temporarily switching on push trigger * fixed typo * lru_cache with default arggs * debug linux lib instrospection * accounting for arch output like i386:x86-64 in regex for linux * continue workflow even if python step fails * forcing /MD and /MT * temporary switch on push trigger * removing special handling for linux x86 * fixed syntax errors * modifying external dependencies after cmake configure * not using temp dir for a quick test * fixed download function * removing push trigger * remove deprecated cmd line flag * keeping the name consistent across repo scripts * removed cmake /MT override for GoogleTest * removed custom vcpkg configs as they have been moved to vcpkg_custom_data * addressed PR comments Quotes around strings for consistency Inspect instead of introspect * added copyright * added copyright * quotes around literal string
1 parent b178ecb commit 6c9d947

19 files changed

+1362
-88
lines changed

.github/workflows/desktop.yml

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Desktop Builds
22

3-
on:
3+
on:
44
pull_request:
55
types: [opened, reopened, synchronize]
66

@@ -9,26 +9,34 @@ env:
99

1010
jobs:
1111
build:
12-
name: ${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.architecture }}-${{ matrix.python_version }}
12+
name: ${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.architecture }}-${{ matrix.msvc_runtime}}
1313
runs-on: ${{ matrix.os }}
1414
strategy:
1515
fail-fast: false
1616
matrix:
1717
os: [windows-latest, ubuntu-latest, macos-latest]
1818
build_type: ["Release", "Debug"]
19-
architecture: ["x64",]
19+
architecture: ["x64", "x86"]
20+
msvc_runtime: ["static", "dynamic"]
2021
python_version: [3.7]
2122
include:
2223
- os: windows-latest
23-
architecture: "x64"
24-
vcpkg_triplet: "x64-windows-static"
25-
msbuild_platform: "x64"
24+
vcpkg_triplet_suffix: "windows-static"
25+
- os: windows-latest
26+
msvc_runtime: "dynamic"
27+
vcpkg_triplet_suffix: "windows-static-md"
2628
- os: ubuntu-latest
27-
architecture: "x64"
28-
vcpkg_triplet: "x64-linux"
29+
vcpkg_triplet_suffix: "linux"
30+
- os: macos-latest
31+
vcpkg_triplet_suffix: "osx"
32+
33+
exclude:
2934
- os: macos-latest
30-
architecture: "x64"
31-
vcpkg_triplet: "x64-osx"
35+
architecture: "x86"
36+
- os: macos-latest
37+
msvc_runtime: "dynamic"
38+
- os: ubuntu-latest
39+
msvc_runtime: "dynamic"
3240

3341
steps:
3442
- uses: actions/checkout@v2
@@ -37,15 +45,15 @@ jobs:
3745

3846
- name: Set env variables for subsequent steps (all)
3947
run: |
40-
echo "::set-env name=VCPKG_RESPONSE_FILE::external/vcpkg_${{ matrix.vcpkg_triplet }}_response_file.txt"
41-
echo "::set-env name=MATRIX_UNIQUE_NAME::${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.architecture }}-${{ matrix.python_version }}"
48+
echo "::set-env name=VCPKG_RESPONSE_FILE::external/vcpkg_custom_data/response_files/${{ matrix.architecture }}-${{ matrix.vcpkg_triplet_suffix }}.txt"
49+
echo "::set-env name=MATRIX_UNIQUE_NAME::${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.architecture }}-${{ matrix.msvc_runtime }}"
4250
4351
- name: Cache vcpkg C++ dependencies
4452
id: cache_vcpkg
4553
uses: actions/cache@v2
4654
with:
4755
path: external/vcpkg/installed
48-
key: dev-vcpkg-${{ matrix.vcpkg_triplet }}-${{ hashFiles(format('{0}', env.VCPKG_RESPONSE_FILE)) }}-${{ hashFiles('.git/modules/external/vcpkg/HEAD') }}
56+
key: dev-vcpkg-${{ matrix.architecture }}-${{ matrix.vcpkg_triplet_suffix }}-${{ matrix.msvc_runtime }}-${{ hashFiles(format('{0}', env.VCPKG_RESPONSE_FILE)) }}-${{ hashFiles('.git/modules/external/vcpkg/HEAD') }}
4957

5058
- name: Cache ccache files
5159
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
@@ -59,15 +67,15 @@ jobs:
5967
uses: actions/setup-python@v2
6068
with:
6169
python-version: ${{ matrix.python_version }}
62-
architecture: ${{ matrix.architecture }}
70+
architecture: 'x64'
6371

6472
- name: Install prerequisites
6573
run: |
6674
python scripts/gha/install_prereqs_desktop.py
6775
6876
- name: Build SDK
6977
run: |
70-
python scripts/gha/build_desktop.py --build_tests --arch "${{ matrix.architecture }}" --config "${{ matrix.build_type }}"
78+
python scripts/gha/build_desktop.py --build_tests --arch "${{ matrix.architecture }}" --config "${{ matrix.build_type }}" --msvc_runtime_library "${{ matrix.msvc_runtime }}"
7179
7280
- name: Stats for ccache (mac and linux)
7381
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
@@ -82,23 +90,30 @@ jobs:
8290
find build -name "*.a"
8391
find build -name "*.so"
8492
93+
- name: Inspect firebase libraries for cpu arch and msvc runtime.
94+
shell: bash
95+
run: |
96+
python scripts/gha/inspect_built_libraries.py build/
97+
continue-on-error: true
98+
8599
- name: Prep crash support (linux)
86-
# Ensures directory structure is in place to capture core files on Linux.
100+
# Ensures directory structure is in place to capture core files on Linux.
87101
if: startsWith(matrix.build_type, 'Debug') && startsWith(matrix.os, 'ubuntu')
88102
shell: bash
89103
run: |
90104
echo '/tmp/cores/core.%E' | sudo tee /proc/sys/kernel/core_pattern
91105
sudo mkdir -p /tmp/cores/
92106
sudo rm -rf /tmp/cores/*
93-
107+
94108
- name: Prep crash support (mac)
95109
# Ensures no lingering crashes from the previous run.
96110
if: startsWith(matrix.build_type, 'Debug') && startsWith(matrix.os, 'macos')
97111
run: |
98112
rm -rf ~/Library/Logs/DiagnosticReports/*
99-
113+
100114
- name: Run unit tests (windows & macos)
101-
if: startsWith(matrix.os, 'windows') || startsWith(matrix.os, 'macos')
115+
# TODO: Enable tests for x86 once they are all working
116+
if: (startsWith(matrix.os, 'windows') || startsWith(matrix.os, 'macos')) && matrix.architecture != 'x86'
102117
env:
103118
LANG: en_US
104119
run: |
@@ -110,14 +125,15 @@ jobs:
110125
# platform-specific `ulimit` to enable crash collection. The ulimit
111126
# command must be invoked in same shell instance of that runs the
112127
# tests.
113-
if: startsWith(matrix.os, 'ubuntu')
128+
# TODO: Enable tests for x86 once they are all working
129+
if: startsWith(matrix.os, 'ubuntu') && matrix.architecture != 'x86'
114130
env:
115131
LANG: en_US
116132
run: |
117-
ulimit -c unlimited
133+
ulimit -c unlimited
118134
cd build
119135
sudo ctest --verbose
120-
136+
121137
- name: Prep bins for achive (linux)
122138
# Copies all of the binary files into one directory for ease in
123139
# archiving. Directory contents are then marked readable for the
@@ -147,7 +163,7 @@ jobs:
147163
shell: bash
148164
if: failure() && startsWith(matrix.build_type, 'Debug') && startsWith(matrix.os, 'macos')
149165
run: |
150-
sudo chmod -R +rwx ~/Library/Logs/DiagnosticReports/* || :
166+
sudo chmod -R +rwx ~/Library/Logs/DiagnosticReports/* || :
151167
152168
- name: Archive crashes and binaries (linux)
153169
uses: actions/upload-artifact@v2
@@ -166,4 +182,3 @@ jobs:
166182
path: |
167183
~/Library/Logs/DiagnosticReports/*
168184
/tmp/bins/*
169-

CMakeLists.txt

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,20 @@ set(FIREBASE_GEN_FILE_DIR ${CMAKE_BINARY_DIR}/generated)
121121
# Directory for any shared scripts.
122122
set(FIREBASE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_DIR})
123123

124-
if (MSVC AND MSVC_RUNTIME_LIBRARY_STATIC)
125-
# Use Multithreaded static runtime libraries for MSVC
126-
# if MSVC_RUNTIME_LIBRARY_STATIC is set.
127-
# Default value if nothing is specified is /MD (dll dynamic runtime).
128-
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
129-
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
130-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
131-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
132-
endif()
133-
134-
if (FIREBASE_CPP_BUILD_TESTS AND MSVC)
135-
# GoogleTest requires MSVC to compile with the static version of the runtime
136-
# library, so define the appropriate runtime flag, before adding libraries.
137-
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
138-
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
139-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
140-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
124+
if (MSVC)
125+
if (MSVC_RUNTIME_LIBRARY_STATIC)
126+
add_compile_options(
127+
$<$<CONFIG:>:/MT>
128+
$<$<CONFIG:Debug>:/MTd>
129+
$<$<CONFIG:Release>:/MT>
130+
)
131+
else()
132+
add_compile_options(
133+
$<$<CONFIG:>:/MD>
134+
$<$<CONFIG:Debug>:/MDd>
135+
$<$<CONFIG:Release>:/MD>
136+
)
137+
endif()
141138
endif()
142139

143140
# Set variables that are used by download_external_sources.

build_scripts/desktop/get_variant.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ os=
2929
arch=
3030
arch_win=
3131
debugmode=Release
32-
msvc_crt_linkage=MD
32+
msvc_runtime_library=MD
3333
vs=VS2015
3434
stl=c++
3535

@@ -99,16 +99,16 @@ for c in $(echo "${filename}" | tr "_.-" "\n\n\n"); do
9999
;;
100100
# Windows OS framework linkages
101101
md)
102-
msvc_crt_linkage=MD
102+
msvc_runtime_library=MD
103103
;;
104104
dynamic)
105-
msvc_crt_linkage=MD
105+
msvc_runtime_library=MD
106106
;;
107107
mt)
108-
msvc_crt_linkage=MT
108+
msvc_runtime_library=MT
109109
;;
110110
static)
111-
msvc_crt_linkage=MT
111+
msvc_runtime_library=MT
112112
;;
113113
# Debug/Release compilation mode
114114
release)
@@ -161,7 +161,7 @@ case ${os} in
161161
echo "Invalid architecture for Windows: ${arch}" 1>&2
162162
exit 1
163163
fi
164-
echo -n "${vs}/${msvc_crt_linkage}/${arch_win}/${debugmode}"
164+
echo -n "${vs}/${msvc_runtime_library}/${arch_win}/${debugmode}"
165165
;;
166166
ios)
167167
if [[ -z "${arch}" ]]; then

cmake/toolchains/linux_32.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2020 Google
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
# Toolchain file for building 32-bit Linux libraries
216

317
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")

external/vcpkg_x64-windows_response_file.txt renamed to external/vcpkg_custom_data/response_files/x64-windows-static-md.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ openssl
22
protobuf
33
zlib
44
--triplet
5-
x64-windows
5+
x64-windows-static-md

external/vcpkg_x86-windows_response_file.txt renamed to external/vcpkg_custom_data/response_files/x86-windows-static-md.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ openssl
22
protobuf
33
zlib
44
--triplet
5-
x86-windows
5+
x86-windows-static-md

0 commit comments

Comments
 (0)