Skip to content

Commit

Permalink
Export of internal ZetaSQL changes.
Browse files Browse the repository at this point in the history
--
Change by ZetaSQL Team <[email protected]>:
Handle templatized macro names in DEFINE MACRO statement.
--
Change by ZetaSQL Team <[email protected]>:
Add %a and %A support in our PARSE_ function docs.
--
Change by ZetaSQL Team <[email protected]>:
Avoid duplication of EOF token in a broken DEFINE TABLE name <<EOF statement.
--
Change by ZetaSQL Team <[email protected]>:
Enforce opaque types cannot be coerced from integer in PRODUCT_EXTERNAL
--
Change by Matthew Brown <[email protected]>:
Fix ZetaSQL Build for java
--
Change by Matthew Brown <[email protected]>:
Enforce opaque types cannot be coerced from integer in PRODUCT_EXTERNAL
--
Change by ZetaSQL Team <[email protected]>:
Internal changes
--
Change by ZetaSQL Team <[email protected]>:
Provide implementation of timestamp_bucket that's more efficient for some constant inputs
--
Change by ZetaSQL Team <[email protected]>:
Fix resolved AST validation failure in query:
--
Change by ZetaSQL Team <[email protected]>:
More test cases for TVFs
--
Change by ZetaSQL Team <[email protected]>:
Fix constexpr issue on gcc with C++17
--
Change by ZetaSQL Team <[email protected]>:
--
Change by Matthew Brown <[email protected]>:
Add IsValidEnumValue to EnumType to help with opaque enums
--
Change by ZetaSQL Team <[email protected]>:
Reduce stack usage of ResolveTVF
--
Change by ZetaSQL Team <[email protected]>:
Build M4, flex, Bison with https://github.com/jmillikin
--
Change by ZetaSQL Team <[email protected]>:
Add a name to MemoryAccountant to distinguish different instances.
--
Change by ZetaSQL Team <[email protected]>:
Allow the characters '!' and '%' for future syntax.
--
Change by ZetaSQL Team <[email protected]>:
Support Range type in ConvertTypeToProto
--
Change by ZetaSQL Team <[email protected]>:
Add a test to capture the bug in lenient_formatter where <<EOF is duplicated.
--
Change by ZetaSQL Team <[email protected]>:
Internal change

GitOrigin-RevId: b0e53c2819f760c42c2f2d79dd0916f28d2e7a69
Change-Id: Iab2b31b38d422e0bc50e424ca570e7b970bc8754
  • Loading branch information
ZetaSQL Team authored and matthewcbrown committed Oct 28, 2022
1 parent b7d7fd8 commit 177d495
Show file tree
Hide file tree
Showing 121 changed files with 4,619 additions and 1,331 deletions.
3 changes: 2 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

# ZetaSQL requires c++17 support to match internal Google development
# environments.
build --cxxopt=-std=c++17
# This is a special snowflake setting that bazel requires special handling for.
build --action_env=BAZEL_CXXOPTS="-std=c++17"

# By default, we don't suppress any warnings, to get clang-specific warning
# suppression you can invoke with --config=clang
Expand Down
70 changes: 3 additions & 67 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

"""
Rules for adding './configure && make' style dependencies.
Bazel build files for ZetaSQL.
"""

load("@rules_foreign_cc//foreign_cc:configure.bzl", "configure_make")
load("flex.bzl", "flex_header")

licenses(["notice"]) # Apache v2.0

Expand All @@ -37,69 +36,6 @@ exports_files([
"zetasql_java_deps.bzl",
])

configure_make(
name = "m4",
env = select({
"@platforms//os:macos": {"AR": ""},
"//conditions:default": {},
}),
lib_source = "@m4//:all",
out_binaries = [
"m4",
],
)

filegroup(
name = "m4_bin",
srcs = [":m4"],
output_group = "m4",
)

configure_make(
name = "bison",
build_data = [":m4_bin"],
# Without specifying m4 directly, cc_rules_foreign may fallback
# on the system m4, which might be too old.
env = select({
"@platforms//os:macos": {
"AR": "",
"M4": "$(execpath :m4_bin)",
},
"//conditions:default": {"M4": "$(execpath :m4_bin)"},
}),
lib_source = "@bison//:all",
out_binaries = [
"bison",
"yacc",
],
)

filegroup(
name = "bison_bin",
srcs = [":bison"],
output_group = "bison",
)

configure_make(
flex_header(
name = "flex",
build_data = [":m4_bin"],
# Flex requires m4 when it _executes_, unlike bison, which only
# requires it when it is built - this requires some additional handling.
env = select({
"@platforms//os:macos": {
"AR": "",
"M4": "$(execpath :m4_bin)",
},
"//conditions:default": {"M4": "$(execpath :m4_bin)"},
}),
lib_source = "@flex//:all",
out_binaries = [
"flex",
],
)

filegroup(
name = "flex_bin",
srcs = [":flex"],
output_group = "flex",
)
29 changes: 11 additions & 18 deletions bazel/bison.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
"""Build rule for generating C or C++ sources with Bison.
"""

load("@rules_bison//bison:bison.bzl", "BISON_TOOLCHAIN_TYPE", "bison_toolchain")
load("@rules_m4//m4:m4.bzl", "M4_TOOLCHAIN_TYPE")

def _genyacc_impl(ctx):
"""Implementation for genyacc rule."""
bison = bison_toolchain(ctx)

# Argument list
args = ctx.actions.args()
Expand All @@ -36,14 +40,10 @@ def _genyacc_impl(ctx):
]

ctx.actions.run(
executable = ctx.executable._bison,
env = {
"M4": ctx.executable._m4.path,
"BISON_PKGDATADIR": ctx.files._bison_data[0].dirname,
},
executable = bison.bison_tool,
env = bison.bison_env,
arguments = [args],
inputs = ctx.files._bison_data + ctx.files.src,
tools = [ctx.executable._m4],
inputs = ctx.files.src,
outputs = outputs,
mnemonic = "Yacc",
progress_message = "Generating %s and %s from %s" %
Expand Down Expand Up @@ -79,17 +79,10 @@ genyacc = rule(
doc = "A list of extra options to pass to Bison. These are " +
"subject to $(location ...) expansion.",
),
"_bison_data": attr.label(default = "@bison//:bison_runtime_data"),
"_bison": attr.label(
default = Label("//bazel:bison_bin"),
executable = True,
cfg = "host",
),
"_m4": attr.label(
default = Label("//bazel:m4_bin"),
executable = True,
cfg = "host",
),
},
toolchains = [
BISON_TOOLCHAIN_TYPE,
M4_TOOLCHAIN_TYPE,
],
output_to_genfiles = True,
)
44 changes: 29 additions & 15 deletions bazel/flex.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ genlex(
```
"""

load("@rules_flex//flex:flex.bzl", "FLEX_TOOLCHAIN_TYPE", "flex_toolchain")
load("@rules_m4//m4:m4.bzl", "M4_TOOLCHAIN_TYPE")

def _genlex_impl(ctx):
"""Implementation for genlex rule."""
flex = flex_toolchain(ctx)

# Compute the prefix, if not specified.
if ctx.attr.prefix:
Expand All @@ -76,13 +80,10 @@ def _genlex_impl(ctx):
args.add(ctx.file.src)

ctx.actions.run(
executable = ctx.executable._flex,
env = {
"M4": ctx.executable._m4.path,
},
executable = flex.flex_tool,
env = flex.flex_env,
arguments = [args],
inputs = ctx.files.src + ctx.files.includes,
tools = [ctx.executable._m4],
outputs = [ctx.outputs.out],
mnemonic = "Flex",
progress_message = "Generating %s from %s" % (
Expand Down Expand Up @@ -115,16 +116,29 @@ genlex = rule(
"lexopts": attr.string_list(
doc = "A list of options to be added to the flex command line.",
),
"_flex": attr.label(
default = Label("//bazel:flex_bin"),
executable = True,
cfg = "host",
),
"_m4": attr.label(
default = Label("//bazel:m4_bin"),
executable = True,
cfg = "host",
),
},
toolchains = [
FLEX_TOOLCHAIN_TYPE,
M4_TOOLCHAIN_TYPE,
],
output_to_genfiles = True,
)

def _flex_header(ctx):
flex = flex_toolchain(ctx)

return [
CcInfo(compilation_context = cc_common.create_compilation_context(
includes = depset([flex.flex_lexer_h.dirname]),
headers = depset([flex.flex_lexer_h]),
)),
]

flex_header = rule(
implementation = _flex_header,
output_to_genfiles = True,
toolchains = [
FLEX_TOOLCHAIN_TYPE,
M4_TOOLCHAIN_TYPE,
],
)
13 changes: 0 additions & 13 deletions bazel/flex.patch

This file was deleted.

133 changes: 0 additions & 133 deletions bazel/m4.patch

This file was deleted.

16 changes: 16 additions & 0 deletions bazel/zetasql_deps_step_1.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,19 @@ def zetasql_deps_step_1(add_bazel_version = True):
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.9.0.tar.gz",
sha256 = "2a4d07cd64b0719b39a7c12218a3e507672b82a97b98c6a89d38565894cf7c51",

This comment has been minimized.

Copy link
@kaybrazy

kaybrazy Dec 14, 2022

bazel/zetasql_deps_step_1.bzl

)

http_archive(
name = "rules_m4",
sha256 = "b0309baacfd1b736ed82dc2bb27b0ec38455a31a3d5d20f8d05e831ebeef1a8e",
urls = ["https://github.com/jmillikin/rules_m4/releases/download/v0.2.2/rules_m4-v0.2.2.tar.xz"],
)
http_archive(
name = "rules_flex",
urls = ["https://github.com/jmillikin/rules_flex/releases/download/v0.2/rules_flex-v0.2.tar.xz"],
sha256 = "f1685512937c2e33a7ebc4d5c6cf38ed282c2ce3b7a9c7c0b542db7e5db59d52",
)
http_archive(
name = "rules_bison",
urls = ["https://github.com/jmillikin/rules_bison/releases/download/v0.2.1/rules_bison-v0.2.1.tar.xz"],
sha256 = "9577455967bfcf52f9167274063ebb74696cb0fd576e4226e14ed23c5d67a693",
)
Loading

0 comments on commit 177d495

Please sign in to comment.