helloworld

This commit is contained in:
KikooDX 2021-11-18 00:11:52 +01:00
commit 3a2609f8e4
11 changed files with 127 additions and 0 deletions

9
.clang-format Normal file
View File

@ -0,0 +1,9 @@
BasedOnStyle: LLVM
IndentWidth: 8
UseTab: AlignWithSpaces
BreakBeforeBraces: Linux
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 80
AlignConsecutiveMacros: true
AlwaysBreakAfterReturnType: TopLevelDefinitions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
out/
build/
build-cg/
build-fx/
*.g3a
*.g1a
*.png~

6
.gitmodules vendored Normal file
View File

@ -0,0 +1,6 @@
[submodule "fe"]
path = fe
url = https://github.com/rxi/fe
[submodule "raygint"]
path = raygint
url = https://gitea.planet-casio.com/KikooDX/raygint

46
CMakeLists.txt Normal file
View File

@ -0,0 +1,46 @@
# Configure with [fxsdk build-cg], which provide the
# toolchain file and module path of the fxSDK
cmake_minimum_required(VERSION 3.18)
project(CRYSTAL C)
set(CMAKE_C_STANDARD 99)
include_directories(inc out raygint/include fe/src)
set(SOURCES
src/main.c
raygint/src/display.c
raygint/src/keyboard.c
fe/src/fe.c
)
set(ASSETS
)
set(FLAGS
-Wall -Wextra -Wshadow -O3
)
if ("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
find_package(Gint 2.6.0 REQUIRED)
include(GenerateG3A)
include(Fxconv)
fxconv_declare_assets(${ASSETS} WITH_METADATA)
add_executable(target ${SOURCES} ${ASSETS})
target_compile_options(target PRIVATE ${FLAGS} -DGINT)
target_link_libraries(target Gint::Gint)
target_link_options(target PRIVATE -Wl,-Map=map)
generate_g3a(TARGET target
OUTPUT "${PROJECT_NAME}.g3a"
NAME ""
ICONS res/icon-uns.png res/icon-sel.png
)
else()
add_executable(target ${SOURCES})
target_compile_options(target PRIVATE ${FLAGS} -DRAYLIB -g)
target_link_libraries(target raylib)
endif()

21
Makefile Normal file
View File

@ -0,0 +1,21 @@
all: format
fxsdk build-cg
ray: clean format
mkdir -p build
cmake -B build .
make -C build
run: ray
build/target
format:
clang-format -style=file -i src/**.c inc/**.h || true
clean:
rm -Rf out/
rm -Rf build/
rm -Rf build-cg/
rm -f *.g3a
.PHONY: format ray run clean

1
fe Submodule

@ -0,0 +1 @@
Subproject commit ed4cda96bd582cbb08520964ba627efb40f3dd91

1
raygint Submodule

@ -0,0 +1 @@
Subproject commit 2403783b3a7574828815aa9be9b541342d4684fa

BIN
res/icon-sel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

BIN
res/icon-uns.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

34
src/main.c Normal file
View File

@ -0,0 +1,34 @@
#include "fe.h"
#include <stdio.h>
int
main(void)
{
const int size = 0xffffff;
void *data = malloc(size);
fe_Context *ctx = fe_open(data, size);
#ifdef RAYLIB
FILE *fp = fopen("test.fe", "rb");
int gc = fe_savegc(ctx);
for (;;) {
fe_Object *obj = fe_readfp(ctx, fp);
/* break if there's nothing left to read */
if (!obj)
break;
/* evaluate read object */
fe_eval(ctx, obj);
/* restore GC stack which would now contain both the
* read object and result from evaluation */
fe_restoregc(ctx, gc);
}
fclose(fp);
#endif
fe_close(ctx);
free(data);
return 0;
}

2
test.fe Normal file
View File

@ -0,0 +1,2 @@
(= x 2) (= y 3)
(print "hello world" (+ y (* x x)))