default platform + impl all functions
This commit is contained in:
parent
8ff3047aec
commit
f32bf63c98
1
HConfig
1
HConfig
|
@ -1,5 +1,4 @@
|
||||||
grbc_want_version("1.0")
|
grbc_want_version("1.0")
|
||||||
grbc_load_platform("platform.hcfg")
|
|
||||||
grbc_ext("GRBC_EXT_pkg_config")
|
grbc_ext("GRBC_EXT_pkg_config")
|
||||||
|
|
||||||
local grbc_pkg_config_ext = grbc_library(LibraryConfig.new({
|
local grbc_pkg_config_ext = grbc_library(LibraryConfig.new({
|
||||||
|
|
|
@ -5,6 +5,25 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/1505582/determining-32-vs-64-bit-in-c
|
||||||
|
|
||||||
|
#if _WIN32 || _WIN64
|
||||||
|
#if _WIN64
|
||||||
|
#define ENVIRONMENT64
|
||||||
|
#else
|
||||||
|
#define ENVIRONMENT32
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Check GCC
|
||||||
|
#if __GNUC__
|
||||||
|
#if __x86_64__ || __ppc64__
|
||||||
|
#define ENVIRONMENT64
|
||||||
|
#else
|
||||||
|
#define ENVIRONMENT32
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#define GRBC_VERSION "1.0"
|
#define GRBC_VERSION "1.0"
|
||||||
|
|
||||||
enum LanguageType { LanguageType_CPP, LanguageType_C };
|
enum LanguageType { LanguageType_CPP, LanguageType_C };
|
||||||
|
@ -171,7 +190,7 @@ struct Platform {
|
||||||
bool is_64bit = true;
|
bool is_64bit = true;
|
||||||
|
|
||||||
/// Type of the platform
|
/// Type of the platform
|
||||||
PlatformType platform_type;
|
PlatformType platform_type = PlatformType_Linux;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Functions
|
/// Functions
|
||||||
|
@ -180,7 +199,7 @@ void grbc_want_version(const std::string &version);
|
||||||
|
|
||||||
void grbc_exception(const std::string &exception_string);
|
void grbc_exception(const std::string &exception_string);
|
||||||
|
|
||||||
GlobalConfig& grbc_get_config();
|
GlobalConfig &grbc_get_config();
|
||||||
|
|
||||||
std::string grbc_file(const std::string &file_path);
|
std::string grbc_file(const std::string &file_path);
|
||||||
|
|
||||||
|
@ -228,3 +247,8 @@ Package grbc_pkg(const std::string &package_name);
|
||||||
void grbc_ext(const std::string &extension_id);
|
void grbc_ext(const std::string &extension_id);
|
||||||
|
|
||||||
void grbc_register_ext(const Extension &ext);
|
void grbc_register_ext(const Extension &ext);
|
||||||
|
|
||||||
|
bool grbc_has_ext(const std::string &extension_id);
|
||||||
|
|
||||||
|
std::string grbc_platform_file(PlatformType platform_type,
|
||||||
|
const std::string &file_name);
|
|
@ -8,7 +8,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct GState {
|
struct GState {
|
||||||
Platform current_platform;
|
Platform current_platform{};
|
||||||
sol::state lua;
|
sol::state lua;
|
||||||
|
|
||||||
std::vector<GeneratorTarget> targets;
|
std::vector<GeneratorTarget> targets;
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
-- Linux platform
|
|
||||||
|
|
||||||
local platform = Platform.new()
|
|
||||||
|
|
||||||
platform.name = "Linux64"
|
|
||||||
platform.cxx_compiler = grbc_find_compiler("g++")
|
|
||||||
platform.cc_compiler = grbc_find_compiler("gcc")
|
|
||||||
platform.is_64bit = true -- If set to false the compiler will need to produce 32bit code
|
|
||||||
|
|
||||||
platform.platform_type = PlatformType.Linux
|
|
||||||
|
|
||||||
return platform
|
|
|
@ -136,15 +136,6 @@ struct GlobalConfig {
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
## OptionalFileType
|
|
||||||
```
|
|
||||||
enum OptionalFileType {
|
|
||||||
OFileType_IsWin32,
|
|
||||||
OFileType_IsUnix,
|
|
||||||
OFileType_IsLinux
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
## Platform
|
## Platform
|
||||||
```c++
|
```c++
|
||||||
struct Platform {
|
struct Platform {
|
||||||
|
@ -172,13 +163,3 @@ enum LanguageType {
|
||||||
LanguageType_C
|
LanguageType_C
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
## Profile
|
|
||||||
```c++
|
|
||||||
struct Profile {
|
|
||||||
string name;
|
|
||||||
|
|
||||||
Array<string> compiler_flags;
|
|
||||||
Array<string> linker_flags;
|
|
||||||
};
|
|
||||||
```
|
|
|
@ -2,15 +2,14 @@
|
||||||
Extensions can be loaded at runtime using grbc_ext(...), functions are then dumped into the runtime
|
Extensions can be loaded at runtime using grbc_ext(...), functions are then dumped into the runtime
|
||||||
|
|
||||||
## How extensions work
|
## How extensions work
|
||||||
Extensions are built into the grbc executable, or can be compiled as a shared library and put into ```/usr/local/share/grbc/extensions```, ```C:\GRBC\Extensions\```, or ```~/.local/share/grbc/extensions```
|
Extensions are built into the grbc executable, and are loaded at runtime as needed
|
||||||
|
|
||||||
## Extension list
|
## Extension list
|
||||||
* GRBC_EXT_pkg_config
|
* GRBC_EXT_pkg_config
|
||||||
* GRBC_EXT_multi_file [NOSUPPORT]
|
|
||||||
* GRBC_EXT_cmake [NOSUPPORT]
|
* GRBC_EXT_cmake [NOSUPPORT]
|
||||||
|
|
||||||
## GRBC_EXT_pkg_config
|
## GRBC_EXT_pkg_config
|
||||||
Pkg config support. UNIX only
|
Pkg config support. UNIX only
|
||||||
|
|
||||||
## GRBC_EXT_multi_file
|
## GRBC_EXT_cmake
|
||||||
Multi file GRBC scripts, supported on all systems.
|
CMake interop support
|
|
@ -31,19 +31,19 @@ Create a new executable and add it to the build list
|
||||||
## [X] grbc_library(library_config: LibraryConfig) -> TargetInfo
|
## [X] grbc_library(library_config: LibraryConfig) -> TargetInfo
|
||||||
Create a new library and add it to the build list
|
Create a new library and add it to the build list
|
||||||
|
|
||||||
## grbc_pkg(package_name: String) -> Package
|
## [X] grbc_pkg(package_name: String) -> Package
|
||||||
Get a package with the given name and return its baked form
|
Get a package with the given name and return its baked form
|
||||||
|
|
||||||
## [X] grbc_file(file_path: String) -> Path
|
## [X] grbc_file(file_path: String) -> Path
|
||||||
Used when listing source files, should perform pre-checks on the file and return its path
|
Used when listing source files, should perform pre-checks on the file and return its path
|
||||||
|
|
||||||
## grbc_file_optional(file_type: OptionalFileType, file_path: String) -> Path
|
## [X] grbc_platform_file(platform: PlatformType, file_path: String) -> String
|
||||||
If file_type is true then file_path is returned, otherwise a blank string
|
If the current platform is equal to platform then return the file path, otherwise return an empty string
|
||||||
|
|
||||||
## grbc_has_ext(extension_name: String) -> Boolean
|
## [X] grbc_has_ext(extension_name: String) -> Boolean
|
||||||
Check if the given extension is supported
|
Check if the given extension is supported
|
||||||
|
|
||||||
## grbc_ext(extension_name: String) -> Void
|
## [X] grbc_ext(extension_name: String) -> Void
|
||||||
Load the given extension into the script
|
Load the given extension into the script
|
||||||
|
|
||||||
## [X] grbc_exception(exception_string: String) -> Void
|
## [X] grbc_exception(exception_string: String) -> Void
|
||||||
|
|
|
@ -10,6 +10,15 @@ void grbc_register_ext(const Extension &ext) {
|
||||||
printf("> init pointer: %p\n", ext.hook_init);
|
printf("> init pointer: %p\n", ext.hook_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool grbc_has_ext(const std::string &extension_id) {
|
||||||
|
for (auto &ext : GState::get().extensions) {
|
||||||
|
if (ext.name == extension_id)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void grbc_ext(const std::string &extension_id) {
|
void grbc_ext(const std::string &extension_id) {
|
||||||
for (auto &ext : GState::get().extensions) {
|
for (auto &ext : GState::get().extensions) {
|
||||||
if (ext.name != extension_id)
|
if (ext.name != extension_id)
|
||||||
|
|
21
src/main.cc
21
src/main.cc
|
@ -103,6 +103,8 @@ int main() {
|
||||||
lua.set("grbc_bake_package_config", grbc_bake_package_config);
|
lua.set("grbc_bake_package_config", grbc_bake_package_config);
|
||||||
lua.set("grbc_pkg", grbc_pkg);
|
lua.set("grbc_pkg", grbc_pkg);
|
||||||
lua.set("grbc_ext", grbc_ext);
|
lua.set("grbc_ext", grbc_ext);
|
||||||
|
lua.set("grbc_has_ext", grbc_has_ext);
|
||||||
|
lua.set("grbc_platform_file", grbc_platform_file);
|
||||||
|
|
||||||
// Load generators
|
// Load generators
|
||||||
|
|
||||||
|
@ -115,6 +117,25 @@ int main() {
|
||||||
grbc_register_ext(grbc_pkg_config());
|
grbc_register_ext(grbc_pkg_config());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Detect platform
|
||||||
|
log_msg("autodetecting platform...");
|
||||||
|
|
||||||
|
#if defined(WIN32)
|
||||||
|
GState::get().current_platform.platform_type = PlatformType_Win32;
|
||||||
|
GState::get().current_platform.name = "Windows";
|
||||||
|
#elif defined(__linux__)
|
||||||
|
GState::get().current_platform.platform_type = PlatformType_Linux;
|
||||||
|
GState::get().current_platform.name = "Linux";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENVIRONMENT32)
|
||||||
|
GState::get().current_platform.is_64bit = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Default compiler is g++
|
||||||
|
GState::get().current_platform.cc_compiler = grbc_find_compiler("gcc");
|
||||||
|
GState::get().current_platform.cxx_compiler = grbc_find_compiler("g++");
|
||||||
|
|
||||||
log_msg("loading HConfig...");
|
log_msg("loading HConfig...");
|
||||||
|
|
||||||
lua.script_file("HConfig");
|
lua.script_file("HConfig");
|
||||||
|
|
|
@ -91,3 +91,9 @@ bool grbc_is_64bit() {
|
||||||
bool grbc_is_32bit() {
|
bool grbc_is_32bit() {
|
||||||
return !grbc_is_64bit();
|
return !grbc_is_64bit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string grbc_platform_file(PlatformType platform_type, const std::string &file_name) {
|
||||||
|
if (grbc_get_platform() == platform_type) return grbc_file(file_name);
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
Loading…
Reference in a new issue