From 29afc49c366c2e773f1b1f959fec3d848a990e4f Mon Sep 17 00:00:00 2001 From: Interfiber Date: Sat, 12 Oct 2024 20:24:10 -0400 Subject: [PATCH] set c++ version --- CMakeFiles/VerifyGlobs.cmake | 22 --------- HConfig | 12 ++++- build.ninja | 47 ++++++++++--------- compile_commands.json | 88 +++++++++++++++++++----------------- fusion_ext/HConfig | 18 -------- fusion_ext/README.txt | 2 - fusion_ext/build.ninja | 57 ----------------------- fusion_ext/src/ext_fusion.cc | 10 ---- include/grbc/ext.h | 1 + include/grbc/ext_cmake.h | 22 +++++++++ include/grbc/spec.h | 40 +++++++++++++++- include/grbc/state.h | 2 + spec/datatypes.md | 17 +++++++ spec/functions.md | 11 ++++- src/ext_cmake.cc | 76 +++++++++++++++++++++++++++++++ src/ext_dynamic.cc | 4 +- src/main.cc | 8 ++++ src/target_exe.cc | 8 ++++ src/target_lib.cc | 9 ++++ src/utils.cc | 29 +++++++++++- 20 files changed, 304 insertions(+), 179 deletions(-) delete mode 100644 CMakeFiles/VerifyGlobs.cmake delete mode 100644 fusion_ext/HConfig delete mode 100644 fusion_ext/README.txt delete mode 100644 fusion_ext/build.ninja delete mode 100644 fusion_ext/src/ext_fusion.cc create mode 100644 include/grbc/ext_cmake.h create mode 100644 src/ext_cmake.cc diff --git a/CMakeFiles/VerifyGlobs.cmake b/CMakeFiles/VerifyGlobs.cmake deleted file mode 100644 index 1df23cb..0000000 --- a/CMakeFiles/VerifyGlobs.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by CMake Version 3.28 -cmake_policy(SET CMP0009 NEW) - -# sol2-headers at vendor/sol2/CMakeLists.txt:83 (file) -file(GLOB_RECURSE NEW_GLOB LIST_DIRECTORIES false "/home/interfiber/dev/grbc/vendor/sol2/include/sol*.hpp") -set(OLD_GLOB - "/home/interfiber/dev/grbc/vendor/sol2/include/sol/sol.hpp" - ) -if(NOT "${NEW_GLOB}" STREQUAL "${OLD_GLOB}") - message("-- GLOB mismatch!") - file(TOUCH_NOCREATE "/home/interfiber/dev/grbc/CMakeFiles/cmake.verify_globs") -endif() - -# sol2-sources at vendor/sol2/CMakeLists.txt:89 (file) -file(GLOB_RECURSE NEW_GLOB LIST_DIRECTORIES false "/home/interfiber/dev/grbc/vendor/sol2/source/**") -set(OLD_GLOB - ) -if(NOT "${NEW_GLOB}" STREQUAL "${OLD_GLOB}") - message("-- GLOB mismatch!") - file(TOUCH_NOCREATE "/home/interfiber/dev/grbc/CMakeFiles/cmake.verify_globs") -endif() diff --git a/HConfig b/HConfig index 5c31abe..2904950 100644 --- a/HConfig +++ b/HConfig @@ -4,6 +4,10 @@ grbc_ext("GRBC_EXT_profiles") grbc_ext("GRBC_EXT_easy") grbc_ext("GRBC_EXT_dynamic_extensions") +grbc_global_properties({ + grbc_cxx_version("c++17") +}) + local hotwire = grbc_library(LibraryConfig.new({ name = "libhotwire", language_type = LanguageType.C, @@ -20,6 +24,9 @@ local hotwire = grbc_library(LibraryConfig.new({ "vendor/hotwire/src", }, + properties = { + }, + package_config = PackageConfig.new({ name = "libhotwire", libraries = {}, @@ -38,7 +45,8 @@ local grbc_extensions = grbc_library(LibraryConfig.new({ grbc_file("src/ext_pkg_config.cc"), grbc_file("src/ext_profiles.cc"), grbc_file("src/ext_easy.cc"), - grbc_file("src/ext_dynamic.cc") + grbc_file("src/ext_dynamic.cc"), + grbc_file("src/ext_cmake.cc") }, lib_type = LibraryType.Static, @@ -123,4 +131,4 @@ local grbc_exe = grbc_executable(ExecutableConfig.new({ })) -- Output the final build script -grbc_build("ninja") \ No newline at end of file +grbc_build("ninja") diff --git a/build.ninja b/build.ninja index 1020412..53dbf4d 100644 --- a/build.ninja +++ b/build.ninja @@ -1,5 +1,5 @@ ### GENERATED BY THE GRBC BUILT-IN NINJA GENERATOR ### -### GENERATED ON: 1727740849 ### +### GENERATED ON: 1728779034 ### ## Default variables ## @@ -44,7 +44,7 @@ rule archive ## Compile: vendor/hotwire/src/dlopen.c ## build $builddir/vendor/hotwire/src/dlopen.o: cc vendor/hotwire/src/dlopen.c - p_cflags = -Ivendor/hotwire/src -g -O1 + p_cflags = -std=c++17 -Ivendor/hotwire/src ## Link: libhotwire.a ## @@ -53,81 +53,86 @@ build $builddir/libhotwire.a: archive $builddir/vendor/hotwire/src/dlopen.o ## Compile: src/ext_pkg_config.cc ## build $builddir/src/ext_pkg_config.o: cxx src/ext_pkg_config.cc - p_cflags = -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -g -O1 + p_cflags = -std=c++17 -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include ## Compile: src/ext_profiles.cc ## build $builddir/src/ext_profiles.o: cxx src/ext_profiles.cc - p_cflags = -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -g -O1 + p_cflags = -std=c++17 -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include ## Compile: src/ext_easy.cc ## build $builddir/src/ext_easy.o: cxx src/ext_easy.cc - p_cflags = -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -g -O1 + p_cflags = -std=c++17 -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include ## Compile: src/ext_dynamic.cc ## build $builddir/src/ext_dynamic.o: cxx src/ext_dynamic.cc - p_cflags = -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -g -O1 + p_cflags = -std=c++17 -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include + +## Compile: src/ext_cmake.cc ## + +build $builddir/src/ext_cmake.o: cxx src/ext_cmake.cc + p_cflags = -std=c++17 -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include ## Link: libgrbc_extensions.a ## -build $builddir/libgrbc_extensions.a: archive $builddir/src/ext_pkg_config.o $builddir/src/ext_profiles.o $builddir/src/ext_easy.o $builddir/src/ext_dynamic.o +build $builddir/libgrbc_extensions.a: archive $builddir/src/ext_pkg_config.o $builddir/src/ext_profiles.o $builddir/src/ext_easy.o $builddir/src/ext_dynamic.o $builddir/src/ext_cmake.o ## Compile: src/file.cc ## build $builddir/src/file.o: cxx src/file.cc - p_cflags = -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O1 + p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include ## Compile: src/ninja.cc ## build $builddir/src/ninja.o: cxx src/ninja.cc - p_cflags = -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O1 + p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include ## Compile: src/platform.cc ## build $builddir/src/platform.o: cxx src/platform.cc - p_cflags = -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O1 + p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include ## Compile: src/target_exe.cc ## build $builddir/src/target_exe.o: cxx src/target_exe.cc - p_cflags = -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O1 + p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include ## Compile: src/utils.cc ## build $builddir/src/utils.o: cxx src/utils.cc - p_cflags = -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O1 + p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include ## Compile: src/generator.cc ## build $builddir/src/generator.o: cxx src/generator.cc - p_cflags = -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O1 + p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include ## Compile: src/target_lib.cc ## build $builddir/src/target_lib.o: cxx src/target_lib.cc - p_cflags = -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O1 + p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include ## Compile: src/package.cc ## build $builddir/src/package.o: cxx src/package.cc - p_cflags = -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O1 + p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include ## Compile: src/ext.cc ## build $builddir/src/ext.o: cxx src/ext.cc - p_cflags = -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O1 + p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include ## Compile: src/task.cc ## build $builddir/src/task.o: cxx src/task.cc - p_cflags = -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O1 + p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include ## Compile: src/options.cc ## build $builddir/src/options.o: cxx src/options.cc - p_cflags = -Ivendor/hotwire/src -Iinclude -Ivendor/sol2/include -g -O1 + p_cflags = -Ivendor/hotwire/src -std=c++17 -Iinclude -Ivendor/sol2/include ## Link: libgrbc.a ## @@ -136,13 +141,13 @@ build $builddir/libgrbc.a: archive $builddir/src/file.o $builddir/src/ninja.o $b ## Compile: 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 -g -O1 + p_cflags = -Iinclude -Ivendor/sol2/include -Iinclude -Ivendor/hotwire/src -Ivendor/sol2/include -Ivendor/hotwire/src -std=c++17 ## Link: grbc ## build $builddir/grbc: link_cxx $builddir/src/main.o | $builddir/libgrbc.a $builddir/libgrbc_extensions.a $builddir/libhotwire.a - p_linker_flags = -llua -lm -ldl build/libgrbc.a build/libgrbc_extensions.a build/libhotwire.a -Lbuild -Wl,-rpath,build:. - p_cflags = -g -O1 + p_linker_flags = -llua -lm -ldl build/libgrbc.a build/libgrbc_extensions.a build/libhotwire.a -O3 -DNDEBUG -Lbuild -Wl,-rpath,build:. + p_cflags = ## clean ## rule clean_task diff --git a/compile_commands.json b/compile_commands.json index 3e05faf..20aee92 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -1,132 +1,138 @@ [ { - "directory": "/home/interfiber/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 -O1 -c vendor/hotwire/src/dlopen.c -o build/vendor/hotwire/src/dlopen.o", + "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", "file": "vendor/hotwire/src/dlopen.c", "output": "build/vendor/hotwire/src/dlopen.o" }, { - "directory": "/home/interfiber/dev/grbc", + "directory": "/home/hstasonis/dev/grbc", "command": "rm -f build/libhotwire.a; ar crs build/libhotwire.a build/vendor/hotwire/src/dlopen.o", "file": "build/vendor/hotwire/src/dlopen.o", "output": "build/libhotwire.a" }, { - "directory": "/home/interfiber/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 -O1 -c src/ext_pkg_config.cc -o build/src/ext_pkg_config.o", + "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", "file": "src/ext_pkg_config.cc", "output": "build/src/ext_pkg_config.o" }, { - "directory": "/home/interfiber/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 -O1 -c src/ext_profiles.cc -o build/src/ext_profiles.o", + "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", "file": "src/ext_profiles.cc", "output": "build/src/ext_profiles.o" }, { - "directory": "/home/interfiber/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 -O1 -c src/ext_easy.cc -o build/src/ext_easy.o", + "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", "file": "src/ext_easy.cc", "output": "build/src/ext_easy.o" }, { - "directory": "/home/interfiber/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 -O1 -c src/ext_dynamic.cc -o build/src/ext_dynamic.o", + "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", "file": "src/ext_dynamic.cc", "output": "build/src/ext_dynamic.o" }, { - "directory": "/home/interfiber/dev/grbc", - "command": "rm -f build/libgrbc_extensions.a; ar crs build/libgrbc_extensions.a build/src/ext_pkg_config.o build/src/ext_profiles.o build/src/ext_easy.o build/src/ext_dynamic.o", + "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", + "file": "src/ext_cmake.cc", + "output": "build/src/ext_cmake.o" + }, + { + "directory": "/home/hstasonis/dev/grbc", + "command": "rm -f build/libgrbc_extensions.a; ar crs build/libgrbc_extensions.a build/src/ext_pkg_config.o build/src/ext_profiles.o build/src/ext_easy.o build/src/ext_dynamic.o build/src/ext_cmake.o", "file": "build/src/ext_pkg_config.o", "output": "build/libgrbc_extensions.a" }, { - "directory": "/home/interfiber/dev/grbc", - "command": "/usr/lib64/ccache/g++ -MMD -MT build/src/file.o -MF build/src/file.o.d -Iinclude -Ivendor/sol2/include -g -O1 -c src/file.cc -o build/src/file.o", + "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", "file": "src/file.cc", "output": "build/src/file.o" }, { - "directory": "/home/interfiber/dev/grbc", - "command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ninja.o -MF build/src/ninja.o.d -Iinclude -Ivendor/sol2/include -g -O1 -c src/ninja.cc -o build/src/ninja.o", + "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", "file": "src/ninja.cc", "output": "build/src/ninja.o" }, { - "directory": "/home/interfiber/dev/grbc", - "command": "/usr/lib64/ccache/g++ -MMD -MT build/src/platform.o -MF build/src/platform.o.d -Iinclude -Ivendor/sol2/include -g -O1 -c src/platform.cc -o build/src/platform.o", + "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", "file": "src/platform.cc", "output": "build/src/platform.o" }, { - "directory": "/home/interfiber/dev/grbc", - "command": "/usr/lib64/ccache/g++ -MMD -MT build/src/target_exe.o -MF build/src/target_exe.o.d -Iinclude -Ivendor/sol2/include -g -O1 -c src/target_exe.cc -o build/src/target_exe.o", + "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", "file": "src/target_exe.cc", "output": "build/src/target_exe.o" }, { - "directory": "/home/interfiber/dev/grbc", - "command": "/usr/lib64/ccache/g++ -MMD -MT build/src/utils.o -MF build/src/utils.o.d -Iinclude -Ivendor/sol2/include -g -O1 -c src/utils.cc -o build/src/utils.o", + "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", "file": "src/utils.cc", "output": "build/src/utils.o" }, { - "directory": "/home/interfiber/dev/grbc", - "command": "/usr/lib64/ccache/g++ -MMD -MT build/src/generator.o -MF build/src/generator.o.d -Iinclude -Ivendor/sol2/include -g -O1 -c src/generator.cc -o build/src/generator.o", + "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", "file": "src/generator.cc", "output": "build/src/generator.o" }, { - "directory": "/home/interfiber/dev/grbc", - "command": "/usr/lib64/ccache/g++ -MMD -MT build/src/target_lib.o -MF build/src/target_lib.o.d -Iinclude -Ivendor/sol2/include -g -O1 -c src/target_lib.cc -o build/src/target_lib.o", + "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", "file": "src/target_lib.cc", "output": "build/src/target_lib.o" }, { - "directory": "/home/interfiber/dev/grbc", - "command": "/usr/lib64/ccache/g++ -MMD -MT build/src/package.o -MF build/src/package.o.d -Iinclude -Ivendor/sol2/include -g -O1 -c src/package.cc -o build/src/package.o", + "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", "file": "src/package.cc", "output": "build/src/package.o" }, { - "directory": "/home/interfiber/dev/grbc", - "command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext.o -MF build/src/ext.o.d -Iinclude -Ivendor/sol2/include -g -O1 -c src/ext.cc -o build/src/ext.o", + "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", "file": "src/ext.cc", "output": "build/src/ext.o" }, { - "directory": "/home/interfiber/dev/grbc", - "command": "/usr/lib64/ccache/g++ -MMD -MT build/src/task.o -MF build/src/task.o.d -Iinclude -Ivendor/sol2/include -g -O1 -c src/task.cc -o build/src/task.o", + "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", "file": "src/task.cc", "output": "build/src/task.o" }, { - "directory": "/home/interfiber/dev/grbc", - "command": "/usr/lib64/ccache/g++ -MMD -MT build/src/options.o -MF build/src/options.o.d -Iinclude -Ivendor/sol2/include -g -O1 -c src/options.cc -o build/src/options.o", + "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", "file": "src/options.cc", "output": "build/src/options.o" }, { - "directory": "/home/interfiber/dev/grbc", + "directory": "/home/hstasonis/dev/grbc", "command": "rm -f build/libgrbc.a; ar crs build/libgrbc.a build/src/file.o build/src/ninja.o build/src/platform.o build/src/target_exe.o build/src/utils.o build/src/generator.o build/src/target_lib.o build/src/package.o build/src/ext.o build/src/task.o build/src/options.o", "file": "build/src/file.o", "output": "build/libgrbc.a" }, { - "directory": "/home/interfiber/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 -O1 -c src/main.cc -o build/src/main.o", + "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", "file": "src/main.cc", "output": "build/src/main.o" }, { - "directory": "/home/interfiber/dev/grbc", - "command": "/usr/lib64/ccache/g++ -g -O1 -o build/grbc build/src/main.o -llua -lm -ldl build/libgrbc.a build/libgrbc_extensions.a build/libhotwire.a -Lbuild -Wl,-rpath,build:. ", + "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:. ", "file": "build/src/main.o", "output": "build/grbc" }, { - "directory": "/home/interfiber/dev/grbc", + "directory": "/home/hstasonis/dev/grbc", "command": "", "file": "build/libhotwire.a", "output": "all" diff --git a/fusion_ext/HConfig b/fusion_ext/HConfig deleted file mode 100644 index c2f5a19..0000000 --- a/fusion_ext/HConfig +++ /dev/null @@ -1,18 +0,0 @@ -local grbc_extensions = grbc_library(LibraryConfig.new({ - name = "libfusion", - language_type = LanguageType.Cpp, - files = { - grbc_file("src/ext_fusion.cc") - }, - lib_type = LibraryType.Shared, - - requirements = {}, - compile_flags = {}, - linker_flags = {}, - - include_dirs = { - "../vendor/sol2/include" - } -})) - -grbc_build("ninja") \ No newline at end of file diff --git a/fusion_ext/README.txt b/fusion_ext/README.txt deleted file mode 100644 index 5937df1..0000000 --- a/fusion_ext/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -FUSION GRBC EXTENSION - diff --git a/fusion_ext/build.ninja b/fusion_ext/build.ninja deleted file mode 100644 index 093abf7..0000000 --- a/fusion_ext/build.ninja +++ /dev/null @@ -1,57 +0,0 @@ -### GENERATED BY THE GRBC BUILT-IN NINJA GENERATOR ### -### GENERATED ON: 1727735253 ### - -## Default variables ## - -builddir = build - -## build_rule_compile_cc ## - -cc_path = /usr/lib64/ccache/gcc -rule cc - command = $cc_path -MMD -MT $out -MF $out.d $p_cflags -c $in -o $out - description = Compiling C object $in - depfile = $out.d - deps = gcc - -## build_rule_compile_cxx ## - -cxx_path = /usr/lib64/ccache/g++ -rule cxx - command = $cxx_path -MMD -MT $out -MF $out.d $p_cflags -c $in -o $out - description = Compiling C++ object $in - depfile = $out.d - deps = gcc - -## build_rule_link_cc ## - -rule link_cc - command = $cc_path $p_cflags -o $out $in $p_linker_flags - description = Linking C target $out - -## build_rule_link_cxx ## - -rule link_cxx - command = $cxx_path $p_cflags -o $out $in $p_linker_flags - description = Linking C++ target $out - -## build_rule_archive_library ## - -rule archive - command = rm -f $out; ar crs $out $in - description = Creating static library $out - -## Compile: src/ext_fusion.cc ## - -build $builddir/src/ext_fusion.o: cxx src/ext_fusion.cc - p_cflags = -fPIC -I../vendor/sol2/include - -## Link: libfusion.so ## - -build $builddir/libfusion.so: link_cxx $builddir/src/ext_fusion.o - p_linker_flags = -shared -Lbuild -Wl,-rpath,build:. - p_cflags = - -build all: phony $builddir/libfusion.so - -default all diff --git a/fusion_ext/src/ext_fusion.cc b/fusion_ext/src/ext_fusion.cc deleted file mode 100644 index cfe2de7..0000000 --- a/fusion_ext/src/ext_fusion.cc +++ /dev/null @@ -1,10 +0,0 @@ -#include "grbc/spec.h" -#include - -const char* GRBC_Get_Name() { - return "GRBC_EXT_Fusion"; -} - -void GRBC_Hook_Init(sol::state &lua) { - -} \ No newline at end of file diff --git a/include/grbc/ext.h b/include/grbc/ext.h index 2bcd12d..69545e4 100644 --- a/include/grbc/ext.h +++ b/include/grbc/ext.h @@ -6,6 +6,7 @@ #define GRBC_EXT_profiles_NAME "GRBC_EXT_profiles" #define GRBC_EXT_easy_NAME "GRBC_EXT_easy" #define GRBC_EXT_dynamic_extensions_NAME "GRBC_EXT_dynamic_extensions" +#define GRBC_EXT_cmake_NAME "GRBC_EXT_cmake" /// Called when the extension is loaded typedef void (*EXT_HookInit)(sol::state &lua); diff --git a/include/grbc/ext_cmake.h b/include/grbc/ext_cmake.h new file mode 100644 index 0000000..994ff1d --- /dev/null +++ b/include/grbc/ext_cmake.h @@ -0,0 +1,22 @@ +#pragma once +#include "grbc/ext.h" +#include "sol/table.hpp" + +struct CMakeConfig { + CMakeConfig(const sol::table &table) { + configure_arguments = table.get>("configure_arguments"); + } + + /// Configuration arguments + std::vector configure_arguments; +}; + +struct CMakeProject { + /// Source directory + std::string source_dir; + + /// Build directory + std::string build_dir; +}; + +Extension grbc_cmake(); \ No newline at end of file diff --git a/include/grbc/spec.h b/include/grbc/spec.h index b11794c..1ddf057 100644 --- a/include/grbc/spec.h +++ b/include/grbc/spec.h @@ -5,6 +5,8 @@ #include #include +#define GRBC_PROPERTY_CXX_VERSION "CXX_VERSION" + // https://stackoverflow.com/questions/1505582/determining-32-vs-64-bit-in-c #if _WIN32 || _WIN64 @@ -26,6 +28,21 @@ #define GRBC_VERSION "1.0" +struct Property { + Property() = default; + + Property(const sol::table &table) { + name = table.get("name"); + value = table.get("value"); + } + + /// Name of this property + std::string name; + + /// Value of this property + std::string value; +}; + enum LanguageType { LanguageType_CPP, LanguageType_C }; enum LibraryType { LibraryType_Shared, LibraryType_Static }; @@ -104,6 +121,10 @@ struct ExecutableConfig { include_dirs = table.get>("include_dirs"); language_type = table.get("language_type"); + + if (table["properties"].valid()) { + properties = table.get>("properties"); + } } /// Name of the executable @@ -126,6 +147,9 @@ struct ExecutableConfig { /// Include directories std::vector include_dirs{}; + + /// Optional list of properties + std::vector properties; }; struct TaskConfig { @@ -162,8 +186,11 @@ struct LibraryConfig { language_type = table.get("language_type"); lib_type = table.get("lib_type"); - if (!table["package_config"].is()) + if (table["package_config"].valid()) package_config = table.get("package_config"); + + if (table["properties"].valid()) + properties = table.get>("properties"); } /// Name of the executable @@ -192,6 +219,9 @@ struct LibraryConfig { /// Include directories std::vector include_dirs{}; + + /// Optional list of properties + std::vector properties; }; struct Platform { @@ -277,4 +307,10 @@ void grbc_task(const TaskConfig &config); bool grbc_has_option(const std::string &option_name); -std::string grbc_get_option(const std::string &option_name); \ No newline at end of file +std::string grbc_get_option(const std::string &option_name); + +Property grbc_property(const std::string &key, const std::string &value); + +Property grbc_cxx_version(const std::string &version_string); + +void grbc_global_properties(const sol::table &properties); \ No newline at end of file diff --git a/include/grbc/state.h b/include/grbc/state.h index 19df9fe..90618be 100644 --- a/include/grbc/state.h +++ b/include/grbc/state.h @@ -18,6 +18,8 @@ struct GState { std::map options; + std::vector global_properties; + std::unordered_map packages; std::vector extensions; diff --git a/spec/datatypes.md b/spec/datatypes.md index 12c9779..cac3818 100644 --- a/spec/datatypes.md +++ b/spec/datatypes.md @@ -63,6 +63,9 @@ struct LibraryConfig { /// Include directories Array include_dirs; + + /// Optional list of properties + Array properties; }; ``` @@ -97,6 +100,9 @@ struct ExecutableConfig { /// Include directories Array include_dirs; + + /// Optional list of properties + Array properties; }; ``` @@ -176,4 +182,15 @@ struct TaskConfig { /// Shell script to be executed when this task is called string shell_script; }; +``` + +## Property +```c++ +struct Property { + /// Property name + std::string name; + + /// Property value + std::string value; +}; ``` \ No newline at end of file diff --git a/spec/functions.md b/spec/functions.md index 7d7bda3..c274239 100644 --- a/spec/functions.md +++ b/spec/functions.md @@ -89,4 +89,13 @@ Create a task and add it to the build script Check if the given option was set on the command line ## [X] grbc_get_option(option_name: String) -> String -Get the value of an option \ No newline at end of file +Get the value of an option + +## [X] grbc_property(name: String, value: String) -> Property +Create a property + +## [X] grbc_cxx_version(version_string: String) -> Property +Create a property that sets the C++ version + +## [X] grbc_global_properties(properties: Array) -> Void +Set the global property list \ No newline at end of file diff --git a/src/ext_cmake.cc b/src/ext_cmake.cc new file mode 100644 index 0000000..cbf7f0a --- /dev/null +++ b/src/ext_cmake.cc @@ -0,0 +1,76 @@ +#include "grbc/ext_cmake.h" +#include "grbc/ext.h" +#include "grbc/helpers.h" +#include "grbc/spec.h" +#include "sol/raii.hpp" +#include +#include + +CMakeProject EXT_grbc_import_cmake(const std::string &cmake_path, + const CMakeConfig &cfg) { + CMakeProject project{}; + + log_msg(("configuring cmake project: " + cmake_path).c_str()); + + if (!std::filesystem::exists(cmake_path)) { + grbc_exception("CMake cannot configure in non-existant directory: " + + cmake_path); + } + + if (!std::filesystem::exists(cmake_path + "/CMakeLists.txt")) { + grbc_exception("No CMakeLists.txt file in: " + cmake_path); + } + + std::filesystem::path old_path = std::filesystem::current_path(); + + // Change directory into the cmake dir + std::filesystem::current_path(cmake_path); + + std::filesystem::create_directory("grbc_configure"); + + std::filesystem::current_path("./grbc_configure"); + + // Create configure arg string + std::string configure_arguments; + + for (const std::string &argument : cfg.configure_arguments) { + configure_arguments += argument + " "; + } + + // Run configure + int exit_code = + std::system(("cmake -S .. -B . -GNinja " + configure_arguments).c_str()); + + if (exit_code != EXIT_SUCCESS) + grbc_exception("Failed to configure cmake project in: " + cmake_path); + + std::filesystem::current_path(old_path); + + return project; +} + +Package EXT_grbc_get_cmake_library(const CMakeProject &self, + const std::string &library_name) { + std::filesystem::path library_path = library_name; +} + +void grbc_cmake_init(sol::state &lua) { + lua.new_usertype( + "CMakeConfig", sol::constructors(), + "configure_arguments", &CMakeConfig::configure_arguments); + lua.new_usertype("CMakeProject", "source_dir", + &CMakeProject::source_dir, "build_dir", + &CMakeProject::build_dir); + + lua["CMakeProject"]["get_library"] = EXT_grbc_get_cmake_library; + + lua.set("grbc_import_cmake", EXT_grbc_import_cmake); +} + +Extension grbc_cmake() { + Extension ext{}; + ext.name = GRBC_EXT_cmake_NAME; + ext.hook_init = grbc_cmake_init; + + return ext; +} \ No newline at end of file diff --git a/src/ext_dynamic.cc b/src/ext_dynamic.cc index 485d453..7490851 100644 --- a/src/ext_dynamic.cc +++ b/src/ext_dynamic.cc @@ -12,8 +12,8 @@ extern "C" { typedef const char *(*EXT_GetName)(); void EXT_dynamic_ext(const std::string &extension_name) { - const std::array extension_paths = {"./grbc_ext", - "C:\\grbc\\ext", "./", "./build"}; + const std::array extension_paths = { + "./grbc_ext", "C:\\grbc\\ext", "./", "./build"}; std::filesystem::path good_extension_path; diff --git a/src/main.cc b/src/main.cc index 02a41ac..e37b9bf 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,4 +1,5 @@ #include "grbc/ext.h" +#include "grbc/ext_cmake.h" #include "grbc/ext_dynamic.h" #include "grbc/ext_easy.h" #include "grbc/ext_pkg_config.h" @@ -144,6 +145,9 @@ int main(int argc, char **argv) { &TaskConfig::name, "task_id", &TaskConfig::task_id, "shell_script", &TaskConfig::shell_script); + // Property + lua.new_usertype("Property", sol::constructors(), "name", &Property::name, "value", &Property::value); + lua.set("grbc_want_version", grbc_want_version); lua.set("grbc_exception", grbc_exception); lua.set("grbc_get_config", grbc_get_config); @@ -174,6 +178,9 @@ int main(int argc, char **argv) { lua.set("grbc_task", grbc_task); lua.set("grbc_has_option", grbc_has_option); lua.set("grbc_get_option", grbc_get_option); + lua.set("grbc_property", grbc_property); + lua.set("grbc_cxx_version", grbc_cxx_version); + lua.set("grbc_global_properties", grbc_global_properties); // Load generators @@ -189,6 +196,7 @@ int main(int argc, char **argv) { grbc_register_ext(grbc_profiles()); grbc_register_ext(grbc_easy()); grbc_register_ext(grbc_dynamic()); + grbc_register_ext(grbc_cmake()); // Detect platform log_msg("autodetecting platform..."); diff --git a/src/target_exe.cc b/src/target_exe.cc index b3ff414..7014ea1 100644 --- a/src/target_exe.cc +++ b/src/target_exe.cc @@ -27,6 +27,14 @@ TargetInfo grbc_executable(const ExecutableConfig &executable_config) { compiler_args += compiler_arg + " "; } + std::vector properties = executable_config.properties; for (auto &global_property : GState::get().global_properties) + properties.push_back(global_property); + + for (auto &property : properties) { + if (property.name == GRBC_PROPERTY_CXX_VERSION) + compiler_args += "-std=" + property.value + " "; + } + // Include directories compiler_args += grbc_include_dirs_to_cflags(executable_config.include_dirs); diff --git a/src/target_lib.cc b/src/target_lib.cc index bdee5d9..2b258e4 100644 --- a/src/target_lib.cc +++ b/src/target_lib.cc @@ -33,6 +33,15 @@ TargetInfo grbc_library(const LibraryConfig &library_config) { compiler_args += "-fPIC "; } + std::vector properties = library_config.properties; + for (auto &global_property : GState::get().global_properties) + properties.push_back(global_property); + + for (auto &property : properties) { + if (property.name == GRBC_PROPERTY_CXX_VERSION) + compiler_args += "-std=" + property.value + " "; + } + // Include directories compiler_args += grbc_include_dirs_to_cflags(library_config.include_dirs); diff --git a/src/utils.cc b/src/utils.cc index 6a11830..886c7c6 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -48,7 +48,7 @@ std::string grbc_replace_string(const std::string &string, char substring, return res; } -GlobalConfig& grbc_get_config() { +GlobalConfig &grbc_get_config() { static GlobalConfig cfg{}; return cfg; @@ -97,4 +97,31 @@ std::string grbc_get_lib_extension(LibraryType lib_type) { "library combo"); return ""; +} + +Property grbc_property(const std::string &key, const std::string &value) { + static std::vector validPropertyNames = { + GRBC_PROPERTY_CXX_VERSION}; + + for (const std::string &propertyName : validPropertyNames) { + if (propertyName == key) { + Property property{}; + property.name = key; + property.value = value; + + return property; + } + } + + grbc_exception("Invalid property name: " + key); + + return {}; +} + +Property grbc_cxx_version(const std::string &version_string) { + return grbc_property(GRBC_PROPERTY_CXX_VERSION, version_string); +} + +void grbc_global_properties(const sol::table &properties) { + GState::get().global_properties = properties.as>(); } \ No newline at end of file