Browse Source

Update tool and Makefile for separate config/target

master
cancel 6 years ago
parent
commit
ab6cc5b92c
  1. 4
      Makefile
  2. 43
      tool
  3. 7
      tui_main.c

4
Makefile

@ -2,11 +2,11 @@ all: debug
.PHONY: debug .PHONY: debug
debug: debug:
@./tool build debug @./tool build debug orca
.PHONY: release .PHONY: release
release: release:
@./tool build release @./tool build release orca
.PHONY: clean .PHONY: clean
clean: clean:

43
tool

@ -5,10 +5,11 @@ print_usage() {
cat <<EOF cat <<EOF
Usage: tool [options] command [args] Usage: tool [options] command [args]
Commands: Commands:
build <target> build <config> <target>
Compile orca. Compile orca.
Targets: debug, release Configs: debug, release
Output: build/<target>/orca Targets: orca, tui
Output: build/<config>/<target>
clean clean
Removes build/ Removes build/
info info
@ -141,18 +142,14 @@ try_make_dir() {
fi fi
} }
out_exe=orca
build_dir=build build_dir=build
source_files=()
add source_files field.c mark.c bank.c sim.c
#local tui_flags=()
#add tui_flags -D_XOPEN_SOURCE_EXTENDED=1
build_target() { build_target() {
local build_subdir local build_subdir
local cc_flags=() local cc_flags=()
local libraries=() local libraries=()
local source_files=()
local out_exe
add cc_flags -std=c99 -pipe -Wall -Wpedantic -Wextra -Wconversion -Werror=implicit-function-declaration -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion add cc_flags -std=c99 -pipe -Wall -Wpedantic -Wextra -Wconversion -Werror=implicit-function-declaration -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion
if [[ $protections_enabled = 1 ]]; then if [[ $protections_enabled = 1 ]]; then
add cc_flags -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fpie -Wl,-pie add cc_flags -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fpie -Wl,-pie
@ -188,9 +185,25 @@ build_target() {
add cc_flags -flto -s add cc_flags -flto -s
fi fi
;; ;;
*) fatal "Unknown build target \"$1\"";; *) fatal "Unknown build config \"$1\"";;
esac esac
add source_files field.c mark.c bank.c sim.c
case "$2" in
orca|cli)
add source_files cli_main.c add source_files cli_main.c
out_exe=orca
;;
tui)
add source_files tui_main.c
add cc_flags -D_XOPEN_SOURCE_EXTENDED=1
out_exe=tui
if [[ $os = mac ]]; then
add libraries -lncurses
else
add libraries -lncursesw
fi
;;
esac
try_make_dir "$build_dir" try_make_dir "$build_dir"
try_make_dir "$build_dir/$build_subdir" try_make_dir "$build_dir/$build_subdir"
local out_path=$build_dir/$build_subdir/$out_exe local out_path=$build_dir/$build_subdir/$out_exe
@ -229,13 +242,13 @@ case "$1" in
exit 0 exit 0
;; ;;
build) build)
if [[ "$#" -gt 2 ]]; then if [[ "$#" -lt 3 ]]; then
fatal "Too many arguments for 'build'" fatal "Too few arguments for 'build'"
fi fi
if [ "$#" -lt 2 ]; then if [[ "$#" -gt 3 ]]; then
fatal "Argument required for build target" fatal "Too many arguments for 'build'"
fi fi
build_target "$2" build_target "$2" "$3"
;; ;;
clean) clean)
if [[ -d "$build_dir" ]]; then if [[ -d "$build_dir" ]]; then

7
tui_main.c

@ -74,11 +74,12 @@ int main() {
field_fill_subrect(&field, 1, 1, (Usz)(field.height - 2), field_fill_subrect(&field, 1, 1, (Usz)(field.height - 2),
(Usz)(field.width - 2), fill_char); (Usz)(field.width - 2), fill_char);
// field_debug_draw(stdscr, &field, 0, 0); // field_debug_draw(stdscr, &field, 0, 0);
field_copy_subrect(&field, &field, 0, 0, 4, 4, 8, 8); // field_copy_subrect(&field, &field, 0, 0, 4, 4, 8, 8);
field_copy_subrect(&field, &field, 0, 0, 0, 0, 0, 0); // field_copy_subrect(&field, &field, 0, 0, 0, 0, 0, 0);
// field_debug_draw(stdscr, &field, field.height + 1, 0); // field_debug_draw(stdscr, &field, field.height + 1, 0);
field_copy_subrect(&field, &field, 6, 6, 9, 9, 30, 30); // field_copy_subrect(&field, &field, 6, 6, 9, 9, 30, 30);
// field_debug_draw(stdscr, &field, 0, field.width + 1); // field_debug_draw(stdscr, &field, 0, field.width + 1);
// field_debug_draw(stdscr, &field, field.height, field.width);
refresh(); refresh();
} }
field_deinit(&field); field_deinit(&field);

Loading…
Cancel
Save