mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-16 21:05:46 +01:00
setup project files
Added (most) of the project files to the working tree. Some work still needs to be done to make the rust/C communication better before we can fully move on to starting to write the actual applicaiton.
This commit is contained in:
210
.clang-format
Normal file
210
.clang-format
Normal file
@@ -0,0 +1,210 @@
|
||||
---
|
||||
# ---------------------------
|
||||
# general style settings
|
||||
# ---------------------------
|
||||
BasedOnStyle: '' # (LLVM,Google,Chromium,Mozilla,WebKit,Microsoft,GNU,InheritParentConfig)
|
||||
Standard: Auto # automatically detect the language version
|
||||
ColumnLimit: 0 # 0: disable column limit
|
||||
LineEnding: LF # use LF line endings
|
||||
UseTab: ForContinuationAndIndentation # (Never,ForIndentation,ForContinuationAndIndentation,Always)
|
||||
TabWidth: 4 # recommended to set this equal to IndentWidth
|
||||
IndentWidth: 4 # how wide each indent is
|
||||
ContinuationIndentWidth: 4 # width for a line continuation
|
||||
|
||||
# ---------------------------
|
||||
# alignment options
|
||||
# ---------------------------
|
||||
AlignAfterOpenBracket: Align # (Align,DontAlign,AlwaysBreak,BlockIndent)
|
||||
AlignArrayOfStructures: Left # (Left,Right,None)
|
||||
AlignConsecutiveMacros: AcrossEmptyLines # (None,Consecutive,AcrossEmptyLines,AcrossComments,AcrossEmptyLinesAndComments)
|
||||
AlignConsecutiveAssignments: None # (None,Consecutive,AcrossEmptyLines,AcrossComments,AcrossEmptyLinesAndComments)
|
||||
AlignConsecutiveBitFields: AcrossEmptyLines # (None,Consecutive,AcrossEmptyLines,AcrossComments,AcrossEmptyLinesAndComments)
|
||||
AlignConsecutiveDeclarations: None # (None,Consecutive,AcrossEmptyLines,AcrossComments,AcrossEmptyLinesAndComments)
|
||||
AlignEscapedNewlines: Left # (DontAlign,Left,LeftWithLastLine,Right)
|
||||
AlignOperands: Align # (DontAlign,Align,AlignAfterOperator)
|
||||
AlignTrailingComments: Always # (Leave,Always,Never)
|
||||
|
||||
# ---------------------------
|
||||
# short constructs on a single line
|
||||
# ---------------------------
|
||||
AllowShortBlocksOnASingleLine: Always # (Never,Empty,Always)
|
||||
AllowShortFunctionsOnASingleLine: All # (None,InlineOnly,Empty,All)
|
||||
AllowShortLambdasOnASingleLine: All # (None,Empty,Inline,All)
|
||||
AllowShortIfStatementsOnASingleLine: AllIfsAndElse # (Never,WithoutElse,OnlyFirstIf,AllIfsAndElse)
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
|
||||
# ---------------------------
|
||||
# break and wrapping options
|
||||
# ---------------------------
|
||||
AlwaysBreakBeforeMultilineStrings: true # when defining multi-line strings, linebreak should be inserted
|
||||
BreakAfterReturnType: Automatic # is decided by PenaltyReturnTypeOnItsOwnLine
|
||||
BreakTemplateDeclarations: MultiLine # (Leave,No,MultiLine,Yes)
|
||||
BreakBeforeBinaryOperators: None # (None,NonAssignment,All)
|
||||
BreakBeforeConceptDeclarations: Never # (Never,Allowed,Always)
|
||||
BreakBeforeBraces: Attach # (Attach,Linux,Mozilla,Stroustrup,Allman,Whitesmiths,GNU,WebKit,Custom)
|
||||
BreakInheritanceList: BeforeColon # (BeforeColon,BeforeComma,AfterColon)
|
||||
BreakConstructorInitializers: BeforeColon # (BeforeColon,BeforeComma,AfterColon)
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakStringLiterals: true
|
||||
|
||||
# ---------------------------
|
||||
# brace wrapping configuration
|
||||
# ---------------------------
|
||||
BraceWrapping:
|
||||
AfterControlStatement: Never # (Never,MultiLine,Always)
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
|
||||
# ---------------------------
|
||||
# constructor initializer and parameter packing options
|
||||
# ---------------------------
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
PackConstructorInitializers: BinPack # (Never,BinPack,CurrentLine,NextLine,NextLineOnly)
|
||||
BinPackParameters: true # use bin-packing for paramter lists
|
||||
BinPackArguments: false # false: function calls either on one line or one per line
|
||||
|
||||
# ---------------------------
|
||||
# pointer alignment
|
||||
# ---------------------------
|
||||
DerivePointerAlignment: false # automatically detect pointer alignment
|
||||
PointerAlignment: Left # (Left,Right,Middle)
|
||||
ReferenceAlignment: Pointer # (Pointer,Left,Right,Middle)
|
||||
|
||||
# ---------------------------
|
||||
# include settings and sorting
|
||||
# ---------------------------
|
||||
IncludeIsMainSourceRegex: '' # only [*.{c,cc,cpp,c++,cxx,m,mm}] are considered to be "main"
|
||||
IncludeIsMainRegex: '([-_](test|unittest))?$' # regex used for identifying an include as "main", to assign catagory 0
|
||||
IncludeBlocks: Regroup # (Preserve,Merge,Regroup)
|
||||
IncludeCategories:
|
||||
- Regex: '^<.*\.h>' # system headers
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: true
|
||||
- Regex: '^".*' # custom headers
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: true
|
||||
|
||||
# ---------------------------
|
||||
# macro and language-specific settings
|
||||
# ---------------------------
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
- NS_SWIFT_NAME
|
||||
- CF_SWIFT_NAME
|
||||
|
||||
# ---------------------------
|
||||
# additional formatting and sorting details
|
||||
# ---------------------------
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
EmptyLineAfterAccessModifier: Never # (Never,Leave,Always)
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock # (Never,Leave,LogicalBlock,Always)
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true # adds comments at namespace delimiters
|
||||
MaxEmptyLinesToKeep: 4 # what the maximum amount of empty lines that we're allowed to keep
|
||||
ReflowComments: true # reflow comment text to match column limits
|
||||
RemoveBracesLLVM: false # don't automatically remove braces
|
||||
SeparateDefinitionBlocks: Leave # (Leave,Always.Never)
|
||||
ShortNamespaceLines: 1 # how many lines a namespaces can be to be regarded "short"
|
||||
SortIncludes: CaseSensitive # (Never,CaseSensitive,CaseInsensitive)
|
||||
SortJavaStaticImport: Before # (After,Before)
|
||||
SortUsingDeclarations: LexicographicNumeric # (Never,Lexicographic,LexicographicNumeric)
|
||||
|
||||
# ---------------------------
|
||||
# spacing options
|
||||
# ---------------------------
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements # (ControlStatements,ControlStatementsExceptControlMacros,NonEmptyParentheses,Always,Custom)
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterOverloadedOperator: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceAroundPointerQualifiers: Default # (Default,Before,After,Both) recommend to use Default and let PointerAlignment decide
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: true
|
||||
SpacesInParens: Custom
|
||||
SpacesInParensOptions:
|
||||
ExceptDoubleParentheses: false
|
||||
InConditionalStatements: false
|
||||
InCStyleCasts: false
|
||||
Other: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never # (Never,Always,Leave)
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: 1
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both # (Both,None,Before,After)
|
||||
|
||||
# ---------------------------
|
||||
# indentation details
|
||||
# ---------------------------
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseLabels: false
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentExternBlock: AfterExternBlock # (AfterExternBlock,NoIndent,Indent)
|
||||
IndentRequiresClause: false
|
||||
IndentPPDirectives: AfterHash # preprocessor indent style (None,AfterHash,BeforeHash)
|
||||
PPIndentWidth: 1
|
||||
|
||||
---
|
||||
# ---------------------------
|
||||
# Objective-C specific settings
|
||||
# ---------------------------
|
||||
Language: ObjC
|
||||
ObjCBinPackProtocolList: Never
|
||||
ObjCBlockIndentWidth: 4
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
...
|
||||
23
.editorconfig
Normal file
23
.editorconfig
Normal file
@@ -0,0 +1,23 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{c,h}]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[*.{rs}]
|
||||
indent_style = space
|
||||
intent_size = 4
|
||||
|
||||
[{makefile}]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[*.{yaml,json}]
|
||||
indent_style = space
|
||||
intent_size = 2
|
||||
0
.github/workflows/release.yaml
vendored
Normal file
0
.github/workflows/release.yaml
vendored
Normal file
0
.github/workflows/validate.yaml
vendored
Normal file
0
.github/workflows/validate.yaml
vendored
Normal file
18
.gitignore
vendored
Normal file
18
.gitignore
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# ignore all dotfiles by default
|
||||
.*
|
||||
|
||||
# unhide dotfiles we want to keep
|
||||
!.gitignore
|
||||
!.editorconfig
|
||||
!.clang-format
|
||||
!/.github/
|
||||
|
||||
# hide output files
|
||||
*.o
|
||||
*.d
|
||||
*.out
|
||||
/bin/
|
||||
/obj/
|
||||
*.lock
|
||||
/target/
|
||||
compile_commands.json
|
||||
15
Cargo.toml
Normal file
15
Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "dummy"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
crate-type = ["staticlib"]
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
|
||||
[dependencies]
|
||||
0
docs/README.md
Normal file
0
docs/README.md
Normal file
0
docs/TODO.md
Normal file
0
docs/TODO.md
Normal file
99
makefile
Normal file
99
makefile
Normal file
@@ -0,0 +1,99 @@
|
||||
# dependencies:
|
||||
# - make
|
||||
# - clang
|
||||
# - rustc
|
||||
# - bear (debug)
|
||||
# - git bash (windows)
|
||||
NAME := mcaselector-lite
|
||||
VER := 0.0.1
|
||||
|
||||
RUSTC := rustc
|
||||
|
||||
# C compiler options
|
||||
CC := clang
|
||||
CLANG := c
|
||||
CSTD := c17
|
||||
CFLAGS := -Wall -Wextra -Wpedantic -Wno-pointer-arith
|
||||
LDFLAGS :=
|
||||
DEBUG ?= 0
|
||||
ARCH ?= 0
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
CFLAGS += -DDEBUG -g -Og
|
||||
PROF := dbg
|
||||
else
|
||||
CFLAGS += -O2
|
||||
PROF := rel
|
||||
endif
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
ifeq ($(ARCH),linux-x86_64)
|
||||
CFLAGS += -target x86_64-pc-linux-gnu
|
||||
else ifeq ($(ARCH),win-x86_64)
|
||||
CFLAGS += -target x86_64-pc-windows-gnu
|
||||
EXT := .exe
|
||||
else
|
||||
$(error you must set the ARCH environment variable to one of these: 'linux-x86_64' 'win-x86_64')
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(ARCH),0)
|
||||
C_SRC := $(wildcard src/*.c) $(wildcard src/**/*.c) $(wildcard src/**/**/*.c) $(wildcard src/**/**/**/*.c) $(wildcard src/**/**/**/**/*.c)
|
||||
C_OBJ := $(patsubst src/%,obj/$(ARCH)/$(PROF)/%,$(C_SRC:.c=.o))
|
||||
C_DEP := $(C_OBJ:.o=.d)
|
||||
RS_SRC := $(wildcard src/*.rs) $(wildcard src/**/*.rs) $(wildcard src/**/**/*.rs) $(wildcard src/**/**/**/*.rs) $(wildcard src/**/**/**/**/*.rs)
|
||||
RS_OBJ := $(patsubst src/%,obj/$(ARCH)/$(PROF)/%,$(RS_SRC:.rs=.o))
|
||||
|
||||
DIR := bin/$(ARCH)/$(PROF) $(sort obj/$(ARCH)/$(PROF) $(dir $(C_SRC)) $(dir $(RS_SRC)))
|
||||
DIR_BUILD := bin/$(ARCH)/$(PROF)
|
||||
TARGET := $(DIR_BUILD)/$(NAME)$(EXT)
|
||||
endif
|
||||
|
||||
define wr_colour
|
||||
@echo -e "\033[$(2)m$(1)\033[0m"
|
||||
endef
|
||||
|
||||
# compiles and executes the produced binary
|
||||
run: compile
|
||||
./$(TARGET)
|
||||
compile: compile_commands.json $(DIR) $(TARGET)
|
||||
clean:
|
||||
rm -rf bin/ obj/ compile_commands.json
|
||||
|
||||
# create the binary (linking step)
|
||||
$(TARGET): $(C_OBJ) $(RS_OBJ)
|
||||
@$(call wr_colour,"RUSTC: '$(RUSTC)'",94)
|
||||
@$(call wr_colour,"CC: '$(CC)'",94)
|
||||
@$(call wr_colour,"CFLAGS: '$(CFLAGS)'",94)
|
||||
@$(call wr_colour,"LDFLAGS: '$(LDFLAGS)'",94)
|
||||
@$(call wr_colour,"linking to: '$@'",92)
|
||||
|
||||
@$(CC) $(LDFLAGS) $(C_OBJ) $(RS_OBJ) -o $(TARGET)
|
||||
@$(call wr_colour,"current profile: '$(PROF)'",93)
|
||||
|
||||
# create .o and .d files for C sources
|
||||
$(C_OBJ): $(C_SRC)
|
||||
$(call wr_colour,"compiling $(notdir $@) from $(notdir $<)",92)
|
||||
@$(CC) $(CFLAGS) -c -MD -MP -std=$(CSTD) -x $(CLANG) -o $@ $<
|
||||
|
||||
# create .o files for RUST sources
|
||||
$(RS_OBJ): $(RS_SRC)
|
||||
$(call wr_colour,"compiling $(notdir $@) from $(notdir $<)",92)
|
||||
$(RUSTC) --crate-type=staticlib --emit=obj -C debuginfo=2 -C panic=abort -o $@ $<
|
||||
|
||||
# create directories
|
||||
$(DIR):
|
||||
mkdir -p $@
|
||||
|
||||
# update compile commands if the makefile has been updated (for linting)
|
||||
ifeq ($(DEBUG),1)
|
||||
compile_commands.json: makefile
|
||||
$(MAKE) clean
|
||||
@touch compile_commands.json
|
||||
bear -- make compile
|
||||
else
|
||||
compile_commands.json:
|
||||
endif
|
||||
|
||||
# include the dependencies
|
||||
-include $(C_DEP)
|
||||
12
src/lib.rs
Normal file
12
src/lib.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
#![no_std]
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn get_str() -> *const u8 {
|
||||
let str = "Hello, World\0";
|
||||
return str.as_ptr();
|
||||
}
|
||||
8
src/main.c
Normal file
8
src/main.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <stdio.h>
|
||||
|
||||
extern char const* get_str(void);
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
(void)argc, (void)argv;
|
||||
printf("%s\n", get_str());
|
||||
}
|
||||
Reference in New Issue
Block a user