cmake interop work
This commit is contained in:
parent
29afc49c36
commit
ca96457590
11
.gdb_history
Normal file
11
.gdb_history
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
break ext_cmake.cc:14
|
||||||
|
r
|
||||||
|
r gen
|
||||||
|
print c_path
|
||||||
|
c
|
||||||
|
r gen
|
||||||
|
print std::filesystem::is_symlink(c_path)
|
||||||
|
print std::filesystem::read_symlink(c_path)
|
||||||
|
print std::filesystem::read_symlink(c_path)
|
||||||
|
print c_path
|
||||||
|
q
|
|
@ -7,8 +7,9 @@ message(${CMAKE_CXX_FLAGS_RELEASE})
|
||||||
add_subdirectory("vendor/sol2")
|
add_subdirectory("vendor/sol2")
|
||||||
|
|
||||||
include_directories("include")
|
include_directories("include")
|
||||||
|
include_directories("include/grbc")
|
||||||
include_directories("vendor/hotwire/src")
|
include_directories("vendor/hotwire/src")
|
||||||
include_directories("vendor/sol2/include")
|
include_directories("vendor/sol2/include")
|
||||||
|
|
||||||
add_executable(grbc src/ext_dynamic.cc vendor/hotwire/src/dlopen.c src/main.cc src/options.cc src/ext_easy.cc src/utils.cc src/file.cc src/target_exe.cc src/platform.cc src/ninja.cc src/generator.cc src/target_lib.cc src/package.cc src/ext.cc src/ext_pkg_config.cc src/task.cc src/ext_profiles.cc)
|
add_executable(grbc src/ext_dynamic.cc vendor/hotwire/src/dlopen.c src/main.cc src/options.cc src/ext_easy.cc src/utils.cc src/file.cc src/target_exe.cc src/platform.cc src/ninja.cc src/generator.cc src/target_lib.cc src/package.cc src/ext.cc src/ext_pkg_config.cc src/task.cc src/ext_profiles.cc src/ext_cmake.cc src/cJSON.c)
|
||||||
target_link_libraries(grbc sol2 lua)
|
target_link_libraries(grbc sol2 lua)
|
||||||
|
|
49
HConfig
49
HConfig
|
@ -3,6 +3,15 @@ grbc_ext("GRBC_EXT_pkg_config")
|
||||||
grbc_ext("GRBC_EXT_profiles")
|
grbc_ext("GRBC_EXT_profiles")
|
||||||
grbc_ext("GRBC_EXT_easy")
|
grbc_ext("GRBC_EXT_easy")
|
||||||
grbc_ext("GRBC_EXT_dynamic_extensions")
|
grbc_ext("GRBC_EXT_dynamic_extensions")
|
||||||
|
grbc_ext("GRBC_EXT_cmake")
|
||||||
|
|
||||||
|
local cmake_project = grbc_import_cmake("/tmp/SDL", CMakeConfig.new({
|
||||||
|
configure_arguments = {}
|
||||||
|
}))
|
||||||
|
|
||||||
|
print(cmake_project:get_library_string())
|
||||||
|
|
||||||
|
local sdl_pkg = cmake_project:get_library("SDL3-shared")
|
||||||
|
|
||||||
grbc_global_properties({
|
grbc_global_properties({
|
||||||
grbc_cxx_version("c++17")
|
grbc_cxx_version("c++17")
|
||||||
|
@ -38,6 +47,36 @@ local hotwire = grbc_library(LibraryConfig.new({
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
local cjson = grbc_library(LibraryConfig.new({
|
||||||
|
name = "libcjson",
|
||||||
|
language_type = LanguageType.C,
|
||||||
|
files = {
|
||||||
|
grbc_file("src/cJSON.c")
|
||||||
|
},
|
||||||
|
lib_type = LibraryType.Static,
|
||||||
|
|
||||||
|
requirements = {},
|
||||||
|
compile_flags = {},
|
||||||
|
linker_flags = {},
|
||||||
|
|
||||||
|
include_dirs = {
|
||||||
|
"include/grbc",
|
||||||
|
},
|
||||||
|
|
||||||
|
properties = {
|
||||||
|
},
|
||||||
|
|
||||||
|
package_config = PackageConfig.new({
|
||||||
|
name = "libcjson",
|
||||||
|
libraries = {},
|
||||||
|
include_dirs = {
|
||||||
|
grbc_file("include/grbc")
|
||||||
|
},
|
||||||
|
compile_flags = {},
|
||||||
|
linker_flags = {},
|
||||||
|
})
|
||||||
|
}))
|
||||||
|
|
||||||
local grbc_extensions = grbc_library(LibraryConfig.new({
|
local grbc_extensions = grbc_library(LibraryConfig.new({
|
||||||
name = "libgrbc_extensions",
|
name = "libgrbc_extensions",
|
||||||
language_type = LanguageType.Cpp,
|
language_type = LanguageType.Cpp,
|
||||||
|
@ -50,7 +89,8 @@ local grbc_extensions = grbc_library(LibraryConfig.new({
|
||||||
},
|
},
|
||||||
lib_type = LibraryType.Static,
|
lib_type = LibraryType.Static,
|
||||||
|
|
||||||
requirements = {},
|
requirements = {
|
||||||
|
},
|
||||||
compile_flags = {},
|
compile_flags = {},
|
||||||
linker_flags = {},
|
linker_flags = {},
|
||||||
|
|
||||||
|
@ -91,7 +131,8 @@ local grbc_lib = grbc_library(LibraryConfig.new({
|
||||||
lib_type = LibraryType.Static,
|
lib_type = LibraryType.Static,
|
||||||
|
|
||||||
requirements = {
|
requirements = {
|
||||||
grbc_pkg("libhotwire")
|
grbc_pkg("libhotwire"),
|
||||||
|
grbc_pkg("libcjson")
|
||||||
},
|
},
|
||||||
compile_flags = {},
|
compile_flags = {},
|
||||||
linker_flags = {},
|
linker_flags = {},
|
||||||
|
@ -123,7 +164,9 @@ local grbc_exe = grbc_executable(ExecutableConfig.new({
|
||||||
grbc_pkg_config("lua"),
|
grbc_pkg_config("lua"),
|
||||||
grbc_pkg("libgrbc"),
|
grbc_pkg("libgrbc"),
|
||||||
grbc_pkg("libgrbc_extensions"),
|
grbc_pkg("libgrbc_extensions"),
|
||||||
grbc_pkg("libhotwire")
|
grbc_pkg("libhotwire"),
|
||||||
|
grbc_pkg("libcjson"),
|
||||||
|
sdl_pkg
|
||||||
},
|
},
|
||||||
compile_flags = {},
|
compile_flags = {},
|
||||||
linker_flags = {},
|
linker_flags = {},
|
||||||
|
|
41
build.ninja
41
build.ninja
|
@ -1,5 +1,5 @@
|
||||||
### GENERATED BY THE GRBC BUILT-IN NINJA GENERATOR ###
|
### GENERATED BY THE GRBC BUILT-IN NINJA GENERATOR ###
|
||||||
### GENERATED ON: 1728779034 ###
|
### GENERATED ON: 1728828711 ###
|
||||||
|
|
||||||
## Default variables ##
|
## Default variables ##
|
||||||
|
|
||||||
|
@ -50,6 +50,15 @@ build $builddir/vendor/hotwire/src/dlopen.o: cc vendor/hotwire/src/dlopen.c
|
||||||
|
|
||||||
build $builddir/libhotwire.a: archive $builddir/vendor/hotwire/src/dlopen.o
|
build $builddir/libhotwire.a: archive $builddir/vendor/hotwire/src/dlopen.o
|
||||||
|
|
||||||
|
## Compile: src/cJSON.c ##
|
||||||
|
|
||||||
|
build $builddir/src/cJSON.o: cc src/cJSON.c
|
||||||
|
p_cflags = -std=c++17 -Iinclude/grbc
|
||||||
|
|
||||||
|
## Link: libcjson.a ##
|
||||||
|
|
||||||
|
build $builddir/libcjson.a: archive $builddir/src/cJSON.o
|
||||||
|
|
||||||
## Compile: src/ext_pkg_config.cc ##
|
## Compile: src/ext_pkg_config.cc ##
|
||||||
|
|
||||||
build $builddir/src/ext_pkg_config.o: cxx src/ext_pkg_config.cc
|
build $builddir/src/ext_pkg_config.o: cxx src/ext_pkg_config.cc
|
||||||
|
@ -82,57 +91,57 @@ build $builddir/libgrbc_extensions.a: archive $builddir/src/ext_pkg_config.o $bu
|
||||||
## Compile: src/file.cc ##
|
## Compile: src/file.cc ##
|
||||||
|
|
||||||
build $builddir/src/file.o: cxx src/file.cc
|
build $builddir/src/file.o: cxx src/file.cc
|
||||||
p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include
|
p_cflags = -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include
|
||||||
|
|
||||||
## Compile: src/ninja.cc ##
|
## Compile: src/ninja.cc ##
|
||||||
|
|
||||||
build $builddir/src/ninja.o: cxx src/ninja.cc
|
build $builddir/src/ninja.o: cxx src/ninja.cc
|
||||||
p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include
|
p_cflags = -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include
|
||||||
|
|
||||||
## Compile: src/platform.cc ##
|
## Compile: src/platform.cc ##
|
||||||
|
|
||||||
build $builddir/src/platform.o: cxx src/platform.cc
|
build $builddir/src/platform.o: cxx src/platform.cc
|
||||||
p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include
|
p_cflags = -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include
|
||||||
|
|
||||||
## Compile: src/target_exe.cc ##
|
## Compile: src/target_exe.cc ##
|
||||||
|
|
||||||
build $builddir/src/target_exe.o: cxx src/target_exe.cc
|
build $builddir/src/target_exe.o: cxx src/target_exe.cc
|
||||||
p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include
|
p_cflags = -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include
|
||||||
|
|
||||||
## Compile: src/utils.cc ##
|
## Compile: src/utils.cc ##
|
||||||
|
|
||||||
build $builddir/src/utils.o: cxx src/utils.cc
|
build $builddir/src/utils.o: cxx src/utils.cc
|
||||||
p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include
|
p_cflags = -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include
|
||||||
|
|
||||||
## Compile: src/generator.cc ##
|
## Compile: src/generator.cc ##
|
||||||
|
|
||||||
build $builddir/src/generator.o: cxx src/generator.cc
|
build $builddir/src/generator.o: cxx src/generator.cc
|
||||||
p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include
|
p_cflags = -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include
|
||||||
|
|
||||||
## Compile: src/target_lib.cc ##
|
## Compile: src/target_lib.cc ##
|
||||||
|
|
||||||
build $builddir/src/target_lib.o: cxx src/target_lib.cc
|
build $builddir/src/target_lib.o: cxx src/target_lib.cc
|
||||||
p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include
|
p_cflags = -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include
|
||||||
|
|
||||||
## Compile: src/package.cc ##
|
## Compile: src/package.cc ##
|
||||||
|
|
||||||
build $builddir/src/package.o: cxx src/package.cc
|
build $builddir/src/package.o: cxx src/package.cc
|
||||||
p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include
|
p_cflags = -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include
|
||||||
|
|
||||||
## Compile: src/ext.cc ##
|
## Compile: src/ext.cc ##
|
||||||
|
|
||||||
build $builddir/src/ext.o: cxx src/ext.cc
|
build $builddir/src/ext.o: cxx src/ext.cc
|
||||||
p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include
|
p_cflags = -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include
|
||||||
|
|
||||||
## Compile: src/task.cc ##
|
## Compile: src/task.cc ##
|
||||||
|
|
||||||
build $builddir/src/task.o: cxx src/task.cc
|
build $builddir/src/task.o: cxx src/task.cc
|
||||||
p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include
|
p_cflags = -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include
|
||||||
|
|
||||||
## Compile: src/options.cc ##
|
## Compile: src/options.cc ##
|
||||||
|
|
||||||
build $builddir/src/options.o: cxx src/options.cc
|
build $builddir/src/options.o: cxx src/options.cc
|
||||||
p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include
|
p_cflags = -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include
|
||||||
|
|
||||||
## Link: libgrbc.a ##
|
## Link: libgrbc.a ##
|
||||||
|
|
||||||
|
@ -141,12 +150,12 @@ build $builddir/libgrbc.a: archive $builddir/src/file.o $builddir/src/ninja.o $b
|
||||||
## Compile: src/main.cc ##
|
## Compile: src/main.cc ##
|
||||||
|
|
||||||
build $builddir/src/main.o: cxx src/main.cc
|
build $builddir/src/main.o: cxx src/main.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -Ivendor/hotwire/src -std=c++17
|
p_cflags = -Iinclude -Ivendor/sol2/include -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -Ivendor/hotwire/src -Iinclude/grbc -std=c++17
|
||||||
|
|
||||||
## Link: grbc ##
|
## Link: grbc ##
|
||||||
|
|
||||||
build $builddir/grbc: link_cxx $builddir/src/main.o | $builddir/libgrbc.a $builddir/libgrbc_extensions.a $builddir/libhotwire.a
|
build $builddir/grbc: link_cxx $builddir/src/main.o | $builddir/libgrbc.a $builddir/libgrbc_extensions.a $builddir/libhotwire.a $builddir/libcjson.a
|
||||||
p_linker_flags = -llua -lm -ldl build/libgrbc.a build/libgrbc_extensions.a build/libhotwire.a -O3 -DNDEBUG -Lbuild -Wl,-rpath,build:.
|
p_linker_flags = -llua -lm -ldl build/libgrbc.a build/libgrbc_extensions.a build/libhotwire.a build/libcjson.a -L/tmp/SDL/grbc_configure /tmp/SDL/grbc_configure/libSDL3.so.0.1.5 -O3 -DNDEBUG -Lbuild -Wl,-rpath,build:.
|
||||||
p_cflags =
|
p_cflags =
|
||||||
|
|
||||||
## clean ##
|
## clean ##
|
||||||
|
@ -163,6 +172,6 @@ rule compdb_task
|
||||||
|
|
||||||
build compdb: compdb_task
|
build compdb: compdb_task
|
||||||
|
|
||||||
build all: phony $builddir/libhotwire.a $builddir/libgrbc_extensions.a $builddir/libgrbc.a $builddir/grbc
|
build all: phony $builddir/libhotwire.a $builddir/libcjson.a $builddir/libgrbc_extensions.a $builddir/libgrbc.a $builddir/grbc
|
||||||
|
|
||||||
default all
|
default all
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/gcc -MMD -MT build/vendor/hotwire/src/dlopen.o -MF build/vendor/hotwire/src/dlopen.o.d -Ivendor/hotwire/src -g -O3 -DNDEBUG -c vendor/hotwire/src/dlopen.c -o build/vendor/hotwire/src/dlopen.o",
|
"command": "/usr/lib64/ccache/gcc -MMD -MT build/vendor/hotwire/src/dlopen.o -MF build/vendor/hotwire/src/dlopen.o.d -std=c++17 -Ivendor/hotwire/src -c vendor/hotwire/src/dlopen.c -o build/vendor/hotwire/src/dlopen.o",
|
||||||
"file": "vendor/hotwire/src/dlopen.c",
|
"file": "vendor/hotwire/src/dlopen.c",
|
||||||
"output": "build/vendor/hotwire/src/dlopen.o"
|
"output": "build/vendor/hotwire/src/dlopen.o"
|
||||||
},
|
},
|
||||||
|
@ -13,31 +13,43 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext_pkg_config.o -MF build/src/ext_pkg_config.o.d -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/ext_pkg_config.cc -o build/src/ext_pkg_config.o",
|
"command": "/usr/lib64/ccache/gcc -MMD -MT build/src/cJSON.o -MF build/src/cJSON.o.d -std=c++17 -Iinclude/grbc -c src/cJSON.c -o build/src/cJSON.o",
|
||||||
|
"file": "src/cJSON.c",
|
||||||
|
"output": "build/src/cJSON.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
|
"command": "rm -f build/libcjson.a; ar crs build/libcjson.a build/src/cJSON.o",
|
||||||
|
"file": "build/src/cJSON.o",
|
||||||
|
"output": "build/libcjson.a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext_pkg_config.o -MF build/src/ext_pkg_config.o.d -std=c++17 -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -c src/ext_pkg_config.cc -o build/src/ext_pkg_config.o",
|
||||||
"file": "src/ext_pkg_config.cc",
|
"file": "src/ext_pkg_config.cc",
|
||||||
"output": "build/src/ext_pkg_config.o"
|
"output": "build/src/ext_pkg_config.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext_profiles.o -MF build/src/ext_profiles.o.d -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/ext_profiles.cc -o build/src/ext_profiles.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext_profiles.o -MF build/src/ext_profiles.o.d -std=c++17 -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -c src/ext_profiles.cc -o build/src/ext_profiles.o",
|
||||||
"file": "src/ext_profiles.cc",
|
"file": "src/ext_profiles.cc",
|
||||||
"output": "build/src/ext_profiles.o"
|
"output": "build/src/ext_profiles.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext_easy.o -MF build/src/ext_easy.o.d -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/ext_easy.cc -o build/src/ext_easy.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext_easy.o -MF build/src/ext_easy.o.d -std=c++17 -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -c src/ext_easy.cc -o build/src/ext_easy.o",
|
||||||
"file": "src/ext_easy.cc",
|
"file": "src/ext_easy.cc",
|
||||||
"output": "build/src/ext_easy.o"
|
"output": "build/src/ext_easy.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext_dynamic.o -MF build/src/ext_dynamic.o.d -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/ext_dynamic.cc -o build/src/ext_dynamic.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext_dynamic.o -MF build/src/ext_dynamic.o.d -std=c++17 -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -c src/ext_dynamic.cc -o build/src/ext_dynamic.o",
|
||||||
"file": "src/ext_dynamic.cc",
|
"file": "src/ext_dynamic.cc",
|
||||||
"output": "build/src/ext_dynamic.o"
|
"output": "build/src/ext_dynamic.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext_cmake.o -MF build/src/ext_cmake.o.d -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/ext_cmake.cc -o build/src/ext_cmake.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext_cmake.o -MF build/src/ext_cmake.o.d -std=c++17 -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -c src/ext_cmake.cc -o build/src/ext_cmake.o",
|
||||||
"file": "src/ext_cmake.cc",
|
"file": "src/ext_cmake.cc",
|
||||||
"output": "build/src/ext_cmake.o"
|
"output": "build/src/ext_cmake.o"
|
||||||
},
|
},
|
||||||
|
@ -49,67 +61,67 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/file.o -MF build/src/file.o.d -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/file.cc -o build/src/file.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/file.o -MF build/src/file.o.d -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include -c src/file.cc -o build/src/file.o",
|
||||||
"file": "src/file.cc",
|
"file": "src/file.cc",
|
||||||
"output": "build/src/file.o"
|
"output": "build/src/file.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ninja.o -MF build/src/ninja.o.d -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/ninja.cc -o build/src/ninja.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ninja.o -MF build/src/ninja.o.d -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include -c src/ninja.cc -o build/src/ninja.o",
|
||||||
"file": "src/ninja.cc",
|
"file": "src/ninja.cc",
|
||||||
"output": "build/src/ninja.o"
|
"output": "build/src/ninja.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/platform.o -MF build/src/platform.o.d -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/platform.cc -o build/src/platform.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/platform.o -MF build/src/platform.o.d -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include -c src/platform.cc -o build/src/platform.o",
|
||||||
"file": "src/platform.cc",
|
"file": "src/platform.cc",
|
||||||
"output": "build/src/platform.o"
|
"output": "build/src/platform.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/target_exe.o -MF build/src/target_exe.o.d -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/target_exe.cc -o build/src/target_exe.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/target_exe.o -MF build/src/target_exe.o.d -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include -c src/target_exe.cc -o build/src/target_exe.o",
|
||||||
"file": "src/target_exe.cc",
|
"file": "src/target_exe.cc",
|
||||||
"output": "build/src/target_exe.o"
|
"output": "build/src/target_exe.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/utils.o -MF build/src/utils.o.d -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/utils.cc -o build/src/utils.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/utils.o -MF build/src/utils.o.d -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include -c src/utils.cc -o build/src/utils.o",
|
||||||
"file": "src/utils.cc",
|
"file": "src/utils.cc",
|
||||||
"output": "build/src/utils.o"
|
"output": "build/src/utils.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/generator.o -MF build/src/generator.o.d -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/generator.cc -o build/src/generator.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/generator.o -MF build/src/generator.o.d -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include -c src/generator.cc -o build/src/generator.o",
|
||||||
"file": "src/generator.cc",
|
"file": "src/generator.cc",
|
||||||
"output": "build/src/generator.o"
|
"output": "build/src/generator.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/target_lib.o -MF build/src/target_lib.o.d -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/target_lib.cc -o build/src/target_lib.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/target_lib.o -MF build/src/target_lib.o.d -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include -c src/target_lib.cc -o build/src/target_lib.o",
|
||||||
"file": "src/target_lib.cc",
|
"file": "src/target_lib.cc",
|
||||||
"output": "build/src/target_lib.o"
|
"output": "build/src/target_lib.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/package.o -MF build/src/package.o.d -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/package.cc -o build/src/package.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/package.o -MF build/src/package.o.d -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include -c src/package.cc -o build/src/package.o",
|
||||||
"file": "src/package.cc",
|
"file": "src/package.cc",
|
||||||
"output": "build/src/package.o"
|
"output": "build/src/package.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext.o -MF build/src/ext.o.d -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/ext.cc -o build/src/ext.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext.o -MF build/src/ext.o.d -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include -c src/ext.cc -o build/src/ext.o",
|
||||||
"file": "src/ext.cc",
|
"file": "src/ext.cc",
|
||||||
"output": "build/src/ext.o"
|
"output": "build/src/ext.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/task.o -MF build/src/task.o.d -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/task.cc -o build/src/task.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/task.o -MF build/src/task.o.d -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include -c src/task.cc -o build/src/task.o",
|
||||||
"file": "src/task.cc",
|
"file": "src/task.cc",
|
||||||
"output": "build/src/task.o"
|
"output": "build/src/task.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/options.o -MF build/src/options.o.d -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O3 -DNDEBUG -c src/options.cc -o build/src/options.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/options.o -MF build/src/options.o.d -Ivendor/hotwire/src -Iinclude/grbc -std=c++17 -Iinclude -Ivendor/sol2/include -c src/options.cc -o build/src/options.o",
|
||||||
"file": "src/options.cc",
|
"file": "src/options.cc",
|
||||||
"output": "build/src/options.o"
|
"output": "build/src/options.o"
|
||||||
},
|
},
|
||||||
|
@ -121,13 +133,13 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/main.o -MF build/src/main.o.d -Iinclude -Ivendor/sol2/include -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -Ivendor/hotwire/src -g -O3 -DNDEBUG -c src/main.cc -o build/src/main.o",
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/main.o -MF build/src/main.o.d -Iinclude -Ivendor/sol2/include -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -Ivendor/hotwire/src -std=c++17 -c src/main.cc -o build/src/main.o",
|
||||||
"file": "src/main.cc",
|
"file": "src/main.cc",
|
||||||
"output": "build/src/main.o"
|
"output": "build/src/main.o"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"directory": "/home/hstasonis/dev/grbc",
|
"directory": "/home/hstasonis/dev/grbc",
|
||||||
"command": "/usr/lib64/ccache/g++ -g -O3 -DNDEBUG -o build/grbc build/src/main.o -llua -lm -ldl build/libgrbc.a build/libgrbc_extensions.a build/libhotwire.a -Lbuild -Wl,-rpath,build:. ",
|
"command": "/usr/lib64/ccache/g++ -o build/grbc build/src/main.o -llua -lm -ldl build/libgrbc.a build/libgrbc_extensions.a build/libhotwire.a -O3 -DNDEBUG -Lbuild -Wl,-rpath,build:. ",
|
||||||
"file": "build/src/main.o",
|
"file": "build/src/main.o",
|
||||||
"output": "build/grbc"
|
"output": "build/grbc"
|
||||||
},
|
},
|
||||||
|
|
306
include/grbc/cJSON.h
Normal file
306
include/grbc/cJSON.h
Normal file
|
@ -0,0 +1,306 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cJSON__h
|
||||||
|
#define cJSON__h
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
||||||
|
#define __WINDOWS__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
|
||||||
|
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options:
|
||||||
|
|
||||||
|
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
|
||||||
|
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
|
||||||
|
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
|
||||||
|
|
||||||
|
For *nix builds that support visibility attribute, you can define similar behavior by
|
||||||
|
|
||||||
|
setting default visibility to hidden by adding
|
||||||
|
-fvisibility=hidden (for gcc)
|
||||||
|
or
|
||||||
|
-xldscope=hidden (for sun cc)
|
||||||
|
to CFLAGS
|
||||||
|
|
||||||
|
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define CJSON_CDECL __cdecl
|
||||||
|
#define CJSON_STDCALL __stdcall
|
||||||
|
|
||||||
|
/* export symbols by default, this is necessary for copy pasting the C and header file */
|
||||||
|
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
|
||||||
|
#define CJSON_EXPORT_SYMBOLS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CJSON_HIDE_SYMBOLS)
|
||||||
|
#define CJSON_PUBLIC(type) type CJSON_STDCALL
|
||||||
|
#elif defined(CJSON_EXPORT_SYMBOLS)
|
||||||
|
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
|
||||||
|
#elif defined(CJSON_IMPORT_SYMBOLS)
|
||||||
|
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
|
||||||
|
#endif
|
||||||
|
#else /* !__WINDOWS__ */
|
||||||
|
#define CJSON_CDECL
|
||||||
|
#define CJSON_STDCALL
|
||||||
|
|
||||||
|
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
||||||
|
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
||||||
|
#else
|
||||||
|
#define CJSON_PUBLIC(type) type
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* project version */
|
||||||
|
#define CJSON_VERSION_MAJOR 1
|
||||||
|
#define CJSON_VERSION_MINOR 7
|
||||||
|
#define CJSON_VERSION_PATCH 18
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/* cJSON Types: */
|
||||||
|
#define cJSON_Invalid (0)
|
||||||
|
#define cJSON_False (1 << 0)
|
||||||
|
#define cJSON_True (1 << 1)
|
||||||
|
#define cJSON_NULL (1 << 2)
|
||||||
|
#define cJSON_Number (1 << 3)
|
||||||
|
#define cJSON_String (1 << 4)
|
||||||
|
#define cJSON_Array (1 << 5)
|
||||||
|
#define cJSON_Object (1 << 6)
|
||||||
|
#define cJSON_Raw (1 << 7) /* raw json */
|
||||||
|
|
||||||
|
#define cJSON_IsReference 256
|
||||||
|
#define cJSON_StringIsConst 512
|
||||||
|
|
||||||
|
/* The cJSON structure: */
|
||||||
|
typedef struct cJSON
|
||||||
|
{
|
||||||
|
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||||
|
struct cJSON *next;
|
||||||
|
struct cJSON *prev;
|
||||||
|
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||||
|
struct cJSON *child;
|
||||||
|
|
||||||
|
/* The type of the item, as above. */
|
||||||
|
int type;
|
||||||
|
|
||||||
|
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
|
||||||
|
char *valuestring;
|
||||||
|
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
|
||||||
|
int valueint;
|
||||||
|
/* The item's number, if type==cJSON_Number */
|
||||||
|
double valuedouble;
|
||||||
|
|
||||||
|
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||||
|
char *string;
|
||||||
|
} cJSON;
|
||||||
|
|
||||||
|
typedef struct cJSON_Hooks
|
||||||
|
{
|
||||||
|
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
|
||||||
|
void *(CJSON_CDECL *malloc_fn)(size_t sz);
|
||||||
|
void (CJSON_CDECL *free_fn)(void *ptr);
|
||||||
|
} cJSON_Hooks;
|
||||||
|
|
||||||
|
typedef int cJSON_bool;
|
||||||
|
|
||||||
|
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
|
||||||
|
* This is to prevent stack overflows. */
|
||||||
|
#ifndef CJSON_NESTING_LIMIT
|
||||||
|
#define CJSON_NESTING_LIMIT 1000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Limits the length of circular references can be before cJSON rejects to parse them.
|
||||||
|
* This is to prevent stack overflows. */
|
||||||
|
#ifndef CJSON_CIRCULAR_LIMIT
|
||||||
|
#define CJSON_CIRCULAR_LIMIT 10000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* returns the version of cJSON as a string */
|
||||||
|
CJSON_PUBLIC(const char*) cJSON_Version(void);
|
||||||
|
|
||||||
|
/* Supply malloc, realloc and free functions to cJSON */
|
||||||
|
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||||
|
|
||||||
|
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
|
||||||
|
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
|
||||||
|
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||||
|
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||||
|
|
||||||
|
/* Render a cJSON entity to text for transfer/storage. */
|
||||||
|
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
|
||||||
|
/* Render a cJSON entity to text for transfer/storage without any formatting. */
|
||||||
|
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
|
||||||
|
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
||||||
|
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
|
||||||
|
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
|
||||||
|
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
|
||||||
|
/* Delete a cJSON entity and all subentities. */
|
||||||
|
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
|
||||||
|
|
||||||
|
/* Returns the number of items in an array (or object). */
|
||||||
|
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
||||||
|
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
|
||||||
|
/* Get item "string" from object. Case insensitive. */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||||
|
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||||
|
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||||
|
|
||||||
|
/* Check item type and return its value */
|
||||||
|
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
|
||||||
|
|
||||||
|
/* These functions check the type of an item */
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
|
||||||
|
|
||||||
|
/* These calls create a cJSON item of the appropriate type. */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
|
||||||
|
/* raw json */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
|
||||||
|
|
||||||
|
/* Create a string where valuestring references a string so
|
||||||
|
* it will not be freed by cJSON_Delete */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
|
||||||
|
/* Create an object/array that only references it's elements so
|
||||||
|
* they will not be freed by cJSON_Delete */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
|
||||||
|
|
||||||
|
/* These utilities create an Array of count items.
|
||||||
|
* The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
|
||||||
|
|
||||||
|
/* Append item to the specified array/object. */
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||||
|
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
|
||||||
|
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
|
||||||
|
* writing to `item->string` */
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
|
||||||
|
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||||
|
|
||||||
|
/* Remove/Detach items from Arrays/Objects. */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
|
||||||
|
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||||
|
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
|
||||||
|
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||||
|
|
||||||
|
/* Update array items. */
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
|
||||||
|
|
||||||
|
/* Duplicate a cJSON item */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
|
||||||
|
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||||
|
* need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||||
|
* The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||||
|
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
|
||||||
|
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
|
||||||
|
|
||||||
|
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
|
||||||
|
* The input pointer json cannot point to a read-only address area, such as a string constant,
|
||||||
|
* but should point to a readable and writable address area. */
|
||||||
|
CJSON_PUBLIC(void) cJSON_Minify(char *json);
|
||||||
|
|
||||||
|
/* Helper functions for creating and adding items to an object at the same time.
|
||||||
|
* They return the added item or NULL on failure. */
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
|
||||||
|
|
||||||
|
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||||
|
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
|
||||||
|
/* helper for the cJSON_SetNumberValue macro */
|
||||||
|
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
|
||||||
|
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
||||||
|
/* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */
|
||||||
|
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
|
||||||
|
|
||||||
|
/* If the object is not a boolean type this does nothing and returns cJSON_Invalid else it returns the new type*/
|
||||||
|
#define cJSON_SetBoolValue(object, boolValue) ( \
|
||||||
|
(object != NULL && ((object)->type & (cJSON_False|cJSON_True))) ? \
|
||||||
|
(object)->type=((object)->type &(~(cJSON_False|cJSON_True)))|((boolValue)?cJSON_True:cJSON_False) : \
|
||||||
|
cJSON_Invalid\
|
||||||
|
)
|
||||||
|
|
||||||
|
/* Macro for iterating over an array or object */
|
||||||
|
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
||||||
|
|
||||||
|
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
|
||||||
|
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
|
||||||
|
CJSON_PUBLIC(void) cJSON_free(void *object);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,4 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "grbc/cJSON.h"
|
||||||
#include "grbc/ext.h"
|
#include "grbc/ext.h"
|
||||||
#include "sol/table.hpp"
|
#include "sol/table.hpp"
|
||||||
|
|
||||||
|
@ -17,6 +18,9 @@ struct CMakeProject {
|
||||||
|
|
||||||
/// Build directory
|
/// Build directory
|
||||||
std::string build_dir;
|
std::string build_dir;
|
||||||
|
|
||||||
|
/// Parsed compilation database
|
||||||
|
cJSON* compdb = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
Extension grbc_cmake();
|
Extension grbc_cmake();
|
3164
src/cJSON.c
Normal file
3164
src/cJSON.c
Normal file
File diff suppressed because it is too large
Load diff
130
src/ext_cmake.cc
130
src/ext_cmake.cc
|
@ -1,4 +1,5 @@
|
||||||
#include "grbc/ext_cmake.h"
|
#include "grbc/ext_cmake.h"
|
||||||
|
#include "grbc/cJSON.h"
|
||||||
#include "grbc/ext.h"
|
#include "grbc/ext.h"
|
||||||
#include "grbc/helpers.h"
|
#include "grbc/helpers.h"
|
||||||
#include "grbc/spec.h"
|
#include "grbc/spec.h"
|
||||||
|
@ -6,6 +7,43 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
|
std::filesystem::path cmake_eval_symlink(const std::filesystem::path &build_dir,
|
||||||
|
const std::filesystem::path &path) {
|
||||||
|
std::filesystem::path c_path = path;
|
||||||
|
|
||||||
|
while (std::filesystem::is_symlink(c_path)) {
|
||||||
|
c_path = std::filesystem::read_symlink(c_path);
|
||||||
|
|
||||||
|
// Make path absolute if its relative
|
||||||
|
if (c_path.is_relative())
|
||||||
|
c_path = path.parent_path() / c_path;
|
||||||
|
|
||||||
|
std::filesystem::path target_path = build_dir / c_path.filename();
|
||||||
|
|
||||||
|
if (std::filesystem::exists(target_path))
|
||||||
|
std::filesystem::remove(target_path);
|
||||||
|
|
||||||
|
std::filesystem::copy(c_path, target_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return c_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string cmake_util_read_file(FILE *file) {
|
||||||
|
// http://www.fundza.com/c4serious/fileIO_reading_all/index.html
|
||||||
|
|
||||||
|
char line[190];
|
||||||
|
std::string result;
|
||||||
|
|
||||||
|
while (fgets(line, 190, file))
|
||||||
|
result += line;
|
||||||
|
|
||||||
|
if (result.back() == '\n')
|
||||||
|
result.pop_back();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
CMakeProject EXT_grbc_import_cmake(const std::string &cmake_path,
|
CMakeProject EXT_grbc_import_cmake(const std::string &cmake_path,
|
||||||
const CMakeConfig &cfg) {
|
const CMakeConfig &cfg) {
|
||||||
CMakeProject project{};
|
CMakeProject project{};
|
||||||
|
@ -30,6 +68,8 @@ CMakeProject EXT_grbc_import_cmake(const std::string &cmake_path,
|
||||||
|
|
||||||
std::filesystem::current_path("./grbc_configure");
|
std::filesystem::current_path("./grbc_configure");
|
||||||
|
|
||||||
|
project.build_dir = std::filesystem::current_path().string();
|
||||||
|
|
||||||
// Create configure arg string
|
// Create configure arg string
|
||||||
std::string configure_arguments;
|
std::string configure_arguments;
|
||||||
|
|
||||||
|
@ -44,6 +84,15 @@ CMakeProject EXT_grbc_import_cmake(const std::string &cmake_path,
|
||||||
if (exit_code != EXIT_SUCCESS)
|
if (exit_code != EXIT_SUCCESS)
|
||||||
grbc_exception("Failed to configure cmake project in: " + cmake_path);
|
grbc_exception("Failed to configure cmake project in: " + cmake_path);
|
||||||
|
|
||||||
|
// Collect compilation database
|
||||||
|
FILE *compdb = popen("ninja -t compdb", "r");
|
||||||
|
|
||||||
|
std::string compdb_raw = cmake_util_read_file(compdb);
|
||||||
|
|
||||||
|
pclose(compdb);
|
||||||
|
|
||||||
|
project.compdb = cJSON_Parse(compdb_raw.c_str());
|
||||||
|
|
||||||
std::filesystem::current_path(old_path);
|
std::filesystem::current_path(old_path);
|
||||||
|
|
||||||
return project;
|
return project;
|
||||||
|
@ -51,7 +100,85 @@ CMakeProject EXT_grbc_import_cmake(const std::string &cmake_path,
|
||||||
|
|
||||||
Package EXT_grbc_get_cmake_library(const CMakeProject &self,
|
Package EXT_grbc_get_cmake_library(const CMakeProject &self,
|
||||||
const std::string &library_name) {
|
const std::string &library_name) {
|
||||||
std::filesystem::path library_path = library_name;
|
|
||||||
|
// Loop over every output in the compdb
|
||||||
|
|
||||||
|
for (int i = 0; i < cJSON_GetArraySize(self.compdb); i++) {
|
||||||
|
cJSON *compdb_item = cJSON_GetArrayItem(self.compdb, i);
|
||||||
|
|
||||||
|
if (!cJSON_HasObjectItem(compdb_item, "output"))
|
||||||
|
grbc_exception("Ninja produced invalid compilation database!");
|
||||||
|
|
||||||
|
if (!cJSON_HasObjectItem(compdb_item, "command"))
|
||||||
|
grbc_exception("Compilation database item is missing 'command'");
|
||||||
|
|
||||||
|
if (!cJSON_HasObjectItem(compdb_item, "file"))
|
||||||
|
grbc_exception("Compilation database item is missing 'file'");
|
||||||
|
|
||||||
|
std::string command =
|
||||||
|
cJSON_GetStringValue(cJSON_GetObjectItem(compdb_item, "command"));
|
||||||
|
|
||||||
|
// Only handle objects with an empty command
|
||||||
|
// In the compilation databse objects with no command, but an output, and
|
||||||
|
// file give us the info we need Info needed: Target name, output name
|
||||||
|
|
||||||
|
if (!command.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
std::string output_name =
|
||||||
|
cJSON_GetStringValue(cJSON_GetObjectItem(compdb_item, "output"));
|
||||||
|
std::string library_path =
|
||||||
|
cJSON_GetStringValue(cJSON_GetObjectItem(compdb_item, "file"));
|
||||||
|
|
||||||
|
if (output_name != library_name)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
std::filesystem::path full_lib_path = self.build_dir + "/" + library_path;
|
||||||
|
full_lib_path =
|
||||||
|
cmake_eval_symlink(grbc_get_config().build_dir, full_lib_path);
|
||||||
|
|
||||||
|
Package pkg{};
|
||||||
|
pkg.name = output_name;
|
||||||
|
pkg.linker_flags =
|
||||||
|
"-L" + self.build_dir + " " + full_lib_path.generic_string();
|
||||||
|
|
||||||
|
grbc_log("found cmake library at: " + full_lib_path.generic_string());
|
||||||
|
|
||||||
|
return pkg;
|
||||||
|
}
|
||||||
|
|
||||||
|
grbc_exception("Failed to find library with name: " + library_name);
|
||||||
|
|
||||||
|
return Package{};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string EXT_grbc_get_cmake_library_string(const CMakeProject &self) {
|
||||||
|
std::string library_string;
|
||||||
|
|
||||||
|
for (int i = 0; i < cJSON_GetArraySize(self.compdb); i++) {
|
||||||
|
cJSON *compdb_item = cJSON_GetArrayItem(self.compdb, i);
|
||||||
|
|
||||||
|
if (!cJSON_HasObjectItem(compdb_item, "output"))
|
||||||
|
grbc_exception("Ninja produced invalid compilation database!");
|
||||||
|
|
||||||
|
if (!cJSON_HasObjectItem(compdb_item, "command"))
|
||||||
|
grbc_exception("Compilation database item is missing 'command'");
|
||||||
|
|
||||||
|
if (!cJSON_HasObjectItem(compdb_item, "file"))
|
||||||
|
grbc_exception("Compilation database item is missing 'file'");
|
||||||
|
|
||||||
|
std::string cmd = cJSON_GetStringValue(cJSON_GetObjectItem(compdb_item, "command"));
|
||||||
|
|
||||||
|
if (!cmd.empty()) continue;
|
||||||
|
|
||||||
|
std::string file = cJSON_GetStringValue(cJSON_GetObjectItem(compdb_item, "file"));
|
||||||
|
std::string output = cJSON_GetStringValue(cJSON_GetObjectItem(compdb_item, "output"));
|
||||||
|
|
||||||
|
library_string += "Target: " + output + "\n";
|
||||||
|
library_string += "\tOutputting to file: " + output + "\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return library_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void grbc_cmake_init(sol::state &lua) {
|
void grbc_cmake_init(sol::state &lua) {
|
||||||
|
@ -63,6 +190,7 @@ void grbc_cmake_init(sol::state &lua) {
|
||||||
&CMakeProject::build_dir);
|
&CMakeProject::build_dir);
|
||||||
|
|
||||||
lua["CMakeProject"]["get_library"] = EXT_grbc_get_cmake_library;
|
lua["CMakeProject"]["get_library"] = EXT_grbc_get_cmake_library;
|
||||||
|
lua["CMakeProject"]["get_library_string"] = EXT_grbc_get_cmake_library_string;
|
||||||
|
|
||||||
lua.set("grbc_import_cmake", EXT_grbc_import_cmake);
|
lua.set("grbc_import_cmake", EXT_grbc_import_cmake);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue