4
0
Fork 2
mirror of https://gerrit.hackerspace.pl/hscloud synced 2025-01-20 15:33:54 +00:00

third_party: replace jq with gojq

Building jq portably is annoying, and the way we were doing it (which we
iirc stole from some google project?) sucked. Let's use a Go jq clone
instead.

This is an alternative for 1535. jq is currently used only in one
script, which could really be replaced by a Go program, but let's keep
it simple for now.

Change-Id: Ie25dffadd545df143490f510e9b75a74adf81492
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1540
Reviewed-by: palid <palid@hackerspace.pl>
This commit is contained in:
q3k 2023-07-24 14:13:16 +00:00 committed by q3k
parent 03c2d996a0
commit 8100a2de97
7 changed files with 24 additions and 112 deletions

View file

@ -292,26 +292,6 @@ load("@io_bazel_rules_docker//go:image.bzl", go_image_repositories = "repositori
go_image_repositories()
# oniguruma, with build from //third_party/oniguruma
http_archive(
name = "com_github_kkos_oniguruma",
build_file = "@hscloud//third_party/oniguruma:BUILD.external",
sha256 = "d33c849d1672af227944878cefe0a8fcf26fc62bedba32aa517f2f63c314a99e",
strip_prefix = "onig-6.9.5",
urls = ["https://github.com/kkos/oniguruma/releases/download/v6.9.5_rev1/onig-6.9.5_rev1.tar.gz"],
)
# jq, with build from //third_party/jq
http_archive(
name = "com_github_stedolan_jq",
build_file = "@hscloud//third_party/jq:BUILD.external",
sha256 = "5de8c8e29aaa3fb9cc6b47bb27299f271354ebb72514e3accadc7d38b5bbaa72",
strip_prefix = "jq-1.6",
urls = ["https://github.com/stedolan/jq/releases/download/jq-1.6/jq-1.6.tar.gz"],
)
# //hswaw/site deps.
load("//hswaw/site:deps.bzl", "hswaw_site_deps")
hswaw_site_deps()

View file

@ -39,7 +39,7 @@ sh_binary(
srcs = ["rook-s3cmd-config.sh"],
data = [
"@bazel_tools//tools/bash/runfiles",
"@com_github_stedolan_jq//:jq",
"@com_github_itchyny_gojq//cmd/gojq",
":kubectl",
],
)

View file

@ -36,7 +36,7 @@ if [ -z "$kubectl" ]; then
exit 1
fi
jq=$(rlocation "com_github_stedolan_jq/jq")
jq=$(rlocation "com_github_itchyny_gojq/cmd/gojq/gojq_/gojq")
if [ -z "$jq" ]; then
echo "Could not find jq in runfiles" >&2
exit 1

View file

@ -824,12 +824,6 @@ def go_repositories():
sum = "h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=",
version = "v1.4.9",
)
go_repository(
name = "ml_vbom_util",
importpath = "github.com/fvbommel/util",
sum = "h1:/uQiVCCb9QGbBGf51tcx2D6Poi+Op2UpU+6qGP5nEdk=",
version = "v0.0.3",
)
go_repository(
name = "com_github_gabriel_vasile_mimetype",
@ -1445,6 +1439,21 @@ def go_repositories():
version = "v0.0.0-20190723014705-7c296d48a2b5",
)
go_repository(
name = "com_github_itchyny_gojq",
build_naming_convention = "go_default_library",
importpath = "github.com/itchyny/gojq",
sum = "h1:IxyYlHYIlspQHHTE0f3cJF0NKDMfajxViuhBLnHd/QU=",
version = "v0.12.13",
)
go_repository(
name = "com_github_itchyny_timefmt_go",
build_naming_convention = "go_default_library",
importpath = "github.com/itchyny/timefmt-go",
sum = "h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm6GE=",
version = "v0.1.5",
)
go_repository(
name = "com_github_jackc_pgx",
commit = "6954c15ad0bd3c9aa6dd1b190732b020379beb28",
@ -3036,6 +3045,12 @@ def go_repositories():
sum = "h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4=",
version = "v0.1.1",
)
go_repository(
name = "ml_vbom_util",
importpath = "github.com/fvbommel/util",
sum = "h1:/uQiVCCb9QGbBGf51tcx2D6Poi+Op2UpU+6qGP5nEdk=",
version = "v0.0.3",
)
go_repository(
name = "ml_vbom_util_sortorder",
@ -3330,6 +3345,7 @@ def go_repositories():
)
go_repository(
name = "tools_gotest_v3",
build_naming_convention = "go_default_library",
importpath = "gotest.tools/v3",
replace = "gotest.tools/v3",
sum = "h1:kG1BFyqVHuQoVQiR1bWGnfz/fmHvvuiSPIV7rvl360E=",

View file

View file

@ -1,78 +0,0 @@
# Copyright 2019 Google LLC
# Copyright 2020 Sergiusz 'q3k' Bazanski
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# The jq binary.
cc_binary(
name = "jq",
srcs = [
":source_files",
],
copts = [
"-Iexternal/com_github_kkos_oniguruma/src",
"-Wno-cpp",
"-Wno-unused-function",
"-Wno-unused-variable",
],
visibility = ["//visibility:public"],
deps = [
"@com_github_kkos_oniguruma//:oniguruma",
],
)
# Generate the source files.
# This will run ./configure and extract a host-dependent confdefs.h file, then
# prefix each .h acd .c file with '#include "confdefs.h"'.
genrule(
name = "source_files",
srcs = glob(["**"]),
outs = ["build/" + f for f in glob(
[
"src/*.h",
"src/*.c",
],
exclude = [
"src/inject_errors.c",
],
)] + [
# The extracted confdefs.h.
"build/src/confdefs.h",
# The generated builtin.inc.
"build/src/builtin.inc",
],
cmd =
# Run ./configure && make src/builtin.inc.
"( " +
" cd external/com_github_stedolan_jq; " +
" ./configure > /dev/null 2> /dev/null; " +
" make src/builtin.inc > /dev/null; " +
"); " +
# Extract confdefs.h from config.log.
"grep '^/\\* confdefs.h \\*/$$' external/com_github_stedolan_jq/config.log -A1000 " +
" | head -n -1 > \"$(@D)\"/build/src/confdefs.h; " +
# Prefix each output file with an include of confdefs.h.
"OUTS=\"$(OUTS)\"; for FILE in $$OUTS; do " +
" touch \"$$FILE\"; " +
" BASENAME=\"$$(basename $$FILE)\"; " +
" if [ \"$$BASENAME\" != \"confdefs.h\" ]; then " +
" echo '#include \"confdefs.h\"' > \"$$FILE\"; " +
" cat external/com_github_stedolan_jq/src/\"$$BASENAME\" >> \"$$FILE\"; " +
" fi; " +
# Replace non-relative references.
" sed -e 's|^#include \"src/|#include \"|g' -i \"$$FILE\"; " +
"done; " +
# Copy builtin.inc and version.h without modificaitons.
"cp external/com_github_stedolan_jq/src/builtin.inc \"$(@D)\"/build/src/builtin.inc; ",
)

View file

@ -1,6 +0,0 @@
third\_party: jq
================
Upstream: https://github.com/stedolan/jq
Pulled in by WORKSPACE (com\_github\_stedolan\_jq), BUILD.external used as root BUILDfile for external repository.