Properly link flecs library

This commit is contained in:
2023-11-09 11:38:29 +01:00
parent dc585396c3
commit 8edcf9305c
1392 changed files with 390081 additions and 164 deletions

View File

@@ -0,0 +1,16 @@
#ifndef AUTO_DEFINE_ENUM_H
#define AUTO_DEFINE_ENUM_H
/* This generated file contains includes for project dependencies */
#include "auto_define_enum/bake_config.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,24 @@
/*
)
(.)
.|.
| |
_.--| |--._
.-'; ;`-'& ; `&.
\ & ; & &_/
|"""---...---"""|
\ | | | | | | | /
`---.|.|.|.---'
* This file is generated by bake.lang.c for your convenience. Headers of
* dependencies will automatically show up in this file. Include bake_config.h
* in your main project file. Do not edit! */
#ifndef AUTO_DEFINE_ENUM_BAKE_CONFIG_H
#define AUTO_DEFINE_ENUM_BAKE_CONFIG_H
/* Headers of public dependencies */
#include <flecs.h>
#endif

View File

@@ -0,0 +1,12 @@
{
"id": "auto_define_enum",
"type": "application",
"value": {
"author": "Jane Doe",
"description": "A simple hello world flecs application",
"use": [
"flecs"
],
"public": false
}
}

View File

@@ -0,0 +1,30 @@
#include <auto_define_enum.h>
#include <stdio.h>
// Color is used by Car, so it must also be captured
ECS_ENUM(Color, {
Red, Black, White, StainlessSteel
});
ECS_STRUCT(Car, {
const char *brand;
Color color;
float speed;
});
int main(int argc, char *argv[]) {
ecs_world_t *ecs = ecs_init_w_args(argc, argv);
// Register both components. Note that Color is registered first, so that
// when Car is registered, the type information of Color can be looked up
ECS_META_COMPONENT(ecs, Color);
ECS_META_COMPONENT(ecs, Car);
// Serialize as usual
Car value = {"Delorean", StainlessSteel, 1.21f};
char *json = ecs_ptr_to_json(ecs, ecs_id(Car), &value);
printf("%s\n", json); // {"brand": "Delorean", "color": "StainlessSteel", "speed": 1.21}
ecs_os_free(json);
return ecs_fini(ecs);
}