diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh index 998a5e406..dd2277b0e 100755 --- a/.github/workflows/release_prep.sh +++ b/.github/workflows/release_prep.sh @@ -8,8 +8,8 @@ TAG=${GITHUB_REF_NAME} # The prefix is chosen to match what GitHub generates for source archives PREFIX="rules_foreign_cc-${TAG}" ARCHIVE="rules_foreign_cc-$TAG.tar.gz" -git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE -SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') +git archive --format=tar --prefix="${PREFIX}"/ "${TAG}" | gzip > "$ARCHIVE" +SHA="$(shasum -a 256 "$ARCHIVE" | awk '{print $1}')" cat << EOF ## Using Bzlmod with Bazel 6 @@ -23,7 +23,7 @@ bazel_dep(name = "rules_foreign_cc", version = "${TAG}") ## Using WORKSPACE -Paste this snippet into your `WORKSPACE.bazel` file: +Paste this snippet into your \`WORKSPACE.bazel\` file: \`\`\`starlark load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") @@ -43,4 +43,4 @@ EOF # TODO: add example of how to configure for bzlmod # awk 'f;/--SNIP--/{f=1}' e2e/smoke/WORKSPACE.bazel -echo "\`\`\`" +echo "\`\`\`" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1138888db..6ad0b37d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,23 @@ # See CONTRIBUTING.md for instructions. # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks +exclude: >- + (?x)^( + bazel-.*/.* + |.*\.patch + |.*\.diff + |test/(expected|.*/expected)/.*\.txt + |examples/(?!.*CMakeLists\.txt$).*\.txt + )$ + repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 hooks: + - id: check-merge-conflict + - id: mixed-line-ending + - id: trailing-whitespace + - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/keith/pre-commit-buildifier @@ -21,16 +34,22 @@ repos: rev: v0.6.0 hooks: - id: action-validator - files: >- - (?x)^( - .github/workflows/pages.yaml - )$ - repo: https://github.com/rhysd/actionlint rev: v1.7.4 hooks: - id: actionlint - files: >- + + - repo: https://github.com/mrtazz/checkmake.git + rev: 0.2.2 + hooks: + - id: checkmake + + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.10.0.1 + hooks: + - id: shellcheck + exclude: >- (?x)^( - .github/workflows/pages.yaml + examples/.* )$ diff --git a/docs/index.md b/docs/index.md index c8f671eaf..608c29c9d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -25,7 +25,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "rules_foreign_cc", - # TODO: Get the latest sha256 value from a bazel debug message or the latest + # TODO: Get the latest sha256 value from a bazel debug message or the latest # release on the releases page: https://github.com/bazel-contrib/rules_foreign_cc/releases # # sha256 = "...", diff --git a/docs/tools/workspace_status.sh b/docs/tools/workspace_status.sh index 5ceb3f76e..3b83a143f 100755 --- a/docs/tools/workspace_status.sh +++ b/docs/tools/workspace_status.sh @@ -4,4 +4,4 @@ set -euo pipefail echo STABLE_SCM_SHORT_VERSION "$(git rev-parse --short HEAD)" echo STABLE_SCM_VERSION "$(git rev-parse HEAD)" -echo STABLE_RELEASE "$(cat ../version.bzl | grep VERSION | sed 's/VERSION = "//' | sed 's/"//')" +echo STABLE_RELEASE "$(grep VERSION ../version.bzl | sed 's/VERSION = "//' | sed 's/"//')" diff --git a/examples/cmake_android/hello_lib-example.cpp b/examples/cmake_android/hello_lib-example.cpp index c42ed6ebe..2b1956ece 100644 --- a/examples/cmake_android/hello_lib-example.cpp +++ b/examples/cmake_android/hello_lib-example.cpp @@ -5,4 +5,4 @@ int main(int argc, char* argv[]) { hello_func(); return 0; -} \ No newline at end of file +} diff --git a/examples/cmake_android/res/mipmap-anydpi-v26/ic_launcher.xml b/examples/cmake_android/res/mipmap-anydpi-v26/ic_launcher.xml index eca70cfe5..6b78462d6 100644 --- a/examples/cmake_android/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/examples/cmake_android/res/mipmap-anydpi-v26/ic_launcher.xml @@ -2,4 +2,4 @@ - \ No newline at end of file + diff --git a/examples/cmake_android/res/mipmap-anydpi-v26/ic_launcher_round.xml b/examples/cmake_android/res/mipmap-anydpi-v26/ic_launcher_round.xml index eca70cfe5..6b78462d6 100644 --- a/examples/cmake_android/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/examples/cmake_android/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -2,4 +2,4 @@ - \ No newline at end of file + diff --git a/examples/cmake_android/zlib-example.cpp b/examples/cmake_android/zlib-example.cpp index 19e7a0576..bef3d2ac7 100644 --- a/examples/cmake_android/zlib-example.cpp +++ b/examples/cmake_android/zlib-example.cpp @@ -77,4 +77,4 @@ int main(int argc, char* argv[]) assert(strcmp(a,c)==0); return 0; -} \ No newline at end of file +} diff --git a/examples/cmake_crosstool/.bazelrc b/examples/cmake_crosstool/.bazelrc index fc07d4b36..bc083132c 100644 --- a/examples/cmake_crosstool/.bazelrc +++ b/examples/cmake_crosstool/.bazelrc @@ -1,2 +1,2 @@ build --crosstool_top=//tools/arm_compiler:toolchain --cpu=armeabi-v7a --spawn_strategy=standalone --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs,@foreign_cc_impl -test --crosstool_top=//tools/arm_compiler:toolchain --cpu=armeabi-v7a --spawn_strategy=standalone --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs,@foreign_cc_impl \ No newline at end of file +test --crosstool_top=//tools/arm_compiler:toolchain --cpu=armeabi-v7a --spawn_strategy=standalone --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs,@foreign_cc_impl diff --git a/examples/cmake_crosstool/static/CMakeLists.txt b/examples/cmake_crosstool/static/CMakeLists.txt index 4e1188e9e..d9663a1d4 100644 --- a/examples/cmake_crosstool/static/CMakeLists.txt +++ b/examples/cmake_crosstool/static/CMakeLists.txt @@ -5,4 +5,4 @@ cmake_minimum_required(VERSION 2.8.4) project(hellolib) -add_subdirectory(src) \ No newline at end of file +add_subdirectory(src) diff --git a/examples/cmake_crosstool/static/hello_client.c b/examples/cmake_crosstool/static/hello_client.c index 6ec7b354f..a6bfc670d 100644 --- a/examples/cmake_crosstool/static/hello_client.c +++ b/examples/cmake_crosstool/static/hello_client.c @@ -4,4 +4,4 @@ int main(int argc, char* argv[]) { hello_func(); return 0; -} \ No newline at end of file +} diff --git a/examples/cmake_crosstool/static/hello_client_version123.c b/examples/cmake_crosstool/static/hello_client_version123.c index deb3b7011..bab7781b0 100644 --- a/examples/cmake_crosstool/static/hello_client_version123.c +++ b/examples/cmake_crosstool/static/hello_client_version123.c @@ -4,4 +4,4 @@ int main(int argc, char* argv[]) { hello_func(); return 0; -} \ No newline at end of file +} diff --git a/examples/cmake_crosstool/static/src/CMakeLists.txt b/examples/cmake_crosstool/static/src/CMakeLists.txt index 4b49a7afb..5603e5a02 100644 --- a/examples/cmake_crosstool/static/src/CMakeLists.txt +++ b/examples/cmake_crosstool/static/src/CMakeLists.txt @@ -13,4 +13,4 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) install(TARGETS hello_static ARCHIVE DESTINATION lib) -install(FILES hello.h DESTINATION include/version123) \ No newline at end of file +install(FILES hello.h DESTINATION include/version123) diff --git a/examples/cmake_crosstool/static/src/hello.c b/examples/cmake_crosstool/static/src/hello.c index 740ba68cb..9e6007dc7 100644 --- a/examples/cmake_crosstool/static/src/hello.c +++ b/examples/cmake_crosstool/static/src/hello.c @@ -4,4 +4,4 @@ void hello_func(void) { printf("Hello World!\n"); return; -} \ No newline at end of file +} diff --git a/examples/cmake_crosstool/static/src/hello.h b/examples/cmake_crosstool/static/src/hello.h index 857e1e243..9dfed43d2 100644 --- a/examples/cmake_crosstool/static/src/hello.h +++ b/examples/cmake_crosstool/static/src/hello.h @@ -5,4 +5,4 @@ void hello_func(void); -#endif \ No newline at end of file +#endif diff --git a/examples/cmake_crosstool/static/test_hello.sh b/examples/cmake_crosstool/static/test_hello.sh index 06092d63e..54843a86f 100644 --- a/examples/cmake_crosstool/static/test_hello.sh +++ b/examples/cmake_crosstool/static/test_hello.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -$(rlocation rules_foreign_cc/examples/cmake_hello_world_lib/$1) \ No newline at end of file +$(rlocation rules_foreign_cc/examples/cmake_hello_world_lib/$1) diff --git a/examples/cmake_defines/lib_a/CMakeLists.txt b/examples/cmake_defines/lib_a/CMakeLists.txt index b73ac4ba0..19d9447d4 100644 --- a/examples/cmake_defines/lib_a/CMakeLists.txt +++ b/examples/cmake_defines/lib_a/CMakeLists.txt @@ -1,4 +1,4 @@ project(cmake_defines) add_library(lib_a lib_a.cpp) -install(TARGETS lib_a ARCHIVE DESTINATION lib) \ No newline at end of file +install(TARGETS lib_a ARCHIVE DESTINATION lib) diff --git a/examples/cmake_defines/lib_b/CMakeLists.txt b/examples/cmake_defines/lib_b/CMakeLists.txt index 6bbe4e598..e89daf0c0 100644 --- a/examples/cmake_defines/lib_b/CMakeLists.txt +++ b/examples/cmake_defines/lib_b/CMakeLists.txt @@ -1,4 +1,4 @@ project(cmake_defines) add_library(lib_b lib_b.cpp) -install(TARGETS lib_b ARCHIVE DESTINATION lib) \ No newline at end of file +install(TARGETS lib_b ARCHIVE DESTINATION lib) diff --git a/examples/cmake_hello_world_lib/binary/CMakeLists.txt b/examples/cmake_hello_world_lib/binary/CMakeLists.txt index 8cd1007b7..a9fb372a8 100644 --- a/examples/cmake_hello_world_lib/binary/CMakeLists.txt +++ b/examples/cmake_hello_world_lib/binary/CMakeLists.txt @@ -5,4 +5,4 @@ cmake_minimum_required(VERSION 2.8.4) project(hellolib LANGUAGES C) -add_subdirectory(src) \ No newline at end of file +add_subdirectory(src) diff --git a/examples/cmake_hello_world_lib/binary/src/CMakeLists.txt b/examples/cmake_hello_world_lib/binary/src/CMakeLists.txt index 478b4943f..48805b167 100644 --- a/examples/cmake_hello_world_lib/binary/src/CMakeLists.txt +++ b/examples/cmake_hello_world_lib/binary/src/CMakeLists.txt @@ -34,4 +34,4 @@ install( TARGETS myapp DESTINATION bin ) -install(FILES hello.h DESTINATION include) \ No newline at end of file +install(FILES hello.h DESTINATION include) diff --git a/examples/cmake_hello_world_lib/binary/src/hello.c b/examples/cmake_hello_world_lib/binary/src/hello.c index ccd8aa30c..f5a0f535f 100644 --- a/examples/cmake_hello_world_lib/binary/src/hello.c +++ b/examples/cmake_hello_world_lib/binary/src/hello.c @@ -2,4 +2,4 @@ void hello_func(char* name) { printf("Hello, %s!", name); -} \ No newline at end of file +} diff --git a/examples/cmake_hello_world_lib/binary/src/hello.h b/examples/cmake_hello_world_lib/binary/src/hello.h index ca19b8c2e..6ab7f65ba 100644 --- a/examples/cmake_hello_world_lib/binary/src/hello.h +++ b/examples/cmake_hello_world_lib/binary/src/hello.h @@ -5,4 +5,4 @@ void hello_func(char*); -#endif \ No newline at end of file +#endif diff --git a/examples/cmake_hello_world_lib/binary/src/main.c b/examples/cmake_hello_world_lib/binary/src/main.c index c5e56518c..4c2359857 100644 --- a/examples/cmake_hello_world_lib/binary/src/main.c +++ b/examples/cmake_hello_world_lib/binary/src/main.c @@ -4,4 +4,4 @@ int main(int argc, char* argv[]) { hello_func(argv[1]); return 0; -} \ No newline at end of file +} diff --git a/examples/cmake_hello_world_lib/shared/CMakeLists.txt b/examples/cmake_hello_world_lib/shared/CMakeLists.txt index 909c92903..f34e17d54 100644 --- a/examples/cmake_hello_world_lib/shared/CMakeLists.txt +++ b/examples/cmake_hello_world_lib/shared/CMakeLists.txt @@ -7,4 +7,4 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) project(hellolib LANGUAGES C) -add_subdirectory(src) \ No newline at end of file +add_subdirectory(src) diff --git a/examples/cmake_hello_world_lib/shared/hello_client.c b/examples/cmake_hello_world_lib/shared/hello_client.c index 6ec7b354f..a6bfc670d 100644 --- a/examples/cmake_hello_world_lib/shared/hello_client.c +++ b/examples/cmake_hello_world_lib/shared/hello_client.c @@ -4,4 +4,4 @@ int main(int argc, char* argv[]) { hello_func(); return 0; -} \ No newline at end of file +} diff --git a/examples/cmake_hello_world_lib/shared/src/CMakeLists.txt b/examples/cmake_hello_world_lib/shared/src/CMakeLists.txt index f59e1d5ed..ff631956b 100644 --- a/examples/cmake_hello_world_lib/shared/src/CMakeLists.txt +++ b/examples/cmake_hello_world_lib/shared/src/CMakeLists.txt @@ -21,4 +21,4 @@ install( LIBRARY DESTINATION lib ) -install(FILES hello.h DESTINATION include) \ No newline at end of file +install(FILES hello.h DESTINATION include) diff --git a/examples/cmake_hello_world_lib/shared/src/hello.c b/examples/cmake_hello_world_lib/shared/src/hello.c index 740ba68cb..9e6007dc7 100644 --- a/examples/cmake_hello_world_lib/shared/src/hello.c +++ b/examples/cmake_hello_world_lib/shared/src/hello.c @@ -4,4 +4,4 @@ void hello_func(void) { printf("Hello World!\n"); return; -} \ No newline at end of file +} diff --git a/examples/cmake_hello_world_lib/shared/src/hello.h b/examples/cmake_hello_world_lib/shared/src/hello.h index 857e1e243..9dfed43d2 100644 --- a/examples/cmake_hello_world_lib/shared/src/hello.h +++ b/examples/cmake_hello_world_lib/shared/src/hello.h @@ -5,4 +5,4 @@ void hello_func(void); -#endif \ No newline at end of file +#endif diff --git a/examples/cmake_hello_world_lib/static/CMakeLists.txt b/examples/cmake_hello_world_lib/static/CMakeLists.txt index 4e1188e9e..d9663a1d4 100644 --- a/examples/cmake_hello_world_lib/static/CMakeLists.txt +++ b/examples/cmake_hello_world_lib/static/CMakeLists.txt @@ -5,4 +5,4 @@ cmake_minimum_required(VERSION 2.8.4) project(hellolib) -add_subdirectory(src) \ No newline at end of file +add_subdirectory(src) diff --git a/examples/cmake_hello_world_lib/static/hello_client.c b/examples/cmake_hello_world_lib/static/hello_client.c index 6ec7b354f..a6bfc670d 100644 --- a/examples/cmake_hello_world_lib/static/hello_client.c +++ b/examples/cmake_hello_world_lib/static/hello_client.c @@ -4,4 +4,4 @@ int main(int argc, char* argv[]) { hello_func(); return 0; -} \ No newline at end of file +} diff --git a/examples/cmake_hello_world_lib/static/hello_client_version123.c b/examples/cmake_hello_world_lib/static/hello_client_version123.c index deb3b7011..bab7781b0 100644 --- a/examples/cmake_hello_world_lib/static/hello_client_version123.c +++ b/examples/cmake_hello_world_lib/static/hello_client_version123.c @@ -4,4 +4,4 @@ int main(int argc, char* argv[]) { hello_func(); return 0; -} \ No newline at end of file +} diff --git a/examples/cmake_hello_world_lib/static/src/hello.c b/examples/cmake_hello_world_lib/static/src/hello.c index 740ba68cb..9e6007dc7 100644 --- a/examples/cmake_hello_world_lib/static/src/hello.c +++ b/examples/cmake_hello_world_lib/static/src/hello.c @@ -4,4 +4,4 @@ void hello_func(void) { printf("Hello World!\n"); return; -} \ No newline at end of file +} diff --git a/examples/cmake_synthetic/liba/CMakeLists.txt b/examples/cmake_synthetic/liba/CMakeLists.txt index 83bc4f083..c02dd9966 100644 --- a/examples/cmake_synthetic/liba/CMakeLists.txt +++ b/examples/cmake_synthetic/liba/CMakeLists.txt @@ -2,4 +2,4 @@ cmake_minimum_required(VERSION 2.8.4) project(liba) -add_subdirectory(src) \ No newline at end of file +add_subdirectory(src) diff --git a/examples/cmake_synthetic/liba/src/CMakeLists.txt b/examples/cmake_synthetic/liba/src/CMakeLists.txt index a08ce9e80..e5497d50b 100644 --- a/examples/cmake_synthetic/liba/src/CMakeLists.txt +++ b/examples/cmake_synthetic/liba/src/CMakeLists.txt @@ -28,4 +28,4 @@ target_include_directories(liba_static INTERFACE install(EXPORT liba_targets DESTINATION lib/cmake/liba - FILE liba-config.cmake) \ No newline at end of file + FILE liba-config.cmake) diff --git a/examples/cmake_synthetic/liba/src/liba.cpp b/examples/cmake_synthetic/liba/src/liba.cpp index 71d7fef35..6dfcbdbc9 100644 --- a/examples/cmake_synthetic/liba/src/liba.cpp +++ b/examples/cmake_synthetic/liba/src/liba.cpp @@ -2,4 +2,4 @@ std::string hello_liba(void) { return "Hello from LIBA!"; -} \ No newline at end of file +} diff --git a/examples/cmake_synthetic/liba/src/liba.h b/examples/cmake_synthetic/liba/src/liba.h index 110c79b78..610c2e6fa 100644 --- a/examples/cmake_synthetic/liba/src/liba.h +++ b/examples/cmake_synthetic/liba/src/liba.h @@ -6,4 +6,4 @@ std::string hello_liba(void); -#endif \ No newline at end of file +#endif diff --git a/examples/cmake_synthetic/libb/src/CMakeLists.txt b/examples/cmake_synthetic/libb/src/CMakeLists.txt index 4ec90fb2f..5a9f02c8a 100644 --- a/examples/cmake_synthetic/libb/src/CMakeLists.txt +++ b/examples/cmake_synthetic/libb/src/CMakeLists.txt @@ -21,4 +21,4 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) install(TARGETS libb_static ARCHIVE DESTINATION lib) -install(FILES libb.h DESTINATION include) \ No newline at end of file +install(FILES libb.h DESTINATION include) diff --git a/examples/cmake_synthetic/libb/src/libb.cpp b/examples/cmake_synthetic/libb/src/libb.cpp index f706e166a..e5bc67fd9 100644 --- a/examples/cmake_synthetic/libb/src/libb.cpp +++ b/examples/cmake_synthetic/libb/src/libb.cpp @@ -2,4 +2,4 @@ std::string hello_libb(void) { return hello_liba() + " Hello from LIBB!"; -} \ No newline at end of file +} diff --git a/examples/cmake_synthetic/libb/src/libb.h b/examples/cmake_synthetic/libb/src/libb.h index 524f44e40..50aa4c66e 100644 --- a/examples/cmake_synthetic/libb/src/libb.h +++ b/examples/cmake_synthetic/libb/src/libb.h @@ -7,4 +7,4 @@ std::string hello_libb(void); -#endif \ No newline at end of file +#endif diff --git a/examples/cmake_synthetic/libc/src/CMakeLists.txt b/examples/cmake_synthetic/libc/src/CMakeLists.txt index 16e4db4c6..6a2a96f6c 100644 --- a/examples/cmake_synthetic/libc/src/CMakeLists.txt +++ b/examples/cmake_synthetic/libc/src/CMakeLists.txt @@ -25,4 +25,4 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) install(TARGETS libc_static ARCHIVE DESTINATION lib) -install(FILES libc.h DESTINATION include) \ No newline at end of file +install(FILES libc.h DESTINATION include) diff --git a/examples/cmake_synthetic/libc/src/libc.cpp b/examples/cmake_synthetic/libc/src/libc.cpp index dff41cac9..dde57f9da 100644 --- a/examples/cmake_synthetic/libc/src/libc.cpp +++ b/examples/cmake_synthetic/libc/src/libc.cpp @@ -2,4 +2,4 @@ std::string hello_libc(void) { return hello_liba() + " " + hello_libb() + " Hello from LIBC!"; -} \ No newline at end of file +} diff --git a/examples/cmake_synthetic/libc/src/libc.h b/examples/cmake_synthetic/libc/src/libc.h index 91181b214..4e8468f52 100644 --- a/examples/cmake_synthetic/libc/src/libc.h +++ b/examples/cmake_synthetic/libc/src/libc.h @@ -8,4 +8,4 @@ std::string hello_libc(void); -#endif \ No newline at end of file +#endif diff --git a/examples/cmake_synthetic/test_libb.cpp b/examples/cmake_synthetic/test_libb.cpp index 405dd9528..79edb38f7 100644 --- a/examples/cmake_synthetic/test_libb.cpp +++ b/examples/cmake_synthetic/test_libb.cpp @@ -11,4 +11,4 @@ int main(int argc, char* argv[]) throw std::runtime_error("Wrong result: " + result); } std::cout << "Everything's fine!"; -} \ No newline at end of file +} diff --git a/examples/cmake_with_bazel_transitive/libb/src/CMakeLists.txt b/examples/cmake_with_bazel_transitive/libb/src/CMakeLists.txt index a17852460..5abcba240 100644 --- a/examples/cmake_with_bazel_transitive/libb/src/CMakeLists.txt +++ b/examples/cmake_with_bazel_transitive/libb/src/CMakeLists.txt @@ -21,4 +21,4 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) install(TARGETS libb_static ARCHIVE DESTINATION lib) -install(FILES libb.h DESTINATION include) \ No newline at end of file +install(FILES libb.h DESTINATION include) diff --git a/examples/cmake_with_bazel_transitive/libb/src/libb.cpp b/examples/cmake_with_bazel_transitive/libb/src/libb.cpp index f706e166a..e5bc67fd9 100644 --- a/examples/cmake_with_bazel_transitive/libb/src/libb.cpp +++ b/examples/cmake_with_bazel_transitive/libb/src/libb.cpp @@ -2,4 +2,4 @@ std::string hello_libb(void) { return hello_liba() + " Hello from LIBB!"; -} \ No newline at end of file +} diff --git a/examples/cmake_with_bazel_transitive/libb/src/libb.h b/examples/cmake_with_bazel_transitive/libb/src/libb.h index 524f44e40..50aa4c66e 100644 --- a/examples/cmake_with_bazel_transitive/libb/src/libb.h +++ b/examples/cmake_with_bazel_transitive/libb/src/libb.h @@ -7,4 +7,4 @@ std::string hello_libb(void); -#endif \ No newline at end of file +#endif diff --git a/examples/cmake_with_bazel_transitive/test_libb.cpp b/examples/cmake_with_bazel_transitive/test_libb.cpp index 405dd9528..79edb38f7 100644 --- a/examples/cmake_with_bazel_transitive/test_libb.cpp +++ b/examples/cmake_with_bazel_transitive/test_libb.cpp @@ -11,4 +11,4 @@ int main(int argc, char* argv[]) throw std::runtime_error("Wrong result: " + result); } std::cout << "Everything's fine!"; -} \ No newline at end of file +} diff --git a/examples/cmake_working_dir/source_root/cmake_dir/CMakeLists.txt b/examples/cmake_working_dir/source_root/cmake_dir/CMakeLists.txt index f7b5abccd..def83971b 100644 --- a/examples/cmake_working_dir/source_root/cmake_dir/CMakeLists.txt +++ b/examples/cmake_working_dir/source_root/cmake_dir/CMakeLists.txt @@ -30,4 +30,4 @@ target_include_directories(liba_static INTERFACE install(EXPORT liba_targets DESTINATION lib/cmake/liba - FILE liba-config.cmake) \ No newline at end of file + FILE liba-config.cmake) diff --git a/examples/cmake_working_dir/source_root/src/liba.h b/examples/cmake_working_dir/source_root/src/liba.h index 110c79b78..610c2e6fa 100644 --- a/examples/cmake_working_dir/source_root/src/liba.h +++ b/examples/cmake_working_dir/source_root/src/liba.h @@ -6,4 +6,4 @@ std::string hello_liba(void); -#endif \ No newline at end of file +#endif diff --git a/examples/cmake_working_dir/test_liba.cpp b/examples/cmake_working_dir/test_liba.cpp index a3649b92d..38dd79e6a 100644 --- a/examples/cmake_working_dir/test_liba.cpp +++ b/examples/cmake_working_dir/test_liba.cpp @@ -11,4 +11,4 @@ int main(int argc, char* argv[]) throw std::runtime_error("Wrong result: " + result); } std::cout << "Everything's fine!"; -} \ No newline at end of file +} diff --git a/examples/configure_modify_input_source/simple_lib/Makefile.in b/examples/configure_modify_input_source/simple_lib/Makefile.in index e765171fc..fc566b168 100644 --- a/examples/configure_modify_input_source/simple_lib/Makefile.in +++ b/examples/configure_modify_input_source/simple_lib/Makefile.in @@ -1,11 +1,19 @@ -simple: $(OUTPUT) +all: simple + +.PHONY: all + +simple: $(OUTPUT) + +.PHONY: simple $(OUTPUT): ./src/simple.c $(CC) $(CPPFLAGS) -o $(OBJECT) -c ./src/simple.c -I./include -I. - $(AR) $(LDFLAGS) + $(AR) $(LDFLAGS) install: $(OUTPUT) - mkdir -p simple + mkdir -p simple mkdir -p simple/lib cp $(OUTPUT) ./simple/lib/$(OUTPUT) cp -r ./include ./simple + +.PHONY: clean test diff --git a/examples/configure_modify_input_source/simple_lib/include/simple.h b/examples/configure_modify_input_source/simple_lib/include/simple.h index fb62eebf8..9caccba58 100644 --- a/examples/configure_modify_input_source/simple_lib/include/simple.h +++ b/examples/configure_modify_input_source/simple_lib/include/simple.h @@ -3,4 +3,4 @@ int simpleFun(void); -#endif // SIMPLE_H_ \ No newline at end of file +#endif // SIMPLE_H_ diff --git a/examples/configure_modify_input_source/simple_lib/src/simple.c b/examples/configure_modify_input_source/simple_lib/src/simple.c index 0602ad6fb..dbec161a8 100644 --- a/examples/configure_modify_input_source/simple_lib/src/simple.c +++ b/examples/configure_modify_input_source/simple_lib/src/simple.c @@ -2,4 +2,4 @@ int simpleFun(void) { return 42; -} \ No newline at end of file +} diff --git a/examples/configure_with_bazel_transitive/builtWithBazel.c b/examples/configure_with_bazel_transitive/builtWithBazel.c index a8ceb0309..0f1fc9dbe 100644 --- a/examples/configure_with_bazel_transitive/builtWithBazel.c +++ b/examples/configure_with_bazel_transitive/builtWithBazel.c @@ -2,4 +2,4 @@ char* bazelSays(void) { return "It's me, Bazel!"; -} \ No newline at end of file +} diff --git a/examples/configure_with_bazel_transitive/builtWithBazel.h b/examples/configure_with_bazel_transitive/builtWithBazel.h index bdb0d5fde..831557c2a 100644 --- a/examples/configure_with_bazel_transitive/builtWithBazel.h +++ b/examples/configure_with_bazel_transitive/builtWithBazel.h @@ -3,4 +3,4 @@ char* bazelSays(void); -#endif // BUILT_WITH_BAZEL_H_ \ No newline at end of file +#endif // BUILT_WITH_BAZEL_H_ diff --git a/examples/configure_with_bazel_transitive/simple_lib/Makefile.in b/examples/configure_with_bazel_transitive/simple_lib/Makefile.in index 223c707a9..225caf9a3 100644 --- a/examples/configure_with_bazel_transitive/simple_lib/Makefile.in +++ b/examples/configure_with_bazel_transitive/simple_lib/Makefile.in @@ -1,5 +1,11 @@ +all: simple + +.PHONY: all + simple: $(OUTPUT) +.PHONY: simple + $(OUTPUT): ./src/simple.c $(CC) $(CPPFLAGS) -o $(OBJECT) -c ./src/simple.c -I./include -I. $(AR) $(LDFLAGS) @@ -9,3 +15,5 @@ install: mkdir -p simple/lib cp -p $(OUTPUT) ./simple/lib/$(OUTPUT) cp -rp ./include ./simple + +.PHONY: clean test diff --git a/examples/configure_with_bazel_transitive/simple_lib/include/simple.h b/examples/configure_with_bazel_transitive/simple_lib/include/simple.h index 52a23b799..b2edf4739 100644 --- a/examples/configure_with_bazel_transitive/simple_lib/include/simple.h +++ b/examples/configure_with_bazel_transitive/simple_lib/include/simple.h @@ -3,4 +3,4 @@ void simpleFun(void); -#endif // SIMPLE_H_ \ No newline at end of file +#endif // SIMPLE_H_ diff --git a/examples/configure_with_bazel_transitive/simple_lib/src/simple.c b/examples/configure_with_bazel_transitive/simple_lib/src/simple.c index b3d960aaa..1d69dda14 100644 --- a/examples/configure_with_bazel_transitive/simple_lib/src/simple.c +++ b/examples/configure_with_bazel_transitive/simple_lib/src/simple.c @@ -4,4 +4,4 @@ void simpleFun(void) { printf("simpleFun: %s", bazelSays()); -} \ No newline at end of file +} diff --git a/examples/configure_with_bazel_transitive/testSimple.c b/examples/configure_with_bazel_transitive/testSimple.c index 5856bf9b9..9bc5a28c6 100644 --- a/examples/configure_with_bazel_transitive/testSimple.c +++ b/examples/configure_with_bazel_transitive/testSimple.c @@ -6,4 +6,4 @@ int main(int argc, char **argv) { printf("Call bazelSays() directly: %s\n", bazelSays()); simpleFun(); return 0; -} \ No newline at end of file +} diff --git a/examples/make_simple/code/Makefile b/examples/make_simple/code/Makefile index 1dcced175..2b9592bbd 100644 --- a/examples/make_simple/code/Makefile +++ b/examples/make_simple/code/Makefile @@ -1,6 +1,6 @@ -BUILD_DIR=build-out +BUILD_DIR := build-out -UNAME:=$(shell uname) +UNAME := $(shell uname) ifneq (,$(findstring NT, $(UNAME))) # If Windows @@ -15,8 +15,12 @@ default all $(BUILD_DIR)/lib/liba.a: liba.cpp liba.h $(CXX_WRAPPER) $(CXXFLAGS) -o $(BUILD_DIR)/lib/liba.o -c liba.cpp ar rcs $(BUILD_DIR)/lib/liba.a $(BUILD_DIR)/lib/liba.o +.PHONY: all + install: $(BUILD_DIR)/lib/liba.a mkdir -p $(PREFIX)/lib $(PREFIX)/include $(PREFIX)/share cp -rpv $(BUILD_DIR)/lib $(PREFIX) cp -p liba.h $(PREFIX)/include cp $(README_DIR)/README.md $(PREFIX)/share/ + +.PHONY: clean test diff --git a/examples/ninja_simple/code/liba.cpp b/examples/ninja_simple/code/liba.cpp index 71d7fef35..6dfcbdbc9 100644 --- a/examples/ninja_simple/code/liba.cpp +++ b/examples/ninja_simple/code/liba.cpp @@ -2,4 +2,4 @@ std::string hello_liba(void) { return "Hello from LIBA!"; -} \ No newline at end of file +} diff --git a/examples/ninja_simple/code/liba.h b/examples/ninja_simple/code/liba.h index 110c79b78..610c2e6fa 100644 --- a/examples/ninja_simple/code/liba.h +++ b/examples/ninja_simple/code/liba.h @@ -6,4 +6,4 @@ std::string hello_liba(void); -#endif \ No newline at end of file +#endif diff --git a/examples/third_party/.gitignore b/examples/third_party/.gitignore index 6d8ad95fa..ac51a054d 100644 --- a/examples/third_party/.gitignore +++ b/examples/third_party/.gitignore @@ -1 +1 @@ -bazel-* \ No newline at end of file +bazel-* diff --git a/examples/third_party/cares/c-ares-test.cpp b/examples/third_party/cares/c-ares-test.cpp index 32ad10fd1..791890ade 100644 --- a/examples/third_party/cares/c-ares-test.cpp +++ b/examples/third_party/cares/c-ares-test.cpp @@ -12,4 +12,4 @@ int main(int argc, char* argv[]) throw std::runtime_error("Wrong version: " + std::string(strVersion)); } std::cout << "C-ares version: " << strVersion; -} \ No newline at end of file +} diff --git a/examples/third_party/libpng/libpng_usage_example.cpp b/examples/third_party/libpng/libpng_usage_example.cpp index 7a34dae69..be878696c 100644 --- a/examples/third_party/libpng/libpng_usage_example.cpp +++ b/examples/third_party/libpng/libpng_usage_example.cpp @@ -155,4 +155,4 @@ int main(int argc, char *argv[]) { write_png_file(argv[2]); return 0; -} \ No newline at end of file +} diff --git a/examples/third_party/zlib/test_shared_zlib.sh b/examples/third_party/zlib/test_shared_zlib.sh index c1b52f5bb..6bd09d695 100755 --- a/examples/third_party/zlib/test_shared_zlib.sh +++ b/examples/third_party/zlib/test_shared_zlib.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -$(rlocation rules_foreign_cc/examples/cmake/zlib_shared_usage_example) \ No newline at end of file +$(rlocation rules_foreign_cc/examples/cmake/zlib_shared_usage_example) diff --git a/examples/third_party/zlib/test_zlib.sh b/examples/third_party/zlib/test_zlib.sh index e742dd5de..7324ae2b8 100755 --- a/examples/third_party/zlib/test_zlib.sh +++ b/examples/third_party/zlib/test_zlib.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -$(rlocation rules_foreign_cc/examples/cmake/zlib_usage_example) \ No newline at end of file +$(rlocation rules_foreign_cc/examples/cmake/zlib_usage_example) diff --git a/examples/third_party/zlib/zlib-example.cpp b/examples/third_party/zlib/zlib-example.cpp index 19e7a0576..bef3d2ac7 100644 --- a/examples/third_party/zlib/zlib-example.cpp +++ b/examples/third_party/zlib/zlib-example.cpp @@ -77,4 +77,4 @@ int main(int argc, char* argv[]) assert(strcmp(a,c)==0); return 0; -} \ No newline at end of file +} diff --git a/foreign_cc/private/runnable_binary_wrapper.sh b/foreign_cc/private/runnable_binary_wrapper.sh index 125b92826..2354022f2 100644 --- a/foreign_cc/private/runnable_binary_wrapper.sh +++ b/foreign_cc/private/runnable_binary_wrapper.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# shellcheck disable=SC1090 + # --- begin runfiles.bash initialization v3 --- # Copy-pasted from the Bazel Bash runfiles library v3. set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash @@ -46,7 +48,7 @@ done < <(find . -name "*${SHARED_LIB_SUFFIX}" -print0) SHARED_LIBS_DIRS_ARRAY=() if [ ${#SHARED_LIBS_ARRAY[@]} -ne 0 ]; then for lib in "${SHARED_LIBS_ARRAY[@]}"; do - SHARED_LIBS_DIRS_ARRAY+=($(dirname $(realpath $lib))) + SHARED_LIBS_DIRS_ARRAY+=("$(dirname "$(realpath "$lib")")") done fi @@ -57,7 +59,7 @@ if [ ${#SHARED_LIBS_DIRS_ARRAY[@]} -ne 0 ]; then # Allow unbound variable here, in case LD_LIBRARY_PATH or similar is not already set set +u for dir in "${SHARED_LIBS_DIRS_ARRAY[@]}"; do - export ${LIB_PATH_VAR}="$dir":"${!LIB_PATH_VAR}" + export "${LIB_PATH_VAR}"="${dir}:${!LIB_PATH_VAR}" done set -u fi diff --git a/test/dir1/include/header1.h b/test/dir1/include/header1.h index d79dbd764..d90e15b38 100644 --- a/test/dir1/include/header1.h +++ b/test/dir1/include/header1.h @@ -1 +1 @@ -#include \ No newline at end of file +#include diff --git a/test/dir2/include/header2.h b/test/dir2/include/header2.h index 34a505f53..d5a732287 100644 --- a/test/dir2/include/header2.h +++ b/test/dir2/include/header2.h @@ -1 +1 @@ -#include \ No newline at end of file +#include diff --git a/toolchains/native_tools/native_tools_toolchain.bzl b/toolchains/native_tools/native_tools_toolchain.bzl index 8fe6fc7d6..cc443f8fd 100644 --- a/toolchains/native_tools/native_tools_toolchain.bzl +++ b/toolchains/native_tools/native_tools_toolchain.bzl @@ -20,14 +20,14 @@ ToolInfo = provider( ) def _resolve_tool_path(ctx, path, target, tools): - """ - Resolve the path to a tool. - - Note that ctx.resolve_command is used instead of ctx.expand_location as the - latter cannot be used with py_binary and sh_binary targets as they both produce multiple files in some contexts, meaning - that the plural make variables must be used, e.g. $(execpaths) must be used. See https://github.com/bazelbuild/bazel/issues/11820. - - The usage of ctx.resolve_command facilitates the usage of the singular make variables, e.g $(execpath), with py_binary and sh_binary targets + """ + Resolve the path to a tool. + + Note that ctx.resolve_command is used instead of ctx.expand_location as the + latter cannot be used with py_binary and sh_binary targets as they both produce multiple files in some contexts, meaning + that the plural make variables must be used, e.g. $(execpaths) must be used. See https://github.com/bazelbuild/bazel/issues/11820. + + The usage of ctx.resolve_command facilitates the usage of the singular make variables, e.g $(execpath), with py_binary and sh_binary targets """ _, resolved_bash_command, _ = ctx.resolve_command( command = path,