diff options
author | 2016-09-21 16:08:11 -0800 | |
---|---|---|
committer | 2016-09-21 17:16:04 -0700 | |
commit | 65038b084059cf934df50fa86dba5b0e765f9d65 (patch) | |
tree | c6498985a80d44e81825325057e4746fe4173c05 /gif.BUILD | |
parent | e16dd877f5a784eb31ac44c98267aa8757385fc2 (diff) |
Optimize Bazel external dependencies
This change does the following:
- Always use {,new_}http_archive rather than git_repository
- Make liberal use of strip_prefix
- Clarify licenses() in BUILD files
- On POSIX include headers like a normal C/C++ program
This change accomplishes the following:
- Reduce download size >100MB: The biggest culprit is grpc which has
tens of thousands of commits in its GitHub repository.
- Reduce disk size >200MB: On disk, grpc takes up 250MB when cloned even
though the tarball of the git repo is 3.2MB. By never using git
externals, we save on network.
- Consume less cpu: Cloning git repositories is much slower than
downloading and extracting a tarball.
Change: 133895791
Diffstat (limited to 'gif.BUILD')
-rw-r--r-- | gif.BUILD | 89 |
1 files changed, 34 insertions, 55 deletions
@@ -1,65 +1,44 @@ -SOURCES = [ - "dgif_lib.c", - "egif_lib.c", - "gif_font.c", - "gif_hash.c", - "gifalloc.c", - "openbsd-reallocarray.c", - "gif_err.c", - "quantize.c", -] +# Description: +# A library for decoding and encoding GIF images -HEADERS = [ - "gif_hash.h", - "gif_lib.h", - "gif_lib_private.h", -] +licenses(["notice"]) # MIT -config_setting( - name = "windows", - values = { - "cpu": "x64_windows_msvc", - }, - visibility = ["//visibility:public"], +cc_library( + name = "gif", + srcs = [ + "dgif_lib.c", + "egif_lib.c", + "gif_err.c", + "gif_font.c", + "gif_hash.c", + "gif_hash.h", + "gif_lib_private.h", + "gifalloc.c", + "openbsd-reallocarray.c", + "quantize.c", + ], + hdrs = ["gif_lib.h"], + includes = ["."], + visibility = ["//visibility:public"], + deps = select({ + ":windows": [":windows_polyfill"], + "//conditions:default": [], + }), ) -prefix_dir = "giflib-5.1.4/lib" -prefix_dir_windows = "windows/giflib-5.1.4/lib" - -genrule( - name = "srcs_without_unistd", - srcs = [prefix_dir + "/" + source for source in SOURCES], - outs = [prefix_dir_windows + "/" + source for source in SOURCES], - cmd = "for f in $(SRCS); do " + - " sed 's/#include <unistd.h>//g' $$f > $(@D)/%s/$$(basename $$f);" % prefix_dir_windows + - "done", +cc_library( + name = "windows_polyfill", + hdrs = ["windows/unistd.h"], + includes = ["windows"], ) genrule( - name = "hdrs_without_unistd", - srcs = [prefix_dir + "/" + hdrs for hdrs in HEADERS], - outs = [prefix_dir_windows + "/" + hdrs for hdrs in HEADERS], - cmd = "for f in $(SRCS); do " + - " sed 's/#include <unistd.h>//g' $$f > $(@D)/%s/$$(basename $$f);" % prefix_dir_windows + - "done", + name = "windows_unistd_h", + outs = ["windows/unistd.h"], + cmd = "touch $@", ) -cc_library( - name = "gif", - srcs = select({ - "//conditions:default" : [prefix_dir + "/" + source for source in SOURCES], - ":windows" : [":srcs_without_unistd"], - }), - hdrs = select({ - "//conditions:default" : [prefix_dir + "/" + hdrs for hdrs in HEADERS], - ":windows" : [":hdrs_without_unistd"], - }), - includes = select({ - "//conditions:default" : [prefix_dir], - ":windows" : [prefix_dir_windows], - }), - defines = [ - "HAVE_CONFIG_H", - ], - visibility = ["//visibility:public"], +config_setting( + name = "windows", + values = {"cpu": "x64_windows_msvc"}, ) |