Skip to content

Commit 46527e0

Browse files
switch to the single-header Rapid YAML, upgrade to v0.5.0
Rapid YAML has an extensive CMake based build, which is probably ok but might be a pain to use from our other build systems (e.g., Bazel, which we probably want to continue supporting). However, Rapid YAML also provides a single-file amalgamation (aka unity build), which is of course much easier to embed.
1 parent 69512da commit 46527e0

File tree

308 files changed

+33677
-83826
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+33677
-83826
lines changed

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ option(BUILD_STATIC_LIBS "Build a static libjsonnet." ON)
1212
option(BUILD_SHARED_BINARIES "Link binaries to the shared libjsonnet instead of the static one." OFF)
1313
option(USE_SYSTEM_GTEST "Use system-provided gtest library" OFF)
1414
option(USE_SYSTEM_JSON "Use the system-provided json library" OFF)
15+
# TODO: Support using a system Rapid YAML install.
1516
set(GLOBAL_OUTPUT_PATH_SUFFIX "" CACHE STRING
1617
"Output artifacts directory.")
1718

@@ -109,6 +110,7 @@ link_directories(${GLOBAL_OUTPUT_PATH})
109110
include_directories(
110111
include
111112
third_party/md5
113+
third_party/rapidyaml
112114
core
113115
cpp)
114116

@@ -120,7 +122,7 @@ endif()
120122
add_subdirectory(include)
121123
add_subdirectory(stdlib)
122124
add_subdirectory(third_party/md5)
123-
add_subdirectory(third_party/rapidyaml/rapidyaml ryml)
125+
add_subdirectory(third_party/rapidyaml)
124126
add_subdirectory(core)
125127
add_subdirectory(cpp)
126128
add_subdirectory(cmd)

Makefile

+3-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ OPT ?= -O3
2828
PREFIX ?= /usr/local
2929

3030
CXXFLAGS ?= -g $(OPT) -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++17 -fPIC
31-
CXXFLAGS += -Iinclude -Ithird_party/md5 -Ithird_party/json -Ithird_party/rapidyaml/rapidyaml/src/ -Ithird_party/rapidyaml/rapidyaml/ext/c4core/src/
31+
CXXFLAGS += -Iinclude -Ithird_party/md5 -Ithird_party/json -Ithird_party/rapidyaml/
3232
CFLAGS ?= -g $(OPT) -Wall -Wextra -pedantic -std=c99 -fPIC
3333
CFLAGS += -Iinclude
34-
MAKEDEPENDFLAGS += -Iinclude -Ithird_party/md5 -Ithird_party/json -Ithird_party/rapidyaml/rapidyaml/src/ -Ithird_party/rapidyaml/rapidyaml/ext/c4core/src/
34+
MAKEDEPENDFLAGS += -Iinclude -Ithird_party/md5 -Ithird_party/json
3535
LDFLAGS ?=
3636

3737

@@ -45,8 +45,7 @@ SOVERSION = 0
4545
################################################################################
4646

4747
RAPIDYAML_SRC = \
48-
$(wildcard third_party/rapidyaml/rapidyaml/src/c4/yml/*.cpp) \
49-
$(wildcard third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/*.cpp)
48+
third_party/rapidyaml/rapidyaml.cpp
5049

5150
LIB_SRC = \
5251
core/desugarer.cpp \

core/vm.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ limitations under the License.
2626
#include "json.hpp"
2727
#include "md5.h"
2828
#include "parser.h"
29-
#include "ryml_std.hpp" // include this before any other ryml header
30-
#include "ryml.hpp"
29+
#include "ryml_all.hpp"
3130
#include "state.h"
3231
#include "static_analysis.h"
3332
#include "string_utils.h"
@@ -1637,7 +1636,7 @@ class Interpreter {
16371636
}
16381637

16391638
const ryml::Tree treeFromString(const std::string& s) {
1640-
return ryml::parse(c4::to_csubstr(s));
1639+
return ryml::parse_in_arena(ryml::to_csubstr(s));
16411640
}
16421641

16431642
const std::vector<std::string> split(const std::string& s, const std::string& delimiter) {

setup.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,7 @@
3232
'core/string_utils.o',
3333
'core/vm.o',
3434
'third_party/md5/md5.o',
35-
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/char_traits.o',
36-
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/base64.o',
37-
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/language.o',
38-
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/memory_util.o',
39-
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/format.o',
40-
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/time.o',
41-
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/memory_resource.o',
42-
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/error.o',
43-
'third_party/rapidyaml/rapidyaml/src/c4/yml/parse.o',
44-
'third_party/rapidyaml/rapidyaml/src/c4/yml/preprocess.o',
45-
'third_party/rapidyaml/rapidyaml/src/c4/yml/common.o',
46-
'third_party/rapidyaml/rapidyaml/src/c4/yml/tree.o',
35+
'third_party/rapidyaml/rapidyaml.o',
4736
]
4837

4938
MODULE_SOURCES = ['python/_jsonnet.c']

third_party/rapidyaml/BUILD

+8-36
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,15 @@
11
licenses(["permissive"])
2-
package(default_visibility = ["//visibility:private"])
3-
4-
cc_library(
5-
name = "debugbreak",
6-
hdrs = glob(["rapidyaml/ext/c4core/src/c4/ext/debugbreak/debugbreak.h"]),
7-
srcs = [],
8-
)
9-
10-
cc_library(
11-
name = "fastfloat",
12-
includes = ["rapidyaml/ext/c4core/src/c4/ext"],
13-
hdrs = glob(["rapidyaml/ext/c4core/src/c4/ext/fast_float.hpp", "rapidyaml/ext/c4core/src/c4/ext/fast_float/**/*.h"]),
14-
srcs = [],
15-
)
162

17-
cc_library(
18-
name = "c4core",
19-
deps = [
20-
":debugbreak",
21-
":fastfloat",
22-
],
23-
includes = ["rapidyaml/ext/c4core/src"],
24-
hdrs = glob(
25-
["rapidyaml/ext/c4core/src/**/*.hpp"],
26-
exclude = ["rapidyaml/ext/c4core/src/c4/ext/**/*"],
27-
),
28-
srcs = glob(
29-
["rapidyaml/ext/c4core/src/**/*.cpp"],
30-
exclude = ["rapidyaml/ext/c4core/src/c4/ext/**/*"],
31-
),
32-
)
3+
package(default_visibility = ["//visibility:private"])
334

345
cc_library(
356
name = "ryml",
36-
visibility = ["//visibility:public"],
37-
deps = [
38-
":c4core",
7+
srcs = [
8+
"rapidyaml.cpp",
9+
],
10+
hdrs = [
11+
"ryml_all.hpp",
3912
],
40-
includes = ["rapidyaml/src"],
41-
hdrs = glob(["rapidyaml/src/**/*.hpp"]),
42-
srcs = glob(["rapidyaml/src/**/*.cpp"]),
13+
includes = ["."],
14+
visibility = ["//visibility:public"],
4315
)

third_party/rapidyaml/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_library(ryml STATIC rapidyaml.cpp ryml_all.hpp)

third_party/rapidyaml/README.md

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
# Vendoring
22

3-
```
4-
git clone \
5-
--depth=1 \
6-
--branch=master \
7-
--recursive \
8-
[email protected]:biojppm/rapidyaml \
9-
third_party/rapidyaml/rapidyaml \
10-
&& \
11-
rm -rf third_party/rapidyaml/rapidyaml/.git
12-
```
3+
This uses the 'single header' release of Rapid YAML.
4+
Download from: https://github.com/biojppm/rapidyaml/releases/tag/v0.5.0
5+
6+
`rapidyaml-0.5.0.hpp` (renamed to `ryml_all.hpp`)
7+
8+
rapidyaml.cpp instantiates the library as a single translation unit.

third_party/rapidyaml/rapidyaml.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define RYML_SINGLE_HDR_DEFINE_NOW
2+
#include "ryml_all.hpp"

0 commit comments

Comments
 (0)