1 | # Wedge definition for cmark
|
2 | #
|
3 | # Loaded by deps/wedge.sh.
|
4 |
|
5 | set -o nounset
|
6 | set -o pipefail
|
7 | set -o errexit
|
8 |
|
9 | # sourced
|
10 | WEDGE_NAME='cmark'
|
11 | WEDGE_VERSION='0.29.0'
|
12 | WEDGE_IS_ABSOLUTE=1 # TODO: try relaxing
|
13 |
|
14 | # 2025-04: cmake broke on a Github Actions Ubuntu image due to a minor version
|
15 | # upgrade. Somehow OLD versions break (are deprecated), not new ones.
|
16 |
|
17 | # CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
|
18 | # Compatibility with CMake < 3.5 has been removed from CMake.
|
19 |
|
20 | # Let's redo the build system in shell, so that devs and the CI don't have a
|
21 | # cmake dependency.
|
22 | # This code is straight C99, building and executable and shared library.
|
23 |
|
24 | # bin/
|
25 | # cmark # executable
|
26 | # lib/
|
27 | # libcmark.so -> libcmark.so.0.29.0
|
28 | # share/ # Probably don't need these two dirs
|
29 | # include/
|
30 |
|
31 | # Copied from cmark-0.29.0/src/CMakeLists.txt
|
32 |
|
33 | # We use the same variable names as CMake
|
34 | LIBRARY='libcmark'
|
35 | SOVERSION=$WEDGE_VERSION
|
36 |
|
37 | # UNUSED
|
38 | HEADERS='
|
39 | cmark.h
|
40 | parser.h
|
41 | buffer.h
|
42 | node.h
|
43 | iterator.h
|
44 | chunk.h
|
45 | references.h
|
46 | utf8.h
|
47 | scanners.h
|
48 | inlines.h
|
49 | houdini.h
|
50 | cmark_ctype.h
|
51 | render.h
|
52 | '
|
53 |
|
54 | # Removed scanners.re - that seems like a bug in the original
|
55 | # - scanners.c is the generated file
|
56 | # Removed ${HEADERS} - they don't need to be compiled
|
57 |
|
58 | # scanners.re
|
59 | LIBRARY_SOURCES="
|
60 | cmark.c
|
61 | node.c
|
62 | iterator.c
|
63 | blocks.c
|
64 | inlines.c
|
65 | scanners.c
|
66 | utf8.c
|
67 | buffer.c
|
68 | references.c
|
69 | render.c
|
70 | man.c
|
71 | xml.c
|
72 | html.c
|
73 | commonmark.c
|
74 | latex.c
|
75 | houdini_href_e.c
|
76 | houdini_html_e.c
|
77 | houdini_html_u.c
|
78 | cmark_ctype.c
|
79 | "
|
80 |
|
81 | PROGRAM_SOURCES="
|
82 | ${LIBRARY_SOURCES}
|
83 | main.c
|
84 | "
|
85 |
|
86 | # Here is an example from cmark-0.29.0/build/compile_commands.json
|
87 | #
|
88 | # "command": "/usr/bin/cc -I/home/andy/git/oils-for-unix/oils/_build/deps-source/cmark/cmark-0.29.0/src/. -I/home/andy/git/oils-for-unix/oils/_build/deps-source/cmark/cmark-0.29.0/build/src -Wall -Wextra -std=c99 -pedantic -O3 -DNDEBUG -DCMARK_STATIC_DEFINE -o CMakeFiles/cmark.dir/cmark.c.o -c /home/andy/git/oils-for-unix/oils/_build/deps-source/cmark/cmark-0.29.0/src/cmark.c",
|
89 | #
|
90 | # So let's just copy those flags for each source, and link them into a dynamic
|
91 | # library.
|
92 |
|
93 | CC_FLAGS='-Wall -Wextra -std=c99 -pedantic -O3 -DNDEBUG -DCMARK_STATIC_DEFINE'
|
94 |
|
95 | DO_CMAKE_BUILD=''
|
96 | #DO_CMAKE_BUILD=T
|
97 |
|
98 |
|
99 | wedge-make() {
|
100 | local src_dir=$1
|
101 | local build_dir=$2
|
102 | local install_dir=$3
|
103 | local wedge_dir=$4
|
104 |
|
105 | # TODO: need $wedge_dir to access vendored cmark_export.h
|
106 | # This is generated by
|
107 | # generate_export_header(${LIBRARY} BASE_NAME ${PROJECT_NAME})
|
108 | # in src/CMakeLists.txt
|
109 |
|
110 | pushd $build_dir
|
111 |
|
112 | if test -z "$DO_CMAKE_BUILD"; then
|
113 | local obj_dir=$build_dir/obj
|
114 | local bin_dir=$build_dir/bin
|
115 | mkdir -v -p $obj_dir $bin_dir
|
116 |
|
117 | for c_src in $PROGRAM_SOURCES; do
|
118 | local obj=$obj_dir/$(basename $c_src).o
|
119 | echo " CC $c_src"
|
120 | #echo cc -I "$src_dir/src" -I "$build_dir/src" $CC_FLAGS -o $obj -c $src_dir/src/$c_src
|
121 |
|
122 | # Note: $wedge_dir/cmark_{export,version}.h are copied from the cmake build
|
123 | cc -I "$src_dir/src" -I "$wedge_dir" $CC_FLAGS -o $obj -c $src_dir/src/$c_src
|
124 | done
|
125 |
|
126 | echo " LINK $bin_dir/cmark"
|
127 | cc -o $bin_dir/cmark $obj_dir/*.o
|
128 | fi
|
129 |
|
130 | # Note: generated re2c source is included, so we don't have to invoke it
|
131 |
|
132 | #-o CMakeFiles/cmark.dir/cmark.c.o -c /home/andy/git/oils-for-unix/oils/_build/deps-source/cmark/cmark-0.29.0/src/cmark.c",
|
133 |
|
134 | if test -n "$DO_CMAKE_BUILD"; then
|
135 | time cmake -DCMAKE_INSTALL_PREFIX=$install_dir $src_dir
|
136 | time make
|
137 | fi
|
138 |
|
139 | # make test
|
140 |
|
141 | popd
|
142 | }
|
143 |
|
144 | wedge-install() {
|
145 | local build_dir=$1
|
146 | local install_dir=$2
|
147 |
|
148 | if test -z "$DO_CMAKE_BUILD"; then
|
149 | mkdir -v -p $install_dir/bin
|
150 | cp -v $build_dir/bin/cmark $install_dir/bin/cmark
|
151 | else
|
152 | pushd $build_dir
|
153 | time make install
|
154 | popd
|
155 | fi
|
156 | }
|
157 |
|
158 | wedge-smoke-test() {
|
159 | local install_dir=$1
|
160 |
|
161 | if test -z "$DO_CMAKE_BUILD"; then
|
162 | echo '*hi*' | $install_dir/bin/cmark
|
163 | else
|
164 | ldd $install_dir/lib/libcmark.so.$WEDGE_VERSION
|
165 | fi
|
166 | }
|