From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6E2AC433E4 for ; Mon, 29 Jun 2020 21:14:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7ED2E206A1 for ; Mon, 29 Jun 2020 21:14:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XsstKU4K" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390146AbgF2VOh (ORCPT ); Mon, 29 Jun 2020 17:14:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730085AbgF2S5N (ORCPT ); Mon, 29 Jun 2020 14:57:13 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3BBFC031C40 for ; Mon, 29 Jun 2020 11:57:13 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id z13so17641970wrw.5 for ; Mon, 29 Jun 2020 11:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=uROyZFHfZL1AuaJO9EBSwQ88aC63JQnbHsrD23bCT6I=; b=XsstKU4Ktnxy1+VQpe5mjVAdjmQ/txTBCF2OLXAty0E3EkExlpPUlGffo2Yn0JbbMI fAhkNHGSuPPlSEAD3xu+9yiMFk+itDEWN0SrLx3hE5QAkY2LhLJbYqBzDY6fq5FT9aMG LU2CB5HUglR9dFsOCZEfkYwyiyHlRqqISiaki3ZytkYZ6FM6UvH0cJa44ETRTSisKMdL SFRTyCzkVgvZld0uPEidXbSAbB/l+EiBvQ1fWXk6dYNpSNaIxxsSe+cKQqGR+eLlFotE b57CJN2U8mYXuSDJyAcLjEQyfW9bmGoQlbjxiZ3R9fSt31DGHepXwYF9RRMRNYN/X7dy d8WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=uROyZFHfZL1AuaJO9EBSwQ88aC63JQnbHsrD23bCT6I=; b=mZiYrj6t4j+hi7dCrZlGT26tlyKr6AHVtF2Wj9FetedorqGX7/acU8y3VbkE36uXj8 uFC14SyMgvpzlE6LyAiL6RIPjkrB7CfQSsPllLbRjb/GgY/C7sR7iaFUI6Jrq+EViCvs +2FrXQSaFXABJYZNoRFDv7BMaegQU1u4HAZFwOtlSO6u+EnrEx075B2fdGHrKlTZHTtC iu/EGcJzSD2lryOj7Xspwkcw4yZ9wGGUKdHoLNz7JGodw4m7WzUCFRmttidrGUaH/4TU rDXdbw5gSvRE+sKVX+BwYEDmlmCjXW7ZevESjQAD24Fp0u5RhhV2ZvJ4GCn/zit0H4Ag AgTg== X-Gm-Message-State: AOAM531fzHnzF4GWN4v6vR00YYqyJEwDpHFc2pi009tpv1LsjeLU61yw z+mlgJXX7mTmlSDdymhswNiQsGUQi08= X-Google-Smtp-Source: ABdhPJy0Y0zvnaoeFWvwJw6dYERlxVSk1xwRvg23/LCTrW2wX38EgHFBNgH2H/18SBGr8A+Sla5MbA== X-Received: by 2002:adf:e3c5:: with SMTP id k5mr18467243wrm.121.1593457032308; Mon, 29 Jun 2020 11:57:12 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w2sm888989wrs.77.2020.06.29.11.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 11:57:11 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Han-Wen Nienhuys via GitGitGadget" Date: Mon, 29 Jun 2020 18:56:51 +0000 Subject: [PATCH v19 13/20] Add standalone build infrastructure for reftable Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys The reftable library is integrates with Git, so it become a first class supported storage mechanism, but is sufficiently complex that other projects (e.g. libgit2) may want to consume the same source code. To make this possible, the library also compiles completely standalone, which is demonstrated with the Bazel BUILD/WORKSPACE files that this commit adds. Signed-off-by: Han-Wen Nienhuys --- reftable/BUILD | 203 ++++++++++++++++++++++++++++++++++++++++++++ reftable/README.md | 33 +++++++ reftable/WORKSPACE | 14 +++ reftable/zlib.BUILD | 36 ++++++++ 4 files changed, 286 insertions(+) create mode 100644 reftable/BUILD create mode 100644 reftable/README.md create mode 100644 reftable/WORKSPACE create mode 100644 reftable/zlib.BUILD diff --git a/reftable/BUILD b/reftable/BUILD new file mode 100644 index 0000000000..d3946a717c --- /dev/null +++ b/reftable/BUILD @@ -0,0 +1,203 @@ +# Mirror core-git COPTS so reftable compiles without warning in CGit. +GIT_COPTS = [ + "-DREFTABLE_STANDALONE", + "-Wall", + "-Werror", + "-Wdeclaration-after-statement", + "-Wstrict-prototypes", + "-Wformat-security", + "-Wno-format-zero-length", + "-Wold-style-definition", + "-Woverflow", + "-Wpointer-arith", + "-Wstrict-prototypes", + "-Wunused", + "-Wvla", + "-Wextra", + "-Wmissing-prototypes", + "-Wno-empty-body", + "-Wno-missing-field-initializers", + "-Wno-sign-compare", + "-Werror=strict-aliasing", + "-Wno-unused-parameter", +] + +cc_library( + name = "reftable", + srcs = [ + "basics.c", + "block.c", + "compat.c", + "file.c", + "iter.c", + "merged.c", + "pq.c", + "reader.c", + "record.c", + "refname.c", + "reftable.c", + "strbuf.c", + "stack.c", + "tree.c", + "writer.c", + "zlib-compat.c", + "basics.h", + "block.h", + "compat.h", + "constants.h", + "iter.h", + "merged.h", + "pq.h", + "reader.h", + "refname.h", + "record.h", + "strbuf.h", + "stack.h", + "system.h", + "tree.h", + "writer.h", + ], + hdrs = [ + "reftable.h", + ], + includes = [ + "include", + ], + copts = [ + "-fvisibility=protected", + ] + GIT_COPTS, + deps = ["@zlib"], + visibility = ["//visibility:public"] +) + +cc_library( + name = "testlib", + srcs = [ + "test_framework.c", + "dump.c", + "test_framework.h", + ], + hdrs = [ + "reftable-tests.h", + ], + copts = GIT_COPTS, + deps = [":reftable"], + visibility = ["//visibility:public"] +) + +cc_test( + name = "record_test", + srcs = ["record_test.c"], + deps = [ + ":reftable", + ":testlib", + ], + copts = [ + "-Drecord_test_main=main", + "-fvisibility=protected", + ] + GIT_COPTS, +) + +cc_test( + name = "reftable_test", + srcs = ["reftable_test.c"], + deps = [ + ":reftable", + ":testlib", + ], + copts = [ + "-Dreftable_test_main=main", + "-fvisibility=protected", + ] + GIT_COPTS, +) + +cc_test( + name = "strbuf_test", + srcs = ["strbuf_test.c"], + deps = [ + ":reftable", + ":testlib", + ] , + copts = [ + "-Dstrbuf_test_main=main", + "-fvisibility=protected", + ] + GIT_COPTS, +) + +cc_test( + name = "stack_test", + srcs = ["stack_test.c"], + deps = [ + ":reftable", + ":testlib", + ], + copts = [ + "-Dstack_test_main=main", + "-fvisibility=protected", + ] + GIT_COPTS, +) + +cc_test( + name = "tree_test", + srcs = ["tree_test.c"], + deps = [ + ":reftable", + ":testlib", + ], + copts = [ + "-Dtree_test_main=main", + "-fvisibility=protected", + ] + GIT_COPTS, +) + +cc_test( + name = "block_test", + srcs = ["block_test.c"], + deps = [ + ":reftable", + ":testlib", + ], + copts = [ + "-Dblock_test_main=main", + "-fvisibility=protected", + ] + GIT_COPTS, +) + +cc_test( + name = "refname_test", + srcs = ["refname_test.c"], + deps = [ + ":reftable", + ":testlib", + ], + copts = [ + "-Drefname_test_main=main", + "-fvisibility=protected", + ] + GIT_COPTS, +) + +cc_test( + name = "merged_test", + srcs = ["merged_test.c"], + deps = [ + ":reftable", + ":testlib", + ], + copts = [ + "-Dmerged_test_main=main", + "-fvisibility=protected", + ] + GIT_COPTS, +) + +[sh_test( + name = "%s_valgrind_test" % t, + srcs = [ "valgrind_test.sh" ], + args = [ t ], + data = [ t ]) + for t in ["record_test", + "merged_test", + "refname_test", + "tree_test", + "block_test", + "strbuf_test", + "stack_test"]] diff --git a/reftable/README.md b/reftable/README.md new file mode 100644 index 0000000000..0345015c57 --- /dev/null +++ b/reftable/README.md @@ -0,0 +1,33 @@ +This directory contains an implementation of the reftable library. + +The library is integrated into the git-core project, but can also be built +standalone, by compiling with -DREFTABLE_STANDALONE. The standalone build is +exercised by the accompanying BUILD/WORKSPACE files, and can be run as + + bazel test :all + +It includes a fragment of the zlib library to provide uncompress2(), which is a +recent addition to the API. zlib is licensed as follows: + +``` + (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu +``` diff --git a/reftable/WORKSPACE b/reftable/WORKSPACE new file mode 100644 index 0000000000..9f91d16208 --- /dev/null +++ b/reftable/WORKSPACE @@ -0,0 +1,14 @@ +workspace(name = "reftable") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "zlib", + build_file = "@//:zlib.BUILD", + sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", + strip_prefix = "zlib-1.2.11", + urls = [ + "https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz", + "https://zlib.net/zlib-1.2.11.tar.gz", + ], +) diff --git a/reftable/zlib.BUILD b/reftable/zlib.BUILD new file mode 100644 index 0000000000..edb77fdf8e --- /dev/null +++ b/reftable/zlib.BUILD @@ -0,0 +1,36 @@ +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # BSD/MIT-like license (for zlib) + +cc_library( + name = "zlib", + srcs = [ + "adler32.c", + "compress.c", + "crc32.c", + "crc32.h", + "deflate.c", + "deflate.h", + "gzclose.c", + "gzguts.h", + "gzlib.c", + "gzread.c", + "gzwrite.c", + "infback.c", + "inffast.c", + "inffast.h", + "inffixed.h", + "inflate.c", + "inflate.h", + "inftrees.c", + "inftrees.h", + "trees.c", + "trees.h", + "uncompr.c", + "zconf.h", + "zutil.c", + "zutil.h", + ], + hdrs = ["zlib.h"], + includes = ["."], +) -- gitgitgadget