Skip to content

Commit c068469

Browse files
MathieuDuponchelleYuki Izumi
authored andcommitted
Extensions API (commonmark#123)
1 parent 4f103d1 commit c068469

32 files changed

+2945
-114
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_
2424
option(CMARK_TESTS "Build cmark tests and enable testing" ON)
2525

2626
add_subdirectory(src)
27+
add_subdirectory(extensions)
2728
if(CMARK_TESTS)
2829
add_subdirectory(api_test)
2930
endif()

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
SRCDIR=src
2+
EXTDIR=extensions
23
DATADIR=data
34
BUILDDIR?=build
45
GENERATOR?=Unix Makefiles
@@ -117,6 +118,19 @@ $(SRCDIR)/scanners.c: $(SRCDIR)/scanners.re
117118
--encoding-policy substitute -o $@ $<
118119
$(CLANG_FORMAT) $@
119120

121+
# We include scanners.c in the repository, so this shouldn't
122+
# normally need to be generated.
123+
$(EXTDIR)/ext_scanners.c: $(EXTDIR)/ext_scanners.re
124+
@case "$$(re2c -v)" in \
125+
*\ 0.13.*|*\ 0.14|*\ 0.14.1) \
126+
echo "re2c >= 0.14.2 is required"; \
127+
false; \
128+
;; \
129+
esac
130+
re2c --case-insensitive -b -i --no-generation-date -8 \
131+
--encoding-policy substitute -o $@ $<
132+
clang-format -style llvm -i $@
133+
120134
# We include entities.inc in the repository, so normally this
121135
# doesn't need to be regenerated:
122136
$(SRCDIR)/entities.inc: tools/make_entities_inc.py

api_test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include_directories(
88
${PROJECT_SOURCE_DIR}/src
99
${PROJECT_BINARY_DIR}/src
1010
)
11-
target_link_libraries(api_test libcmark)
11+
target_link_libraries(api_test libcmark ${CMAKE_DL_LIBS})
1212

1313
# Compiler flags
1414
if(MSVC)

extensions/CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
cmake_minimum_required(VERSION 2.8)
2+
set(LIBRARY "cmarkextensions")
3+
set(LIBRARY_SOURCES
4+
${PROJECT_SOURCE_DIR}/src/buffer.c
5+
${PROJECT_SOURCE_DIR}/src/cmark_ctype.c
6+
core-extensions.c
7+
ext_scanners.c
8+
ext_scanners.h
9+
)
10+
11+
include_directories(
12+
${PROJECT_SOURCE_DIR}/src
13+
${PROJECT_BINARY_DIR}/src
14+
)
15+
16+
# We make LIB_INSTALL_DIR configurable rather than
17+
# hard-coding lib, because on some OSes different locations
18+
# are used for different architectures (e.g. /usr/lib64 on
19+
# 64-bit Fedora).
20+
if(NOT LIB_INSTALL_DIR)
21+
set(LIB_INSTALL_DIR "lib" CACHE STRING
22+
"Set the installation directory for libraries." FORCE)
23+
endif(NOT LIB_INSTALL_DIR)
24+
25+
include_directories(. ${CMAKE_CURRENT_BINARY_DIR})
26+
27+
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
28+
set(CMAKE_LINKER_PROFILE "${CMAKE_LINKER_FLAGS_RELEASE} -pg")
29+
30+
add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})
31+
32+
target_link_libraries(cmarkextensions libcmark)

0 commit comments

Comments
 (0)