set c++ version

This commit is contained in:
Hunter 2024-10-12 20:24:10 -04:00
parent b3a326720b
commit 29afc49c36
20 changed files with 304 additions and 179 deletions

View file

@ -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);

22
include/grbc/ext_cmake.h Normal file
View file

@ -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<std::vector<std::string>>("configure_arguments");
}
/// Configuration arguments
std::vector<std::string> configure_arguments;
};
struct CMakeProject {
/// Source directory
std::string source_dir;
/// Build directory
std::string build_dir;
};
Extension grbc_cmake();

View file

@ -5,6 +5,8 @@
#include <string>
#include <vector>
#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<std::string>("name");
value = table.get<std::string>("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<std::vector<std::string>>("include_dirs");
language_type = table.get<LanguageType>("language_type");
if (table["properties"].valid()) {
properties = table.get<std::vector<Property>>("properties");
}
}
/// Name of the executable
@ -126,6 +147,9 @@ struct ExecutableConfig {
/// Include directories
std::vector<std::string> include_dirs{};
/// Optional list of properties
std::vector<Property> properties;
};
struct TaskConfig {
@ -162,8 +186,11 @@ struct LibraryConfig {
language_type = table.get<LanguageType>("language_type");
lib_type = table.get<LibraryType>("lib_type");
if (!table["package_config"].is<sol::nil_t>())
if (table["package_config"].valid())
package_config = table.get<PackageConfig>("package_config");
if (table["properties"].valid())
properties = table.get<std::vector<Property>>("properties");
}
/// Name of the executable
@ -192,6 +219,9 @@ struct LibraryConfig {
/// Include directories
std::vector<std::string> include_dirs{};
/// Optional list of properties
std::vector<Property> 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);
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);

View file

@ -18,6 +18,8 @@ struct GState {
std::map<std::string, std::string> options;
std::vector<Property> global_properties;
std::unordered_map<std::string, Package> packages;
std::vector<Extension> extensions;