Skip to content

Commit

Permalink
Don't use grep or sort
Browse files Browse the repository at this point in the history
  • Loading branch information
isuruf authored and xoviat committed Dec 23, 2017
1 parent 1adca50 commit 1aab8cd
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tools/flang2/utils/upper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,24 @@ add_executable(upperl
)

# Generate upper tables
file(STRINGS "${UTILS_UPPER_DIR}/upperilm.in" UPPERILM_H_CONTENTS)
list(SORT UPPERILM_H_CONTENTS)
set(UPPERILM_H_CONTENTS_SORTED "")
foreach(Line ${UPPERILM_H_CONTENTS})
# Don't modify the line if it contains #local at the end.
if(NOT "${Line}" MATCHES "^ *\#$")
if ("${UPPERILM_H_CONTENTS_SORTED}" STREQUAL "")
set(UPPERILM_H_CONTENTS_SORTED "${Line}")
else()
set(UPPERILM_H_CONTENTS_SORTED "${UPPERILM_H_CONTENTS_SORTED}\n${Line}")
endif()
endif()
endforeach()

file(WRITE ${UTILS_UPPER_BIN_DIR}/upperilm.sort "${UPPERILM_H_CONTENTS_SORTED}")

add_custom_command(
OUTPUT ${UTILS_UPPER_BIN_DIR}/upperilm.h
COMMAND LC_ALL=C sort ${UTILS_UPPER_DIR}/upperilm.in | grep -v "^ *\#" > ${UTILS_UPPER_BIN_DIR}/upperilm.sort
COMMAND ${CMAKE_BINARY_DIR}/bin/upperl ${UTILS_UPPER_BIN_DIR}/upperilm.sort ${UTILS_UPPER_BIN_DIR}/upperilm.h
DEPENDS upperl ${UTILS_UPPER_DIR}/upperilm.in
)
Expand Down

0 comments on commit 1aab8cd

Please sign in to comment.