ext_easy impl + demo + fixes

This commit is contained in:
Hunter 2024-09-29 20:21:39 -04:00
parent 1036d97ec6
commit ec26aa89e7
33 changed files with 2796 additions and 40 deletions

46
example/HConfig Normal file
View file

@ -0,0 +1,46 @@
grbc_want_version("1.0")
grbc_ext("GRBC_EXT_profiles")
local test_lib = grbc_library(LibraryConfig.new({
name = "libtest",
files = {
grbc_file("test.c")
},
requirements = {},
include_dirs = {
grbc_file("include")
},
lib_type = LibraryType.Shared,
compile_flags = {},
linker_flags = {},
package_config = PackageConfig.new({
name = "libtest",
libraries = {},
include_dirs = {
grbc_file("include")
},
compile_flags = {},
linker_flags = {}
})
}))
local hello_world = grbc_executable(ExecutableConfig.new({
name = "hello_world",
files = {
grbc_file("main.c")
},
requirements = {
grbc_pkg("libtest")
},
include_dirs = {},
compile_flags = {},
linker_flags = {}
}))
grbc_task(TaskConfig.new({
name = "Clean",
task_id = "clean",
shell_script = "ninja -t clean"
}))
grbc_build("ninja")

75
example/build.ninja Normal file
View file

@ -0,0 +1,75 @@
### GENERATED BY THE GRBC BUILT-IN NINJA GENERATOR ###
### GENERATED ON: 1727643213 ###
## Default variables ##
builddir = build
## build_rule_compile_cc ##
cc_path = /usr/lib64/ccache/gcc
rule cc
command = $cc_path -MMD -MT $out -MF $out.d $p_cflags -c $in -o $out
description = Compiling C object $in
depfile = $out.d
deps = gcc
## build_rule_compile_cxx ##
cxx_path = /usr/lib64/ccache/g++
rule cxx
command = $cxx_path -MMD -MT $out -MF $out.d $p_cflags -c $in -o $out
description = Compiling C++ object $in
depfile = $out.d
deps = gcc
## build_rule_link_cc ##
rule link_cc
command = $cc_path $p_cflags -o $out $in $p_linker_flags
description = Linking C target $out
## build_rule_link_cxx ##
rule link_cxx
command = $cxx_path $p_cflags -o $out $in $p_linker_flags
description = Linking C++ target $out
## build_rule_archive_library ##
rule archive
command = rm -f $out; ar crs $out $in
description = Creating static library $out
## Compile: test.c ##
build $builddir/test.o: cxx test.c
p_cflags = -fPIC -Iinclude
## Link: libtest.so ##
build $builddir/libtest.so: link_cxx $builddir/test.o
p_linker_flags = -shared -O3 -DNDEBUG -Lbuild -Wl,-rpath,build:.
p_cflags =
## Compile: main.c ##
build $builddir/main.o: cxx main.c
p_cflags = -Iinclude
## Link: hello_world ##
build $builddir/hello_world: link_cxx $builddir/main.o | $builddir/libtest.so
p_linker_flags = build/libtest.so -O3 -DNDEBUG -Lbuild -Wl,-rpath,build:.
p_cflags =
## clean ##
rule clean_task
command = ninja -t clean
description = Running task: Clean (clean)
build clean: clean_task
build all: phony $builddir/libtest.so $builddir/hello_world
default all

View file

@ -0,0 +1,32 @@
[
{
"directory": "/home/interfiber/dev/grbc/example",
"command": "/usr/lib64/ccache/g++ -MMD -MT build/test.o -MF build/test.o.d -fPIC -Iinclude -c test.c -o build/test.o",
"file": "test.c",
"output": "build/test.o"
},
{
"directory": "/home/interfiber/dev/grbc/example",
"command": "/usr/lib64/ccache/g++ -o build/libtest.so build/test.o -shared -Lbuild -Wl,-rpath,build:. ",
"file": "build/test.o",
"output": "build/libtest.so"
},
{
"directory": "/home/interfiber/dev/grbc/example",
"command": "/usr/lib64/ccache/g++ -MMD -MT build/main.o -MF build/main.o.d -Iinclude -c main.c -o build/main.o",
"file": "main.c",
"output": "build/main.o"
},
{
"directory": "/home/interfiber/dev/grbc/example",
"command": "/usr/lib64/ccache/g++ -o build/hello_world build/main.o build/libtest.so -Lbuild -Wl,-rpath,build:. ",
"file": "build/main.o",
"output": "build/hello_world"
},
{
"directory": "/home/interfiber/dev/grbc/example",
"command": "",
"file": "build/libtest.so",
"output": "all"
}
]

3
example/include/test.h Normal file
View file

@ -0,0 +1,3 @@
#pragma once
void test_function();

8
example/main.c Normal file
View file

@ -0,0 +1,8 @@
#include <stdio.h>
#include "test.h"
int main() {
printf("Hello World!\n");
test_function();
}

6
example/test.c Normal file
View file

@ -0,0 +1,6 @@
#include "test.h"
#include <stdio.h>
void test_function() {
printf("void test_function();\n");
}