-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from FelixEcker/topic/mcfg_2
Update to MCFG/2
- Loading branch information
Showing
34 changed files
with
2,269 additions
and
1,330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CompileFlags: | ||
Add: -I./include/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
out/ | ||
Session.vim | ||
obj/ | ||
lib/ | ||
.vs | ||
mb | ||
vgcore.* | ||
valgrind.* | ||
*.log | ||
*.swp | ||
compile_flags.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
CC="clang" | ||
SRCDIR="src/" | ||
OBJDIR="obj/" | ||
|
||
CFLAGS="-ggdb -Iinclude/ -Isrc/ -DDEFAULT_LOG_LEVEL=LOG_DEBUG" | ||
LDFLAGS="-lm -Llib/ -lmcfg_2" | ||
|
||
BIN_NAME="mb" | ||
|
||
function build_objs() { | ||
COMPILED_OBJECTS=() | ||
|
||
for i in $1 | ||
do | ||
OUTNAME="$OBJDIR$i.o" | ||
INNAME="$SRCDIR$i.c" | ||
|
||
echo " CC $INNAME" | ||
|
||
$CC $CFLAGS -c -o $OUTNAME $INNAME || exit | ||
|
||
COMPILED_OBJECTS+=("${OUTNAME}") | ||
done | ||
} | ||
|
||
function build() { | ||
OBJECTS=("xmem strlist logging types executor c_rule target build main") | ||
|
||
echo "==> Compiling Sources for \"$BIN_NAME\"" | ||
build_objs "${OBJECTS[@]}" | ||
|
||
echo "==> Linking \"$BIN_NAME\"" | ||
echo " LD -o $BIN_NAME ${COMPILED_OBJECTS[@]} $LDFLAGS" | ||
$CC $CFLAGS -o $BIN_NAME ${COMPILED_OBJECTS[@]} $LDFLAGS | ||
} | ||
|
||
echo "MB build script. " | ||
|
||
if [ "$1" = "--compile-flags" ]; then | ||
sed --posix 's/ /\n/g' <<<"${CFLAGS[@]}" > compile_flags.txt | ||
|
||
echo "==> Generated compile_flags.txt" | ||
else | ||
build | ||
echo "==> Finished build!" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,106 @@ | ||
sector .config | ||
fields depends: | ||
list includes 'include/:src/' | ||
str libdir 'lib/' | ||
str libs '-Llib/ -lmcfg' | ||
list srcs '' | ||
|
||
fields mariebuild: | ||
str name 'mb' | ||
str compiler 'gcc' | ||
str src_dir 'src' | ||
str obj_dir 'out' | ||
|
||
str shell 'bash' | ||
|
||
list srcs 'mb_utils.c:mb_execute.c:mb.c' | ||
list files '$(depends/srcs):$(srcs)' | ||
|
||
str std_flags '-Wall -I$(depends/includes)' | ||
str debug_flags '-ggdb' | ||
str release_flags '-O3' | ||
|
||
str comp_cmd '$(compiler) $(mode_flags) $(std_flags) -c -o $(obj_dir)/$(file).o $(src_dir)/$(file)' | ||
str finalize_cmd '$(compiler) $(mode_flags) -o $(name) out/$(files).o $(depends/libs)' | ||
|
||
sector .scripts | ||
|
||
lines prepare: | ||
#!/usr/bin/bash | ||
if [[ ! -f lib/libmcfg.a ]]; then | ||
sh setup.sh | ||
fi | ||
; !MCFG_VERSION 3 | ||
|
||
sector config | ||
section info | ||
str name 'example' | ||
str version '1.0' | ||
str license 'BSD-3' | ||
end | ||
|
||
section files | ||
str obj 'obj/' | ||
list str sources 'xmem', 'strlist', 'logging', 'types', 'executor', 'c_rule', 'target', 'build', 'main' | ||
end | ||
|
||
section mariebuild | ||
; mariebuild now supports incremental building. In this mode, a compilation rule | ||
; is only executed if a file it executes upon is | ||
str build_type 'incremental' | ||
|
||
str cc 'clang' | ||
|
||
; mcfg 2 has brought along a new list syntax, where each element is its own string | ||
; and seperated by commas. | ||
list str targets 'clean', 'debug', 'release' | ||
str default 'debug' | ||
end | ||
end | ||
|
||
if [[ -d "./out/" ]]; then | ||
rm -rf out/* | ||
; Mariebuild now works with targets defined in this sector. | ||
; Each target can list other targets which it requires. Fields | ||
; from the current target are accesible via %target%. | ||
sector targets | ||
section clean | ||
str exec ' | ||
#!/bin/sh | ||
if [ -d obj ]; then | ||
rm -rf obj/ | ||
fi | ||
|
||
mkdir -p out/ | ||
mkdir obj | ||
' | ||
end | ||
|
||
section debug | ||
; Each target lists c_rules (or compilation rules) which are executed in order. | ||
list str c_rules 'executable' | ||
end | ||
|
||
section release | ||
list str required_targets 'clean' | ||
|
||
list str c_rules 'executable' | ||
end | ||
end | ||
|
||
; Each compilation rule is defined within this sector. They can access Fields | ||
; of the current target using %target%. | ||
sector c_rules | ||
section executable | ||
; Compilation rules can list other compilation rules which they require | ||
; These are executed in order. | ||
list str c_rules 'main' | ||
|
||
str binname 'mb' | ||
|
||
str build_type 'full' | ||
str exec_mode 'unify' | ||
|
||
str input_src '/config/files/sources' | ||
|
||
str input_format '$(/config/files/obj)$(%element%).o' | ||
str output_format '$(binname)' | ||
|
||
str ldflags '-lm -Llib/ -lmcfg_2' | ||
|
||
; The command which is specified in the exec field is executed for each member of | ||
; the list specified in exec_on | ||
str exec ' | ||
$(/config/mariebuild/cc) -o $(%output%) $(%input%) $(ldflags) | ||
' | ||
end | ||
|
||
section main | ||
; Run the 'exec' command for each input element. | ||
str exec_mode 'singular' | ||
|
||
str obj 'obj/' | ||
str src 'src/' | ||
|
||
; Declare our set of input elements. If no output list is defined, | ||
; the input list is used for that as well. | ||
str input_src '/config/files/sources' | ||
str output_src '/config/files/sources' | ||
|
||
; The input and output_format fields are used to determine if a output file | ||
; is out of date. They are also used to generate the input and output dynfields | ||
str input_format '$(src)$(%element%).c' | ||
str output_format '$(obj)$(%element%).o' | ||
|
||
str cflags '-ggdb -Iinclude/ -Isrc/' | ||
|
||
str exec ' | ||
$(/config/mariebuild/cc) $(cflags) -c $(%input%) -o $(%output%) | ||
' | ||
end | ||
end |
Oops, something went wrong.