yeptris 0.6.64.0-riscv64-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.adoc +150 -0
- data/ext/build_windows_native.rb +60 -0
- data/ext/libyeptris/extconf.rb +57 -0
- data/ext/yeptris_native/cbor_ruby.c +198 -0
- data/ext/yeptris_native/extconf.rb +99 -0
- data/ext/yeptris_native/json_ruby.c +414 -0
- data/ext/yeptris_native/version.h +29 -0
- data/ext/yeptris_native/yeptris_native.c +507 -0
- data/lib/yeptris/3.3/native.so +0 -0
- data/lib/yeptris/cbor.rb +169 -0
- data/lib/yeptris/document.rb +319 -0
- data/lib/yeptris/ffi.rb +572 -0
- data/lib/yeptris/json/descriptor.rb +266 -0
- data/lib/yeptris/json.rb +502 -0
- data/lib/yeptris/materializer.rb +389 -0
- data/lib/yeptris/node.rb +482 -0
- data/lib/yeptris/psych/class_loader.rb +24 -0
- data/lib/yeptris/psych/coder_shim.rb +55 -0
- data/lib/yeptris/psych/drop_in.rb +63 -0
- data/lib/yeptris/psych/encodable.rb +14 -0
- data/lib/yeptris/psych/handler.rb +95 -0
- data/lib/yeptris/psych/parser.rb +114 -0
- data/lib/yeptris/psych/scalar_scanner.rb +149 -0
- data/lib/yeptris/psych/tree_builder.rb +119 -0
- data/lib/yeptris/psych/visitors.rb +670 -0
- data/lib/yeptris/psych.rb +796 -0
- data/lib/yeptris/schema.rb +253 -0
- data/lib/yeptris/validation.rb +320 -0
- data/lib/yeptris/valueml.rb +477 -0
- data/lib/yeptris/yaml/descriptor.rb +56 -0
- data/lib/yeptris/yaml.rb +668 -0
- data/lib/yeptris.rb +130 -0
- data/libyeptris.so +0 -0
- data/vendor/libyeptris/CMakeLists.txt +280 -0
- data/vendor/libyeptris/cmake/yeptris-config.cmake.in +5 -0
- data/vendor/libyeptris/cmake/yeptris.pc.in +11 -0
- data/vendor/libyeptris/src/CMakeLists.txt +183 -0
- data/vendor/libyeptris/src/include/yeptris/api.h +32 -0
- data/vendor/libyeptris/src/include/yeptris/cbor.h +174 -0
- data/vendor/libyeptris/src/include/yeptris/dom.h +196 -0
- data/vendor/libyeptris/src/include/yeptris/emit.h +128 -0
- data/vendor/libyeptris/src/include/yeptris/error.h +42 -0
- data/vendor/libyeptris/src/include/yeptris/events.h +171 -0
- data/vendor/libyeptris/src/include/yeptris/json.h +57 -0
- data/vendor/libyeptris/src/include/yeptris/json.hpp +258 -0
- data/vendor/libyeptris/src/include/yeptris/jsonc_compat.h +115 -0
- data/vendor/libyeptris/src/include/yeptris/marshal.h +75 -0
- data/vendor/libyeptris/src/include/yeptris/parse.h +121 -0
- data/vendor/libyeptris/src/include/yeptris/plan.h +100 -0
- data/vendor/libyeptris/src/include/yeptris/resolve.h +81 -0
- data/vendor/libyeptris/src/include/yeptris/schema.h +121 -0
- data/vendor/libyeptris/src/include/yeptris/tape.h +128 -0
- data/vendor/libyeptris/src/include/yeptris/types.h +38 -0
- data/vendor/libyeptris/src/include/yeptris/validate.h +401 -0
- data/vendor/libyeptris/src/include/yeptris/values.h +108 -0
- data/vendor/libyeptris/src/include/yeptris/version.h.in +29 -0
- data/vendor/libyeptris/src/include/yeptris/visit.h +77 -0
- data/vendor/libyeptris/src/include/yeptris/yajl_compat.h +135 -0
- data/vendor/libyeptris/src/include/yeptris.h +24 -0
- data/vendor/libyeptris/src/yeptris/build.c +393 -0
- data/vendor/libyeptris/src/yeptris/cbor/cbor.h +35 -0
- data/vendor/libyeptris/src/yeptris/cbor/decode.c +1054 -0
- data/vendor/libyeptris/src/yeptris/cbor/encode.c +836 -0
- data/vendor/libyeptris/src/yeptris/cbor/encode_priv.h +32 -0
- data/vendor/libyeptris/src/yeptris/cbor/from_marshal.c +982 -0
- data/vendor/libyeptris/src/yeptris/cbor/sink.h +36 -0
- data/vendor/libyeptris/src/yeptris/common/chartype.c +41 -0
- data/vendor/libyeptris/src/yeptris/common/chartype.h +77 -0
- data/vendor/libyeptris/src/yeptris/common/cpu.c +81 -0
- data/vendor/libyeptris/src/yeptris/common/cpu.h +40 -0
- data/vendor/libyeptris/src/yeptris/common/error.c +65 -0
- data/vendor/libyeptris/src/yeptris/common/error.h +81 -0
- data/vendor/libyeptris/src/yeptris/common/mutex.h +45 -0
- data/vendor/libyeptris/src/yeptris/common/nametab.c +275 -0
- data/vendor/libyeptris/src/yeptris/common/nametab.h +68 -0
- data/vendor/libyeptris/src/yeptris/common/port.h +74 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text.c +49 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text.h +342 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_avx2.c +672 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_neon.c +793 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_scalar.c +324 -0
- data/vendor/libyeptris/src/yeptris/common/string_view.c +34 -0
- data/vendor/libyeptris/src/yeptris/common/string_view.h +93 -0
- data/vendor/libyeptris/src/yeptris/doc.h +86 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.c +1312 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.h +332 -0
- data/vendor/libyeptris/src/yeptris/dom/hpool.c +107 -0
- data/vendor/libyeptris/src/yeptris/dom/mapindex.c +173 -0
- data/vendor/libyeptris/src/yeptris/dom/mapindex.h +61 -0
- data/vendor/libyeptris/src/yeptris/dom/mutate.c +431 -0
- data/vendor/libyeptris/src/yeptris/dom/ytape.c +2323 -0
- data/vendor/libyeptris/src/yeptris/dom/ytape.h +96 -0
- data/vendor/libyeptris/src/yeptris/emit/emit.c +670 -0
- data/vendor/libyeptris/src/yeptris/emit/float/api.h +43 -0
- data/vendor/libyeptris/src/yeptris/emit/float/dragon.c +405 -0
- data/vendor/libyeptris/src/yeptris/emit/float/floatint.h +231 -0
- data/vendor/libyeptris/src/yeptris/emit/float/fpconv.c +428 -0
- data/vendor/libyeptris/src/yeptris/emit/float/print.c +396 -0
- data/vendor/libyeptris/src/yeptris/emit/style.c +21 -0
- data/vendor/libyeptris/src/yeptris/emit/style.h +32 -0
- data/vendor/libyeptris/src/yeptris/emit/writer.c +1951 -0
- data/vendor/libyeptris/src/yeptris/emit/writer.h +111 -0
- data/vendor/libyeptris/src/yeptris/encoding/bom.c +31 -0
- data/vendor/libyeptris/src/yeptris/encoding/encoding.h +63 -0
- data/vendor/libyeptris/src/yeptris/encoding/transcode.c +157 -0
- data/vendor/libyeptris/src/yeptris/encoding/utf8_validate.c +178 -0
- data/vendor/libyeptris/src/yeptris/events/capture.c +166 -0
- data/vendor/libyeptris/src/yeptris/events/capture.h +39 -0
- data/vendor/libyeptris/src/yeptris/events/iterparse.c +298 -0
- data/vendor/libyeptris/src/yeptris/events/pull.c +117 -0
- data/vendor/libyeptris/src/yeptris/events/push.c +151 -0
- data/vendor/libyeptris/src/yeptris/events/recorder.c +144 -0
- data/vendor/libyeptris/src/yeptris/events/values.c +630 -0
- data/vendor/libyeptris/src/yeptris/events/values_priv.h +53 -0
- data/vendor/libyeptris/src/yeptris/events/yaml_compat.c +86 -0
- data/vendor/libyeptris/src/yeptris/events/yaml_compat.h +90 -0
- data/vendor/libyeptris/src/yeptris/jsonapi/jsonc_compat.c +687 -0
- data/vendor/libyeptris/src/yeptris/jsonapi/yajl_compat.c +728 -0
- data/vendor/libyeptris/src/yeptris/marshal/to_json.c +650 -0
- data/vendor/libyeptris/src/yeptris/marshal.c +988 -0
- data/vendor/libyeptris/src/yeptris/memory/allocator.c +20 -0
- data/vendor/libyeptris/src/yeptris/memory/allocator.h +43 -0
- data/vendor/libyeptris/src/yeptris/memory/arena.c +150 -0
- data/vendor/libyeptris/src/yeptris/memory/arena.h +52 -0
- data/vendor/libyeptris/src/yeptris/memory/pool.c +133 -0
- data/vendor/libyeptris/src/yeptris/memory/pool.h +36 -0
- data/vendor/libyeptris/src/yeptris/parse/engine.c +6528 -0
- data/vendor/libyeptris/src/yeptris/parse/engine.h +96 -0
- data/vendor/libyeptris/src/yeptris/parse/events.h +137 -0
- data/vendor/libyeptris/src/yeptris/parse/numbers.c +374 -0
- data/vendor/libyeptris/src/yeptris/parse/numbers.h +33 -0
- data/vendor/libyeptris/src/yeptris/parse/scalars.c +435 -0
- data/vendor/libyeptris/src/yeptris/parse/scalars.h +87 -0
- data/vendor/libyeptris/src/yeptris/parse/stream_iter.c +358 -0
- data/vendor/libyeptris/src/yeptris/parse.c +1074 -0
- data/vendor/libyeptris/src/yeptris/plan.c +824 -0
- data/vendor/libyeptris/src/yeptris/resolve/compat11.c +339 -0
- data/vendor/libyeptris/src/yeptris/resolve/core12.c +153 -0
- data/vendor/libyeptris/src/yeptris/resolve/full12.c +201 -0
- data/vendor/libyeptris/src/yeptris/resolve/json12.c +109 -0
- data/vendor/libyeptris/src/yeptris/resolve/resolver.h +103 -0
- data/vendor/libyeptris/src/yeptris/resolve/tags.c +250 -0
- data/vendor/libyeptris/src/yeptris/scan/json.c +839 -0
- data/vendor/libyeptris/src/yeptris/scan/json.h +116 -0
- data/vendor/libyeptris/src/yeptris/scan/scan.c +862 -0
- data/vendor/libyeptris/src/yeptris/scan/scan.h +177 -0
- data/vendor/libyeptris/src/yeptris/schema.c +309 -0
- data/vendor/libyeptris/src/yeptris/tape.c +2375 -0
- data/vendor/libyeptris/src/yeptris/tape_in.h +39 -0
- data/vendor/libyeptris/src/yeptris/validate/compile.c +306 -0
- data/vendor/libyeptris/src/yeptris/validate/internal.h +347 -0
- data/vendor/libyeptris/src/yeptris/validate/jsonschema.c +1922 -0
- data/vendor/libyeptris/src/yeptris/validate/output.c +246 -0
- data/vendor/libyeptris/src/yeptris/validate/regexp.c +1600 -0
- data/vendor/libyeptris/src/yeptris/validate/registry.c +118 -0
- data/vendor/libyeptris/src/yeptris/validate/resources.c +601 -0
- data/vendor/libyeptris/src/yeptris/validate/stream.c +1155 -0
- data/vendor/libyeptris/src/yeptris/validate/validate.c +1043 -0
- data/vendor/libyeptris/src/yeptris/version.c +7 -0
- data/vendor/libyeptris/src/yeptris/visit/dom_visit.c +115 -0
- data/vendor/libyeptris/src/yeptris/visit/json_visit.c +293 -0
- data/vendor/libyeptris/src/yeptris/visit/yaml_visit.c +127 -0
- metadata +221 -0
data/lib/yeptris.rb
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yeptris
|
|
4
|
+
# The gem's version lives in the parent namespace's file — the last
|
|
5
|
+
# internal require (yeptris/version) retired with it.
|
|
6
|
+
VERSION = "0.6.64.0".freeze
|
|
7
|
+
|
|
8
|
+
# Informational notices are OPT-IN (yeptris-ruby#217): consumers
|
|
9
|
+
# embed yeptris inside CLIs that assert clean stderr, and a
|
|
10
|
+
# successful fallback is not a warning. YEPTRIS_DEBUG=1 turns the
|
|
11
|
+
# notices on.
|
|
12
|
+
def self.debug?
|
|
13
|
+
return @debug unless @debug.nil?
|
|
14
|
+
v = ENV["YEPTRIS_DEBUG"]
|
|
15
|
+
@debug = !v.nil? && !v.empty? && v != "0"
|
|
16
|
+
end
|
|
17
|
+
# The error hierarchy lives in THIS file (the parent namespace's
|
|
18
|
+
# own file): nested constants do not trigger a parent-constant
|
|
19
|
+
# autoload, and the law forbids internal requires — defining the
|
|
20
|
+
# hierarchy here makes it eager by construction.
|
|
21
|
+
|
|
22
|
+
# The base error for everything this library raises deliberately.
|
|
23
|
+
class Error < StandardError; end
|
|
24
|
+
|
|
25
|
+
# The input is not valid YAML (or valid for the requested mode).
|
|
26
|
+
# message carries the C parser's line/column detail.
|
|
27
|
+
class ParseError < Error; end
|
|
28
|
+
|
|
29
|
+
# A handle was used after its document was freed. Raised, never a
|
|
30
|
+
# segfault: the Document is the sole C-memory owner and every Node
|
|
31
|
+
# checks liveness through it.
|
|
32
|
+
class FreedError < Error; end
|
|
33
|
+
|
|
34
|
+
# Building a document from a Ruby object graph hit something the
|
|
35
|
+
# builder refuses (cycles, unsupported objects).
|
|
36
|
+
class DumpError < Error; end
|
|
37
|
+
|
|
38
|
+
# Input coercion — the ONE place the input boundary is typed
|
|
39
|
+
# (no respond_to? duck-probing): IO-like objects read, Strings
|
|
40
|
+
# pass through, anything else must be stringable and is.
|
|
41
|
+
def self.read_input(source)
|
|
42
|
+
case source
|
|
43
|
+
when String then source
|
|
44
|
+
when IO, StringIO then source.read
|
|
45
|
+
else source.to_s
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
autoload :Document, "yeptris/document"
|
|
50
|
+
autoload :Node, "yeptris/node"
|
|
51
|
+
autoload :YAML, "yeptris/yaml"
|
|
52
|
+
autoload :JSON, "yeptris/json"
|
|
53
|
+
autoload :Materializer, "yeptris/materializer"
|
|
54
|
+
autoload :ValueML, "yeptris/valueml"
|
|
55
|
+
autoload :Psych, "yeptris/psych"
|
|
56
|
+
autoload :Schema, "yeptris/schema"
|
|
57
|
+
autoload :Validation, "yeptris/validation"
|
|
58
|
+
autoload :CBOR, "yeptris/cbor"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# NOTE (the #318 poisoned-process class): the Psych error-name aliases
|
|
62
|
+
# live BELOW the ffi require — reading Psych here would trigger the
|
|
63
|
+
# psych autoload BEFORE the native library resolves, and a mid-load
|
|
64
|
+
# ffi failure under a drop-in rebind left ::Psych rebound against a
|
|
65
|
+
# half-initialized FFI module (every to_yaml in the process died).
|
|
66
|
+
# With this order an ffi failure is a clean, loud require failure.
|
|
67
|
+
|
|
68
|
+
# Eager native-library resolution (leptris-ruby lesson): fail at
|
|
69
|
+
# require time, not at first parse. The ffi require MUST come after
|
|
70
|
+
# the autoload registrations — ffi.rb opens module Yeptris, and
|
|
71
|
+
# requiring it first would shadow the manifest (leptris-ruby#53).
|
|
72
|
+
begin
|
|
73
|
+
require "yeptris/ffi"
|
|
74
|
+
rescue LoadError => e
|
|
75
|
+
raise LoadError, <<~MSG
|
|
76
|
+
Yeptris could not load the native libyeptris library.
|
|
77
|
+
Set YEPTRIS_LIB_PATH to a libyeptris.{so,dylib,dll}, or use the
|
|
78
|
+
platform gem that vendors it.
|
|
79
|
+
(Underlying error: #{e.message})
|
|
80
|
+
MSG
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# The safe_load error names, aliased at the top level so consumers
|
|
85
|
+
# writing rescues need no nesting knowledge (issue #73's naming
|
|
86
|
+
# note): Yeptris::DisallowedClass is Yeptris::Psych::DisallowedClass.
|
|
87
|
+
# LAZY (const_missing): a standalone require "yeptris/psych" loads
|
|
88
|
+
# yeptris.rb MID-psych — an eager alias here would re-enter the
|
|
89
|
+
# half-loaded psych.rb through the autoload and NameError. At first
|
|
90
|
+
# touch psych is complete in every load order.
|
|
91
|
+
module Yeptris
|
|
92
|
+
def self.const_missing(name)
|
|
93
|
+
case name
|
|
94
|
+
when :DisallowedClass, :AliasesError
|
|
95
|
+
const_set(name, Psych.const_get(name))
|
|
96
|
+
else
|
|
97
|
+
super
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Optional C-API materializer (TODO.restructure/22): fused visit →
|
|
103
|
+
# Ruby objects via the Ruby C API. Feature-detected — LoadError leaves
|
|
104
|
+
# the FFI ladder (Marshal → columns → records) as the sole path.
|
|
105
|
+
# One bundle per Ruby minor (the leptris-ruby #207/#227 lesson: a PE
|
|
106
|
+
# DLL must bind its build Ruby's runtime; a unix bundle is also
|
|
107
|
+
# minor-locked by the internal API it compiles against). The MINOR
|
|
108
|
+
# lives in the DIRECTORY (lib/yeptris/<minor>/native.<ext>) and the
|
|
109
|
+
# FILE name stays unversioned: ruby derives the init symbol from the
|
|
110
|
+
# feature basename, so native-3.4.so asked for the untypeable
|
|
111
|
+
# "Init_native-3" and the versioned-file scheme could never load
|
|
112
|
+
# (#157 — every shipped bundle was dead code). Dev checkouts keep
|
|
113
|
+
# the plain native.<ext> name (mkmf layout, built for the running
|
|
114
|
+
# Ruby). A missing cell falls back LOUDLY to the ladder.
|
|
115
|
+
begin
|
|
116
|
+
# per-minor FIRST: a single version-agnostic native.so loads under
|
|
117
|
+
# ANY Ruby and is an ABI gamble across minors — Ruby 3.0 ran a
|
|
118
|
+
# 3.3-built ext and the JSON parse failed.
|
|
119
|
+
require "yeptris/#{RUBY_VERSION[/\A\d+\.\d+/]}/native"
|
|
120
|
+
rescue LoadError
|
|
121
|
+
begin
|
|
122
|
+
require "yeptris/native"
|
|
123
|
+
rescue LoadError => e
|
|
124
|
+
if Yeptris.debug? # the require chain is top-level (self = main)
|
|
125
|
+
warn "yeptris: no precompiled native materializer for Ruby " \
|
|
126
|
+
"#{RUBY_VERSION[/\A\d+\.\d+/]} on this platform " \
|
|
127
|
+
"(#{e.message}); the FFI ladder carries the load"
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
data/libyeptris.so
ADDED
|
Binary file
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# yeptris — Ultra-fast YAML 1.2 parser, emitter and streamer in C
|
|
2
|
+
# The YAML counterpart of libleptris. Pure C library with CLI and bindings.
|
|
3
|
+
cmake_minimum_required(VERSION 3.20)
|
|
4
|
+
|
|
5
|
+
project(yeptris
|
|
6
|
+
VERSION 0.6.64
|
|
7
|
+
DESCRIPTION "Ultra-fast YAML 1.2 parser, emitter and streamer in C"
|
|
8
|
+
LANGUAGES C CXX
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
# C11 (the standard question, settled with evidence 2026-09-18): going
|
|
12
|
+
# C99 needs FOUR downgrades, not one — _Static_assert (fixed: the
|
|
13
|
+
# typedef-array YEPTRIS_CT_ASSERT), typedef redefinition (mapindex.c),
|
|
14
|
+
# _Thread_local (the per-thread error channel) and <stdatomics> (the
|
|
15
|
+
# lock-free handle pool). The last two are architecture-critical and
|
|
16
|
+
# absent from MSVC's C99 mode; pthread TLS / lock-based pools would
|
|
17
|
+
# regress the hot paths and weaken the concurrency contract.
|
|
18
|
+
set(CMAKE_C_STANDARD 11)
|
|
19
|
+
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
20
|
+
set(CMAKE_C_EXTENSIONS OFF)
|
|
21
|
+
|
|
22
|
+
# C++11 standard for tests and benchmarks.
|
|
23
|
+
set(CMAKE_CXX_STANDARD 11)
|
|
24
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
25
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
26
|
+
|
|
27
|
+
# MSVC (the windows CI leg): the C++ suites use designated initializers
|
|
28
|
+
# (a GCC/Clang extension at C++11; MSVC requires C++20), and the test
|
|
29
|
+
# targets — test_conformance included — need test/compat on the include
|
|
30
|
+
# path for the dirent surface.
|
|
31
|
+
if(MSVC)
|
|
32
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
33
|
+
endif()
|
|
34
|
+
|
|
35
|
+
# MSVC multi-config: one runtime home so ctest -C Release and the CLI
|
|
36
|
+
# smoke find every exe (the per-target default scattered them)
|
|
37
|
+
if(MSVC)
|
|
38
|
+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
39
|
+
endif()
|
|
40
|
+
|
|
41
|
+
# MSVC's default stack is 1 MiB; the Unix builds run on 8 MiB — deep
|
|
42
|
+
# document paths (the depth guard's teardown) measured against the
|
|
43
|
+
# Unix default get the same room here
|
|
44
|
+
if(MSVC)
|
|
45
|
+
add_link_options(/STACK:8388608)
|
|
46
|
+
endif()
|
|
47
|
+
|
|
48
|
+
# ---------------------------------------------------------------- options --
|
|
49
|
+
option(BUILD_TESTING "Build tests" ON)
|
|
50
|
+
option(YEPTRIS_BUILD_CLI "Build the yeptris CLI tool" ON)
|
|
51
|
+
option(YEPTRIS_BUILD_STATIC "Build the static library" ON)
|
|
52
|
+
option(YEPTRIS_BUILD_SHARED "Build the shared library" OFF)
|
|
53
|
+
option(YEPTRIS_BUILD_BENCHMARKS "Build performance benchmarks (TODO.impl/18)" OFF)
|
|
54
|
+
option(YEPTRIS_BUILD_JSONC_COMPAT
|
|
55
|
+
"Build libyeptris-jsonc: the json-c drop-in migration layer (TODO.impl/21)" ON)
|
|
56
|
+
option(YEPTRIS_WITH_CBOR "Build the CBOR (RFC 8949) codec surface" ON)
|
|
57
|
+
option(YEPTRIS_ENABLE_ASAN "Enable AddressSanitizer" OFF)
|
|
58
|
+
option(YEPTRIS_ENABLE_TSAN "Enable ThreadSanitizer (requires all-TSAN build)" OFF)
|
|
59
|
+
option(YEPTRIS_ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer" OFF)
|
|
60
|
+
option(YEPTRIS_ENABLE_FUZZING "Build libFuzzer harnesses (TODO.impl/19; requires clang)" OFF)
|
|
61
|
+
option(YEPTRIS_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF)
|
|
62
|
+
|
|
63
|
+
# LTO: ON for Release/RelWithDebInfo by default (libleptris measured
|
|
64
|
+
# 1.3-3.5x on parse paths); override with -DYEPTRIS_ENABLE_LTO=OFF.
|
|
65
|
+
if(NOT DEFINED YEPTRIS_ENABLE_LTO)
|
|
66
|
+
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
|
67
|
+
set(YEPTRIS_ENABLE_LTO_DEFAULT ON)
|
|
68
|
+
else()
|
|
69
|
+
set(YEPTRIS_ENABLE_LTO_DEFAULT OFF)
|
|
70
|
+
endif()
|
|
71
|
+
else()
|
|
72
|
+
set(YEPTRIS_ENABLE_LTO_DEFAULT ${YEPTRIS_ENABLE_LTO})
|
|
73
|
+
endif()
|
|
74
|
+
option(YEPTRIS_ENABLE_LTO "Enable link-time optimization (default ON for Release)" ${YEPTRIS_ENABLE_LTO_DEFAULT})
|
|
75
|
+
|
|
76
|
+
# ------------------------------------------------------------- sanitizers --
|
|
77
|
+
if(YEPTRIS_ENABLE_ASAN AND YEPTRIS_ENABLE_TSAN)
|
|
78
|
+
message(FATAL_ERROR "ASAN and TSAN are mutually exclusive")
|
|
79
|
+
endif()
|
|
80
|
+
|
|
81
|
+
if(YEPTRIS_ENABLE_ASAN)
|
|
82
|
+
add_compile_options(-fsanitize=address -fno-omit-frame-pointer -g)
|
|
83
|
+
add_link_options(-fsanitize=address)
|
|
84
|
+
message(STATUS "AddressSanitizer: ENABLED")
|
|
85
|
+
endif()
|
|
86
|
+
|
|
87
|
+
if(YEPTRIS_ENABLE_TSAN)
|
|
88
|
+
add_compile_options(-fsanitize=thread -fno-omit-frame-pointer -g)
|
|
89
|
+
add_link_options(-fsanitize=thread)
|
|
90
|
+
message(STATUS "ThreadSanitizer: ENABLED")
|
|
91
|
+
endif()
|
|
92
|
+
|
|
93
|
+
if(YEPTRIS_ENABLE_UBSAN)
|
|
94
|
+
add_compile_options(
|
|
95
|
+
-fsanitize=undefined -fsanitize=float-cast-overflow
|
|
96
|
+
-fno-sanitize-recover=undefined -fno-omit-frame-pointer -g)
|
|
97
|
+
add_link_options(-fsanitize=undefined -fsanitize=float-cast-overflow)
|
|
98
|
+
message(STATUS "UndefinedBehaviorSanitizer: ENABLED (fatal)")
|
|
99
|
+
endif()
|
|
100
|
+
|
|
101
|
+
# libFuzzer implies ASAN+UBSan (the teptris fuzz.yml pattern: the
|
|
102
|
+
# memory-safety contracts ride the SAME binary as the fuzzer, so every
|
|
103
|
+
# nightly round reports UB at the crash site instead of libFuzzer's
|
|
104
|
+
# "combine with AddressSanitizer" note).
|
|
105
|
+
if(YEPTRIS_ENABLE_FUZZING)
|
|
106
|
+
# instrument everything, but link the fuzzer MAIN only into the
|
|
107
|
+
# harnesses: a global -fsanitize=fuzzer link option demands
|
|
108
|
+
# LLVMFuzzerTestOneInput from every executable (the CLI and the
|
|
109
|
+
# test binaries died on it once CXX also pinned to clang++)
|
|
110
|
+
if(APPLE)
|
|
111
|
+
# Apple ld64 cannot link UBSan'd static archives
|
|
112
|
+
# ("invalid r_symbolnum"): ASan-only locally
|
|
113
|
+
add_compile_options(-fsanitize=fuzzer-no-link,address -fno-omit-frame-pointer -g)
|
|
114
|
+
add_link_options(-fsanitize=address)
|
|
115
|
+
message(STATUS "libFuzzer: ENABLED (implies ASAN; UBSan needs linux ld)")
|
|
116
|
+
else()
|
|
117
|
+
add_compile_options(-fsanitize=fuzzer-no-link,address,undefined
|
|
118
|
+
-fno-sanitize-recover=undefined -fno-omit-frame-pointer -g)
|
|
119
|
+
add_link_options(-fsanitize=address,undefined)
|
|
120
|
+
message(STATUS "libFuzzer: ENABLED (implies ASAN+UBSan)")
|
|
121
|
+
endif()
|
|
122
|
+
endif()
|
|
123
|
+
|
|
124
|
+
# -------------------------------------------------------------------- LTO --
|
|
125
|
+
if(YEPTRIS_ENABLE_LTO)
|
|
126
|
+
include(CheckIPOSupported)
|
|
127
|
+
check_ipo_supported(RESULT yeptris_lto_supported OUTPUT yeptris_lto_error)
|
|
128
|
+
if(yeptris_lto_supported)
|
|
129
|
+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
|
130
|
+
message(STATUS "Link-time optimization: ENABLED")
|
|
131
|
+
else()
|
|
132
|
+
message(WARNING "YEPTRIS_ENABLE_LTO requested but not supported: ${yeptris_lto_error}")
|
|
133
|
+
endif()
|
|
134
|
+
endif()
|
|
135
|
+
|
|
136
|
+
# -------------------------------------------------------------- visibility --
|
|
137
|
+
# Position-independent code for static libraries (embeddable in DSOs).
|
|
138
|
+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
139
|
+
|
|
140
|
+
# Hide all symbols by default; the public surface is exactly the
|
|
141
|
+
# YEPTRIS_API-marked functions (libleptris TODO 80 pattern).
|
|
142
|
+
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
|
143
|
+
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
|
144
|
+
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
|
|
145
|
+
|
|
146
|
+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
147
|
+
|
|
148
|
+
# ---------------------------------------------------------------- warnings --
|
|
149
|
+
# Scoped per-target so fetched dependencies (GTest) keep their own flags.
|
|
150
|
+
function(yeptris_set_warnings target)
|
|
151
|
+
if(MSVC)
|
|
152
|
+
# /wd4100 mirrors -Wno-unused-parameter; /experimental:c11atomics
|
|
153
|
+
# un-breaks the C11 headers' stdatomic gate (the windows sentinel
|
|
154
|
+
# surfaced both — the leg rides in the test matrix now)
|
|
155
|
+
target_compile_options(${target} PRIVATE /W4 /wd4100 /wd4996 /experimental:c11atomics)
|
|
156
|
+
if(YEPTRIS_WARNINGS_AS_ERRORS)
|
|
157
|
+
target_compile_options(${target} PRIVATE /WX)
|
|
158
|
+
endif()
|
|
159
|
+
else()
|
|
160
|
+
target_compile_options(${target} PRIVATE -Wall -Wextra -Wno-unused-parameter)
|
|
161
|
+
if(YEPTRIS_WARNINGS_AS_ERRORS)
|
|
162
|
+
target_compile_options(${target} PRIVATE -Werror)
|
|
163
|
+
endif()
|
|
164
|
+
endif()
|
|
165
|
+
endfunction()
|
|
166
|
+
|
|
167
|
+
# ------------------------------------------------------------- versioning --
|
|
168
|
+
# CMakeLists project(VERSION) is the single source of truth (TODO.impl/01);
|
|
169
|
+
# scripts/bump-version.sh syncs vcpkg.json and CHANGELOG.md from it.
|
|
170
|
+
configure_file(
|
|
171
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src/include/yeptris/version.h.in
|
|
172
|
+
${CMAKE_BINARY_DIR}/generated/yeptris/version.h
|
|
173
|
+
@ONLY
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
# --------------------------------------------------------------- subdirs --
|
|
177
|
+
enable_testing()
|
|
178
|
+
|
|
179
|
+
add_subdirectory(src)
|
|
180
|
+
|
|
181
|
+
if(YEPTRIS_BUILD_CLI)
|
|
182
|
+
add_subdirectory(cli)
|
|
183
|
+
endif()
|
|
184
|
+
|
|
185
|
+
if(BUILD_TESTING)
|
|
186
|
+
if(MSVC)
|
|
187
|
+
add_compile_options(-I${CMAKE_SOURCE_DIR}/test/compat)
|
|
188
|
+
endif()
|
|
189
|
+
add_subdirectory(test)
|
|
190
|
+
|
|
191
|
+
# Conformance runner (TODO.impl/16): builds on demand; the corpus
|
|
192
|
+
# arrives via scripts/fetch-corpora.sh.
|
|
193
|
+
add_executable(test_conformance
|
|
194
|
+
test/conformance/main.c
|
|
195
|
+
test/conformance/suite.c
|
|
196
|
+
test/conformance/tree.c)
|
|
197
|
+
# Runs in CI after fetch-corpora.sh; passes-as-skip when absent.
|
|
198
|
+
add_test(NAME conformance
|
|
199
|
+
COMMAND test_conformance ${CMAKE_SOURCE_DIR}/test/conformance/data/yaml-test-suite/src)
|
|
200
|
+
# strict: the suite is at 100% — a regression must fail CI, not hide
|
|
201
|
+
# behind the non-strict exit (a tree-mismatch once slipped through)
|
|
202
|
+
set_tests_properties(conformance PROPERTIES ENVIRONMENT "YEP_STRICT=1")
|
|
203
|
+
# psych-pure's parse-{block,flow,scalar,props,stream} corpora,
|
|
204
|
+
# ported by scripts/port-pure-tml.py (checked-in fixtures)
|
|
205
|
+
add_test(NAME conformance-pure
|
|
206
|
+
COMMAND test_conformance ${CMAKE_SOURCE_DIR}/test/conformance/data/psych-pure)
|
|
207
|
+
set_tests_properties(conformance-pure PROPERTIES ENVIRONMENT "YEP_STRICT=1")
|
|
208
|
+
target_link_libraries(test_conformance PRIVATE yeptris_static)
|
|
209
|
+
target_include_directories(test_conformance PRIVATE
|
|
210
|
+
${CMAKE_SOURCE_DIR}/src/yeptris
|
|
211
|
+
${CMAKE_SOURCE_DIR}/src/include
|
|
212
|
+
${CMAKE_BINARY_DIR}/generated)
|
|
213
|
+
yeptris_set_warnings(test_conformance)
|
|
214
|
+
endif()
|
|
215
|
+
|
|
216
|
+
if(YEPTRIS_BUILD_BENCHMARKS)
|
|
217
|
+
add_subdirectory(benchmarks)
|
|
218
|
+
endif()
|
|
219
|
+
|
|
220
|
+
# --------------------------------------------------------------- install --
|
|
221
|
+
# (TODO.impl/20) targets, headers, pkg-config, and the find_package
|
|
222
|
+
# config; relative paths keep relocatable installs.
|
|
223
|
+
include(GNUInstallDirs)
|
|
224
|
+
|
|
225
|
+
if(TARGET yeptris_static)
|
|
226
|
+
install(TARGETS yeptris_static
|
|
227
|
+
EXPORT yeptris-targets
|
|
228
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
229
|
+
)
|
|
230
|
+
endif()
|
|
231
|
+
if(TARGET yeptris_shared)
|
|
232
|
+
install(TARGETS yeptris_shared
|
|
233
|
+
EXPORT yeptris-targets
|
|
234
|
+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
235
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
236
|
+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
237
|
+
)
|
|
238
|
+
endif()
|
|
239
|
+
if(TARGET yeptris_jsonc)
|
|
240
|
+
install(TARGETS yeptris_jsonc
|
|
241
|
+
EXPORT yeptris-targets
|
|
242
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
243
|
+
)
|
|
244
|
+
endif()
|
|
245
|
+
if(YEPTRIS_BUILD_CLI AND TARGET yeptris)
|
|
246
|
+
install(TARGETS yeptris DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
247
|
+
endif()
|
|
248
|
+
|
|
249
|
+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/include/
|
|
250
|
+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
251
|
+
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
|
|
252
|
+
)
|
|
253
|
+
install(FILES ${CMAKE_BINARY_DIR}/generated/yeptris/version.h
|
|
254
|
+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/yeptris
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
# pkg-config
|
|
258
|
+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/yeptris.pc.in
|
|
259
|
+
${CMAKE_BINARY_DIR}/yeptris.pc @ONLY)
|
|
260
|
+
install(FILES ${CMAKE_BINARY_DIR}/yeptris.pc
|
|
261
|
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
|
262
|
+
|
|
263
|
+
# find_package(yeptris) config
|
|
264
|
+
include(CMakePackageConfigHelpers)
|
|
265
|
+
write_basic_package_version_file(
|
|
266
|
+
${CMAKE_BINARY_DIR}/yeptris-config-version.cmake
|
|
267
|
+
VERSION ${PROJECT_VERSION}
|
|
268
|
+
COMPATIBILITY SameMajorVersion
|
|
269
|
+
)
|
|
270
|
+
install(EXPORT yeptris-targets
|
|
271
|
+
NAMESPACE yeptris::
|
|
272
|
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/yeptris)
|
|
273
|
+
configure_package_config_file(
|
|
274
|
+
${CMAKE_CURRENT_SOURCE_DIR}/cmake/yeptris-config.cmake.in
|
|
275
|
+
${CMAKE_BINARY_DIR}/yeptris-config.cmake
|
|
276
|
+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/yeptris)
|
|
277
|
+
install(FILES ${CMAKE_BINARY_DIR}/yeptris-config.cmake
|
|
278
|
+
${CMAKE_BINARY_DIR}/yeptris-config-version.cmake
|
|
279
|
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/yeptris)
|
|
280
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
prefix=@CMAKE_INSTALL_PREFIX@
|
|
2
|
+
exec_prefix=${prefix}
|
|
3
|
+
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
|
|
4
|
+
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
|
5
|
+
|
|
6
|
+
Name: yeptris
|
|
7
|
+
Description: @PROJECT_DESCRIPTION@
|
|
8
|
+
Version: @PROJECT_VERSION@
|
|
9
|
+
URL: https://github.com/leptris/yeptris
|
|
10
|
+
Cflags: -I${includedir}
|
|
11
|
+
Libs: -L${libdir} -lyeptris
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# libyeptris — core library sources.
|
|
2
|
+
#
|
|
3
|
+
# Subsystems land with their TODO.impl items (common/ 02, memory/ 03,
|
|
4
|
+
# simd/ 04, encoding/ 05, scan/ 06, parse/ 07+). The SIMD per-ISA TUs get
|
|
5
|
+
# their own -m flags here when item 04 lands.
|
|
6
|
+
|
|
7
|
+
set(YEPTRIS_SOURCES
|
|
8
|
+
yeptris/version.c
|
|
9
|
+
yeptris/common/cpu.c
|
|
10
|
+
yeptris/common/chartype.c
|
|
11
|
+
yeptris/common/string_view.c
|
|
12
|
+
yeptris/common/error.c
|
|
13
|
+
yeptris/common/nametab.c
|
|
14
|
+
yeptris/common/simd_text.c
|
|
15
|
+
yeptris/common/simd_text_scalar.c
|
|
16
|
+
yeptris/memory/allocator.c
|
|
17
|
+
yeptris/memory/pool.c
|
|
18
|
+
yeptris/memory/arena.c
|
|
19
|
+
yeptris/encoding/bom.c
|
|
20
|
+
yeptris/encoding/transcode.c
|
|
21
|
+
yeptris/encoding/utf8_validate.c
|
|
22
|
+
yeptris/scan/json.c
|
|
23
|
+
yeptris/scan/scan.c
|
|
24
|
+
yeptris/parse/scalars.c
|
|
25
|
+
yeptris/parse/engine.c
|
|
26
|
+
yeptris/dom/dom.c
|
|
27
|
+
yeptris/dom/ytape.c
|
|
28
|
+
yeptris/dom/hpool.c
|
|
29
|
+
yeptris/dom/mapindex.c
|
|
30
|
+
yeptris/dom/mutate.c
|
|
31
|
+
yeptris/parse.c
|
|
32
|
+
yeptris/parse/stream_iter.c
|
|
33
|
+
yeptris/build.c
|
|
34
|
+
yeptris/events/capture.c
|
|
35
|
+
yeptris/events/push.c
|
|
36
|
+
yeptris/events/pull.c
|
|
37
|
+
yeptris/events/recorder.c
|
|
38
|
+
yeptris/events/iterparse.c
|
|
39
|
+
yeptris/events/yaml_compat.c
|
|
40
|
+
yeptris/resolve/tags.c
|
|
41
|
+
yeptris/resolve/core12.c
|
|
42
|
+
yeptris/resolve/compat11.c
|
|
43
|
+
yeptris/resolve/json12.c
|
|
44
|
+
yeptris/resolve/full12.c
|
|
45
|
+
yeptris/parse/numbers.c
|
|
46
|
+
yeptris/events/values.c
|
|
47
|
+
yeptris/schema.c
|
|
48
|
+
yeptris/validate/regexp.c
|
|
49
|
+
yeptris/validate/validate.c
|
|
50
|
+
yeptris/validate/compile.c
|
|
51
|
+
yeptris/validate/resources.c
|
|
52
|
+
yeptris/validate/jsonschema.c
|
|
53
|
+
yeptris/validate/registry.c
|
|
54
|
+
yeptris/validate/output.c
|
|
55
|
+
yeptris/validate/stream.c
|
|
56
|
+
yeptris/tape.c
|
|
57
|
+
yeptris/plan.c
|
|
58
|
+
|
|
59
|
+
yeptris/marshal.c
|
|
60
|
+
yeptris/marshal/to_json.c
|
|
61
|
+
yeptris/visit/json_visit.c
|
|
62
|
+
yeptris/visit/yaml_visit.c
|
|
63
|
+
yeptris/visit/dom_visit.c
|
|
64
|
+
yeptris/emit/style.c
|
|
65
|
+
yeptris/emit/writer.c
|
|
66
|
+
yeptris/emit/emit.c
|
|
67
|
+
yeptris/emit/float/print.c
|
|
68
|
+
yeptris/emit/float/dragon.c
|
|
69
|
+
yeptris/emit/float/fpconv.c
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
if(YEPTRIS_WITH_CBOR)
|
|
73
|
+
list(APPEND YEPTRIS_SOURCES yeptris/cbor/decode.c yeptris/cbor/encode.c
|
|
74
|
+
yeptris/cbor/from_marshal.c)
|
|
75
|
+
endif()
|
|
76
|
+
|
|
77
|
+
# AOT SIMD TUs (TODO.impl/04): per-ISA compile flags; the TUs and the
|
|
78
|
+
# dispatch share architecture guards, so links resolve on every platform.
|
|
79
|
+
# CMAKE_OSX_ARCHITECTURES participates: an -arch x86_64 cross-build on
|
|
80
|
+
# an arm Mac compiles the dispatch for x86 — the source pick must
|
|
81
|
+
# follow the TARGET arch, not the host (the all-platform wheels ride
|
|
82
|
+
# this; host-processor-only selection linked NEON objects into an
|
|
83
|
+
# x86_64 image).
|
|
84
|
+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|i[3-6]86)$" OR
|
|
85
|
+
CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
|
|
86
|
+
list(APPEND YEPTRIS_SOURCES yeptris/common/simd_text_avx2.c)
|
|
87
|
+
if(MSVC)
|
|
88
|
+
set_source_files_properties(yeptris/common/simd_text_avx2.c
|
|
89
|
+
PROPERTIES COMPILE_OPTIONS "/arch:AVX2")
|
|
90
|
+
else()
|
|
91
|
+
set_source_files_properties(yeptris/common/simd_text_avx2.c
|
|
92
|
+
PROPERTIES COMPILE_OPTIONS "-mavx2;-mpopcnt")
|
|
93
|
+
endif()
|
|
94
|
+
elseif((CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64|ARM64)$" OR
|
|
95
|
+
CMAKE_OSX_ARCHITECTURES MATCHES "arm64") AND NOT CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
|
|
96
|
+
list(APPEND YEPTRIS_SOURCES yeptris/common/simd_text_neon.c)
|
|
97
|
+
endif()
|
|
98
|
+
|
|
99
|
+
set(YEPTRIS_PUBLIC_HEADERS
|
|
100
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris.h
|
|
101
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/api.h
|
|
102
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/dom.h
|
|
103
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/error.h
|
|
104
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/events.h
|
|
105
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/emit.h
|
|
106
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/resolve.h
|
|
107
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/parse.h
|
|
108
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/values.h
|
|
109
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/schema.h
|
|
110
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/validate.h
|
|
111
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/tape.h
|
|
112
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/plan.h
|
|
113
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/marshal.h
|
|
114
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/visit.h
|
|
115
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/json.h
|
|
116
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/types.h
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
set(YEPTRIS_INCLUDE_DIRS
|
|
120
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
121
|
+
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/generated>
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
# json-c drop-in (TODO.impl/21): REAL json-c symbol names in its own
|
|
125
|
+
# library — users link -lyeptris-jsonc instead of -ljson-c.
|
|
126
|
+
option(YEPTRIS_BUILD_YAJL_COMPAT
|
|
127
|
+
"Build libyeptris-yajl: the yajl generator drop-in (TODO.impl/21)" ON)
|
|
128
|
+
if(YEPTRIS_BUILD_YAJL_COMPAT AND YEPTRIS_BUILD_STATIC)
|
|
129
|
+
add_library(yeptris_yajl STATIC yeptris/jsonapi/yajl_compat.c)
|
|
130
|
+
set_target_properties(yeptris_yajl PROPERTIES OUTPUT_NAME yeptris-yajl)
|
|
131
|
+
target_link_libraries(yeptris_yajl PUBLIC yeptris_static)
|
|
132
|
+
target_include_directories(yeptris_yajl PUBLIC
|
|
133
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
|
134
|
+
target_include_directories(yeptris_yajl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/yeptris)
|
|
135
|
+
yeptris_set_warnings(yeptris_yajl)
|
|
136
|
+
add_library(yeptris::yajl ALIAS yeptris_yajl)
|
|
137
|
+
endif()
|
|
138
|
+
|
|
139
|
+
if(YEPTRIS_BUILD_JSONC_COMPAT AND YEPTRIS_BUILD_STATIC)
|
|
140
|
+
add_library(yeptris_jsonc STATIC yeptris/jsonapi/jsonc_compat.c)
|
|
141
|
+
set_target_properties(yeptris_jsonc PROPERTIES OUTPUT_NAME yeptris-jsonc)
|
|
142
|
+
target_link_libraries(yeptris_jsonc PUBLIC yeptris_static)
|
|
143
|
+
target_include_directories(yeptris_jsonc PUBLIC
|
|
144
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
|
145
|
+
# internal headers (emit/writer.h, float/api.h): PRIVATE — they
|
|
146
|
+
# never leak into the compat library's public interface
|
|
147
|
+
target_include_directories(yeptris_jsonc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/yeptris)
|
|
148
|
+
yeptris_set_warnings(yeptris_jsonc)
|
|
149
|
+
add_library(yeptris::jsonc ALIAS yeptris_jsonc)
|
|
150
|
+
endif()
|
|
151
|
+
|
|
152
|
+
if(YEPTRIS_BUILD_STATIC)
|
|
153
|
+
find_package(Threads REQUIRED)
|
|
154
|
+
|
|
155
|
+
add_library(yeptris_static STATIC ${YEPTRIS_SOURCES})
|
|
156
|
+
add_library(yeptris::yeptris ALIAS yeptris_static)
|
|
157
|
+
set_target_properties(yeptris_static PROPERTIES OUTPUT_NAME yeptris)
|
|
158
|
+
target_include_directories(yeptris_static
|
|
159
|
+
PUBLIC ${YEPTRIS_INCLUDE_DIRS}
|
|
160
|
+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/yeptris) # internal root-relative includes
|
|
161
|
+
target_compile_definitions(yeptris_static PRIVATE YEPTRIS_BUILDING)
|
|
162
|
+
if(YEPTRIS_WITH_CBOR)
|
|
163
|
+
target_compile_definitions(yeptris_static PUBLIC YEPTRIS_WITH_CBOR)
|
|
164
|
+
endif()
|
|
165
|
+
target_link_libraries(yeptris_static PRIVATE Threads::Threads)
|
|
166
|
+
yeptris_set_warnings(yeptris_static)
|
|
167
|
+
endif()
|
|
168
|
+
|
|
169
|
+
if(YEPTRIS_BUILD_SHARED)
|
|
170
|
+
add_library(yeptris_shared SHARED ${YEPTRIS_SOURCES})
|
|
171
|
+
set_target_properties(yeptris_shared
|
|
172
|
+
PROPERTIES OUTPUT_NAME yeptris
|
|
173
|
+
SOVERSION ${PROJECT_VERSION_MAJOR})
|
|
174
|
+
target_include_directories(yeptris_shared
|
|
175
|
+
PUBLIC ${YEPTRIS_INCLUDE_DIRS}
|
|
176
|
+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/yeptris
|
|
177
|
+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/yeptris/emit/float)
|
|
178
|
+
target_compile_definitions(yeptris_shared PRIVATE YEPTRIS_BUILDING)
|
|
179
|
+
if(YEPTRIS_WITH_CBOR)
|
|
180
|
+
target_compile_definitions(yeptris_shared PUBLIC YEPTRIS_WITH_CBOR)
|
|
181
|
+
endif()
|
|
182
|
+
yeptris_set_warnings(yeptris_shared)
|
|
183
|
+
endif()
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* api.h — export control for libyeptris.
|
|
2
|
+
*
|
|
3
|
+
* The library is built with hidden visibility; exactly the YEPTRIS_API-marked
|
|
4
|
+
* surface is exported. Define YEPTRIS_BUILDING when compiling libyeptris
|
|
5
|
+
* itself; define YEPTRIS_SHARED when consuming the shared library on Windows.
|
|
6
|
+
*/
|
|
7
|
+
#ifndef YEPTRIS_API_H
|
|
8
|
+
/* YEPTRIS_CT_ASSERT — the compile-time layout gate, C99/MSVC-C-mode/
|
|
9
|
+
* C++ portable (typedef-array; libleptris's same migration): the old
|
|
10
|
+
* C11 _Static_assert was the ONE C11 feature pinning the standard. */
|
|
11
|
+
#define YEPTRIS_CT_ASSERT_(cond, line) typedef char yeptris_ct_assert_##line[(cond) ? 1 : -1]
|
|
12
|
+
#define YEPTRIS_CT_ASSERT(cond) YEPTRIS_CT_ASSERT_(cond, __LINE__)
|
|
13
|
+
|
|
14
|
+
#define YEPTRIS_API_H
|
|
15
|
+
|
|
16
|
+
#if defined(YEPTRIS_BUILDING) && defined(YEPTRIS_SHARED)
|
|
17
|
+
#error "define YEPTRIS_BUILDING (building) or YEPTRIS_SHARED (consuming), not both"
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
#if defined(YEPTRIS_BUILDING)
|
|
21
|
+
#if defined(_WIN32) || defined(__CYGWIN__)
|
|
22
|
+
#define YEPTRIS_API __declspec(dllexport)
|
|
23
|
+
#else
|
|
24
|
+
#define YEPTRIS_API __attribute__((visibility("default")))
|
|
25
|
+
#endif
|
|
26
|
+
#elif defined(YEPTRIS_SHARED) && (defined(_WIN32) || defined(__CYGWIN__))
|
|
27
|
+
#define YEPTRIS_API __declspec(dllimport)
|
|
28
|
+
#else
|
|
29
|
+
#define YEPTRIS_API
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
#endif /* YEPTRIS_API_H */
|