From 8404acae22033e6e2e6921d0a2c29cb7155abff5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 11 Nov 2016 10:05:12 -0600 Subject: [PATCH] tcledit/libwld: Add support for building debug versions. --- graphics/traveler/tools/libwld/Makefile | 2 +- graphics/traveler/tools/libwld/README.txt | 7 ++++++- graphics/traveler/tools/tcledit/README.txt | 20 ++++++++++++++------ graphics/traveler/tools/tcledit/tcl_edit.c | 21 +++++++++++++++++++-- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/graphics/traveler/tools/libwld/Makefile b/graphics/traveler/tools/libwld/Makefile index c27ddf086..3d1dab82c 100644 --- a/graphics/traveler/tools/libwld/Makefile +++ b/graphics/traveler/tools/libwld/Makefile @@ -60,7 +60,7 @@ OBJS = $(SRCS:.c=.o) CC = gcc AR = ar -rcv -DEBUG_LEVEL = 0 +DEBUG_LEVEL ?= 0 DEFINES = -DDEBUG_LEVEL=$(DEBUG_LEVEL) INCLUDES = -I. -I$(APPDIR)/include -I$(TRAVELER)/include -isystem $(NUTTXDIR) WARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wno-trigraphs diff --git a/graphics/traveler/tools/libwld/README.txt b/graphics/traveler/tools/libwld/README.txt index 99f4b65f9..9dacd0461 100644 --- a/graphics/traveler/tools/libwld/README.txt +++ b/graphics/traveler/tools/libwld/README.txt @@ -20,4 +20,9 @@ Build instuctions: Then you can build the world library: 5. cd apps/graphics/traveler/tools/libwld - 6. make + 6a. make + + If you want to create a debug-able version of the library, do: + + 6b. make DEBUG_LEVEL=1 + diff --git a/graphics/traveler/tools/tcledit/README.txt b/graphics/traveler/tools/tcledit/README.txt index 9131f9d29..34084dfe2 100644 --- a/graphics/traveler/tools/tcledit/README.txt +++ b/graphics/traveler/tools/tcledit/README.txt @@ -21,7 +21,11 @@ Build instuctions Build the world library: 5. cd apps/graphics/traveler/tools/libwld - 6. make + 6a. make + + If you want to create a debug-able version of the library, do: + + 6b. make DEBUG_LEVEL=1 Then you can use xmfmk to create the Makefile and build the tool: @@ -30,19 +34,23 @@ Build instuctions a minimum. These are the paths to where you have clones the apps/ repository and the nuttx/ repositories, respectively. 9. xmfmk - 10. make tcledit + 10a. make tcledit + + If you want to create a debug-able version of tcledit, do: + + 10b. make tcledit DEBUG_LEVEL=1 Usage ===== - . /tcledit [-o ] + . /tcledit [-D ] [-o ] Where is the original world file name which will be overwritten - unless is provided. + unless is provided. Optionally, switch to before + opening . NOTE: The default traveler world file is apps/graphics/traverler/world/transfrm.wld. The file contains relative paths so you may have to CD in to the directory first like: - cd world - ../tools/tcledit/tcledit transfrm.wld + ./tcledit -D ../../world transfrm.wld diff --git a/graphics/traveler/tools/tcledit/tcl_edit.c b/graphics/traveler/tools/tcledit/tcl_edit.c index 1864f59da..1595fec67 100644 --- a/graphics/traveler/tools/tcledit/tcl_edit.c +++ b/graphics/traveler/tools/tcledit/tcl_edit.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include "trv_types.h" @@ -593,7 +594,8 @@ static int tcledit_save_rectangles(ClientData clientData, static void show_usage(const char *progname) { - fprintf(stderr, "USAGE:\n\t%s [-o ] \n", progname); + fprintf(stderr, "USAGE:\n\t%s [-D ] [-o ] \n", + progname); exit(1); } @@ -603,19 +605,34 @@ static void show_usage(const char *progname) int main(int argc, char **argv, char **envp) { + char *directory; int option; + int ret; /* Parse command line options */ g_out_filename = g_default_filename; - while ((option = getopt(argc, argv, "o:")) != EOF) + while ((option = getopt(argc, argv, "D:o:")) != EOF) { switch (option) { + case 'D': + directory = optarg; + ret = chdir(directory); + if (ret < 0) + { + int errcode = errno; + fprintf(stderr, "ERROR: Failed to CD to %s: %s\n", + directory, strerror(errcode)); + show_usage(argv[0]); + } + break; + case 'o': g_out_filename = optarg; break; + default: fprintf(stderr, "Unrecognized option: %c\n", option); show_usage(argv[0]);