Skip to content

Commit 5f32e93

Browse files
committed
Merge branch 'feature/include-x86-md-mt-desktop-packaging' into dev
2 parents 067579d + e5faee8 commit 5f32e93

File tree

6 files changed

+79
-63
lines changed

6 files changed

+79
-63
lines changed

.github/workflows/android.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
submodules: true
3131

3232
- name: Set env variables for subsequent steps (all)
33+
shell: bash
3334
run: |
3435
echo "MATRIX_UNIQUE_NAME=${{ matrix.os }}-${{ matrix.architecture }}" >> $GITHUB_ENV
3536
echo "GHA_INSTALL_CCACHE=1" >> $GITHUB_ENV
@@ -42,7 +43,7 @@ jobs:
4243

4344
- name: Add msbuild to PATH
4445
if: startsWith(matrix.os, 'windows')
45-
uses: microsoft/[email protected].1
46+
uses: microsoft/[email protected].2
4647

4748
- name: Install prerequisites
4849
shell: bash

.github/workflows/cpp-packaging.yml

Lines changed: 42 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ on:
1414

1515
env:
1616
# Packaging prerequisites
17-
# Binutils 2.34 released Feb 1, 2020
18-
binutilsVer: 2.34
17+
# Binutils 2.35.1 released Sep 19, 2020
18+
binutilsVer: 2.35.1
1919
# Demumble 1.1.0 released Nov 13, 2018
2020
demumbleVer: 1.1.0
2121

@@ -159,90 +159,71 @@ jobs:
159159
path: firebase-cpp-sdk-android-${{ matrix.stl }}-package.tgz
160160

161161
build_desktop:
162-
name: build-${{ matrix.sdk_platform }}-${{ matrix.architecture }}-${{ matrix.build_type }}-${{ matrix.linkage }}
162+
name: build-${{ matrix.sdk_platform }}-${{ matrix.architecture }}-${{ matrix.build_type }}-${{ matrix.msvc_runtime }}
163163
runs-on: ${{ matrix.os }}
164164
if: ${{ github.event.inputs.downloadPublicVersion == '' && github.event.inputs.downloadPreviousRun == '' }}
165165
strategy:
166166
fail-fast: false
167167
matrix:
168168
os: [windows-latest, ubuntu-latest, macos-latest]
169-
architecture: ["x86", "x64"]
170-
build_type: ["Debug", "Release"]
171-
linkage: ["dynamic", "static"]
169+
build_type: ["Release", "Debug"]
170+
architecture: ["x64", "x86"]
171+
msvc_runtime: ["static", "dynamic"]
172172
python_version: [3.7]
173173
include:
174174
- os: windows-latest
175-
linkage: "static"
176-
architecture: "x64"
177-
vcpkg_triplet: "x64-windows-static"
178-
sdk_platform: windows
175+
vcpkg_triplet_suffix: "windows-static"
179176
additional_build_flags: "--build_tests"
177+
sdk_platform: "windows"
180178
- os: windows-latest
181-
linkage: "dynamic"
182-
architecture: "x64"
183-
vcpkg_triplet: "x64-windows"
184-
sdk_platform: windows
179+
msvc_runtime: "dynamic"
180+
vcpkg_triplet_suffix: "windows-static-md"
185181
additional_build_flags: "--build_tests"
186-
- os: windows-latest
187-
linkage: "static"
188-
architecture: "x86"
189-
vcpkg_triplet: "x86-windows-static"
190-
sdk_platform: windows
191-
additional_build_flags: "--build_tests"
192-
- os: windows-latest
193-
linkage: "dynamic"
194-
architecture: "x86"
195-
vcpkg_triplet: "x86-windows"
196-
sdk_platform: windows
197-
additional_build_flags: "--build_tests"
198-
- os: ubuntu-latest
199-
architecture: "x86"
200-
vcpkg_triplet: "x86-linux-dynamic" # special case
201-
sdk_platform: linux
202-
additional_build_flags: ""
182+
sdk_platform: "windows"
203183
- os: ubuntu-latest
204-
architecture: "x64"
205-
vcpkg_triplet: "x64-linux"
206-
sdk_platform: linux
184+
vcpkg_triplet_suffix: "linux"
207185
additional_build_flags: ""
186+
sdk_platform: "linux"
208187
- os: macos-latest
209-
vcpkg_triplet: "x64-osx"
210-
sdk_platform: darwin
188+
vcpkg_triplet_suffix: "osx"
211189
additional_build_flags: "--target_format libraries"
190+
sdk_platform: "darwin"
191+
212192
exclude:
213193
- os: macos-latest
214194
architecture: "x86"
215195
- os: macos-latest
216-
build_type: "Debug"
196+
msvc_runtime: "dynamic"
217197
- os: macos-latest
218-
linkage: "dynamic"
219-
- os: ubuntu-latest
220198
build_type: "Debug"
221199
- os: ubuntu-latest
222-
linkage: "dynamic"
223-
200+
msvc_runtime: "dynamic"
201+
- os: ubuntu-latest
202+
build_type: "Debug"
203+
224204
steps:
225205
- uses: actions/checkout@v2
226206
with:
227207
submodules: true
228208
ref: ${{ github.event.inputs.commitIdToPackage }}
229209

230210
- name: Set env variables for subsequent steps (all)
211+
shell: bash
231212
run: |
232213
echo "VCPKG_RESPONSE_FILE=external/vcpkg_${{ matrix.vcpkg_triplet }}_response_file.txt" >> $GITHUB_ENV
233214
echo "MATRIX_UNIQUE_NAME=${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.architecture }}-${{ matrix.python_version }}" >> $GITHUB_ENV
234-
echo "SDK_NAME=${{ matrix.sdk_platform }}-${{ matrix.architecture }}-${{ matrix.build_type }}-${{ matrix.linkage }}" >> $GITHUB_ENV
215+
echo "SDK_NAME=${{ matrix.sdk_platform }}-${{ matrix.architecture }}-${{ matrix.build_type }}-${{ matrix.msvc_runtime }}" >> $GITHUB_ENV
235216
236217
- name: Add msbuild to PATH (windows)
237218
if: startsWith(matrix.os, 'windows')
238-
uses: microsoft/[email protected].1
219+
uses: microsoft/[email protected].2
239220

240221
- name: Cache vcpkg C++ dependencies
241222
id: cache_vcpkg
242223
uses: actions/cache@v2
243224
with:
244225
path: external/vcpkg/installed
245-
key: dev-vcpkg-${{ matrix.vcpkg_triplet }}-${{ hashFiles(format('{0}', env.VCPKG_RESPONSE_FILE)) }}-${{ hashFiles('.git/modules/external/vcpkg/HEAD') }}
226+
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') }}
246227

247228
- name: Cache ccache files
248229
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
@@ -264,20 +245,28 @@ jobs:
264245
- name: Build desktop SDK
265246
shell: bash
266247
run: |
267-
python scripts/gha/build_desktop.py --arch "${{ matrix.architecture }}" --config "${{ matrix.build_type }}" --build_dir firebase-cpp-sdk-${{ env.SDK_NAME }}-build ${{ matrix.additional_build_flags }}
248+
python scripts/gha/build_desktop.py --arch "${{ matrix.architecture }}" --config "${{ matrix.build_type }}" --msvc_runtime_library "${{ matrix.msvc_runtime }}" --build_dir out-${{ env.SDK_NAME }} ${{ matrix.additional_build_flags }}
268249
# Make a list of all the source files, for debugging purposes.
269-
cd firebase-cpp-sdk-${{ env.SDK_NAME }}-build
250+
cd out-${{ env.SDK_NAME }}
270251
find .. -type f -print > src_file_list.txt
271252
tar -czhf ../firebase-cpp-sdk-${{ env.SDK_NAME }}-build.tgz .
253+
272254
- name: Print built libraries
273255
shell: bash
274256
run: |
275-
find firebase-cpp-sdk-*-build -name "*.lib"
276-
find firebase-cpp-sdk-*-build -name "*.dll"
277-
find firebase-cpp-sdk-*-build -name "*.dylib"
278-
find firebase-cpp-sdk-*-build -name "*.a"
279-
find firebase-cpp-sdk-*-build -name "*.so"
280-
find firebase-cpp-sdk-*-build -name "*.framework"
257+
find out-* -name "*.lib"
258+
find out-* -name "*.dll"
259+
find out-* -name "*.dylib"
260+
find out-* -name "*.a"
261+
find out-* -name "*.so"
262+
find out-* -name "*.framework"
263+
264+
- name: Inspect firebase libraries for cpu arch and msvc runtime.
265+
shell: bash
266+
run: |
267+
python scripts/gha/inspect_built_libraries.py out-${{ env.SDK_NAME }}/
268+
continue-on-error: true
269+
281270
- name: upload artifacts
282271
uses: actions/upload-artifact@v2
283272
with:
@@ -424,7 +413,7 @@ jobs:
424413
with:
425414
name: firebase_cpp_sdk
426415
path: firebase-cpp-sdk-final
427-
416+
428417
merge_packages:
429418
name: final-merge-packages
430419
runs-on: ubuntu-latest

.github/workflows/desktop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
vcpkg_triplet_suffix: "windows-static"
2525
- os: windows-latest
2626
msvc_runtime: "dynamic"
27+
2728
vcpkg_triplet_suffix: "windows-static-md"
2829
- os: ubuntu-latest
2930
vcpkg_triplet_suffix: "linux"
@@ -44,6 +45,7 @@ jobs:
4445
submodules: true
4546

4647
- name: Set env variables for subsequent steps (all)
48+
shell: bash
4749
run: |
4850
echo "VCPKG_RESPONSE_FILE=external/vcpkg_custom_data/response_files/${{ matrix.architecture }}-${{ matrix.vcpkg_triplet_suffix }}.txt" >> $GITHUB_ENV
4951
echo "MATRIX_UNIQUE_NAME=${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.architecture }}-${{ matrix.msvc_runtime }}" >> $GITHUB_ENV

.github/workflows/integration_tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,16 @@ jobs:
7171
if: startsWith(matrix.os, 'macos')
7272
run: echo "VCPKG_TRIPLET=x64-osx" >> $GITHUB_ENV
7373
- name: Set env vars (windows)
74+
shell: bash
7475
if: startsWith(matrix.os, 'windows')
7576
run: echo "VCPKG_TRIPLET=x64-windows-static" >> $GITHUB_ENV
7677
- name: Set env vars(all)
78+
shell: bash
7779
run: echo "VCPKG_RESPONSE_FILE=external/vcpkg_${{ env.VCPKG_TRIPLET }}_response_file.txt" >> $GITHUB_ENV
7880

7981
- name: Add msbuild to PATH (windows)
8082
if: startsWith(matrix.os, 'windows')
81-
uses: microsoft/[email protected].1
83+
uses: microsoft/[email protected].2
8284

8385
- name: Cache vcpkg C++ dependencies
8486
if: matrix.target_platform == 'Desktop'

scripts/gha/build_desktop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def main():
205205
# Copy libraries from appropriate vcpkg directory to build output
206206
# directory for later inclusion.
207207
vcpkg_path = ('external/vcpkg/installed/%s/%slib/' %
208-
(utils.get_vcpkg_triplet(args.arch),
208+
(utils.get_vcpkg_triplet(args.arch, args.msvc_runtime_library),
209209
'debug/' if args.config == 'Debug' else ''))
210210
if (os.path.exists(vcpkg_path)):
211211
shutil.rmtree('vcpkg-libs', ignore_errors=True)

scripts/merge_libraries.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,18 @@ def add_automatic_namespaces(symbols):
475475
# "windows": ["__imp_"]
476476
}
477477

478+
# If a binutils tool returns a "file format is ambiguous" error,
479+
# prefer matching formats that begin with the given prefix (depending
480+
# on the platform). It will select the first format that starts with the
481+
# given prefix. (A blank prefix just means use the first format no
482+
# matter what.)
483+
BINUTILS_PREFERRED_FORMAT_PREFIX_IF_AMBIGUOUS = {
484+
"windows": "pe-",
485+
"linux": "",
486+
"android": "",
487+
"darwin": "",
488+
"ios": "",
489+
}
478490

479491
def read_symbols_from_archive(archive_file):
480492
"""Read the symbols defined in a library archive.
@@ -755,19 +767,29 @@ def run_binutils_command(cmdline, error_output=None, ignore_errors=False):
755767
# Line 0: filename.o: File format is ambiguous
756768
# Line 1: Matching formats: format1 format2 [...]
757769
#
758-
# If this occurs, we will run the command again, passing in --target=format1
759-
# (except on Windows where we know we want fmt2.)
770+
# If this occurs, we will run the command again, passing in the
771+
# target format that we believe we should use instead.
760772
elif (len(error_output) >= 2 and
761773
"ile format is ambiguous" in error_output[0]):
762-
m = re.search("Matching formats: (?P<fmt>[^ ]+) (?P<fmt2>[^ ]+)",
763-
error_output[1])
774+
m = re.search("Matching formats: (.+)", error_output[1])
764775
if m:
765-
fmt = m.group("fmt" if FLAGS.platform != "windows" else "fmt2")
776+
all_formats = m.group(1).split(" ")
777+
preferred_formats = [
778+
fmt
779+
for fmt
780+
in all_formats
781+
if fmt.startswith(
782+
BINUTILS_PREFERRED_FORMAT_PREFIX_IF_AMBIGUOUS[FLAGS.platform])
783+
]
784+
# Or if for some reason none was found, just take the default (first).
785+
retry_format = (preferred_formats[0]
786+
if len(preferred_formats) > 0
787+
else all_formats[0])
766788
error_output = []
767789
logging.debug("Ambiguous file format when running %s %s",
768790
os.path.basename(cmdline[0]), " ".join(cmdline[1:]))
769-
logging.debug("Retrying with --target=%s", fmt)
770-
output = run_command([cmdline[0]] + ["--target=%s" % fmt] + cmdline[1:],
791+
logging.debug("Retrying with --target=%s", retry_format)
792+
output = run_command([cmdline[0]] + ["--target=%s" % retry_format] + cmdline[1:],
771793
error_output, ignore_errors)
772794
if error_output and not ignore_errors:
773795
# If we failed any other way, or if the second run failed, bail.

0 commit comments

Comments
 (0)