Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Rapid YAML to v0.5.0, and switch to the single file amalgamation #1134

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ option(BUILD_STATIC_LIBS "Build a static libjsonnet." ON)
option(BUILD_SHARED_BINARIES "Link binaries to the shared libjsonnet instead of the static one." OFF)
option(USE_SYSTEM_GTEST "Use system-provided gtest library" OFF)
option(USE_SYSTEM_JSON "Use the system-provided json library" OFF)
# TODO: Support using a system Rapid YAML install.
set(GLOBAL_OUTPUT_PATH_SUFFIX "" CACHE STRING
"Output artifacts directory.")

Expand Down Expand Up @@ -109,6 +110,7 @@ link_directories(${GLOBAL_OUTPUT_PATH})
include_directories(
include
third_party/md5
third_party/rapidyaml
core
cpp)

Expand All @@ -120,7 +122,7 @@ endif()
add_subdirectory(include)
add_subdirectory(stdlib)
add_subdirectory(third_party/md5)
add_subdirectory(third_party/rapidyaml/rapidyaml ryml)
add_subdirectory(third_party/rapidyaml)
add_subdirectory(core)
add_subdirectory(cpp)
add_subdirectory(cmd)
Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ OPT ?= -O3
PREFIX ?= /usr/local

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


Expand All @@ -45,8 +45,7 @@ SOVERSION = 0
################################################################################

RAPIDYAML_SRC = \
$(wildcard third_party/rapidyaml/rapidyaml/src/c4/yml/*.cpp) \
$(wildcard third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/*.cpp)
third_party/rapidyaml/rapidyaml.cpp

LIB_SRC = \
core/desugarer.cpp \
Expand Down
5 changes: 2 additions & 3 deletions core/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ limitations under the License.
#include <nlohmann/json.hpp>
#include "md5.h"
#include "parser.h"
#include "ryml_std.hpp" // include this before any other ryml header
#include "ryml.hpp"
#include "ryml_all.hpp"
#include "state.h"
#include "static_analysis.h"
#include "string_utils.h"
Expand Down Expand Up @@ -1637,7 +1636,7 @@ class Interpreter {
}

const ryml::Tree treeFromString(const std::string& s) {
return ryml::parse(c4::to_csubstr(s));
return ryml::parse_in_arena(ryml::to_csubstr(s));
}

const std::vector<std::string> split(const std::string& s, const std::string& delimiter) {
Expand Down
13 changes: 1 addition & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,7 @@
'core/string_utils.o',
'core/vm.o',
'third_party/md5/md5.o',
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/char_traits.o',
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/base64.o',
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/language.o',
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/memory_util.o',
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/format.o',
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/time.o',
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/memory_resource.o',
'third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/error.o',
'third_party/rapidyaml/rapidyaml/src/c4/yml/parse.o',
'third_party/rapidyaml/rapidyaml/src/c4/yml/preprocess.o',
'third_party/rapidyaml/rapidyaml/src/c4/yml/common.o',
'third_party/rapidyaml/rapidyaml/src/c4/yml/tree.o',
'third_party/rapidyaml/rapidyaml.o',
]

MODULE_SOURCES = ['python/_jsonnet.c']
Expand Down
44 changes: 8 additions & 36 deletions third_party/rapidyaml/BUILD
Original file line number Diff line number Diff line change
@@ -1,43 +1,15 @@
licenses(["permissive"])
package(default_visibility = ["//visibility:private"])

cc_library(
name = "debugbreak",
hdrs = glob(["rapidyaml/ext/c4core/src/c4/ext/debugbreak/debugbreak.h"]),
srcs = [],
)

cc_library(
name = "fastfloat",
includes = ["rapidyaml/ext/c4core/src/c4/ext"],
hdrs = glob(["rapidyaml/ext/c4core/src/c4/ext/fast_float.hpp", "rapidyaml/ext/c4core/src/c4/ext/fast_float/**/*.h"]),
srcs = [],
)

cc_library(
name = "c4core",
deps = [
":debugbreak",
":fastfloat",
],
includes = ["rapidyaml/ext/c4core/src"],
hdrs = glob(
["rapidyaml/ext/c4core/src/**/*.hpp"],
exclude = ["rapidyaml/ext/c4core/src/c4/ext/**/*"],
),
srcs = glob(
["rapidyaml/ext/c4core/src/**/*.cpp"],
exclude = ["rapidyaml/ext/c4core/src/c4/ext/**/*"],
),
)
package(default_visibility = ["//visibility:private"])

cc_library(
name = "ryml",
visibility = ["//visibility:public"],
deps = [
":c4core",
srcs = [
"rapidyaml.cpp",
],
hdrs = [
"ryml_all.hpp",
],
includes = ["rapidyaml/src"],
hdrs = glob(["rapidyaml/src/**/*.hpp"]),
srcs = glob(["rapidyaml/src/**/*.cpp"]),
includes = ["."],
visibility = ["//visibility:public"],
)
1 change: 1 addition & 0 deletions third_party/rapidyaml/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_library(ryml STATIC rapidyaml.cpp ryml_all.hpp)
16 changes: 6 additions & 10 deletions third_party/rapidyaml/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# Vendoring

```
git clone \
--depth=1 \
--branch=master \
--recursive \
[email protected]:biojppm/rapidyaml \
third_party/rapidyaml/rapidyaml \
&& \
rm -rf third_party/rapidyaml/rapidyaml/.git
```
This uses the 'single header' release of Rapid YAML.
Download from: https://github.com/biojppm/rapidyaml/releases/tag/v0.5.0

`rapidyaml-0.5.0.hpp` (renamed to `ryml_all.hpp`)

rapidyaml.cpp instantiates the library as a single translation unit.
2 changes: 2 additions & 0 deletions third_party/rapidyaml/rapidyaml.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define RYML_SINGLE_HDR_DEFINE_NOW
#include "ryml_all.hpp"
Loading