diff options
-rw-r--r-- | .appveyor.yml | 37 | ||||
-rw-r--r-- | .github/workflows/ci.yml | 66 | ||||
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | lib/jobs/basejob.cpp | 4 | ||||
-rw-r--r-- | lib/quotient_common.h | 31 |
5 files changed, 74 insertions, 69 deletions
diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index fa031ed8..00000000 --- a/.appveyor.yml +++ /dev/null @@ -1,37 +0,0 @@ -image: Visual Studio 2017 - -environment: - CMAKE_ARGS: '-G "NMake Makefiles JOM" -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo' - matrix: - - QTDIR: C:\Qt\5.13\msvc2017 # Fresh Qt, 32-bit - VCVARS: "vcvars32.bat" - PLATFORM: x86 - - QTDIR: C:\Qt\5.13\msvc2017_64 # Fresh Qt, 64-bit - VCVARS: "vcvars64.bat" - PLATFORM: - -init: -- call "%QTDIR%\bin\qtenv2.bat" -- set PATH=C:\Qt\Tools\QtCreator\bin;%PATH% -- call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\%VCVARS%" %PLATFORM% -- cd /D "%APPVEYOR_BUILD_FOLDER%" - -before_build: -- git submodule update --init --recursive - -build_script: -- cmake %CMAKE_ARGS% -H. -Bbuild -- cmake --build build - -#after_build: -#- cmake --build build --target install -#- 7z a quotient.zip "%DEPLOY_DIR%\" - -# Uncomment this to connect to the AppVeyor build worker -#on_finish: -# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - -test: off - -#artifacts: -#- path: quotient.zip diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20100e5f..670153eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,13 +18,27 @@ jobs: matrix: os: [ubuntu-20.04, macos-10.15] compiler: [ GCC, Clang ] + platform: [ '' ] qt-version: [ '5.12.10' ] + qt-arch: [ '' ] # Not using binary values here, to make the job captions more readable e2ee: [ '' ] update-api: [ '', 'update-api' ] exclude: - os: macos-10.15 compiler: GCC + include: + - os: windows-2019 + compiler: MSVC + platform: x64 + qt-version: '5.12.10' + qt-arch: win64_msvc2017_64 + - os: windows-2019 + compiler: MSVC + platform: x64 + qt-version: '5.12.10' + qt-arch: win64_msvc2017_64 + update-api: update-api steps: - uses: actions/checkout@v2 @@ -36,15 +50,16 @@ jobs: uses: actions/cache@v2 with: path: ${{ runner.workspace }}/Qt - key: ${{ runner.os }}-Qt${{ matrix.qt-version }}-cache + key: ${{ runner.os }}${{ matrix.platform }}-Qt${{ matrix.qt-version }}-cache - name: Install Qt uses: jurplel/install-qt-action@v2.11.1 with: version: ${{ matrix.qt-version }} + arch: ${{ matrix.qt-arch }} cached: ${{ steps.cache-qt.outputs.cache-hit }} - - name: Install Ninja (macOS) + - name: Install Ninja (macOS/Windows) if: ${{ !startsWith(matrix.os, 'ubuntu') }} uses: seanmiddleditch/gha-setup-ninja@v3 @@ -60,9 +75,13 @@ jobs: if [ -n "${{ matrix.update-api }}" ]; then VERSION_POSTFIX='-9'; fi echo "CC=gcc$VERSION_POSTFIX" >>$GITHUB_ENV echo "CXX=g++$VERSION_POSTFIX" >>$GITHUB_ENV - else + elif [[ '${{ matrix.compiler }}' == 'Clang' ]]; then echo "CC=clang" >>$GITHUB_ENV echo "CXX=clang++" >>$GITHUB_ENV + if [[ '${{ runner.os }}' == 'Linux' ]]; then + # Do CodeQL analysis on one of Linux branches + echo "CODEQL_ANALYSIS=true" >>$GITHUB_ENV + fi fi if grep -q 'refs/tags' <<<'${{ github.ref }}'; then VERSION="$(git describe --tags)" @@ -76,10 +95,16 @@ jobs: -DCMAKE_INSTALL_PREFIX=~/.local -DCMAKE_PREFIX_PATH=~/.local" >>$GITHUB_ENV cmake -E make_directory ${{ runner.workspace }}/build + - name: Setup MSVC environment + uses: ilammy/msvc-dev-cmd@v1 + if: matrix.compiler == 'MSVC' + with: + arch: ${{ matrix.platform }} + - name: Build and install olm if: matrix.e2ee run: | - cd ${{ runner.workspace }} + cd .. git clone https://gitlab.matrix.org/matrix-org/olm.git cmake -S olm -B olm/build $CMAKE_ARGS cmake --build olm/build --target install @@ -88,18 +113,35 @@ jobs: - name: Pull CS API and build GTAD if: matrix.update-api run: | - cd ${{ runner.workspace }} + cd .. git clone https://github.com/matrix-org/matrix-doc.git git clone --recursive https://github.com/KitsuneRal/gtad.git - cmake -S gtad -B gtad $CMAKE_ARGS + cmake -S gtad -B gtad $CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF cmake --build gtad - echo "CMAKE_ARGS=$CMAKE_ARGS -DMATRIX_DOC_PATH=${{ runner.workspace }}/matrix-doc \ - -DGTAD_PATH=${{ runner.workspace }}/gtad/gtad" \ + echo "CMAKE_ARGS=$CMAKE_ARGS -DMATRIX_DOC_PATH=$GITHUB_WORKSPACE/../matrix-doc \ + -DGTAD_PATH=$GITHUB_WORKSPACE/../gtad/gtad" \ >>$GITHUB_ENV echo "QUOTEST_ORIGIN=$QUOTEST_ORIGIN and API files regeneration" >>$GITHUB_ENV + + - name: Initialize CodeQL tools + if: env.CODEQL_ANALYSIS + uses: github/codeql-action/init@v1 + with: + languages: cpp + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main - name: Configure libQuotient - run: cmake -S $GITHUB_WORKSPACE -B build $CMAKE_ARGS -DQuotient_ENABLE_E2EE=${{ matrix.e2ee }} + run: | + if [[ '${{ runner.os }}' == 'Windows' ]]; then + BIN_DIR=. + else + BIN_DIR=bin + fi + echo "BIN_DIR=$BIN_DIR" >>$GITHUB_ENV + cmake -S $GITHUB_WORKSPACE -B build $CMAKE_ARGS -DQuotient_ENABLE_E2EE=${{ matrix.e2ee }} - name: Regenerate API code if: matrix.update-api @@ -108,7 +150,7 @@ jobs: - name: Build and install libQuotient run: | cmake --build build --target install - ls ~/.local/bin/quotest + ls ~/.local/$BIN_DIR/quotest - name: Run tests env: @@ -117,3 +159,7 @@ jobs: run: | [[ -z "$TEST_USER" ]] || $VALGRIND build/quotest/quotest "$TEST_USER" "$TEST_PWD" quotest-gha '#quotest:matrix.org' "$QUOTEST_ORIGIN" timeout-minutes: 5 # quotest is supposed to finish within 3 minutes, actually + + - name: Perform CodeQL analysis + if: env.CODEQL_ANALYSIS + uses: github/codeql-action/analyze@v1 diff --git a/CMakeLists.txt b/CMakeLists.txt index aca1f982..62fa43de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,7 +177,7 @@ set(ASAPI_DEF_DIR application-service/definitions) set(ISAPI_DEF_DIR identity/definitions) if (GTAD_PATH AND MATRIX_DOC_PATH) - get_filename_component(ABS_GTAD_PATH "${GTAD_PATH}" REALPATH) + get_filename_component(ABS_GTAD_PATH "${GTAD_PATH}" PROGRAM PROGRAM_ARGS GTAD_ARGS) if (EXISTS ${ABS_GTAD_PATH}) get_filename_component(ABS_API_DEF_PATH "${MATRIX_DOC_PATH}/data/api" REALPATH) if (NOT IS_DIRECTORY ${ABS_API_DEF_PATH}) @@ -199,7 +199,7 @@ if (API_GENERATION_ENABLED) if (NOT CLANG_FORMAT) set(CLANG_FORMAT clang-format) endif() - get_filename_component(ABS_CLANG_FORMAT "${CLANG_FORMAT}" PROGRAM) + get_filename_component(ABS_CLANG_FORMAT "${CLANG_FORMAT}" PROGRAM PROGRAM_ARGS CLANG_FORMAT_ARGS) if (ABS_CLANG_FORMAT) set(API_FORMATTING_ENABLED 1) message( STATUS "clang-format is at ${ABS_CLANG_FORMAT}") @@ -228,6 +228,7 @@ if (API_GENERATION_ENABLED) old_sync.yaml- room_initial_sync.yaml- # deprecated key_backup.yaml- # immature and buggy in terms of API definition sync.yaml- # we have a better handcrafted implementation + ${GTAD_ARGS} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/lib SOURCES gtad/gtad.yaml gtad/data.h.mustache diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp index 239cef28..6346db9d 100644 --- a/lib/jobs/basejob.cpp +++ b/lib/jobs/basejob.cpp @@ -156,8 +156,8 @@ public: { // FIXME: use std::array {} when Apple stdlib gets deduction guides for it static const auto verbs = - to_array({ QStringLiteral("GET"), QStringLiteral("PUT"), - QStringLiteral("POST"), QStringLiteral("DELETE") }); + make_array(QStringLiteral("GET"), QStringLiteral("PUT"), + QStringLiteral("POST"), QStringLiteral("DELETE")); const auto verbWord = verbs.at(size_t(verb)); return verbWord % ' ' % (reply ? reply->url().toString(QUrl::RemoveQuery) diff --git a/lib/quotient_common.h b/lib/quotient_common.h index d225ad63..bb2e6a6b 100644 --- a/lib/quotient_common.h +++ b/lib/quotient_common.h @@ -10,22 +10,17 @@ namespace Quotient { Q_NAMESPACE -namespace impl { - template <class T, std::size_t N, std::size_t... I> - constexpr std::array<std::remove_cv_t<T>, N> - to_array_impl(T (&&a)[N], std::index_sequence<I...>) - { - return { {std::move(a[I])...} }; - } -} // std::array {} needs explicit template parameters on macOS because -// Apple stdlib doesn't have deduction guides for std::array; to alleviate that, -// to_array() is borrowed from C++20 (thanks to cppreference for the possible -// implementation: https://en.cppreference.com/w/cpp/container/array/to_array) -template <typename T, size_t N> -constexpr auto to_array(T (&& items)[N]) +// Apple stdlib doesn't have deduction guides for std::array. C++20 has +// to_array() but that can't be borrowed, this time because of MSVC: +// https://developercommunity.visualstudio.com/t/vc-ice-p1-initc-line-3652-from-stdto-array/1464038 +// Therefore a simpler (but also slightly more wobbly - it resolves the element +// type using std::common_type<>) make_array facility is implemented here. +template <typename... Ts> +constexpr auto make_array(Ts&&... items) { - return impl::to_array_impl(std::move(items), std::make_index_sequence<N>{}); + return std::array<std::common_type_t<Ts...>, sizeof...(items)>( + { std::forward<Ts>(items)... }); } // TODO: code like this should be generated from the CS API definition @@ -49,9 +44,9 @@ enum class Membership : unsigned int { Q_DECLARE_FLAGS(MembershipMask, Membership) Q_FLAG_NS(MembershipMask) -constexpr inline auto MembershipStrings = to_array( +constexpr inline auto MembershipStrings = make_array( // The order MUST be the same as the order in the original enum - { "join", "leave", "invite", "knock", "ban" }); + "join", "leave", "invite", "knock", "ban"); //! \brief Local user join-state names //! @@ -68,10 +63,10 @@ enum class JoinState : std::underlying_type_t<Membership> { Q_DECLARE_FLAGS(JoinStates, JoinState) Q_FLAG_NS(JoinStates) -constexpr inline auto JoinStateStrings = to_array({ +constexpr inline auto JoinStateStrings = make_array( MembershipStrings[0], MembershipStrings[1], MembershipStrings[2], MembershipStrings[3] /* same as MembershipStrings, sans "ban" */ -}); +); //! \brief Network job running policy flags //! |