aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-01-02 22:19:48 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-01-02 22:27:38 -0800
commit46d2c286045f4d2616d348cbaaea7fd52fadfe8b (patch)
treef8c1b4cd1ea1f17e7a80b6f969555ee3b0b65837 /third_party
parent143556267343e8f3f352b0ddba5272fc30b80078 (diff)
Merge changes from github.
Change: 143412147
Diffstat (limited to 'third_party')
-rw-r--r--third_party/common.bzl43
-rw-r--r--third_party/jpeg/BUILD1
-rw-r--r--third_party/jpeg/jpeg.BUILD142
-rw-r--r--third_party/llvm/llvm.BUILD21
-rw-r--r--third_party/llvm/llvm.bzl42
5 files changed, 162 insertions, 87 deletions
diff --git a/third_party/common.bzl b/third_party/common.bzl
new file mode 100644
index 0000000000..db981a5e31
--- /dev/null
+++ b/third_party/common.bzl
@@ -0,0 +1,43 @@
+# Rule for simple expansion of template files. This performs a simple
+# search over the template file for the keys in substitutions,
+# and replaces them with the corresponding values.
+#
+# Typical usage:
+# load("/tools/build_rules/template_rule", "expand_header_template")
+# template_rule(
+# name = "ExpandMyTemplate",
+# src = "my.template",
+# out = "my.txt",
+# substitutions = {
+# "$VAR1": "foo",
+# "$VAR2": "bar",
+# }
+# )
+#
+# Args:
+# name: The name of the rule.
+# template: The template file to expand
+# out: The destination of the expanded file
+# substitutions: A dictionary mapping strings to their substitutions
+
+def template_rule_impl(ctx):
+ ctx.template_action(
+ template = ctx.file.src,
+ output = ctx.outputs.out,
+ substitutions = ctx.attr.substitutions,
+ )
+
+template_rule = rule(
+ attrs = {
+ "src": attr.label(
+ mandatory = True,
+ allow_files = True,
+ single_file = True,
+ ),
+ "substitutions": attr.string_dict(mandatory = True),
+ "out": attr.output(mandatory = True),
+ },
+ # output_to_genfiles is required for header files.
+ output_to_genfiles = True,
+ implementation = template_rule_impl,
+)
diff --git a/third_party/jpeg/BUILD b/third_party/jpeg/BUILD
new file mode 100644
index 0000000000..5b01f6e3e4
--- /dev/null
+++ b/third_party/jpeg/BUILD
@@ -0,0 +1 @@
+licenses(["notice"])
diff --git a/third_party/jpeg/jpeg.BUILD b/third_party/jpeg/jpeg.BUILD
index cbc1e86e51..37401b41d0 100644
--- a/third_party/jpeg/jpeg.BUILD
+++ b/third_party/jpeg/jpeg.BUILD
@@ -5,6 +5,8 @@ licenses(["notice"]) # custom notice-style license, see LICENSE.md
exports_files(["LICENSE.md"])
+load("@//third_party:common.bzl", "template_rule")
+
libjpegturbo_nocopts = "-[W]error"
libjpegturbo_copts = select({
@@ -274,50 +276,118 @@ cc_library(
nocopts = libjpegturbo_nocopts,
)
+template_rule(
+ name = "jconfig_win",
+ src = "win/jconfig.h.in",
+ out = "jconfig_win.h",
+ substitutions = {
+ "@JPEG_LIB_VERSION@": "62",
+ "@VERSION@": "1.5.1",
+ "@LIBJPEG_TURBO_VERSION_NUMBER@": "1005001",
+ "cmakedefine": "define",
+ "@BITS_IN_JSAMPLE@": "8",
+ },
+)
+
+template_rule(
+ name = "jconfigint_win",
+ src = "win/jconfigint.h.in",
+ out = "jconfigint_win.h",
+ substitutions = {
+ "@VERSION@": "1.5.1",
+ "@BUILD@": "20161115",
+ "@CMAKE_PROJECT_NAME@": "libjpeg-turbo",
+ },
+)
+
+JCONFIG_NOWIN_COMMON_SUBSTITUTIONS = {
+ "LIBJPEG_TURBO_VERSION 0": "LIBJPEG_TURBO_VERSION 1.5.1",
+ "LIBJPEG_TURBO_VERSION_NUMBER 0": "LIBJPEG_TURBO_VERSION_NUMBER 1005001",
+ "#undef C_ARITH_CODING_SUPPORTED": "#define C_ARITH_CODING_SUPPORTED 1",
+ "#undef D_ARITH_CODING_SUPPORTED": "#define D_ARITH_CODING_SUPPORTED 1",
+ "#undef HAVE_LOCALE_H": "#define HAVE_LOCALE_H 1",
+ "#undef HAVE_STDDEF_H": "#define HAVE_STDDEF_H 1",
+ "#undef HAVE_STDLIB_H": "#define HAVE_STDLIB_H 1",
+ "#undef HAVE_UNSIGNED_CHAR": "#define HAVE_UNSIGNED_CHAR 1",
+ "#undef HAVE_UNSIGNED_SHORT": "#define HAVE_UNSIGNED_SHORT 1",
+ "#undef INCOMPLETE_TYPES_BROKEN": "",
+ "#undef MEM_SRCDST_SUPPORTED": "#define MEM_SRCDST_SUPPORTED 1",
+ "#undef NEED_BSD_STRINGS": "",
+ "#undef NEED_SYS_TYPES_H": "#define NEED_SYS_TYPES_H 1",
+ "#undef __CHAR_UNSIGNED__": "",
+ "#undef const": "",
+ "#undef size_t": "",
+ "#undef RIGHT_SHIFT_IS_UNSIGNED": "",
+}
+
+JCONFIG_NOWIN_SIMD_SUBSTITUTIONS = JCONFIG_NOWIN_COMMON_SUBSTITUTIONS + {
+ "#undef WITH_SIMD": "#define WITH_SIMD 1",
+}
+
+JCONFIG_NOWIN_NOSIMD_SUBSTITUTIONS = JCONFIG_NOWIN_COMMON_SUBSTITUTIONS + {
+ "#undef WITH_SIMD": "",
+}
+
+template_rule(
+ name = "jconfig_nowin_nosimd",
+ src = "jconfig.h.in",
+ out = "jconfig_nowin_nosimd.h",
+ substitutions = JCONFIG_NOWIN_NOSIMD_SUBSTITUTIONS,
+)
+
+template_rule(
+ name = "jconfig_nowin_simd",
+ src = "jconfig.h.in",
+ out = "jconfig_nowin_simd.h",
+ substitutions = JCONFIG_NOWIN_SIMD_SUBSTITUTIONS,
+)
+
+template_rule(
+ name = "jconfigint_nowin",
+ src = "jconfigint.h.in",
+ out = "jconfigint_nowin.h",
+ substitutions = {
+ "#undef BUILD": "#define BUILD \"20161115\"",
+ "#undef inline": "",
+ "#undef INLINE": "#define INLINE inline __attribute__((always_inline))",
+ "#undef PACKAGE_NAME": "#define PACKAGE_NAME \"libjpeg-turbo\"",
+ "#undef VERSION": "#define VERSION \"1.5.1\"",
+ "#undef SIZEOF_SIZE_T": "#if (__WORDSIZE==64 && !defined(__native_client__))\n" +
+ "#define SIZEOF_SIZE_T 8\n" +
+ "#else\n" +
+ "#define SIZEOF_SIZE_T 4\n" +
+ "#endif\n",
+ },
+)
+
genrule(
name = "configure",
+ srcs = [
+ "jconfig_win.h",
+ "jconfig_nowin_nosimd.h",
+ "jconfig_nowin_simd.h",
+ ],
outs = ["jconfig.h"],
- cmd = "cat <<'EOF' >$@\n" +
- "#define JPEG_LIB_VERSION 62\n" +
- "#define LIBJPEG_TURBO_VERSION 1.5.1\n" +
- "#define LIBJPEG_TURBO_VERSION_NUMBER 1005001\n" +
- "#define C_ARITH_CODING_SUPPORTED 1\n" +
- "#define D_ARITH_CODING_SUPPORTED 1\n" +
- "#define BITS_IN_JSAMPLE 8\n" +
- "#define HAVE_LOCALE_H 1\n" +
- "#define HAVE_STDDEF_H 1\n" +
- "#define HAVE_STDLIB_H 1\n" +
- "#define HAVE_UNSIGNED_CHAR 1\n" +
- "#define HAVE_UNSIGNED_SHORT 1\n" +
- "#define MEM_SRCDST_SUPPORTED 1\n" +
- "#define NEED_SYS_TYPES_H 1\n" +
- select({
- ":k8": "#define WITH_SIMD 1\n",
- ":armeabi-v7a": "#define WITH_SIMD 1\n",
- ":arm64-v8a": "#define WITH_SIMD 1\n",
- "//conditions:default": "",
- }) +
- "EOF",
+ cmd = select({
+ ":windows": "cp $(location jconfig_win.h) $@",
+ ":k8": "cp $(location jconfig_nowin_simd.h) $@",
+ ":armeabi-v7a": "cp $(location jconfig_nowin_simd.h) $@",
+ ":arm64-v8a": "cp $(location jconfig_nowin_simd.h) $@",
+ "//conditions:default": "cp $(location jconfig_nowin_nosimd.h) $@",
+ }),
)
genrule(
name = "configure_internal",
+ srcs = [
+ "jconfigint_win.h",
+ "jconfigint_nowin.h",
+ ],
outs = ["jconfigint.h"],
- cmd = "cat <<'EOF' >$@\n" +
- "#define BUILD \"20161115\"\n" +
- "#ifdef _MSC_VER /* Windows */\n" +
- "#define INLINE __inline\n" +
- "#else\n" +
- "#define INLINE inline __attribute__((always_inline))\n" +
- "#endif\n" +
- "#define PACKAGE_NAME \"libjpeg-turbo\"\n" +
- "#define VERSION \"1.5.1\"\n" +
- "#if (__WORDSIZE==64 && !defined(__native_client__)) || defined(_WIN64)\n" +
- "#define SIZEOF_SIZE_T 8\n" +
- "#else\n" +
- "#define SIZEOF_SIZE_T 4\n" +
- "#endif\n" +
- "EOF",
+ cmd = select({
+ ":windows": "cp $(location jconfigint_win.h) $@",
+ "//conditions:default": "cp $(location jconfigint_nowin.h) $@",
+ }),
)
# jiminy cricket the way this file is generated is completely outrageous
diff --git a/third_party/llvm/llvm.BUILD b/third_party/llvm/llvm.BUILD
index 711ae38c3a..c6ed697013 100644
--- a/third_party/llvm/llvm.BUILD
+++ b/third_party/llvm/llvm.BUILD
@@ -10,10 +10,13 @@ load(
"@//third_party/llvm:llvm.bzl",
"gentbl",
"expand_cmake_vars",
- "expand_header_template",
"llvm_target_cmake_vars",
"cmake_var_string",
)
+load(
+ "@//third_party:common.bzl",
+ "template_rule",
+)
package(default_visibility = ["@//tensorflow/compiler/xla:internal"])
@@ -176,48 +179,48 @@ expand_cmake_vars(
)
# Performs macro expansions on .def.in files
-expand_header_template(
+template_rule(
name = "targets_def_gen",
+ src = "include/llvm/Config/Targets.def.in",
out = "include/llvm/Config/Targets.def",
substitutions = {
"@LLVM_ENUM_TARGETS@": "\n".join(
["LLVM_TARGET({})".format(t) for t in llvm_targets],
),
},
- template = "include/llvm/Config/Targets.def.in",
)
-expand_header_template(
+template_rule(
name = "asm_parsers_def_gen",
+ src = "include/llvm/Config/AsmParsers.def.in",
out = "include/llvm/Config/AsmParsers.def",
substitutions = {
"@LLVM_ENUM_ASM_PARSERS@": "\n".join(
["LLVM_ASM_PARSER({})".format(t) for t in llvm_target_asm_parsers],
),
},
- template = "include/llvm/Config/AsmParsers.def.in",
)
-expand_header_template(
+template_rule(
name = "asm_printers_def_gen",
+ src = "include/llvm/Config/AsmPrinters.def.in",
out = "include/llvm/Config/AsmPrinters.def",
substitutions = {
"@LLVM_ENUM_ASM_PRINTERS@": "\n".join(
["LLVM_ASM_PRINTER({})".format(t) for t in llvm_target_asm_printers],
),
},
- template = "include/llvm/Config/AsmPrinters.def.in",
)
-expand_header_template(
+template_rule(
name = "disassemblers_def_gen",
+ src = "include/llvm/Config/Disassemblers.def.in",
out = "include/llvm/Config/Disassemblers.def",
substitutions = {
"@LLVM_ENUM_DISASSEMBLERS@": "\n".join(
["LLVM_DISASSEMBLER({})".format(t) for t in llvm_target_disassemblers],
),
},
- template = "include/llvm/Config/Disassemblers.def.in",
)
# A common library that all LLVM targets depend on.
diff --git a/third_party/llvm/llvm.bzl b/third_party/llvm/llvm.bzl
index 1d6bf1c706..4a0814fb7f 100644
--- a/third_party/llvm/llvm.bzl
+++ b/third_party/llvm/llvm.bzl
@@ -46,48 +46,6 @@ def gentbl(name, tblgen, td_file, td_srcs, tbl_outs, library = True, **kwargs):
native.cc_library(name=name, textual_hdrs=[f for (_, f) in tbl_outs],
includes=includes, **kwargs)
-
-# Rule for simple expansion of template files. This performs a simple
-# search over the template file for the keys in substitutions,
-# and replaces them with the corresponding values.
-#
-# Typical usage:
-# load("/tools/build_rules/expand_header_template", "expand_header_template")
-# expand_header_template(
-# name = "ExpandMyTemplate",
-# template = "my.template",
-# out = "my.txt",
-# substitutions = {
-# "$VAR1": "foo",
-# "$VAR2": "bar",
-# }
-# )
-#
-# Args:
-# name: The name of the rule.
-# template: The template file to expand
-# out: The destination of the expanded file
-# substitutions: A dictionary mapping strings to their substitutions
-
-def expand_header_template_impl(ctx):
- ctx.template_action(
- template = ctx.file.template,
- output = ctx.outputs.out,
- substitutions = ctx.attr.substitutions,
- )
-
-expand_header_template = rule(
- implementation = expand_header_template_impl,
- attrs = {
- "template": attr.label(mandatory=True, allow_files=True, single_file=True),
- "substitutions": attr.string_dict(mandatory=True),
- "out": attr.output(mandatory=True),
- },
- # output_to_genfiles is required for header files.
- output_to_genfiles = True,
-)
-
-
def llvm_target_cmake_vars(native_arch, target_triple):
return {
"LLVM_HOST_TRIPLE": target_triple,