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..7f11dde --- /dev/null +++ b/.github/workflows/make_feed.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Retrieves the latest release output to generate a QiToolchain XML feed. +set -e +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 | + 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..49c0176 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,68 @@ +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 + env: + CURRENT_RELEASE_TAG: ${{ steps.release.outputs.automatic_releases_tag }} + + - 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 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) 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}") 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\", "; 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)