Skip to content

Commit 92d8bc1

Browse files
authored
Merge pull request #150 from firebase/feature/android-builds-on-windows-clean
Feature/android builds on windows clean
2 parents 6abdb01 + b086644 commit 92d8bc1

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

.github/workflows/android.yml

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

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

@@ -14,13 +14,15 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
os: [ubuntu-latest, macos-latest]
17+
os: [ubuntu-latest, macos-latest, windows-latest]
1818
architecture: ["x64",]
1919
include:
2020
- os: ubuntu-latest
2121
architecture: "x64"
2222
- os: macos-latest
2323
architecture: "x64"
24+
- os: windows-latest
25+
architecture: "x64"
2426

2527
steps:
2628
- uses: actions/checkout@v2
@@ -38,10 +40,15 @@ jobs:
3840
python-version: 3.7
3941
architecture: ${{ matrix.architecture }}
4042

43+
- name: Add msbuild to PATH
44+
if: startsWith(matrix.os, 'windows')
45+
uses: microsoft/[email protected]
46+
4147
- name: Install prerequisites
48+
shell: bash
4249
run: |
4350
build_scripts/android/install_prereqs.sh
44-
51+
4552
- name: Cache ccache files
4653
id: cache_ccache
4754
uses: actions/cache@v2
@@ -50,6 +57,7 @@ jobs:
5057
key: dev-test-ccache-${{ env.MATRIX_UNIQUE_NAME }}
5158

5259
- name: Build SDK
60+
shell: bash
5361
run: |
5462
build_scripts/android/build.sh android_build .
5563

build_scripts/android/build.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ if [[ -n $(ls) ]]; then
2020
exit 2
2121
fi
2222
cd -
23-
# Turn buildpath into an absolute path for use later with rsync.
24-
buildpath=$( cd "${buildpath}" ; pwd -P )
2523

2624
# If NDK_ROOT is not set or is the wrong version, use to the version in /tmp.
2725
if [[ -z "${NDK_ROOT}" || ! $(grep -q "Pkg\.Revision = 16\." "${NDK_ROOT}/source.properties") ]]; then
@@ -54,6 +52,15 @@ for lib in *; do
5452
fi
5553
done
5654
set -x
57-
# Use rsync to copy the relevent paths to the destination directory.
58-
rsync -aR "${paths[@]}" "${buildpath}/"
5955

56+
if [[ $(uname) == "Linux" ]] || [[ $(uname) == "Darwin" ]]; then
57+
# Turn buildpath into an absolute path for use later with rsync.
58+
buildpath=$( cd "${buildpath}" ; pwd -P )
59+
# Use rsync to copy the relevent paths to the destination directory.
60+
rsync -aR "${paths[@]}" "${buildpath}/"
61+
else
62+
# rsync has to be specifically installed on windows bash (including github runners)
63+
# Also, rsync with absolute destination path doesn't work on Windows.
64+
# Using a simple copy instead of rsync on Windows.
65+
cp -R --parents "${paths[@]}" "${buildpath}"
66+
fi

build_scripts/android/install_prereqs.sh

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ elif [[ $(uname) == "Linux" ]]; then
1313
echo "::set-env name=CCACHE_INSTALLED::1"
1414
fi
1515
else
16-
echo "Unsupported platform, this script must run on a MacOS or Linux machine."
17-
exit 1
16+
platform=windows
17+
# On Windows, we have an additional dependency for Strings
18+
curl -LSs \ curl -LSs \
19+
"https://download.sysinternals.com/files/Strings.zip" \
20+
--output Strings.zip
21+
unzip -q Strings.zip && rm -f Strings.zip
1822
fi
1923

2024
if [[ -z $(which cmake) ]]; then
@@ -28,11 +32,16 @@ if [[ -z $(which python) ]]; then
2832
else
2933
updated_pip=0
3034
if ! $(echo "import absl"$'\n'"import google.protobuf" | python - 2> /dev/null); then
31-
echo "Installing python packages."
32-
set -x
33-
sudo python -m pip install --upgrade pip
34-
pip install absl-py protobuf
35-
set +x
35+
echo "Installing python packages."
36+
set -x
37+
# On Windows bash shell, sudo doesn't exist
38+
if [[ $(uname) == "Linux" ]] || [[ $(uname) == "Darwin" ]]; then
39+
sudo python -m pip install --upgrade pip
40+
else
41+
python -m pip install --upgrade pip
42+
fi
43+
pip install absl-py protobuf
44+
set +x
3645
fi
3746
fi
3847

0 commit comments

Comments
 (0)