Skip to content

Commit ada19c9

Browse files
add program comment support
Signed-off-by: mateoconlechuga <matthewwaltzis@gmail.com>
1 parent 230e433 commit ada19c9

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/makefile.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ PREFER_OS_CRT ?= NO
4848
PREFER_OS_LIBC ?= YES
4949
LIBLOAD_OPTIONAL ?=
5050
COMPRESSED_MODE ?= zx7
51+
COMMENT ?= $(shell cedev-config --comment)
5152
#----------------------------
5253
CEDEV_TOOLCHAIN ?= $(shell cedev-config --prefix)
5354
#----------------------------
@@ -209,6 +210,9 @@ endif
209210
ifeq ($(HAS_UPPERCASE_NAME),YES)
210211
CONVBINFLAGS += -u
211212
endif
213+
ifneq ($(COMMENT),)
214+
CONVBINFLAGS += -b $(call QUOTE_ARG,$(COMMENT))
215+
endif
212216
CONVBINFLAGS += -n $(NAME)
213217

214218
# output debug map file

tools/cedev-config/src/main.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <string.h>
44
#include <stdlib.h>
55
#include <stdio.h>
6+
#include <time.h>
67

78
#include "cwalk.h"
89
#include "whereami.h"
@@ -13,6 +14,8 @@
1314
#define FILENAME_MAX_LENGTH 65536
1415
#endif
1516

17+
#define TIME_MAX_LENGTH 42
18+
1619
static int help(const char *prgm)
1720
{
1821
fprintf(stdout, "usage: %s <OPTION>\n", prgm);
@@ -74,6 +77,9 @@ int main(int argc, char *argv[])
7477
{
7578
static char cedev[FILENAME_MAX_LENGTH];
7679
static char buffer[FILENAME_MAX_LENGTH];
80+
static char timebuffer[TIME_MAX_LENGTH];
81+
time_t rawtime;
82+
struct tm * timeinfo;
7783

7884
if (argc != 2)
7985
{
@@ -92,10 +98,11 @@ int main(int argc, char *argv[])
9298
{"version", no_argument, 0, 'v'},
9399
{"prefix", no_argument, 0, 'p'},
94100
{"makefile", no_argument, 0, 'm'},
101+
{"comment", no_argument, 0, 'c'},
95102
{0, 0, 0, 0}
96103
};
97104

98-
c = getopt_long(argc, argv, "h", long_options, NULL);
105+
c = getopt_long(argc, argv, "hvpmc", long_options, NULL);
99106
if (c < 0)
100107
{
101108
break;
@@ -124,6 +131,13 @@ int main(int argc, char *argv[])
124131
fprintf(stdout, "%s\n", buffer);
125132
break;
126133

134+
case 'c':
135+
time(&rawtime);
136+
timeinfo = localtime(&rawtime);
137+
strftime(timebuffer, TIME_MAX_LENGTH, "%FT%T%z", timeinfo);
138+
fprintf(stdout, "%s " CEDEV_VERSION "\n", timebuffer);
139+
break;
140+
127141
case 'h':
128142
default:
129143
return help(argv[0]);

0 commit comments

Comments
 (0)