Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
BasedOnStyle: LLVM
SortIncludes:
Enabled: true
IgnoreCase: false
12 changes: 2 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ VERSION?=$(SPECVERSION)
RELEASE?=cmark-$(VERSION)
INSTALL_PREFIX?=/usr/local
CLANG_CHECK?=clang-check
CLANG_FORMAT=clang-format -style llvm -sort-includes=0 -i
CLANG_FORMAT=clang-format -i
AFL_PATH?=/usr/local/bin

.PHONY: all cmake_build leakcheck clean fuzztest test debug ubsan asan mingw archive newbench bench format update-spec afl libFuzzer lint
Expand Down Expand Up @@ -141,15 +141,7 @@ $(SRCDIR)/case_fold.inc: $(DATADIR)/CaseFolding.txt
# We include scanners.c in the repository, so this shouldn't
# normally need to be generated.
$(SRCDIR)/scanners.c: $(SRCDIR)/scanners.re
@case "$$(re2c -v)" in \
*\ 0.13.*|*\ 0.14|*\ 0.14.1) \
echo "re2c >= 0.14.2 is required"; \
false; \
;; \
esac
re2c -W -Werror -b -i --no-generation-date \
-o $@ $<
$(CLANG_FORMAT) $@
./tools/make_scanners $< $@

# We include entities.inc in the repository, so normally this
# doesn't need to be regenerated:
Expand Down
37 changes: 37 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,49 @@ configure_file(libcmark.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libcmark.pc
@ONLY)

find_program(PYTHON3_EXECUTABLE python3 OPTIONAL)

if(PYTHON3_EXECUTABLE)
add_custom_command(
OUTPUT case_fold.inc
COMMAND ${PYTHON3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/../tools/make_case_fold_inc.py
< ${CMAKE_CURRENT_SOURCE_DIR}/../data/CaseFolding.txt
> case_fold.inc
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../data/CaseFolding.txt
VERBATIM)
add_custom_command(
OUTPUT entities.inc
COMMAND ${PYTHON3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/../tools/make_entities_inc.py
> entities.inc
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../tools/make_entities_inc.py
VERBATIM)
endif()

find_program(RE2C_EXECUTABLE re2c OPTIONAL)
find_program(CLANG_FORMAT_EXECUTABLE clang-format OPTIONAL)

if(RE2C_EXECUTABLE AND CLANG_FORMAT_EXECUTABLE)
add_custom_command(
OUTPUT scanners.c
COMMAND RE2C_EXECUTABLE=${RE2C_EXECUTABLE}
CLANG_FORMAT_EXECUTABLE=${CLANG_FORMAT_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/../tools/make_scanners
${CMAKE_CURRENT_SOURCE_DIR}/scanners.re
scanners.c
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scanners.re
VERBATIM)
endif()

add_library(cmark
blocks.c
buffer.c
case_fold.inc
cmark.c
cmark_ctype.c
commonmark.c
entities.inc
houdini_href_e.c
houdini_html_e.c
houdini_html_u.c
Expand Down
24 changes: 24 additions & 0 deletions tools/make_scanners
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

# Creates C scanner code using re2c.
# Usage: ./tools/make_scanners src/scanners.re src/scanners.c
# Environment variable: RE2C_EXECUTABLE, CLANG_FORMAT_EXECUTABLE

set -eu

in=${1?no input file}
out=${2?no output file}

: "${RE2C_EXECUTABLE:=re2c}"
: "${CLANG_FORMAT_EXECUTABLE:=clang-format}"

case "$("$RE2C_EXECUTABLE" -v)" in
*\ 0.13.*|*\ 0.14|*\ 0.14.1)
echo "re2c >= 0.14.2 is required"
false
;;
esac

"$RE2C_EXECUTABLE" -W -Werror -b -i --no-generation-date \
-o "$out" "$in"
"$CLANG_FORMAT_EXECUTABLE" -i "$out"
Loading