gint project template

This commit is contained in:
KikooDX 2021-04-16 11:08:47 +02:00
commit 226ea40887
15 changed files with 203 additions and 0 deletions

10
.clang-format Normal file
View File

@ -0,0 +1,10 @@
# https://clang.llvm.org/docs/ClangFormat.html
BasedOnStyle: LLVM
IndentWidth: 8
UseTab: AlignWithSpaces
BreakBeforeBraces: Linux
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 72
AlignConsecutiveMacros: true
AlwaysBreakAfterReturnType: TopLevelDefinitions

17
.gitignore vendored Normal file
View File

@ -0,0 +1,17 @@
# Build files
/build-fx
/build-cg
/*.g1a
/*.g3a
# Python bytecode
__pycache__/
# Common IDE files
*.sublime-project
*.sublime-workspace
.vscode
*.swp
# Krita backup files
*.png~

85
CMakeLists.txt Normal file
View File

@ -0,0 +1,85 @@
# Configure with [fxsdk build-fx] or [fxsdk build-cg], which provide the
# toolchain file and module path of the fxSDK
cmake_minimum_required(VERSION 3.18)
# replace this with your project's name
project(ProjectName)
include(GenerateG1A)
include(GenerateG3A)
include(Fxconv)
find_package(Gint 2.1 REQUIRED)
# include directories, put your .h files in those folders
include_directories(include)
# source files
set(SOURCES
src/main.c
src/sample.c
# ...
)
# shared assets
set(ASSETS
# ...
)
# fx-9860G-only assets (monochrome)
set(ASSETS_fx
assets-fx/example.png
# ...
)
# fx-CG-50-only assets (polychrome)
set(ASSETS_cg
assets-cg/example.png
# ...
)
# Compile flags
set(FLAGS
# C standard, other values: c89, c99
-std=c11
# general warnings
-Wall -Wextra -pedantic
# enable this flag to stop compilation on warnings
#-Werror
# specific warnings
# variable shadowing
-Wshadow
# switch/case safety
-Wswitch-default -Wswitch-enum
# unreachable code, bad 99% of the time
-Wunreachable-code
# prototypes warnings
-Wstrict-prototypes -Wmissing-prototypes
# function declaration
-Werror-implicit-function-declaration
# optimisation level
# -Os: small binary
# -O2: good speed/size tradeoff
# -O3: gotta go fast
-Os
)
fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA)
add_executable(${PROJECT_NAME} ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}})
target_compile_options(${PROJECT_NAME} PRIVATE ${FLAGS})
target_link_libraries(${PROJECT_NAME} Gint::Gint)
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
generate_g1a(
TARGET ${PROJECT_NAME}
OUTPUT "${PROJECT_NAME}.g1a"
NAME "${PROJECT_NAME}"
ICON assets-fx/icon.png)
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
generate_g3a(
TARGET ${PROJECT_NAME}
OUTPUT "${PROJECT_NAME}.g3a"
NAME "${PROJECT_NAME}"
ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
endif()

12
LICENSE Normal file
View File

@ -0,0 +1,12 @@
Copyright (C) 2021 KikooDX
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

46
README Normal file
View File

@ -0,0 +1,46 @@
KikooDX's gint project template
===============================
This is a base project for gint softwares.
Before anything
---------------
Open and read CMakeLists.txt.
Building your project
---------------------
For monochrome calculator target:
$ fxsdk build-fx
For color calculator target:
$ fxsdk build-cg
Making changes
--------------
After creating new .c files, add those to the SRC list in CMakeLists and
rebuild. Same process for graphical assets in the corresponding ASSETS
in the corresponding ASSETS* list, but you will also need to edit
assets*/fxconv-metada.
Before commiting
----------------
Run this command at the base of the git tree:
$ clang-format -i src/**.c include/**.h
It will beautify the source of your project according to the
configuration in the .clang-format file.
Nice tricks
-----------
Search for a function declaration.
$ git grep '$sample'
See changes since last commit.
$ git diff <file>
Require entr, recompile whenever a source file change (poor man LSP).
Ctrl-C to end.
$ find src/ include/ -type f | entr -r fxsdk build-cg
License
-------
Copyright (C) 2021 KikooDX <kikoodx@paranoici.org>
This template is under the 0BSD license. See LICENSE for informations.

BIN
assets-cg/example.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -0,0 +1,3 @@
example.png:
type: bopti-image
name: img_example

BIN
assets-cg/icon-sel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

BIN
assets-cg/icon-uns.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
assets-fx/example.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1,3 @@
example.png:
type: bopti-image
name: img_example

BIN
assets-fx/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

4
include/sample.h Normal file
View File

@ -0,0 +1,4 @@
#pragma once
/* return 42 */
int sample(void);

16
src/main.c Normal file
View File

@ -0,0 +1,16 @@
#include "sample.h"
#include <gint/display.h>
#include <gint/keyboard.h>
int
main(void)
{
dclear(C_WHITE);
dtext(1, 1, C_BLACK, "Sample add-in.");
dprint(1, 16, C_BLACK, "Return value of sample(): %d.",
sample());
dupdate();
getkey();
return 1;
}

7
src/sample.c Normal file
View File

@ -0,0 +1,7 @@
#include "sample.h"
int
sample(void)
{
return 42;
}