--- /dev/null +++ BUILD.bazel @@ -0,0 +1,63 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") + +cc_library( + # Named to produce "libzopfli.{a,so}" + # avoiding https://github.com/bazelbuild/bazel-central-registry/issues/716 + name = "zopfli", + srcs = glob(["src/zopfli/*.c"], exclude = ["**/*_bin.c"]), + hdrs = glob(["src/zopfli/*.h"]), + linkopts = ["-lm"], + strip_include_prefix = "src/", + visibility = ["//visibility:public"], +) + +cc_binary( + name = "bin", + srcs = ["src/zopfli/zopfli_bin.c"], + # To build zopfli, compile all .c source files under src/zopfli to a single binary + # with C, and link to the standard C math library, e.g.: + # gcc src/zopfli/*.c -O2 -W -Wall -Wextra -Wno-unused-function -ansi -pedantic -lm -o zopfli + copts = select({ + "@bazel_tools//src/conditions:windows": [], + "//conditions:default": [ + "-Wno-unused-function", + ], + }), + deps = [":zopfli"], +) + +cc_library( + name = "lodepng", + srcs = glob( + ["src/zopflipng/lodepng/*.cpp"], + exclude = ["**/*_bin.*"], + ), + hdrs = glob(["src/zopflipng/lodepng/*.h"]), + strip_include_prefix = "src/", +) + +cc_library( + name = "zopflipng_lib", + srcs = glob( + ["src/zopflipng/*.cc"], + exclude = ["**/*_bin.*"], + ), + hdrs = glob(["src/zopflipng/*.h"]), + strip_include_prefix = "src/", + deps = [ + ":lodepng", + ":zopfli", + ], +) + +cc_binary( + name = "zopflipng", + srcs = ["src/zopflipng/zopflipng_bin.cc"], + copts = select({ + "@bazel_tools//src/conditions:windows": [], + "//conditions:default": [ + "-Wno-unused-function", + ], + }), + deps = [":zopflipng_lib"], +)