diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.yml new file mode 100644 index 0000000000..1570534428 --- /dev/null +++ b/.github/workflows/desktop.yml @@ -0,0 +1,161 @@ +name: Desktop Builds + +on: + push: + pull_request: + +env: + CCACHE_DIR: ${{ github.workspace }}/ccache_dir + +jobs: + build: + name: ${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.architecture }}-${{ matrix.python_version }}-${{ matrix.generator }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + build_type: ["Release"] + architecture: ["x64",] + python_version: [2.7] + generator: ["Visual Studio 16 2019", "Unix Makefiles", "Ninja"] + exclude: + - os: ubuntu-latest + generator: "Visual Studio 16 2019" + - os: macos-latest + generator: "Visual Studio 16 2019" + - os: windows-latest + generator: "Unix Makefiles" + - os: windows-latest + generator: "Ninja" + + include: + - os: windows-latest + architecture: "x64" + vcpkg_triplet: "x64-windows-static" + msbuild_platform: "x64" + - os: ubuntu-latest + architecture: "x64" + vcpkg_triplet: "x64-linux" + - os: macos-latest + architecture: "x64" + vcpkg_triplet: "x64-osx" + + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Set env variables for subsequent steps (all) + run: | + echo "::set-env name=VCPKG_RESPONSE_FILE::external/vcpkg_${{ matrix.vcpkg_triplet }}_response_file.txt" + echo "::set-env name=PIP_REQUIREMENTS_FILE::external/pip_requirements.txt" + echo "::set-env name=MATRIX_UNIQUE_NAME::${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.architecture }}-${{ matrix.python_version }}-${{ matrix.generator }}" + + - name: Install Ninja (windows) + if: startsWith(matrix.generator, 'Ninja') && startsWith(matrix.os, 'windows') + run: | + choco install ninja + + - name: Install Ninja (mac) + if: startsWith(matrix.generator, 'Ninja') && startsWith(matrix.os, 'macos') + run: | + brew install ninja + + - name: Install Ninja (linux) + if: startsWith(matrix.generator, 'Ninja') && startsWith(matrix.os, 'ubuntu') + run: | + sudo apt install ninja-build + + - name: Install system level applications (mac) + if: startsWith(matrix.os, 'macos') + id: macos-brew-install + run: | + brew install ccache + echo "::set-env name=CCACHE_INSTALLED::1" + + - name: Install system level applications (linux) + if: startsWith(matrix.os, 'ubuntu') + id: ubuntu-apt-install + run: | + sudo apt install ccache + echo "::set-env name=CCACHE_INSTALLED::1" + + - name: Cache vcpkg C++ dependencies + id: cache_vcpkg + uses: actions/cache@v2 + with: + path: external/vcpkg/installed + key: dev-vcpkg-${{ matrix.vcpkg_triplet }}-${{ hashFiles(format('{0}', env.VCPKG_RESPONSE_FILE)) }}-${{ hashFiles('.git/modules/external/vcpkg/HEAD') }} + + - name: Install vcpkg packages (windows) + if: steps.cache_vcpkg.outputs.cache-hit!='true' && startsWith(matrix.os, 'windows') + run: | + ${{ github.workspace }}/external/vcpkg/bootstrap-vcpkg.bat -disableMetrics + ${{ github.workspace }}/external/vcpkg/vcpkg install @${{env.VCPKG_RESPONSE_FILE}} + + - name: Install vcpkg packages (mac and linux) + if: steps.cache_vcpkg.outputs.cache-hit!='true' && startsWith(matrix.os, 'windows')!='true' + run: | + ${{ github.workspace }}/external/vcpkg/bootstrap-vcpkg.sh -disableMetrics + ${{ github.workspace }}/external/vcpkg/vcpkg install @${{env.VCPKG_RESPONSE_FILE}} + + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version }} + architecture: ${{ matrix.architecture }} + + - name: Get pip cache dir + id: get_pip_cache_dir + run: | + echo "::set-output name=cachedir::$(pip cache dir)" + + - name: pip cache + id: cache_pip + uses: actions/cache@v2 + with: + path: ${{ steps.get_pip_cache_dir.outputs.cachedir }} + key: dev-pip-${{ runner.os }}-${{ matrix.python_version }}-${{ matrix.architecture }}-${{ hashFiles(format('{0}', env.PIP_REQUIREMENTS_FILE)) }} + + - name: Install pip packages + run: | + python -m pip install --upgrade pip + pip install -r ${{ env.PIP_REQUIREMENTS_FILE }} + + - name: Cache ccache files + if: env.CCACHE_INSTALLED + id: cache_ccache + uses: actions/cache@v2 + with: + path: ccache_dir + key: dev-test-ccache-${{ env.MATRIX_UNIQUE_NAME }} + + - name: Configure + shell: bash + run: | + mkdir build + cmake \ + -S . \ + -B build \ + -G "${{ matrix.generator }}" \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DCMAKE_TOOLCHAIN_FILE=external/vcpkg/scripts/buildsystems/vcpkg.cmake \ + -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }} \ + + - name: Build + shell: bash + run: cmake --build build --config ${{ matrix.build_type }} -j 8 + + - name: Stats for ccache (mac and linux) + if: env.CCACHE_INSTALLED + run: ccache -s + + - name: Print built libraries + shell: bash + run: | + find build -name "*.lib" + find build -name "*.dll" + find build -name "*.dylib" + find build -name "*.a" + find build -name "*.so" diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000000..9ffa4ed390 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,91 @@ +name: Windows Builds + +on: + push: + pull_request: + +jobs: + build: + name: ${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.architecture }}-${{ matrix.python_version }}-${{ matrix.generator }} + runs-on: ${{ matrix.os }} + strategy: + # If any of the configurations fail, others will proceed to run + fail-fast: false + matrix: + os: [windows-latest,] + build_type: ["Release"] + architecture: ["x64",] + python_version: [2.7] + generator: ["Visual Studio 16 2019",] + include: + - os: windows-latest + architecture: "x64" + vcpkg_triplet: "x64-windows-static" + # For x64, this variable probably doesnt make sense but + # for x86, the command line argument to pass to cmake is -A Win32 and not -A x86 + msbuild_platform: "x64" + + steps: + # Check out with submodule (vcpkg is a submodule) + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Set env variables for subsequent steps (all) + run: | + echo "::set-env name=VCPKG_RESPONSE_FILE::external/vcpkg_${{ matrix.vcpkg_triplet }}_response_file.txt" + echo "::set-env name=PIP_REQUIREMENTS_FILE::external/pip_requirements.txt" + + - name: Install Ninja + if: startsWith(matrix.generator, 'Ninja') && startsWith(matrix.os, 'windows') + run: | + choco install ninja + + - name: Cache vcpkg C++ dependencies + id: cache_vcpkg + uses: actions/cache@v2 + with: + path: external/vcpkg/installed + key: dev-vcpkg-${{ matrix.vcpkg_triplet }}-${{ hashFiles(format('{0}', env.VCPKG_RESPONSE_FILE)) }}-${{ hashFiles('.git/modules/external/vcpkg/HEAD') }} + + - name: Install vcpkg packages (windows) + if: steps.cache_vcpkg.outputs.cache-hit!='true' && startsWith(matrix.os, 'windows') + run: | + ${{ github.workspace }}/external/vcpkg/bootstrap-vcpkg.bat -disableMetrics + ${{ github.workspace }}/external/vcpkg/vcpkg install @${{env.VCPKG_RESPONSE_FILE}} + + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version }} + architecture: ${{ matrix.architecture }} + + - name: Install pip packages + run: | + python -m pip install --upgrade pip + pip install -r ${{ env.PIP_REQUIREMENTS_FILE }} + + - name: Configure + shell: bash + run: | + mkdir build + cmake \ + -S . \ + -B build \ + -G "${{ matrix.generator }}" \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DCMAKE_TOOLCHAIN_FILE=external/vcpkg/scripts/buildsystems/vcpkg.cmake \ + -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }} \ + + - name: Build + shell: bash + run: cmake --build build --config ${{ matrix.build_type }} -j 8 + + - name: Print built libraries + shell: bash + run: | + find build -name "*.lib" + find build -name "*.dll" + find build -name "*.dylib" + find build -name "*.a" + find build -name "*.so" diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..63ff859c51 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "external/vcpkg"] + path = external/vcpkg + url = https://github.com/microsoft/vcpkg.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d3b1ce226..070f565ea5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,15 @@ project (firebase NONE) enable_language(C) enable_language(CXX) +set(compiler_cache_program ccache) + +find_program(compilercache_program ${compiler_cache_program}) +if(compilercache_program) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${compiler_cache_program}") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${compiler_cache_program}") + message( STATUS "Found compiler cache program : ${compiler_cache_program}" ) +endif() + list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_LIST_DIR}/cmake) include(external_rules) include(cpp_pack) diff --git a/external/pip_requirements.txt b/external/pip_requirements.txt new file mode 100644 index 0000000000..5aaa75d727 --- /dev/null +++ b/external/pip_requirements.txt @@ -0,0 +1,2 @@ +absl-py +protobuf diff --git a/external/vcpkg b/external/vcpkg new file mode 160000 index 0000000000..ee17a68508 --- /dev/null +++ b/external/vcpkg @@ -0,0 +1 @@ +Subproject commit ee17a685087a6886e5681e355d36cd784f0dd2c8 diff --git a/external/vcpkg_x64-linux_response_file.txt b/external/vcpkg_x64-linux_response_file.txt new file mode 100644 index 0000000000..1adba55af6 --- /dev/null +++ b/external/vcpkg_x64-linux_response_file.txt @@ -0,0 +1,6 @@ +openssl +protobuf +zlib +abseil +--triplet +x64-linux diff --git a/external/vcpkg_x64-osx_response_file.txt b/external/vcpkg_x64-osx_response_file.txt new file mode 100644 index 0000000000..4199f79c2f --- /dev/null +++ b/external/vcpkg_x64-osx_response_file.txt @@ -0,0 +1,6 @@ +openssl +protobuf +zlib +abseil +--triplet +x64-osx diff --git a/external/vcpkg_x64-windows-static_response_file.txt b/external/vcpkg_x64-windows-static_response_file.txt new file mode 100644 index 0000000000..d5889f747a --- /dev/null +++ b/external/vcpkg_x64-windows-static_response_file.txt @@ -0,0 +1,6 @@ +openssl +protobuf +zlib +abseil +--triplet +x64-windows-static