Initial commit, first project from 0 with xmake
This commit is contained in:
60
.gitignore
vendored
Normal file
60
.gitignore
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# Directories
|
||||
build/
|
||||
build-*/
|
||||
cmake-build-*/
|
||||
.cache/
|
||||
out/
|
||||
out/Debug/
|
||||
out/Release/
|
||||
|
||||
# xmake
|
||||
xmake/
|
||||
.xmake/*
|
||||
.xmake
|
||||
|
||||
# Cmake files
|
||||
CMakeCache.txt
|
||||
cmake
|
||||
CMakeFiles/
|
||||
cmake_install.cmake
|
||||
CTestTestfile.cmake
|
||||
Testing/
|
||||
compile_commands.json
|
||||
../compile_commands.json
|
||||
build/compile_commands.json
|
||||
|
||||
# Make / Ninja
|
||||
Makefile
|
||||
*.ninja
|
||||
*.ninja_deps
|
||||
*.ninja_log
|
||||
rules.ninja
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.obj
|
||||
*.lo
|
||||
*.la
|
||||
|
||||
# Binaries
|
||||
*.out
|
||||
*.exe
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
*.a
|
||||
|
||||
# Debug / Sanitizer
|
||||
*.dSYM/
|
||||
*.gcno
|
||||
*.gcda
|
||||
*.gcov
|
||||
|
||||
# Editors
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
6
include/lae_strings.h
Normal file
6
include/lae_strings.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef LAE_STRINGS_H
|
||||
#define LAE_STRINGS_H
|
||||
|
||||
typedef struct ByteStr ByteStr;
|
||||
|
||||
#endif
|
||||
9
src/lae_strings.c
Normal file
9
src/lae_strings.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "lae_strings.h"
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct ByteStr {
|
||||
uint8_t* buf;
|
||||
size_t len;
|
||||
size_t cap;
|
||||
};
|
||||
18
src/main.c
Normal file
18
src/main.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "mylib.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
MyLib *lib = mylib_create();
|
||||
if (!lib) {
|
||||
fprintf(stderr, "Error: could not create MyLib\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
int result = mylib_do_something(lib, 42);
|
||||
printf("Result: %d\n", result);
|
||||
|
||||
mylib_destroy(lib);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
11
test/test_string.c
Normal file
11
test/test_string.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <cmocka.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdarg.h> /* required by cmocka */
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lae_strings.h"
|
||||
|
||||
int main(void) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
88
xmake.lua
Normal file
88
xmake.lua
Normal file
@@ -0,0 +1,88 @@
|
||||
set_project("lae_strings")
|
||||
set_version("1.0.0")
|
||||
|
||||
set_languages("c11")
|
||||
|
||||
add_rules("mode.debug", "mode.release")
|
||||
|
||||
-- Export compile_commands.json
|
||||
add_rules("plugin.compile_commands.autoupdate")
|
||||
|
||||
-- =========================================================
|
||||
-- Options
|
||||
-- =========================================================
|
||||
|
||||
option("tests")
|
||||
set_default(false)
|
||||
set_showmenu(true)
|
||||
option_end()
|
||||
|
||||
option("example")
|
||||
set_default(false)
|
||||
set_showmenu(true)
|
||||
option_end()
|
||||
|
||||
option("asan")
|
||||
set_default(false)
|
||||
set_showmenu(true)
|
||||
option_end()
|
||||
|
||||
-- =========================================================
|
||||
-- Packages
|
||||
-- =========================================================
|
||||
|
||||
add_requires("cmocka", { optional = true })
|
||||
add_requires("lae_allocator")
|
||||
|
||||
-- =========================================================
|
||||
-- Library
|
||||
-- =========================================================
|
||||
|
||||
target("lae_strings")
|
||||
set_kind("static")
|
||||
|
||||
add_packages("lae_allocator")
|
||||
|
||||
add_files("src/lae_strings.c")
|
||||
|
||||
add_headerfiles("include/*.h")
|
||||
|
||||
add_includedirs("include", { public = true })
|
||||
|
||||
if is_mode("debug") then
|
||||
add_cflags("-Wall", "-Wextra", "-Wpedantic")
|
||||
end
|
||||
|
||||
-- =========================================================
|
||||
-- Example executable
|
||||
-- =========================================================
|
||||
|
||||
if has_config("example") then
|
||||
target("example")
|
||||
set_kind("binary")
|
||||
|
||||
add_files("src/main.c")
|
||||
|
||||
add_deps("lae_strings")
|
||||
end
|
||||
|
||||
-- =========================================================
|
||||
-- Tests
|
||||
-- =========================================================
|
||||
|
||||
if has_config("tests") then
|
||||
target("test_string")
|
||||
set_kind("binary")
|
||||
|
||||
add_files("test/test_string.c")
|
||||
|
||||
add_deps("lae_strings")
|
||||
|
||||
add_packages("cmocka")
|
||||
|
||||
if has_config("asan") then
|
||||
add_cflags("-fsanitize=address", "-fno-omit-frame-pointer", { force = true })
|
||||
|
||||
add_ldflags("-fsanitize=address", { force = true })
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user