Skip to content

Commit

Permalink
build: satisfy Bazel 0.18.0 --all_incompatible_changes (kythe#3159)
Browse files Browse the repository at this point in the history
This requires a bump to our Bazel minimum version.

See: bazelbuild/bazel#6383
  • Loading branch information
schroederc committed Oct 18, 2018
1 parent b076de7 commit c34ceab
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 126 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ load("//:version.bzl", "check_version")

# Check that the user has a version between our minimum supported version of
# Bazel and our maximum supported version of Bazel.
check_version("0.16", "0.18")
check_version("0.18", "0.18")

load("//:setup.bzl", "kythe_rule_repositories")

Expand Down
2 changes: 1 addition & 1 deletion kythe/proto/go.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ KYTHE_IMPORT_BASE = "kythe.io/kythe/proto"
def _go_proto_src_impl(ctx):
"""Copy the generated source of a go_proto_library."""
lib = ctx.attr.library
for src in lib.actions[0].outputs:
for src in lib.actions[0].outputs.to_list():
out = ctx.outputs.generated
ctx.actions.run_shell(
outputs = [out],
Expand Down
176 changes: 95 additions & 81 deletions third_party/libzip.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ _CMAKE_VARIABLES = {
"__INT16_LIBZIP": None,
"__INT32_LIBZIP": None,
"__INT64_LIBZIP": None,
} + dict([
}

_CMAKE_VARIABLES.update(dict([
(
"ZIP_{sign}INT{size}_T".format(
sign = sign.upper(),
Expand All @@ -42,73 +44,104 @@ _CMAKE_VARIABLES = {
)
for sign in ("U", "")
for size in (8, 16, 32, 64)
])
]))

_SUBSTITUTIONS = {
"@PACKAGE@": "libzip",
"@VERSION@": "1.5.1", # Keep in sync with actual package!
}

_DEFINES = {
"HAVE_CLONEFILE": False,
"HAVE_COMMONCRYPTO": False,
"HAVE_CRYPTO": False,
"HAVE_DIRENT_H": False,
"HAVE_FICLONERANGE": False,
"HAVE_FILENO": True,
"HAVE_FSEEK": True,
"HAVE_FSEEKO": True,
"HAVE_FTELLO": True,
"HAVE_FTS_H": True,
"HAVE_GETPROGNAME": False,
"HAVE_GNUTLS": False,
"HAVE_LIBBZ2": False,
"HAVE_MKSTEMP": True,
"HAVE_NDIR_H": False,
"HAVE_OPEN": True,
"HAVE_OPENSSL": False,
"HAVE_SETMODE": False,
"HAVE_SHARED": True,
"HAVE_SNPRINTF": True,
"HAVE_SSIZE_T_LIBZIP": True,
"HAVE_STDBOOL_H": True,
"HAVE_STRCASECMP": True,
"HAVE_STRDUP": True,
"HAVE_STRICMP": False,
"HAVE_STRINGS_H": True,
"HAVE_STRTOLL": True,
"HAVE_STRTOULL": True,
"HAVE_STRUCT_TM_TM_ZONE": False,
"HAVE_SYS_DIR_H": False,
"HAVE_SYS_NDIR_H": False,
"HAVE_UNISTD_H": True,
"HAVE__CHMOD": False,
"HAVE__CLOSE": False,
"HAVE__DUP": False,
"HAVE__FDOPEN": False,
"HAVE__FILENO": False,
"HAVE__OPEN": False,
"HAVE__SETMODE": False,
"HAVE__SNPRINTF": False,
"HAVE__STRDUP": False,
"HAVE__STRICMP": False,
"HAVE__STRTOI64": False,
"HAVE__STRTOUI64": False,
"HAVE__UMASK": False,
"HAVE__UNLINK": False,
"HAVE___PROGNAME": False,
"WORDS_BIGENDIAN": False,
}

_DEFINES.update(dict([(
key,
value != None,
) for key, value in _CMAKE_VARIABLES.items()]))

_SUBSTITUTIONS.update(cmake_substitutions(
defines = _DEFINES,
vars = _CMAKE_VARIABLES,
))

expand_template(
name = "config_h",
out = "config.h",
substitutions = {
"@PACKAGE@": "libzip",
"@VERSION@": "1.5.1", # Keep in sync with actual package!
} + cmake_substitutions(
defines = {
"HAVE_CLONEFILE": False,
"HAVE_COMMONCRYPTO": False,
"HAVE_CRYPTO": False,
"HAVE_DIRENT_H": False,
"HAVE_FICLONERANGE": False,
"HAVE_FILENO": True,
"HAVE_FSEEK": True,
"HAVE_FSEEKO": True,
"HAVE_FTELLO": True,
"HAVE_FTS_H": True,
"HAVE_GETPROGNAME": False,
"HAVE_GNUTLS": False,
"HAVE_LIBBZ2": False,
"HAVE_MKSTEMP": True,
"HAVE_NDIR_H": False,
"HAVE_OPEN": True,
"HAVE_OPENSSL": False,
"HAVE_SETMODE": False,
"HAVE_SHARED": True,
"HAVE_SNPRINTF": True,
"HAVE_SSIZE_T_LIBZIP": True,
"HAVE_STDBOOL_H": True,
"HAVE_STRCASECMP": True,
"HAVE_STRDUP": True,
"HAVE_STRICMP": False,
"HAVE_STRINGS_H": True,
"HAVE_STRTOLL": True,
"HAVE_STRTOULL": True,
"HAVE_STRUCT_TM_TM_ZONE": False,
"HAVE_SYS_DIR_H": False,
"HAVE_SYS_NDIR_H": False,
"HAVE_UNISTD_H": True,
"HAVE__CHMOD": False,
"HAVE__CLOSE": False,
"HAVE__DUP": False,
"HAVE__FDOPEN": False,
"HAVE__FILENO": False,
"HAVE__OPEN": False,
"HAVE__SETMODE": False,
"HAVE__SNPRINTF": False,
"HAVE__STRDUP": False,
"HAVE__STRICMP": False,
"HAVE__STRTOI64": False,
"HAVE__STRTOUI64": False,
"HAVE__UMASK": False,
"HAVE__UNLINK": False,
"HAVE___PROGNAME": False,
"WORDS_BIGENDIAN": False,
} + dict([(
key,
value != None,
) for key, value in _CMAKE_VARIABLES.items()]),
vars = _CMAKE_VARIABLES,
),
substitutions = _SUBSTITUTIONS,
template = "cmake-config.h.in",
)

_VARS = {
"LIBZIP_TYPES_INCLUDE": "#include <stdint.h>",
"PACKAGE_VERSION": "1.5.1",
"PACKAGE_VERSION_MAJOR": "1",
"PACKAGE_VERSION_MINOR": "5",
"PACKAGE_VERSION_MICRO": "1",
}

_VARS.update(dict([
(
"ZIP_{sign}INT{size}_T".format(
sign = sign.upper(),
size = size,
),
"{sign}int{size}_t".format(
sign = sign.lower(),
size = size,
),
)
for sign in ("U", "")
for size in (8, 16, 32, 64)
]))

expand_template(
name = "zipconf_h",
out = "lib/zipconf.h",
Expand All @@ -120,26 +153,7 @@ expand_template(
"LIBZIP_VERSION_MICRO": True,
"ZIP_STATIC": False,
},
vars = {
"LIBZIP_TYPES_INCLUDE": "#include <stdint.h>",
"PACKAGE_VERSION": "1.5.1",
"PACKAGE_VERSION_MAJOR": "1",
"PACKAGE_VERSION_MINOR": "5",
"PACKAGE_VERSION_MICRO": "1",
} + dict([
(
"ZIP_{sign}INT{size}_T".format(
sign = sign.upper(),
size = size,
),
"{sign}int{size}_t".format(
sign = sign.lower(),
size = size,
),
)
for sign in ("U", "")
for size in (8, 16, 32, 64)
]),
vars = _VARS,
),
template = "cmake-zipconf.h.in",
)
Expand Down
3 changes: 1 addition & 2 deletions tools/build_rules/expand_template.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ expand_template = rule(
attrs = {
"template": attr.label(
mandatory = True,
allow_files = True,
single_file = True,
allow_single_file = True,
),
"substitutions": attr.string_dict(mandatory = True),
"out": attr.output(mandatory = True),
Expand Down
3 changes: 1 addition & 2 deletions tools/build_rules/shims.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@bazel_gazelle//:deps.bzl", _git_repository = "git_repository", _go_repository = "go_repository")
load("@io_bazel_rules_go//go:def.bzl", _go_binary = "go_binary", _go_library = "go_library", _go_test = "go_test")

def go_repository(name, commit, importpath, custom = None, custom_git = None, **kwargs):
"""Macro wrapping the Gazelle go_repository rule. Works identically, except
Expand All @@ -21,8 +22,6 @@ def go_repository(name, commit, importpath, custom = None, custom_git = None, **
overlay = {"@io_kythe//third_party/go:" + custom + ".BUILD": "BUILD"},
)

load("@io_bazel_rules_go//go:def.bzl", _go_binary = "go_binary", _go_library = "go_library", _go_test = "go_test")

# Go importpath prefix shared by all Kythe libraries
go_prefix = "kythe.io/"

Expand Down
31 changes: 17 additions & 14 deletions tools/build_rules/verifier_test/cc_indexer_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _compiler_options(ctx, cpp, copts, includes):
variables = cc_common.create_compile_variables(
feature_configuration = feature_configuration,
cc_toolchain = cpp,
user_compile_flags = depset(copts),
user_compile_flags = copts,
system_include_directories = depset(includes),
add_legacy_cxx_options = True,
)
Expand Down Expand Up @@ -127,12 +127,12 @@ def _split_flags(kwargs):
return flags

def _transitive_entries(deps):
files, compressed = depset(), depset()
files, compressed = [], []
for dep in deps:
if KytheEntries in dep:
files += dep[KytheEntries].files
compressed += dep[KytheEntries].compressed
return KytheEntries(files = files, compressed = compressed)
return KytheEntries(files = depset(transitive = files), compressed = depset(transitive = compressed))

def _cc_extract_kzip_impl(ctx):
cpp = find_cpp_toolchain(ctx)
Expand Down Expand Up @@ -241,18 +241,19 @@ cc_extract_kzip = rule(
def _extract_bundle_impl(ctx):
bundle = ctx.actions.declare_directory(ctx.label.name + "_unbundled")
ctx.actions.run(
inputs = [ctx.executable.unbundle, ctx.file.src],
inputs = [ctx.file.src],
tools = [ctx.executable.unbundle],
outputs = [bundle],
mnemonic = "Unbundle",
executable = ctx.executable.unbundle,
arguments = [ctx.file.src.path, bundle.path],
)
ctx.actions.run_shell(
inputs = [
ctx.executable.extractor,
ctx.file.vnames_config,
bundle,
],
tools = [ctx.executable.extractor],
outputs = [ctx.outputs.kzip],
mnemonic = "ExtractBundle",
env = {
Expand Down Expand Up @@ -310,12 +311,12 @@ def _bazel_extract_kzip_impl(ctx):
# Unlike `attr.label`, `attr.label_list` lacks an `executable` argument.
# Excluding "is_source" files may be overly aggressive, but effective.
scripts = [s for s in ctx.files.scripts if not s.is_source]
ctx.action(
ctx.actions.run(
inputs = [
ctx.executable.extractor,
ctx.file.vnames_config,
ctx.file.data,
] + scripts + ctx.files.srcs,
tools = [ctx.executable.extractor],
outputs = [ctx.outputs.kzip],
mnemonic = "BazelExtractKZip",
executable = ctx.executable.extractor,
Expand All @@ -326,7 +327,7 @@ def _bazel_extract_kzip_impl(ctx):
] + [script.path for script in scripts],
)
return [
KytheVerifierSources(files = ctx.files.srcs),
KytheVerifierSources(files = depset(ctx.files.srcs)),
CxxCompilationUnits(files = depset([ctx.outputs.kzip])),
]

Expand Down Expand Up @@ -369,7 +370,8 @@ def _cc_index_source(ctx, src):
ctx.actions.run(
mnemonic = "CcIndexSource",
outputs = [entries],
inputs = [ctx.executable.indexer] + ctx.files.srcs + ctx.files.deps,
inputs = ctx.files.srcs + ctx.files.deps,
tools = [ctx.executable.indexer],
executable = ctx.executable.indexer,
arguments = [ctx.expand_location(o) for o in ctx.attr.opts] + [
"-i",
Expand All @@ -391,7 +393,8 @@ def _cc_index_compilation(ctx, compilation):
ctx.actions.run(
mnemonic = "CcIndexCompilation",
outputs = [entries],
inputs = [ctx.executable.indexer, compilation],
inputs = [compilation],
tools = [ctx.executable.indexer],
executable = ctx.executable.indexer,
arguments = [ctx.expand_location(o) for o in ctx.attr.opts] + [
"-o",
Expand Down Expand Up @@ -432,15 +435,15 @@ def _cc_index_impl(ctx):
inputs = entries,
command = '("${@:1:${#@}-1}" || rm -f "${@:${#@}}") | gzip -c > "${@:${#@}}"',
mnemonic = "CompressEntries",
arguments = ["cat"] + [i.path for i in entries] + [ctx.outputs.entries.path],
arguments = ["cat"] + [i.path for i in entries.to_list()] + [ctx.outputs.entries.path],
)

sources = depset([src for src in ctx.files.srcs if src.extension != "kzip"])
sources = [depset([src for src in ctx.files.srcs if src.extension != "kzip"])]
for dep in ctx.attr.srcs:
if KytheVerifierSources in dep:
sources += dep[KytheVerifierSources].files
sources += [dep[KytheVerifierSources].files]
return [
KytheVerifierSources(files = sources),
KytheVerifierSources(files = depset(transitive = sources)),
KytheEntries(files = entries, compressed = depset([ctx.outputs.entries])),
]

Expand Down
Loading

0 comments on commit c34ceab

Please sign in to comment.