Przeglądaj źródła

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/<project>/original`.
- Created a `third_party/<project>/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.
Jon Meow 5 lat temu
rodzic
commit
acd10c01ef

+ 9 - 0
.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

+ 12 - 0
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",
+)

+ 11 - 0
third_party/README.md

@@ -0,0 +1,11 @@
+# Third-party
+
+<!--
+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
+-->
+
+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.

+ 12 - 0
third_party/examples/README.md

@@ -0,0 +1,12 @@
+# Third-party examples
+
+<!--
+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
+-->
+
+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.

+ 1 - 0
third_party/examples/brotli/original

@@ -0,0 +1 @@
+Subproject commit bbe5d72ba37b164c4e8e0d7baeb78a22aa849c38

+ 106 - 0
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"],
+)

+ 5 - 0
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")

+ 1 - 0
third_party/examples/woff2/original

@@ -0,0 +1 @@
+Subproject commit a0d0ed7da27b708c0a4e96ad7a998bddc933c06e