From 67acb5cbf8cbf8e97eb36b83372e1d31567e3dfc Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Fri, 24 May 2024 17:24:31 -0300 Subject: [PATCH 01/11] refactor: references to excluded symbols are not an error --- src/lib/Metadata/Finalize.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/Metadata/Finalize.cpp b/src/lib/Metadata/Finalize.cpp index f90238f42..76ffb6a61 100644 --- a/src/lib/Metadata/Finalize.cpp +++ b/src/lib/Metadata/Finalize.cpp @@ -183,11 +183,17 @@ class Finalizer if constexpr(std::derived_from) { +#if 0 + // This warning shouldn't be triggered if the symbol has + // been explicitly marked excluded in mrdocs.yml if(! resolveReference(N)) { report::warn("Failed to resolve reference to '{}' from '{}'", N.string, current_->Name); } +#else + resolveReference(N); +#endif } }); } From b22fc1b27ba2a4037354ef6ddc1e9de66a3316ae Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Fri, 24 May 2024 17:25:46 -0300 Subject: [PATCH 02/11] refactor: invalid commands emit error messages --- src/lib/AST/ParseJavadoc.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/AST/ParseJavadoc.cpp b/src/lib/AST/ParseJavadoc.cpp index 72bda6b2c..a9b66046b 100644 --- a/src/lib/AST/ParseJavadoc.cpp +++ b/src/lib/AST/ParseJavadoc.cpp @@ -619,8 +619,11 @@ convertCopydoc(unsigned id) case CommandTraits::KCI_copydetails: return doc::Parts::description; default: + { + report::error("error: unsupported CommandTrait id <{}>", id); MRDOCS_UNREACHABLE(); } + } } static @@ -640,6 +643,7 @@ convertStyle(InlineCommandRenderKind kind) return doc::Style::none; default: // unknown RenderKind + report::error("error: unsupported InlineCommandRenderKind <{}>", static_cast(kind)); MRDOCS_UNREACHABLE(); } } @@ -657,6 +661,7 @@ convertDirection(ParamCommandPassDirection kind) case ParamCommandPassDirection::InOut: return doc::ParamDirection::inout; default: + report::error("error: unsupported ParamCommandPassDirection <{}>", static_cast(kind)); MRDOCS_UNREACHABLE(); } } @@ -1240,9 +1245,10 @@ visitBlockCommandComment( case CommandTraits::KCI_copybrief: case CommandTraits::KCI_copydetails: case CommandTraits::KCI_copydoc: + report::error("error: inline command {} should be handled elsewhere", cmd->Name); MRDOCS_UNREACHABLE(); - default: + report::error("error: unsupported block command {}", cmd->Name); MRDOCS_UNREACHABLE(); } } From d4de2a570a4aeca987018692410775f07d26874b Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Tue, 28 May 2024 13:35:14 -0300 Subject: [PATCH 03/11] ci: demo comparison artifact --- .github/workflows/ci.yml | 76 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac551de1c..4247298c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -431,9 +431,10 @@ jobs: - name: Upload demo artifacts uses: actions/upload-artifact@v3 with: - name: demos + name: demos${{ contains(fromJSON('["master", "develop"]'), github.ref_name) || format('-{0}', github.ref_name) || '' }} path: ${{ env.demos_path }} - retention-days: 1 + # develop and master are retained for longer so that they can be compared + retention-days: ${{ contains(fromJSON('["master", "develop"]'), github.ref_name) || '30' || '1' }} - name: Update website demos if: ${{ github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) }} @@ -454,6 +455,77 @@ jobs: chmod 755 -R $(pwd)/demos scp -o StrictHostKeyChecking=no -r $(pwd)/demos/* ubuntu@dev-websites.cpp.al:$demo_dir/ + - name: Download previous demos + if: startsWith(github.ref, 'refs/tags/') + id: download-prev-demos + uses: actions/download-artifact@v3 + with: + name: demos-develop + path: demos-previous + + - name: Compare demos + if: startsWith(github.ref, 'refs/tags/') && steps.download-prev-demos.outputs.cache-hit == 'true' + id: compare-demos + run: | + set -x + + # Define URLs and directories + LOCAL_DEMOS_DIR="./demos/" + PREV_DEMOS_DIR="./demos-previous/" + DIFF_DIR="./demos-diff/" + + # Create directories if they don't exist + mkdir -p $PREV_DEMOS_DIR $DIFF_DIR + + # Iterate over the previous files and compare them with the corresponding local files + find $PREV_DEMOS_DIR -type f | while read previous_file; do + # Derive the corresponding local file path + local_file="${LOCAL_DEMOS_DIR}${previous_file#$PREV_DEMOS_DIR}" + diff_output="$DIFF_DIR${previous_file#$PREV_DEMOS_DIR}" + if [[ -f $local_file ]]; then + mkdir -p "$(dirname "$diff_output")" + diff "$previous_file" "$local_file" > "$diff_output" + if [[ ! -s $diff_output ]]; then + rm "$diff_output" + fi + else + echo "LOCAL FILE $local_file DOES NOT EXITS." > "$diff_output" + echo "PREVIOUS CONTENT OF THE FILE WAS:" >> "$diff_output" + cat "$previous_file" >> "$diff_output" + fi + done + + # Iterate over the local files to find new files + find $LOCAL_DEMOS_DIR -type f | while read local_file; do + previous_file="${PREV_DEMOS_DIR}${local_file#$LOCAL_DEMOS_DIR}" + diff_output="$DIFF_DIR${local_file#$LOCAL_DEMOS_DIR}" + if [[ ! -f $previous_file ]]; then + echo "PREVIOUS $previous_file DOES NOT EXIST." > "$diff_output" + echo "IT HAS BEEN INCLUDED IN THIS VERSION." >> "$diff_output" + echo "NEW CONTENT OF THE FILE IS:" >> "$diff_output" + fi + done + + # Check if the diff directory is empty + if [[ -z $(ls -A $DIFF_DIR) ]]; then + echo "No differences found." + # Store this as an output for the next step + echo "diff=false" >> $GITHUB_OUTPUT + else + # Calculate number of files in the diff directory + N_FILES=$(find $DIFF_DIR -type f | wc -l) + echo "Differences found in $N_FILES output files." + echo "diff=true" >> $GITHUB_OUTPUT + fi + + - name: Upload diff artifacts + if: startsWith(github.ref, 'refs/tags/') && steps.download-prev-demos.outputs.cache-hit == 'true' && steps.compare-demos.outputs.diff == 'true' + uses: actions/upload-artifact@v3 + with: + name: demos-diff + path: demos-diff + retention-days: 30 + releases: needs: build defaults: From 170bffc74108052e6ab56e007a6a718973a4fcbc Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Tue, 28 May 2024 14:06:07 -0300 Subject: [PATCH 04/11] fix: atomic shared_ptr checks --- include/mrdocs/Dom/Object.hpp | 4 ++++ src/lib/Dom/Object.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/include/mrdocs/Dom/Object.hpp b/include/mrdocs/Dom/Object.hpp index a94159921..3e4713664 100644 --- a/include/mrdocs/Dom/Object.hpp +++ b/include/mrdocs/Dom/Object.hpp @@ -432,7 +432,11 @@ class MRDOCS_DECL class MRDOCS_DECL LazyObjectImpl : public ObjectImpl { +#ifdef __cpp_lib_atomic_shared_ptr std::atomic> mutable sp_; +#else + std::shared_ptr mutable sp_; +#endif using impl_type = Object::impl_type; diff --git a/src/lib/Dom/Object.cpp b/src/lib/Dom/Object.cpp index 2f373d5cd..c34c0d19d 100644 --- a/src/lib/Dom/Object.cpp +++ b/src/lib/Dom/Object.cpp @@ -217,6 +217,7 @@ ObjectImpl& LazyObjectImpl:: obj() const { +#ifdef __cpp_lib_atomic_shared_ptr auto impl = sp_.load(); if(impl) return *impl; @@ -225,6 +226,9 @@ obj() const expected, construct().impl())) return *sp_.load(); return *expected; +#else + return *sp_; +#endif } std::size_t From 979a9c73396416bfcbacce36a1107ce7160ec891 Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Tue, 28 May 2024 14:06:43 -0300 Subject: [PATCH 05/11] fix: expected does not support class template argument deduction --- src/lib/Lib/ExecutionContext.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/Lib/ExecutionContext.cpp b/src/lib/Lib/ExecutionContext.cpp index c236df598..729e94539 100644 --- a/src/lib/Lib/ExecutionContext.cpp +++ b/src/lib/Lib/ExecutionContext.cpp @@ -166,7 +166,8 @@ results() // Each Bitcode can have multiple Infos for(auto& bitcode : bitcodes) { - Expected infos = readBitcode(bitcode); + Expected>> infos = + readBitcode(bitcode); if (infos.has_value()) { std::move( @@ -179,7 +180,7 @@ results() report::error("Failed to read bitcode: {}", infos.error()); } } - Expected merged = mergeInfos(Infos); + Expected> merged = mergeInfos(Infos); std::unique_ptr I = std::move(merged.value()); MRDOCS_ASSERT(I); MRDOCS_ASSERT(id == I->id); From 13c323e96f0fd169c8d570ef3c516f9e0bd193f9 Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Tue, 28 May 2024 14:07:55 -0300 Subject: [PATCH 06/11] fix: StringRef::equals replaced with operator== StringRef::equals has been deprecated. --- src/lib/Lib/SingleFileDB.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Lib/SingleFileDB.hpp b/src/lib/Lib/SingleFileDB.hpp index 488667d2f..16af01ed5 100644 --- a/src/lib/Lib/SingleFileDB.hpp +++ b/src/lib/Lib/SingleFileDB.hpp @@ -54,7 +54,7 @@ class SingleFileDB getCompileCommands( llvm::StringRef FilePath) const override { - if(! FilePath.equals(cc_.front().Filename)) + if (FilePath != cc_.front().Filename) return {}; return { cc_.front() }; } From f846ffe798603fc02262826c1e0b7322d3bd1cb8 Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Tue, 28 May 2024 16:15:41 -0300 Subject: [PATCH 07/11] fix: no extra ';'s --- src/lib/Gen/adoc/AdocCorpus.cpp | 6 +++--- src/lib/Gen/html/HTMLCorpus.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/Gen/adoc/AdocCorpus.cpp b/src/lib/Gen/adoc/AdocCorpus.cpp index e1c42bc23..e2307ce80 100644 --- a/src/lib/Gen/adoc/AdocCorpus.cpp +++ b/src/lib/Gen/adoc/AdocCorpus.cpp @@ -418,7 +418,7 @@ class DomJavadoc : public dom::LazyObjectImpl doc::visit(I, visitor); if(! s.empty()) list.emplace_back(key, std::move(s)); - }; + } template void @@ -435,7 +435,7 @@ class DomJavadoc : public dom::LazyObjectImpl { list.emplace_back(key, std::move(s)); } - }; + } template void @@ -457,7 +457,7 @@ class DomJavadoc : public dom::LazyObjectImpl return; list.emplace_back(key, dom::newArray< dom::DefaultArrayImpl>(std::move(elements))); - }; + } dom::Object construct() const override diff --git a/src/lib/Gen/html/HTMLCorpus.cpp b/src/lib/Gen/html/HTMLCorpus.cpp index dc4aa18c9..954112752 100644 --- a/src/lib/Gen/html/HTMLCorpus.cpp +++ b/src/lib/Gen/html/HTMLCorpus.cpp @@ -286,7 +286,7 @@ class DomJavadoc : public dom::LazyObjectImpl doc::visit(I, visitor); if(! s.empty()) list.emplace_back(key, std::move(s)); - }; + } template void @@ -303,7 +303,7 @@ class DomJavadoc : public dom::LazyObjectImpl { list.emplace_back(key, std::move(s)); } - }; + } dom::Object construct() const override From d610f6ea5a0617c7dd4e11587d70a1f148a69097 Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Wed, 29 May 2024 12:05:53 -0300 Subject: [PATCH 08/11] fix: version string final line break --- src/tool/ToolMain.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/tool/ToolMain.cpp b/src/tool/ToolMain.cpp index d199c8a39..798d516da 100644 --- a/src/tool/ToolMain.cpp +++ b/src/tool/ToolMain.cpp @@ -35,7 +35,8 @@ print_version(llvm::raw_ostream& os) os << project_name << "\n " << project_description << "\n version: " << project_version - << "\n built with LLVM " << LLVM_VERSION_STRING; + << "\n built with LLVM " << LLVM_VERSION_STRING + << "\n"; } int @@ -60,7 +61,15 @@ mrdocs_main(int argc, char const** argv) toolArgs.reportLevel.getValue())); // Set up addons directory +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +// error: ISO C++ forbids taking address of function ‘::main’ +#endif void* addressOfMain = reinterpret_cast(&main); +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif auto exp = setupAddonsDir( toolArgs.addonsDir,argv[0], addressOfMain); if (!exp) From 730a18c600c9d848baa6d12d2b0a85ffb8a38aba Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Wed, 29 May 2024 12:07:37 -0300 Subject: [PATCH 09/11] docs: source code callouts --- docs/modules/ROOT/pages/install.adoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/modules/ROOT/pages/install.adoc b/docs/modules/ROOT/pages/install.adoc index 9e3e74ce6..2c0825fb0 100644 --- a/docs/modules/ROOT/pages/install.adoc +++ b/docs/modules/ROOT/pages/install.adoc @@ -128,7 +128,7 @@ Windows PowerShell:: -- [source,bash] ---- -Invoke-WebRequest -Uri "https://github.com/svaarala/duktape/releases/download/v2.7.0/duktape-2.7.0.tar.xz" -OutFile "duktape-2.7.0.tar.xz" +Invoke-WebRequest -Uri "https://github.com/svaarala/duktape/releases/download/v2.7.0/duktape-2.7.0.tar.xz" -OutFile "duktape-2.7.0.tar.xz" <.> ---- <.> Downloads the `duktape` source code. @@ -169,9 +169,9 @@ Windows PowerShell:: -- [source,bash] ---- -$content = Get-Content -Path "src\duk_config.h" -$content = $content -replace '#define DUK_F_DLL_BUILD', '#undef DUK_F_DLL_BUILD' -$content | Set-Content -Path "src\duk_config.h" +$content = Get-Content -Path "src\duk_config.h" <.> +$content = $content -replace '#define DUK_F_DLL_BUILD', '#undef DUK_F_DLL_BUILD' <.> +$content | Set-Content -Path "src\duk_config.h" <.> ---- <.> Read the content of `duk_config.h` From 421dc993382ae671156822a54dc0393a088aee13 Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Wed, 29 May 2024 13:28:32 -0300 Subject: [PATCH 10/11] ci: gcc uses -static fix #547 --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4247298c0..a272bae62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -240,9 +240,9 @@ jobs: cmake-version: ${{ matrix.compiler == 'clang' && '3.26' || '>=3.26' }} cxxstd: ${{ matrix.cxxstd }} cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }} - ccflags: ${{ matrix.ccflags }}${{ ( matrix.compiler == 'gcc' && ' -static-libstdc++') || '' }}${{ ( matrix.asan && ' -static-libasan') || '' }}${{ ( matrix.tsan && ' -static-libtsan') || '' }} + ccflags: ${{ matrix.ccflags }}${{ ( matrix.compiler == 'gcc' && ' -static') || '' }}${{ ( matrix.asan && ' -static-libasan') || '' }}${{ ( matrix.tsan && ' -static-libtsan') || '' }} cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }} - cxxflags: ${{ matrix.cxxflags }}${{ ( matrix.compiler == 'gcc' && ' -static-libstdc++') || '' }}${{ ( matrix.asan && ' -static-libasan') || '' }}${{ ( matrix.tsan && ' -static-libtsan') || '' }} + cxxflags: ${{ matrix.cxxflags }}${{ ( matrix.compiler == 'gcc' && ' -static') || '' }}${{ ( matrix.asan && ' -static-libasan') || '' }}${{ ( matrix.tsan && ' -static-libtsan') || '' }} generator: Ninja toolchain: ${{ steps.package-install.outputs.vcpkg_toolchain || steps.package-install.outputs.vcpkg-toolchain }} build-type: ${{ matrix.build-type }} @@ -357,7 +357,9 @@ jobs: name: Demos timeout-minutes: 120 - runs-on: ubuntu-22.04 + # We purposefully use an older version of Ubuntu to + # ensure compatibility with the oldest supported version + runs-on: ubuntu-20.04 container: ubuntu:23.04 permissions: From 76b4f26b96ce8325428fb11d6817f813dbc4eafa Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Wed, 29 May 2024 14:38:45 -0300 Subject: [PATCH 11/11] ci: gcc uses default container --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a272bae62..e565e4db0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: name: ${{ matrix.name }} runs-on: ${{ matrix.runs-on }} - container: ${{ (matrix.compiler == 'gcc' && 'ubuntu:22.04') || matrix.container }} + container: ${{ matrix.container }} env: ${{ matrix.env }} permissions: contents: write @@ -86,7 +86,7 @@ jobs: DEBIAN_FRONTEND: 'noninteractive' TZ: 'Etc/UTC' with: - apt-get: ${{ matrix.install }} git build-essential python3 curl openjdk-11-jdk ninja-build pkg-config libncurses-dev + apt-get: ${{ matrix.install }} git build-essential python3 curl openjdk-11-jdk ninja-build pkg-config libncurses-dev libxml2-utils libxml2-dev cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }} ccflags: ${{ matrix.ccflags }} cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }} @@ -148,6 +148,7 @@ jobs: - name: Install Libxml2 id: libxml2-install + if: matrix.compiler == 'msvc' shell: bash run: | set -x @@ -254,8 +255,8 @@ jobs: -D duktape_ROOT=${{ steps.duktape-install.outputs.duktape-root }} -D Duktape_ROOT=${{ steps.duktape-install.outputs.duktape-root }} -D fmt_ROOT=${{ steps.fmt-install.outputs.fmt-root }} - -D libxml2_ROOT=${{ steps.libxml2-install.outputs.libxml2-root }} - -D LibXml2_ROOT=${{ steps.libxml2-install.outputs.libxml2-root }} + ${{ (steps.libxml2-install.outputs.libxml2-root && format('-D libxml2_ROOT={0}', steps.libxml2-install.outputs.libxml2-root)) || '' }} + ${{ (steps.libxml2-install.outputs.libxml2-root && format('-D LibXml2_ROOT={0}', steps.libxml2-install.outputs.libxml2-root)) || '' }} export-compile-commands: true run-tests: true install: true