Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a check for re2c version #2347

Merged
merged 2 commits into from
Oct 30, 2023
Merged

Add a check for re2c version #2347

merged 2 commits into from
Oct 30, 2023

Conversation

sunshaoce
Copy link
Contributor

As an improved version of #2346.

In some systems, the provided version of re2c is too low to build the latest release, so an option needs to be provided. For example, on CentOS7, the re2c version is re2c 0.14.3.

CMakeLists.txt Outdated
endif()
endif()

if(RE2C_PROPER)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop RE2C_PROPER and use RE2C AND ${RE2C_MAJOR_VERSION} GREATER 1 here?

CMakeLists.txt Outdated
@@ -69,7 +78,7 @@ if(RE2C)
re2c(${PROJECT_SOURCE_DIR}/src/lexer.in.cc ${PROJECT_BINARY_DIR}/lexer.cc)
add_library(libninja-re2c OBJECT ${PROJECT_BINARY_DIR}/depfile_parser.cc ${PROJECT_BINARY_DIR}/lexer.cc)
else()
message(WARNING "re2c was not found; changes to src/*.in.cc will not affect your build.")
message(WARNING "re2c was not found/used; changes to src/*.in.cc will not affect your build.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re2c <our version number> or later was not found; changes to src/*.in.cc will not affect your build.

find_program(RE2C re2c)
if(RE2C)
execute_process(COMMAND "${RE2C}" --vernum OUTPUT_VARIABLE RE2C_RAW_VERSION)
math(EXPR RE2C_MAJOR_VERSION "${RE2C_RAW_VERSION} / 10000")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To obtain the version number, use re2c --vernum, for example:

Ubuntu:~$ re2c --vernum
030000

Then divide the number by 10000 to calculate the major version.

@jhasse jhasse added this to the 1.12.0 milestone Oct 30, 2023
@jhasse jhasse merged commit b60a7dd into ninja-build:master Oct 30, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants