tcledit/libwld: Add support for building debug versions.

This commit is contained in:
Gregory Nutt 2016-11-11 10:05:12 -06:00
parent c79f1deb2b
commit 8404acae22
4 changed files with 40 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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 <outfilename>] <infilename>
. /tcledit [-D <directory>] [-o <outfilename>] <infilename>
Where <infilename> is the original world file name which will be overwritten
unless <outfilename> is provided.
unless <outfilename> is provided. Optionally, switch to <directory> before
opening <infilenamea>.
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

View File

@ -42,6 +42,7 @@
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <tk.h>
#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 <outfilename>] <infilename>\n", progname);
fprintf(stderr, "USAGE:\n\t%s [-D <directory>] [-o <outfilename>] <infilename>\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]);