Skip to content

Commit

Permalink
Fix platform issues with md5sum utility (#4077)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxwli authored Aug 14, 2024
1 parent c76e05c commit ed6d847
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ jobs:

- name: Ensure generated grammar files are up to date
run: |
cat src/antlr4/keywords.txt src/antlr4/Cypher.g4 | md5sum > tmphashfile
python3 scripts/antlr4/hash.py src/antlr4/keywords.txt src/antlr4/Cypher.g4 > tmphashfile
cmp tmphashfile scripts/antlr4/hash.md5
rm tmphashfile
Expand Down
12 changes: 3 additions & 9 deletions scripts/antlr4/generate_grammar.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
# This is to make sure clean build from source needn't have Java installed.
# We can't use checksums because of windows line ending normalization.

find_package(Python3 REQUIRED COMPONENTS Interpreter)


file(READ hash.md5 OLDHASH)
execute_process(
COMMAND cat ${ROOT_DIR}/src/antlr4/keywords.txt ${ROOT_DIR}/src/antlr4/Cypher.g4
COMMAND md5sum OUTPUT_VARIABLE NEWHASH
RESULTS_VARIABLE RESVAR
ERROR_VARIABLE ERRVAR)

if(NOT "${RESVAR}" STREQUAL "0 0")
message(DEBUG "${ERRVAR}")
endif()
execute_process(
COMMAND ${Python3_EXECUTABLE} hash.py ${ROOT_DIR}/src/antlr4/keywords.txt ${ROOT_DIR}/src/antlr4/Cypher.g4 OUTPUT_VARIABLE NEWHASH)

if("${OLDHASH}" STREQUAL "${NEWHASH}")
message(DEBUG " Not regenerating grammar files as Cypher.g4 and keywords.txt is unchanged.")
Expand All @@ -35,7 +30,6 @@ endif()
file(MAKE_DIRECTORY generated)

find_package(Java REQUIRED)
find_package(Python3 REQUIRED COMPONENTS Interpreter)

# use script to generate final Cypher.g4 file and update tools/shell/include/keywords.h
execute_process(COMMAND ${Python3_EXECUTABLE} keywordhandler.py ${ROOT_DIR}/src/antlr4/Cypher.g4 ${ROOT_DIR}/src/antlr4/keywords.txt Cypher.g4 ${ROOT_DIR}/tools/shell/include/keywords.h)
Expand Down
2 changes: 1 addition & 1 deletion scripts/antlr4/hash.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e9d15715485e7edcd27e1374e1ef57cc -
e9d15715485e7edcd27e1374e1ef57cc
2 changes: 2 additions & 0 deletions scripts/antlr4/hash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import hashlib, sys
print(hashlib.md5((''.join(open(sys.argv[1])) + ''.join(open(sys.argv[2]))).encode('utf-8')).hexdigest())

0 comments on commit ed6d847

Please sign in to comment.