Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zstd BUILD include attr #1394

Merged
merged 13 commits into from
Jan 30, 2024
Merged

Fix zstd BUILD include attr #1394

merged 13 commits into from
Jan 30, 2024

Conversation

lalten
Copy link
Contributor

@lalten lalten commented Jan 28, 2024

This should fix

 In file included from external/_main~non_module_deps~ros2_rosbag2/rosbag2_compression_zstd/src/rosbag2_compression_zstd/zstd_decompressor.cpp:24:
external/_main~non_module_deps~ros2_rosbag2/rosbag2_compression_zstd/src/rosbag2_compression_zstd/compression_utils.hpp:18:10: fatal error: zstd.h: No such file or directory
   18 | #include <zstd.h>
      |          ^~~~~~~~
compilation terminated.

which I hit in mvukov/rules_ros2#238

I formatted the BUILD.bazel patch with buildifier. That's why if you compare the BUILD with the previous one it's a little more than just that include = ["lib"] line:

diff --git a/BUILD.bazel b/BUILD.bazel
index 27886d8a..7fca1671 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -7,19 +7,25 @@ package(default_visibility = ["//visibility:public"])
 
 filegroup(
     name = "common_sources",
-    srcs = glob(["lib/common/*.c", "lib/common/*.h"]),
+    srcs = glob([
+        "lib/common/*.c",
+        "lib/common/*.h",
+    ]),
 )
 
 filegroup(
     name = "compress_sources",
-    srcs = glob(["lib/compress/*.c", "lib/compress/*.h"]),
+    srcs = glob([
+        "lib/compress/*.c",
+        "lib/compress/*.h",
+    ]),
 )
 
 filegroup(
     name = "decompress_sources",
     srcs = glob([
         "lib/decompress/*.c",
-        "lib/decompress/*.h"
+        "lib/decompress/*.h",
     ]) + select({
         "@platforms//os:windows": [],
         "//conditions:default": glob(["lib/decompress/*.S"]),
@@ -28,7 +34,10 @@ filegroup(
 
 filegroup(
     name = "dictbuilder_sources",
-    srcs = glob(["lib/dictBuilder/*.c", "lib/dictBuilder/*.h"]),
+    srcs = glob([
+        "lib/dictBuilder/*.c",
+        "lib/dictBuilder/*.h",
+    ]),
 )
 
 cc_library(
@@ -44,6 +53,9 @@ cc_library(
         "lib/zstd.h",
         "lib/zstd_errors.h",
     ],
+    includes = ["lib"],
+    linkopts = ["-pthread"],
+    linkstatic = True,
     local_defines = [
         "XXH_NAMESPACE=ZSTD_",
         "ZSTD_MULTITHREAD",
@@ -53,37 +65,31 @@ cc_library(
         "@platforms//os:windows": ["ZSTD_DISABLE_ASM"],
         "//conditions:default": [],
     }),
-    linkopts = [
-        "-pthread",
-    ],
-    linkstatic = True,
 )
 
 cc_library(
     name = "util",
+    srcs = [
+        "programs/platform.h",
+        "programs/util.c",
+    ],
     hdrs = [
-        "programs/util.h",
-        "lib/common/mem.h",
         "lib/common/compiler.h",
-        "lib/common/portability_macros.h",
         "lib/common/debug.h",
+        "lib/common/mem.h",
+        "lib/common/portability_macros.h",
         "lib/common/zstd_deps.h",
-    ],
-    srcs = [
-        "programs/util.c",
-        "programs/platform.h",
+        "programs/util.h",
     ],
 )
 
 cc_library(
     name = "datagen",
-    hdrs = [
-        "programs/datagen.h",
-    ],
     srcs = [
         "programs/datagen.c",
         "programs/platform.h",
     ],
+    hdrs = ["programs/datagen.h"],
     deps = [":util"],
 )
 
@@ -96,20 +102,26 @@ cc_binary(
 
 cc_test(
     name = "fullbench",
-    deps = [":zstd", ":datagen"],
     srcs = [
-        "programs/timefn.c",
-        "programs/timefn.h",
+        "lib/decompress/zstd_decompress_internal.h",
         "programs/benchfn.c",
         "programs/benchfn.h",
         "programs/benchzstd.c",
         "programs/benchzstd.h",
+        "programs/timefn.c",
+        "programs/timefn.h",
         "tests/fullbench.c",
-        "lib/decompress/zstd_decompress_internal.h",
     ],
-    includes = ["programs", "lib", "lib/common"],
     copts = select({
         "@platforms//os:windows": [],
         "//conditions:default": ["-Wno-deprecated-declarations"],
     }),
+    includes = [
+        "lib/common",
+        "programs",
+    ],
+    deps = [
+        ":datagen",
+        ":zstd",
+    ],
 )

modules/zstd/metadata.json Outdated Show resolved Hide resolved
@Wyverald Wyverald merged commit 3704fc1 into bazelbuild:main Jan 30, 2024
11 checks passed
@lalten lalten deleted the fix-zstd-include branch March 28, 2024 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants