skvadrik / re2c

Lexer generator for C, C++, Go and Rust.
https://re2c.org
Other
1.06k stars 169 forks source link

Provide a min viable http://bazel.build integration. #442

Closed helly25 closed 1 year ago

helly25 commented 1 year ago

This allows other projects that use bazel to utilize re2c as a tool.

Limitations:

. Input files (docs, lexer, parser) are not being re-generated. . No tests are executed. . Only the main binary is being build as nothing else is needed.

A user will load the package using bazel's 'http_archive' in their WORKSPACE file.

In their BUILD files they can then use:

load("@re2c//bazel:re2c.bzl", "re2c_gen")

re2c_gen(
    name = "file_re2c",
    srcs = ["file.re2c"],
    outs = [
        "file.cc",
        "file.h",
    ]
)

cc_library(
    name = "file_cc",
    srcs = ["file.cc"],
    hdrs = ["file.h"],
)

The approach here is to automate as much as possible. In that way, all source and header files will be found automatically (using glob). Also, the provided bazel integration is kept to an absolute minimum.

An alternative is to use a rules_foreign_cc based approach. But that would require much more bazel work and knowledge. Plus the result would end up being a non-hermetic build, thereby bypassing bazel's advantages. Further, using a rules_foreign_cc approach is much slower (for me ~x10).

skvadrik commented 1 year ago

@helly25 Can you rebase and squash all commits except https://github.com/skvadrik/re2c/pull/442/commits/99404d027bb10be710fe4bf6f26d64dced63016f into one?

skvadrik commented 1 year ago

Sorry for nitpcking, there is still one merge commit https://github.com/skvadrik/re2c/pull/442/commits/ccf3fe60f8e6500cc01f34516490de59b99e0037, can you get rid of that? If that's hard to do for some reason I'm ok with having one merge commit, but the general rule is to always rebase and keep a simple linear history on master.

helly25 commented 1 year ago

My bad, I picked the wrong base obviously. Maybe I need to find a UI based tool that can do these things reliably.

On Thu, Apr 27, 2023 at 12:29 PM Ulya Trofimovich @.***> wrote:

Sorry for nitpcking, there is still one merge commit ccf3fe6 https://github.com/skvadrik/re2c/commit/ccf3fe60f8e6500cc01f34516490de59b99e0037, can you get rid of that? If that's hard to do for some reason I'm ok with having one merge commit, but the general rule is to always rebase and keep a simple linear history on master.

— Reply to this email directly, view it on GitHub https://github.com/skvadrik/re2c/pull/442#issuecomment-1525412044, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQ7NSM3C4HMEMVBS4E5HQ3XDJDBPANCNFSM6AAAAAAXLI4BGY . You are receiving this because you were mentioned.Message ID: @.***>

skvadrik commented 1 year ago

Thanks for addressing all the comments! Good to go (ignoring the three failures on Windows which are my fault).