]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
GHA/linux: build out-of-tree, make autotools `tidy` target support it
authorViktor Szakats <commit@vsz.me>
Tue, 25 Feb 2025 15:49:04 +0000 (16:49 +0100)
committerViktor Szakats <commit@vsz.me>
Wed, 26 Feb 2025 11:35:03 +0000 (12:35 +0100)
To sync with the rest of core workflows.

Also fix the `tidy` (clang-tidy) target in autotools to support
out-of-tree builds:
```
clang-tidy slist_wc.c terminal.c tool_bname.c [...] var.c tool_hugehelp.c tool_ca_embed.c
  -quiet --warnings-as-errors=* -checks=-clang-analyzer-security.insecureAPI.strcpy,-clang-analyzer-optin.performance.Padding,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-valist.Uninitialized --
  -I../../include -I../lib -I../src -I../../lib -I../../src
  -DBUILDING_CURL -DUSE_MANUAL -D_GNU_SOURCE -DHAVE_CONFIG_H
[1/45] Processing file /home/runner/work/curl/curl/bld/src/slist_wc.c.
Error while processing /home/runner/work/curl/curl/bld/src/slist_wc.c.
[2/45] Processing file /home/runner/work/curl/curl/bld/src/terminal.c.
Error while processing /home/runner/work/curl/curl/bld/src/terminal.c.
[3/45] Processing file /home/runner/work/curl/curl/bld/src/tool_bname.c.
Error while processing /home/runner/work/curl/curl/bld/src/tool_bname.c.
[...]
```
Ref: https://github.com/curl/curl/actions/runs/13525337357/job/37794388404?pr=16480#step:36:561

Closes #16480

.github/workflows/linux.yml
lib/Makefile.am
src/Makefile.am

index 5fbde6b4fd683fe0a8130e480c23b7c0a8362b6b..4594bd8a60f259b229b950f098d579a045f85aa9 100644 (file)
@@ -593,37 +593,39 @@ jobs:
             export PKG_CONFIG_PATH="${{ matrix.build.PKG_CONFIG_PATH }}"
           fi
           if [ -n '${{ matrix.build.generate }}' ]; then
-            cmake -B . -G Ninja \
+            cmake -B bld -G Ninja \
               -DCMAKE_INSTALL_PREFIX="$HOME/curl" \
               -DCMAKE_C_COMPILER_TARGET=$(uname -m)-pc-linux-gnu -DBUILD_STATIC_LIBS=ON \
               -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON -DCURL_WERROR=ON \
               ${{ matrix.build.generate }}
           else
+            mkdir bld && cd bld && \
             ${{ matrix.build.configure-prefix }} \
-            ./configure --disable-dependency-tracking --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
+            ../configure --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
+              --disable-dependency-tracking \
               ${{ matrix.build.configure }}
           fi
 
       - name: 'configure log'
         if: ${{ !cancelled() }}
-        run: cat config.log CMakeFiles/CMakeConfigureLog.yaml 2>/dev/null || true
+        run: cat bld/config.log bld/CMakeFiles/CMakeConfigureLog.yaml 2>/dev/null || true
 
       - name: 'curl_config.h'
         run: |
-          echo '::group::raw'; cat lib/curl_config.h || true; echo '::endgroup::'
-          grep -F '#define' lib/curl_config.h | sort || true
+          echo '::group::raw'; cat bld/lib/curl_config.h || true; echo '::endgroup::'
+          grep -F '#define' bld/lib/curl_config.h | sort || true
 
       - name: 'test configs'
         run: |
-          cat tests/config || true
-          cat tests/http/config.ini || true
+          cat bld/tests/config || true
+          cat bld/tests/http/config.ini || true
 
       - name: 'build'
         run: |
           if [ -n '${{ matrix.build.generate }}' ]; then
-            ${{ matrix.build.make-prefix }} cmake --build . --verbose
+            ${{ matrix.build.make-prefix }} cmake --build bld --verbose
           else
-            ${{ matrix.build.make-prefix }} make V=1 ${{ matrix.build.make-custom-target }}
+            ${{ matrix.build.make-prefix }} make -C bld V=1 ${{ matrix.build.make-custom-target }}
           fi
 
       - name: 'single-use function check'
@@ -631,27 +633,27 @@ jobs:
         run: |
           git config --global --add safe.directory "*"
           if [ -n '${{ matrix.build.generate }}' ]; then
-            libcurla=lib/libcurl.a
+            libcurla=bld/lib/libcurl.a
           else
-            libcurla=lib/.libs/libcurl.a
+            libcurla=bld/lib/.libs/libcurl.a
           fi
           ./scripts/singleuse.pl --unit ${libcurla}
 
       - name: 'check curl -V output'
         if: ${{ matrix.build.make-custom-target != 'tidy' }}
-        run: ./src/curl -V
+        run: bld/src/curl -V
 
       - name: 'cmake install'
         if: ${{ matrix.build.generate }}
-        run: cmake --install . --strip
+        run: cmake --install bld --strip
 
       - name: 'build tests'
         if: ${{ matrix.build.install_steps != 'skipall' }}
         run: |
           if [ -n '${{ matrix.build.generate }}' ]; then
-            cmake --build . --verbose --target testdeps
+            cmake --build bld --verbose --target testdeps
           else
-            make V=1 -C tests
+            make -C bld V=1 -C tests
           fi
 
       - name: 'install test prereqs'
@@ -678,9 +680,9 @@ jobs:
           fi
           [ -x "$HOME/venv/bin/activate" ] && source $HOME/venv/bin/activate
           if [ -n '${{ matrix.build.generate }}' ]; then
-            cmake --build . --verbose --target ${{ matrix.build.torture && 'test-torture' || 'test-ci' }}
+            cmake --build bld --verbose --target ${{ matrix.build.torture && 'test-torture' || 'test-ci' }}
           else
-            make V=1 ${{ matrix.build.torture && 'test-torture' || 'test-ci' }}
+            make -C bld V=1 ${{ matrix.build.torture && 'test-torture' || 'test-ci' }}
           fi
 
       - name: 'install pytest prereqs'
@@ -698,16 +700,16 @@ jobs:
         run: |
           [ -x "$HOME/venv/bin/activate" ] && source $HOME/venv/bin/activate
           if [ -n '${{ matrix.build.generate }}' ]; then
-            cmake --build . --verbose --target curl-pytest-ci
+            cmake --build bld --verbose --target curl-pytest-ci
           else
-            make V=1 pytest-ci
+            make -C bld V=1 pytest-ci
           fi
 
       - name: 'build examples'
         if: ${{ matrix.build.make-custom-target != 'tidy' }}
         run: |
           if [ -n '${{ matrix.build.generate }}' ]; then
-            ${{ matrix.build.make-prefix }} cmake --build . --verbose --target curl-examples
+            ${{ matrix.build.make-prefix }} cmake --build bld --verbose --target curl-examples
           else
-            ${{ matrix.build.make-prefix }} make V=1 examples
+            ${{ matrix.build.make-prefix }} make -C bld V=1 examples
           fi
index b77d10bb22b30f8952a8526ce59366e459fea514..3cba38fafb278f1354cfb1566ea64dacf6e774fb 100644 (file)
@@ -162,7 +162,8 @@ endif
 TIDY := clang-tidy
 
 tidy:
-       $(TIDY) $(CSOURCES) $(TIDYFLAGS) $(CURL_CLANG_TIDYFLAGS) -- $(AM_CPPFLAGS) $(CPPFLAGS) -DHAVE_CONFIG_H
+       (_csources=`echo ' $(CSOURCES)' | sed -e 's/ +/ /g' -e 's| | $(srcdir)/|g'`; \
+       $(TIDY) $$_csources $(TIDYFLAGS) $(CURL_CLANG_TIDYFLAGS) -- $(AM_CPPFLAGS) $(CPPFLAGS) -DHAVE_CONFIG_H)
 
 optiontable:
        perl optiontable.pl < $(top_srcdir)/include/curl/curl.h > easyoptions.c
index b3b4fd0535a97ecd89fabad5c68941db75f9f433..f45920b16f4d60c610fda7bcd6a34a62320f04dc 100644 (file)
@@ -206,7 +206,8 @@ endif
 TIDY := clang-tidy
 
 tidy: $(HUGE) $(CA_EMBED_CSOURCE)
-       $(TIDY) $(CURL_CFILES) $(curl_cfiles_gen) $(TIDYFLAGS) $(CURL_CLANG_TIDYFLAGS) -- $(curl_CPPFLAGS) $(CPPFLAGS) $(AM_CPPFLAGS) -DHAVE_CONFIG_H
+       (_curl_cfiles=`echo ' $(CURL_CFILES)' | sed -e 's/ +/ /g' -e 's| | $(srcdir)/|g'`; \
+       $(TIDY) $$_curl_cfiles $(curl_cfiles_gen) $(TIDYFLAGS) $(CURL_CLANG_TIDYFLAGS) -- $(curl_CPPFLAGS) $(CPPFLAGS) $(AM_CPPFLAGS) -DHAVE_CONFIG_H)
 
 listhelp:
        (cd $(top_srcdir)/docs/cmdline-opts && make listhelp)