Skip to content

Commit c8960d7

Browse files
MathieuDuponchelleYuki Izumi
authored andcommitted
Extensions API (commonmark#123)
1 parent f30d3c6 commit c8960d7

32 files changed

+2977
-132
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ option(CMARK_SHARED "Build shared libcmark library" ON)
2727
option(CMARK_LIB_FUZZER "Build libFuzzer fuzzing harness" OFF)
2828

2929
add_subdirectory(src)
30+
add_subdirectory(extensions)
3031
if(CMARK_TESTS AND CMARK_SHARED)
3132
add_subdirectory(api_test)
3233
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
@@ -126,6 +127,19 @@ $(SRCDIR)/scanners.c: $(SRCDIR)/scanners.re
126127
--encoding-policy substitute -o $@ $<
127128
$(CLANG_FORMAT) $@
128129

130+
# We include scanners.c in the repository, so this shouldn't
131+
# normally need to be generated.
132+
$(EXTDIR)/ext_scanners.c: $(EXTDIR)/ext_scanners.re
133+
@case "$$(re2c -v)" in \
134+
*\ 0.13.*|*\ 0.14|*\ 0.14.1) \
135+
echo "re2c >= 0.14.2 is required"; \
136+
false; \
137+
;; \
138+
esac
139+
re2c --case-insensitive -b -i --no-generation-date -8 \
140+
--encoding-policy substitute -o $@ $<
141+
clang-format -style llvm -i $@
142+
129143
# We include entities.inc in the repository, so normally this
130144
# doesn't need to be regenerated:
131145
$(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)