summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/util/gen-luatags.pl
blob: db0e1800fa42ca8f188b47545a3e2670b43c2e44 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env perl
use strict;
use warnings;

my @tags=("TAG_MINOR_RESET");
open IN, "<tag-version.h" or die "Can't open tag-version.h\n";
while (<IN>)
{
    push @tags, $1 if /^\s*((?:NUM_)?TAG_MINOR[A-Z_0-9]+),/;
}
die "Didn't find any TAG_MINOR enums.\n" unless @tags;

open OUT, ">dat/dlua/tags.lua" or die;
print OUT <<END;
-- Autogenerated by util/gen-luatags.pl, do not edit.

------------------------------------------------------------------------------
-- tags.lua:
-- Tag and version compatibility functions and info.
------------------------------------------------------------------------------
tags = {}

------------------------------------------------------------------------------
-- simpler access to tag_major_version
------------------------------------------------------------------------------

function tags.major_version ()
  return file.major_version()
end

END
my $num = 0;
printf OUT "tags.%s = %d\n", $_, $num++ for @tags;
print OUT "tags.TAG_MINOR_VERSION = tags.NUM_TAG_MINORS - 1\n";