From acd10c01ef66cb45a6000ed57e02f469c776cc30 Mon Sep 17 00:00:00 2001 From: Jon Meow <46229924+jonmeow@users.noreply.github.com> Date: Mon, 19 Apr 2021 16:49:09 -0700 Subject: [PATCH] Add submodule entries for brotli and woff2 (#453) This is to support converting the code to Carbon. My theory with the setup is: - Have the code available to build in C++ under `third_party//original`. - Created a `third_party//carbon` for the converted version. Having the existing code building should, I think, make it easier to run analysis on said code. Using a submodule means we should be aiming to keep it pristine, for easy comparison / updates. --- .gitmodules | 9 ++ WORKSPACE | 12 ++ third_party/README.md | 11 ++ third_party/examples/README.md | 12 ++ third_party/examples/brotli/original | 1 + third_party/examples/woff2/BUILD.original | 106 ++++++++++++++++++ third_party/examples/woff2/WORKSPACE.original | 5 + third_party/examples/woff2/original | 1 + 8 files changed, 157 insertions(+) create mode 100644 third_party/README.md create mode 100644 third_party/examples/README.md create mode 160000 third_party/examples/brotli/original create mode 100644 third_party/examples/woff2/BUILD.original create mode 100644 third_party/examples/woff2/WORKSPACE.original create mode 160000 third_party/examples/woff2/original diff --git a/.gitmodules b/.gitmodules index 1df2491d7f50..e9a0c92c8de5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,3 +9,12 @@ [submodule "third_party/llvm-project"] path = third_party/llvm-project url = https://github.com/llvm/llvm-project.git +[submodule "third_party/examples/brotli/original"] + path = third_party/examples/brotli/original + url = https://github.com/google/brotli + shallow = true +[submodule "third_party/examples/woff2/original"] + path = third_party/examples/woff2/original + url = https://github.com/google/woff2 + shallow = true + fetchRecurseSubmodules = false diff --git a/WORKSPACE b/WORKSPACE index a5842c28656c..f36225a883bb 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -110,3 +110,15 @@ load("@rules_bison//bison:bison.bzl", "bison_register_toolchains") # When building Bison, disable all compiler warnings as we can't realistically # fix them anyways. bison_register_toolchains(extra_copts = ["-w"]) + +local_repository( + name = "brotli", + path = "third_party/examples/brotli/original", +) + +new_local_repository( + name = "woff2", + build_file = "third_party/examples/woff2/BUILD.original", + path = "third_party/examples/woff2/original", + workspace_file = "third_party/examples/woff2/WORKSPACE.original", +) diff --git a/third_party/README.md b/third_party/README.md new file mode 100644 index 000000000000..decf2f002c94 --- /dev/null +++ b/third_party/README.md @@ -0,0 +1,11 @@ +# Third-party + + + +This directory contains code from third-party projects used by Carbon. Code +under this directory has some "upstream" that is not Carbon itself. In some +cases, they may be under their own open source license. diff --git a/third_party/examples/README.md b/third_party/examples/README.md new file mode 100644 index 000000000000..8d3f5140bffe --- /dev/null +++ b/third_party/examples/README.md @@ -0,0 +1,12 @@ +# Third-party examples + + + +This directory contains third-party examples of C++ libraries and how they might +be ported to Carbon. The goal is to illustrate both how Carbon works using +real-world code as well as relevant and expected steps when migrating from C++ +to Carbon. diff --git a/third_party/examples/brotli/original b/third_party/examples/brotli/original new file mode 160000 index 000000000000..bbe5d72ba37b --- /dev/null +++ b/third_party/examples/brotli/original @@ -0,0 +1 @@ +Subproject commit bbe5d72ba37b164c4e8e0d7baeb78a22aa849c38 diff --git a/third_party/examples/woff2/BUILD.original b/third_party/examples/woff2/BUILD.original new file mode 100644 index 000000000000..a6da131467c4 --- /dev/null +++ b/third_party/examples/woff2/BUILD.original @@ -0,0 +1,106 @@ +# Part of the Carbon Language project, under the Apache License v2.0 with LLVM +# Exceptions. See /LICENSE for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Rules are adapted from CMakeLists.txt. + +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") + +package( + default_visibility = ["//visibility:public"], +) + +# Common part used by decoder and encoder +cc_library( + name = "woff2common", + srcs = [ + "src/table_tags.cc", + "src/variable_length.cc", + "src/woff2_common.cc", + ], + hdrs = [ + "src/buffer.h", + "src/file.h", + "src/port.h", + "src/round.h", + "src/store_bytes.h", + "src/table_tags.h", + "src/variable_length.h", + "src/woff2_common.h", + ], + strip_include_prefix = "src/", +) + +# WOFF2 Decoder +cc_library( + name = "woff2dec", + srcs = [ + "src/woff2_dec.cc", + "src/woff2_out.cc", + ], + hdrs = [ + "include/woff2/decode.h", + "include/woff2/output.h", + ], + copts = [ + "-Wno-unused-variable", + "-Wno-unused-const-variable", + ], + strip_include_prefix = "include/", + deps = [ + ":woff2common", + "@brotli//:brotlidec", + ], +) + +cc_binary( + name = "woff2_decompress", + srcs = ["src/woff2_decompress.cc"], + deps = [":woff2dec"], +) + +# WOFF2 Encoder +cc_library( + name = "woff2enc", + srcs = [ + "src/font.cc", + "src/font.h", + "src/glyph.cc", + "src/glyph.h", + "src/normalize.cc", + "src/normalize.h", + "src/transform.cc", + "src/transform.h", + "src/woff2_enc.cc", + ], + hdrs = [ + "include/woff2/encode.h", + ], + copts = [ + "-Wno-unused-variable", + "-Wno-unused-const-variable", + "-Wno-sign-compare", + ], + strip_include_prefix = "include/", + deps = [ + ":woff2common", + "@brotli//:brotlienc", + ], +) + +cc_binary( + name = "woff2_compress", + srcs = ["src/woff2_compress.cc"], + deps = [":woff2enc"], +) + +# WOFF2 info +cc_binary( + name = "woff2_info", + srcs = [ + "src/font.h", + "src/woff2_info.cc", + ], + copts = ["-Wno-sign-compare"], + deps = [":woff2common"], +) diff --git a/third_party/examples/woff2/WORKSPACE.original b/third_party/examples/woff2/WORKSPACE.original new file mode 100644 index 000000000000..d2fc05bde52f --- /dev/null +++ b/third_party/examples/woff2/WORKSPACE.original @@ -0,0 +1,5 @@ +# Part of the Carbon Language project, under the Apache License v2.0 with LLVM +# Exceptions. See /LICENSE for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +workspace(name = "woff2") diff --git a/third_party/examples/woff2/original b/third_party/examples/woff2/original new file mode 160000 index 000000000000..a0d0ed7da27b --- /dev/null +++ b/third_party/examples/woff2/original @@ -0,0 +1 @@ +Subproject commit a0d0ed7da27b708c0a4e96ad7a998bddc933c06e