From 314a3a206ee188b01dbd0179d9528c57fa26a863 Mon Sep 17 00:00:00 2001 From: Victor Paleologue Date: Wed, 8 Sep 2021 17:37:07 +0200 Subject: [PATCH 1/6] format: Fixes compilation for C++17 --- src/format_doc.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/format_doc.cpp b/src/format_doc.cpp index b707d68..61591a2 100644 --- a/src/format_doc.cpp +++ b/src/format_doc.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -14,8 +15,6 @@ #include #include "formatter_p.hpp" #include -#include -#include #include #include "cpptype.hpp" @@ -94,7 +93,7 @@ class QiLangGenDoc: public NodeFormatter<> } std::stack first; - boost::scoped_ptr curDoc; + std::unique_ptr curDoc; void putComma() { if (first.top()) @@ -169,9 +168,7 @@ class QiLangGenDoc: public NodeFormatter<> curDoc.reset(new Doc(doc)); } - BOOST_SCOPE_EXIT(&curDoc) { - curDoc.reset(); - } BOOST_SCOPE_EXIT_END + ka::scoped([this] { curDoc.reset(); }); out() << "\"" << node->name << "\" : {"; out() << "\"type\" : \"method\", "; From b2874410e0adbe98cca315850ad347e2a940896c Mon Sep 17 00:00:00 2001 From: Victor Paleologue Date: Wed, 8 Sep 2021 18:32:42 +0200 Subject: [PATCH 2/6] lexer: Avoids putting in stone the type of the scanning result. This allow building on Windows, Linux, even when updates of Flex leads to reconsidering the type of that result. --- src/token.l | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/token.l b/src/token.l index f7f0ad8..cb1ca5a 100644 --- a/src/token.l +++ b/src/token.l @@ -84,36 +84,34 @@ #define STEP() LOC.step() -#define YY_INPUT(buf, result, max_size) qilang_readsome(yyextra, buf, &result, max_size) +// See https://www.cs.princeton.edu/~appel/modern/c/software/flex/flex.html#SEC10 +#define YY_INPUT(buf, result, max_size) \ + { \ + auto p = yyextra; \ + if (p->file->in().eof() || p->file->in().fail()) { \ + result = 0; \ + } else { \ + p->file->in().readsome(buf, max_size); \ + if (!p->file->in().gcount() && !p->file->in().eof()) \ + { \ + p->file->in().peek(); \ + p->file->in().readsome(buf, max_size); \ + } \ + if (p->file->in().bad()) \ + { \ + result = -1; \ + } else { \ + result = p->file->in().gcount(); \ + } \ + } \ + } #ifdef _WIN32 static bool isatty(int fp) { return false; } #endif -#ifdef _WIN32 - static void qilang_readsome(qilang::Parser* p, char* buf, int *result, size_t max_size) -#else - static void qilang_readsome(qilang::Parser* p, char* buf, yy_size_t *result, size_t max_size) -#endif - { - if (p->file->in().eof() || p->file->in().fail()) { - *result = 0; - return; - } - p->file->in().readsome(buf, max_size); - if (!p->file->in().gcount() && !p->file->in().eof()) - { - p->file->in().peek(); - p->file->in().readsome(buf, max_size); - } - if (p->file->in().bad()) - { - *result = -1; - return; - } - *result = p->file->in().gcount(); - } + #define yyterminate() \ return yy::parser::make_END_OF_FILE(LOC) From 747f05c78381b33cb52b7eab272b36d287183e34 Mon Sep 17 00:00:00 2001 From: Victor Paleologue Date: Wed, 8 Sep 2021 17:27:20 +0200 Subject: [PATCH 3/6] github.workflow: Adds continuous and release GitHub workflows. --- .github/workflows/continuous.yml | 46 ++++++++++++++++++++++ .github/workflows/make_feed.sh | 26 +++++++++++++ .github/workflows/release.yml | 66 ++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 .github/workflows/continuous.yml create mode 100755 .github/workflows/make_feed.sh create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml new file mode 100644 index 0000000..c8272b8 --- /dev/null +++ b/.github/workflows/continuous.yml @@ -0,0 +1,46 @@ +name: Build and Test + +on: + push: + branches: [ master, release-2.9, team/platform/dev ] + pull_request: + branches: [ master, release-2.9, team/platform/dev ] + +env: + FEED: https://github.com/victorpaleologue/libqi/releases/download/v1.8.8-actions/feed.xml + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: ubuntu-20.04 + + steps: + + - name: Install Build Tools + run: pip install qibuild + + - name: Install Dependencies + # TODO move these dependencies in the toolchain + run: sudo apt install libgtest-dev libgmock-dev + + - uses: actions/checkout@v2 + + - name: Prepare QiBuild Toolchain + run: qitoolchain create qisdk $FEED + + - name: Prepare QiBuild Config + run: | + qibuild init + qibuild add-config qisdk -t qisdk + + - name: Configure + run: qibuild configure -c qisdk --debug -DQI_WITH_TESTS=ON -DCMAKE_CXX_FLAGS=-pthread + + - name: Build + run: qibuild make -c qisdk + + - name: Test + run: qitest run -c qisdk diff --git a/.github/workflows/make_feed.sh b/.github/workflows/make_feed.sh new file mode 100755 index 0000000..138927b --- /dev/null +++ b/.github/workflows/make_feed.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Retrieves the latest release output to generate a QiToolchain XML feed. +set -e +echo "Getting packages from current release at ${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/latest" +ASSETS_URL=$(curl --silent "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/latest" | + jq -r '.assets_url') +PACKAGES_URLS=$(curl --silent ${ASSETS_URL} | + jq '.[] | .browser_download_url' | + grep .zip | xargs -L 1 echo) # echo removes the extra quotes + +echo "Making a toolchain feed." +echo "" > feed.xml +echo "Adding sub-toolchain from ${FEED}" +echo " " >> feed.xml +echo "Adding links for the following packages:" ${PACKAGES_URLS} +for URL in $PACKAGES_URLS; do + ZIP=package.zip + wget -q $URL -O $ZIP; + NAME=$(unzip -p $ZIP package.xml | xmllint --xpath "string(/package/@name)" -) + VERSION=$(unzip -p $ZIP package.xml | xmllint --xpath "string(/package/@version)" -) + echo " " >> feed.xml + rm $ZIP +done +echo "" >> feed.xml + +realpath feed.xml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1b23bae --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: Release with Toolchain + +on: + push: + tags: "v*" + +env: + FEED: https://github.com/victorpaleologue/libqi/releases/download/v1.8.8-actions/feed.xml + +jobs: + gh_tagged_release: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: ubuntu-20.04 + + steps: + + - name: Install Utilities + run: sudo apt install apt-utils ca-certificates locales curl wget jq libxml2-utils xmlstarlet + + - name: Install Build Tools + run: pip install qibuild + + - name: Install Dependencies + # TODO move these dependencies in the toolchain + run: sudo apt install libgtest-dev libgmock-dev + + - uses: actions/checkout@v2 + + - name: Prepare QiBuild Toolchain + run: qitoolchain create qisdk $FEED + + - name: Prepare QiBuild Config + run: | + qibuild init + qibuild add-config qisdk -t qisdk + + - name: Set Version + run: xmlstarlet ed --inplace -i '/project/qibuild' -t attr -n version -v `git describe --tags` qiproject.xml + + - name: Build QiToolchain Package # Outputs the package as a .zip in ./package/ + run: qibuild package -c qisdk --release -DQI_WITH_TESTS=OFF -DCMAKE_CXX_FLAGS=-pthread + + - name: Release Package + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: false + files: | + package/*.zip + id: "release" + + - name: Make Feed # Outputs feed.xml + run: .github/workflows/make_feed.sh + + - name: Release Feed + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ steps.release.outputs.upload_url }} + asset_path: feed.xml + asset_name: feed.xml + asset_content_type: application/xml From 1fd90499918a7bb329b7fdc574ac25b27e20e175 Mon Sep 17 00:00:00 2001 From: Victor Paleologue Date: Thu, 9 Sep 2021 14:12:03 +0200 Subject: [PATCH 4/6] KLUDGE: boost chrono --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b70fdac..b6268d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,7 @@ qi_use_lib(qilang qi) qi_stage_lib(qilang) -qi_create_bin(qicc src/qic_main.cpp DEPENDS qi qilang) +qi_create_bin(qicc src/qic_main.cpp DEPENDS qi qilang boost_chrono) qi_stage_bin(qicc) qi_stage_cmake(qilang-tools-config.cmake) From 2d3cf5600a19dac08cf5e510dec33fc96a796eda Mon Sep 17 00:00:00 2001 From: Victor Paleologue Date: Thu, 9 Sep 2021 14:18:01 +0200 Subject: [PATCH 5/6] TMP: more log when running qicc --- qilang-tools-config.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qilang-tools-config.cmake b/qilang-tools-config.cmake index f9a585d..6290f09 100644 --- a/qilang-tools-config.cmake +++ b/qilang-tools-config.cmake @@ -108,7 +108,7 @@ function(qi_gen_idl OUT lang pkg dir) SRC "${abs_idl_path}" COMMENT "Generating remote proxy implementation ${generated_path}" DEPENDS "${QICC_EXECUTABLE}" "${staged_idl_path}" ${mirror_idl_file_target} - COMMAND "${QICC_EXECUTABLE}" -c cpp_remote "${staged_idl_path}" -o "${generated_path}" -t ${QI_SDK_DIR}) + COMMAND readelf -d "${CMAKE_CURRENT_SOURCE_DIR}/../build-qisdk/sdk/bin/qicc" | head -20 && readelf -d "/home/runner/.local/share/qi/toolchains/qisdk/libqi/lib/libqi.so" | head -20 && "${QICC_EXECUTABLE}" -c cpp_remote "${staged_idl_path}" -o "${generated_path}" -t ${QI_SDK_DIR}) list(APPEND _out "${generated_path}") list(APPEND _${OUT}_REMOTE "${generated_path}") message(STATUS "Will generate C++ remote proxy implementation: ${generated_path}") From f736b796dbeaf5d1161e7e4393e15cc57367d351 Mon Sep 17 00:00:00 2001 From: Victor Paleologue Date: Mon, 13 Sep 2021 15:18:26 +0200 Subject: [PATCH 6/6] github.workflow: reconstruct current release URL from tag Instead of relying on the "latest" release, we use the actual release tag to make sure to retrieve the right release. That does not work better for pre-releases, though. --- .github/workflows/make_feed.sh | 7 ++++--- .github/workflows/release.yml | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/make_feed.sh b/.github/workflows/make_feed.sh index 138927b..7f11dde 100755 --- a/.github/workflows/make_feed.sh +++ b/.github/workflows/make_feed.sh @@ -1,10 +1,11 @@ #!/bin/bash # Retrieves the latest release output to generate a QiToolchain XML feed. set -e -echo "Getting packages from current release at ${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/latest" -ASSETS_URL=$(curl --silent "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/latest" | +RELEASE_URL="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${CURRENT_RELEASE_TAG}" +echo "Getting packages from current release at $RELEASE_URL" +ASSETS_URL=$(curl --silent $RELEASE_URL | jq -r '.assets_url') -PACKAGES_URLS=$(curl --silent ${ASSETS_URL} | +PACKAGES_URLS=$(curl --silent $ASSETS_URL | jq '.[] | .browser_download_url' | grep .zip | xargs -L 1 echo) # echo removes the extra quotes diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b23bae..49c0176 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,6 +54,8 @@ jobs: - name: Make Feed # Outputs feed.xml run: .github/workflows/make_feed.sh + env: + CURRENT_RELEASE_TAG: ${{ steps.release.outputs.automatic_releases_tag }} - name: Release Feed uses: actions/upload-release-asset@v1