/ Check-in [4d0f29d5]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Move some work out of the makefiles and into awk scripts in separate files. Ticket #940. (CVS 2005)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4d0f29d54c0ccb153abd77d9b62b6461ec1e978f
User & Date: drh 2004-10-06 15:03:57
Context
2004-10-06
15:41
Convert many constants to have type "const". (CVS 2006) check-in: d790c84c user: drh tags: trunk
15:03
Move some work out of the makefiles and into awk scripts in separate files. Ticket #940. (CVS 2005) check-in: 4d0f29d5 user: drh tags: trunk
14:39
Size optimization in the parser. (CVS 2004) check-in: 8e2ae244 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Makefile.in.

282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305

pager.lo:	$(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
	$(LTCOMPILE) -c $(TOP)/src/pager.c

opcodes.lo:	opcodes.c
	$(LTCOMPILE) -c opcodes.c

opcodes.c:	opcodes.h
	echo '/* Automatically generated file.  Do not edit */' >opcodes.c
	echo 'char *sqlite3OpcodeNames[] = { "???", ' >>opcodes.c
	grep OP_ opcodes.h | sort -n +2 | \
	  sed -e 's/^.*OP_/  "/' -e 's/ [ 0-9]*$$/", /' >>opcodes.c
	echo '};' >>opcodes.c

opcodes.h:	parse.h $(TOP)/src/vdbe.c $(TOP)/mkopcodeh.awk
	echo '/* Automatically generated file.  Do not edit */' >opcodes.h
	cat parse.h $(TOP)/src/vdbe.c | awk -f $(TOP)/mkopcodeh.awk >>opcodes.h

os_mac.lo:	$(TOP)/src/os_mac.c $(HDR)
	$(LTCOMPILE) $(THREADSAFE) -c $(TOP)/src/os_mac.c

os_unix.lo:	$(TOP)/src/os_unix.c $(HDR)
	$(LTCOMPILE) $(THREADSAFE) -c $(TOP)/src/os_unix.c








|
|
<
<
<
<


<
|







282
283
284
285
286
287
288
289
290




291
292

293
294
295
296
297
298
299
300

pager.lo:	$(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
	$(LTCOMPILE) -c $(TOP)/src/pager.c

opcodes.lo:	opcodes.c
	$(LTCOMPILE) -c opcodes.c

opcodes.c:	opcodes.h $(TOP)/mkopcodec.awk
	sort -n +2 opcodes.h | awk -f $(TOP)/mkopcodec.awk >opcodes.c





opcodes.h:	parse.h $(TOP)/src/vdbe.c $(TOP)/mkopcodeh.awk

	cat parse.h $(TOP)/src/vdbe.c | awk -f $(TOP)/mkopcodeh.awk >opcodes.h

os_mac.lo:	$(TOP)/src/os_mac.c $(HDR)
	$(LTCOMPILE) $(THREADSAFE) -c $(TOP)/src/os_mac.c

os_unix.lo:	$(TOP)/src/os_unix.c $(HDR)
	$(LTCOMPILE) $(THREADSAFE) -c $(TOP)/src/os_unix.c

Changes to main.mk.

251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274

pager.o:	$(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
	$(TCCX) -c $(TOP)/src/pager.c

opcodes.o:	opcodes.c
	$(TCCX) -c opcodes.c

opcodes.c:	opcodes.h
	echo '/* Automatically generated file.  Do not edit */' >opcodes.c
	echo 'char *sqlite3OpcodeNames[] = { "???", ' >>opcodes.c
	grep OP_ opcodes.h | sort -n +2 | \
	  sed -e 's/^.*OP_/  "/' -e 's/ [ 0-9]*$$/", /' >>opcodes.c
	echo '};' >>opcodes.c

opcodes.h:	parse.h $(TOP)/src/vdbe.c $(TOP)/mkopcodeh.awk
	echo '/* Automatically generated file.  Do not edit */' >opcodes.h
	cat parse.h $(TOP)/src/vdbe.c | awk -f $(TOP)/mkopcodeh.awk >>opcodes.h

os_mac.o:	$(TOP)/src/os_mac.c $(HDR)
	$(TCCX) -c $(TOP)/src/os_mac.c

os_unix.o:	$(TOP)/src/os_unix.c $(HDR)
	$(TCCX) -c $(TOP)/src/os_unix.c








|
|
<
<
<
<


<
|







251
252
253
254
255
256
257
258
259




260
261

262
263
264
265
266
267
268
269

pager.o:	$(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
	$(TCCX) -c $(TOP)/src/pager.c

opcodes.o:	opcodes.c
	$(TCCX) -c opcodes.c

opcodes.c:	opcodes.h $(TOP)/mkopcodec.awk
	sort -n +2 opcodes.h | awk -f $(TOP)/mkopcodec.awk >opcodes.c





opcodes.h:	parse.h $(TOP)/src/vdbe.c $(TOP)/mkopcodeh.awk

	cat parse.h $(TOP)/src/vdbe.c | awk -f $(TOP)/mkopcodeh.awk >opcodes.h

os_mac.o:	$(TOP)/src/os_mac.c $(HDR)
	$(TCCX) -c $(TOP)/src/os_mac.c

os_unix.o:	$(TOP)/src/os_unix.c $(HDR)
	$(TCCX) -c $(TOP)/src/os_unix.c

Added mkopcodec.awk.













































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/awk -f
#
# This AWK script scans the opcodes.h file (which is itself generated by
# another awk script) and uses the information gleaned to create the
# opcodes.c source file.
#
# Opcodes.c contains strings which are the symbolic names for the various
# opcodes used by the VDBE.  These strings are used when disassembling a
# VDBE program during tracing or as a result of the EXPLAIN keyword.
#
BEGIN {
  print "/* Automatically generated.  Do not edit */"
  print "/* See the mkopcodec.h script for details. */"
  print "const char *sqlite3OpcodeNames[] = { \"?\","
}
/^#define OP_/ {
  sub("OP_","",$2)
  print "  \"" $2 "\","
}
END {
  print "};"
}

Changes to mkopcodeh.awk.

30
31
32
33
34
35
36


37
38
39
40
41
42
43
44
45
    }
  }
}

# Assign numbers to all opcodes and output the result.
END {
  cnt = 0


  for(name in op){
    if( op[name]<0 ){
      cnt++
      while( used[cnt] ) cnt++
      op[name] = cnt
    }
    printf "#define %-30s %d\n", name, op[name]
  }
}







>
>









30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
    }
  }
}

# Assign numbers to all opcodes and output the result.
END {
  cnt = 0
  print "/* Automatically generated.  Do not edit */"
  print "/* See the mkopcodeh.awk script for details */"
  for(name in op){
    if( op[name]<0 ){
      cnt++
      while( used[cnt] ) cnt++
      op[name] = cnt
    }
    printf "#define %-30s %d\n", name, op[name]
  }
}