From 65038b084059cf934df50fa86dba5b0e765f9d65 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Wed, 21 Sep 2016 16:08:11 -0800 Subject: 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 --- jpeg.BUILD | 160 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 83 insertions(+), 77 deletions(-) (limited to 'jpeg.BUILD') diff --git a/jpeg.BUILD b/jpeg.BUILD index ad9e44363c..92c9ddcacf 100644 --- a/jpeg.BUILD +++ b/jpeg.BUILD @@ -1,83 +1,89 @@ -SOURCES = [ - "jaricom.c", - "jcapimin.c", - "jcapistd.c", - "jcarith.c", - "jccoefct.c", - "jccolor.c", - "jcdctmgr.c", - "jchuff.c", - "jcinit.c", - "jcmainct.c", - "jcmarker.c", - "jcmaster.c", - "jcomapi.c", - "jcparam.c", - "jcprepct.c", - "jcsample.c", - "jctrans.c", - "jdarith.c", - "jdapimin.c", - "jdapistd.c", - "jdatadst.c", - "jdatasrc.c", - "jdcoefct.c", - "jdcolor.c", - "jddctmgr.c", - "jdhuff.c", - "jdinput.c", - "jdmainct.c", - "jdmarker.c", - "jdmaster.c", - "jdmerge.c", - "jdpostct.c", - "jdsample.c", - "jdtrans.c", - "jerror.c", - "jfdctflt.c", - "jfdctfst.c", - "jfdctint.c", - "jidctflt.c", - "jidctfst.c", - "jidctint.c", - "jmemmgr.c", - "jmemnobs.c", - "jquant1.c", - "jquant2.c", - "jutils.c", -] +# Description: +# The Independent JPEG Group's JPEG runtime library. -HEADERS = [ - "cderror.h", - "cdjpeg.h", - "jconfig.h", - "jdct.h", - "jerror.h", - "jinclude.h", - "jmemsys.h", - "jmorecfg.h", - "jpegint.h", - "jpeglib.h", - "jversion.h", - "transupp.h", -] - -prefix_dir = "jpeg-9a" - -genrule( - name = "configure", - srcs = glob( - ["**/*"], - exclude = [prefix_dir + "/jconfig.h"], - ), - outs = [prefix_dir + "/jconfig.h"], - cmd = "pushd external/jpeg_archive/%s; workdir=$$(mktemp -d -t tmp.XXXXXXXXXX); cp -a * $$workdir; pushd $$workdir; ./configure; popd; popd; cp $$workdir/jconfig.h $(@D); rm -rf $$workdir;" % prefix_dir, -) +licenses(["notice"]) # custom notice-style license, see LICENSE cc_library( name = "jpeg", - srcs = [prefix_dir + "/" + source for source in SOURCES], - hdrs = glob(["**/*.h"]) + [":configure"], - includes = [prefix_dir], + srcs = [ + "cderror.h", + "cdjpeg.h", + "jaricom.c", + "jcapimin.c", + "jcapistd.c", + "jcarith.c", + "jccoefct.c", + "jccolor.c", + "jcdctmgr.c", + "jchuff.c", + "jcinit.c", + "jcmainct.c", + "jcmarker.c", + "jcmaster.c", + "jcomapi.c", + "jconfig.h", + "jcparam.c", + "jcprepct.c", + "jcsample.c", + "jctrans.c", + "jdapimin.c", + "jdapistd.c", + "jdarith.c", + "jdatadst.c", + "jdatasrc.c", + "jdcoefct.c", + "jdcolor.c", + "jdct.h", + "jddctmgr.c", + "jdhuff.c", + "jdinput.c", + "jdmainct.c", + "jdmarker.c", + "jdmaster.c", + "jdmerge.c", + "jdpostct.c", + "jdsample.c", + "jdtrans.c", + "jerror.c", + "jfdctflt.c", + "jfdctfst.c", + "jfdctint.c", + "jidctflt.c", + "jidctfst.c", + "jidctint.c", + "jinclude.h", + "jmemmgr.c", + "jmemnobs.c", + "jmemsys.h", + "jmorecfg.h", + "jquant1.c", + "jquant2.c", + "jutils.c", + "jversion.h", + "transupp.h", + ], + hdrs = [ + "jerror.h", + "jpegint.h", + "jpeglib.h", + ], + includes = ["."], visibility = ["//visibility:public"], ) + +genrule( + name = "configure", + outs = ["jconfig.h"], + cmd = "cat <$@\n" + + "#define HAVE_PROTOTYPES 1\n" + + "#define HAVE_UNSIGNED_CHAR 1\n" + + "#define HAVE_UNSIGNED_SHORT 1\n" + + "#define HAVE_STDDEF_H 1\n" + + "#define HAVE_STDLIB_H 1\n" + + "#ifdef WIN32\n" + + "#define INLINE __inline\n" + + "#else\n" + + "#define INLINE __inline__\n" + + "#endif\n" + + "EOF\n", +) -- cgit v1.2.3