File: Developer.txt

package info (click to toggle)
nethack 3.6.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,468 kB
  • sloc: ansic: 266,495; cpp: 13,652; yacc: 2,903; perl: 1,426; lex: 581; sh: 535; xml: 372; awk: 98; makefile: 68; fortran: 51; sed: 11
file content (235 lines) | stat: -rw-r--r-- 9,463 bytes parent folder | download | duplicates (4)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
  ___              _
 |   \ _____ _____| |___ _ __  ___ _ _
 | |) / -_) V / -_) / _ \ '_ \/ -_) '_|
 |___/\___|\_/\___|_\___/ .__/\___|_|
                        |_|

# NetHack 3.6  Developer.txt       $NHDT-Date: 1524689668 2018/04/25 20:54:28 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.13 $
# Copyright (c) 2015 by Kenneth Lorber, Kensington, Maryland
# NetHack may be freely redistributed.  See license for details.

Welcome to the NetHack Infrastructure Developer's Guide.

This is the info you need if you are developing code for NetHack.
(This information is from DevTeam.  If you are working with a variant please
check for additional documentation for that variant.)

For information on building NetHack, see README in the top level directory.
For information on playing NetHack, see the Guidebook in the doc directory.

DANGER!  WORK IN PROGRESS!  Known issues marked XXX.

CONTENTS
1. email
2. git repositories
3. bug reporting
4. git configuration
5. variable expansion
6. reserved names
7. nhadd/nhcommit
8. hooks
------------------------------------------------------------------------------
1. email
Email to devteam@nethack.org will usually get a response, but it may take a
while.  Please do not send save files, binary screen grabs, or other large
things.
------------------------------------------------------------------------------
2. git repositories
A public repository of the latest NetHack code that we've made 
available can be obtained via git from either of two locations:
    https://github.com/NetHack/NetHack
     or
    https://sourceforge.net/p/nethack/NetHack/

Branches:
NetHack-3.6.0	The 3.6.0 release code and subsequent fixes and additions.
------------------------------------------------------------------------------
3. bug reporting
Please use the form at http://www.nethack.org/common/contact.html (or send
us an email if that's more appropriate).
------------------------------------------------------------------------------
4. git configuration

NOTE: These instructions assume you are on the default branch; this _is_
      where you want to be for setting things up.  This may or may not be
      the branch you want to use for your changes; see the appropriate
      project private documentation for more information (if you are working
      alone we suggest using branch names starting with "LOCAL-").

NOTE: The following instructions require perl.  If you do not have perl on
      your system, please install it before proceeding.

A. If you have never set up git on this machine before:
   (This assumes you will only be using git for NetHack.  If you are going to
   use it for other projects as well, think before you type.)
	Tell git what name (or nickname) and email address to use for you:
		git config --global user.name "MY NAME"
		git config --global user.email USER@EXAMPLE.COM
   You probably want to set up a credential cache.
	Mac OS X:
		git config --global credential.helper osxkeychain
	Windows:
		git config --global credential.helper store
XXX linux
B. Specify the prefix for variable substitution:
   (This assumes you are not a member of DevTeam or any variant's development
   team.  If you are, this may be wrong.  Look for more specific documentation.
   For example, this file uses "MINE" for the substitution prefix - this will
   almost always be wrong if you are working with someone else.)
	Decide where you want to put this info; it should NOT be inside the
	tree you cloned from git.  I use ~/nethack/GITADDDIR; for that base,
	create the needed directories and edit the file:
		~/nethack/GITADDDIR/DOTGIT/PRE
	Put this in it (if your OS is not Unix-like you may need to change
	the first line):
		#!/bin/sh
		git config nethack.substprefix MINE
	Now make it executable:
		chmod +x ~/nethack/GITADDDIR/DOTGIT/PRE
C. Configure the repository:
	- cd to the top level of the repository
	- tell the repository about the directory you created above:
		git config nethack.gitadddir FULL_PATH_TO_GITADDDIR
	   so for the example above:
		git config nethack.gitadddir ~/nethack/GITADDDIR
	- do the automated setup:
		perl DEVEL/nhgitset.pl
	  If it complains, fix what it complains about.  nhgitset.pl accepts
	  the following options:
		-v verbose
		-n dry run
   You can re-run nhgitset.pl as often as needed; occasionally we will
   update it (or something it installs) and you will need to run it again
   so the changes take effect.
D. aliases
   Two aliases are installed by nhgitset.pl:
	nhadd
	nhcommit
   These two commands take the same options as the normal git add and commit
   commands but perform RCS/CVS-style variable substitution.

   Note that nothing terrible will happen if you do not use the nh* versions
   of the commands.

   Supported substitutions:
	MINE-Date	the commit time and date
   Experimental substitutions:
	MINE-Revision	CVS style revision number
	MINE-Branch	the current git branch

   For direct access to the substitution mechanism, use:
	nhsub

   See the section "nhadd/nhcommit" for details on those aliases.
   Run "perldoc DEVEL/hooksdir/nhsub" for details on nhsub.

That's it.  If you need to do something more when setting up your repository,
keep reading.  Otherwise, you are done with this section.

1) to run your own hooks in addition to ours:
	name your hook
		WHEN-HOOKNAME
	where WHEN is
		PRE	(run your code before the NetHack hook)
		POST	(run your code after the NetHack hook)
	and HOOKNAME is the normal git name of the hook.
   Make sure the hooks are executable (chmod +x ...).
   Be sure to test carefully since the composition of two bits of code may or
   may not do what you want.
2) to install other bits on setup:
	Put additional files in the GITADDDIR tree.  Use "DOTGIT" instead of
	".git".  If a file called PRE, POST, or INSTEAD exists in a
	subdirectory of GITADDDIR, it is run before the copy, after the copy,
	or instead of the copy.  No copy operation is attempted in the DOTGIT
	directory; use a script and standard git commands to change the
	contents as needed.
3) NB: In all namespaces, anything that matches m/^nh/i or m/^nethack/i is
   reserved.
------------------------------------------------------------------------------
5. variable expansion
A. Introduction
   We have implemented an RCS/CVS/SVN style variable expansion mechanism.
   References of either of the formats:
	$PREFIX-VARNAME$
	$PREFIX-VARNAME: VALUE $
   will be handled (if enabled).

   The PREFIX is the value in the git config variable nethack.substprefix.
   VARNAME is one of:
	Date
	Branch (experimental)
	Revision (experimental)
   other names will give a warning.

B. Enabling variable expansion
   Variable expansion is controlled by the .gitattributes file.

   To enable variable expansion:
        pattern NHSUBST
   To disable variable expansion:
	pattern -NHSUBST

   More information: "git help gitattributes"

C. Oddities
   To trigger variable expansion, you _must_ use "git nhadd" or "git nhcommit"
   instead of "git add" or "git commit."  Nothing terrible will happen if you
   use the wrong one, but the values will not be updated.

   Variable expansion modifies the files in the work tree - your editor or
   IDE may or may not be happy with this.

D. Using your own hooks
   You can use your own hooks - put them in .git/hooks as usual BUT name them
   as follows:
	WHEN-HOOKNAME
   where WHEN is:
	PRE	(execute the code before the NetHack hook)
	POST	(execute the code after the NetHack hook)
   and HOOKNAME is the normal git name for the hook.

   Test carefully - interactions between hooks can be nasty.
------------------------------------------------------------------------------
6. reserved names
   Anything that matches m/^nh/i or m/^nethack/i is reserved in all
   namespaces (environment, file names, git config, etc).
------------------------------------------------------------------------------
7. nhadd/nhcommit
   nhadd is essentially "git nhsub $*; git add $*"
   nhcommit is essentially "git nhsub $*; git commit $*"

   As "git add" and "git commit" have complex arguments, nhsub attempts to
   do the right thing - or at least something reasonable - for most arguments.
   If nhadd/nhcommit don't do what you need, run "git nhsub" on its own then
   add/commit.

   So when do I need to use what?
   The object is to get nhsub run right before git takes a snapshot of each
   file.  So for example:
   - use "git nhcommit <filespec>" instead of "git commit <filespec>"
   - use "git nhadd <filespec>" instead of "git add <filespec>"
   - use either "git commit" or "git nhcommit" (because the snapshot was
     already taken)
   - if you use "git nhsub <filespec>" then you can "git add <filespec>" or
     "git commit <filespec>" 

   For more complex situations, "git nhsub" takes -v and -n flags - see
   "perldoc DEVEL/hooksdir/nhsub".
   
------------------------------------------------------------------------------
8. hooks

   nhgitset.pl also installs hooks into .git/hooks.  These hooks provide
   a framework which allows local hook code to co-exist with hook code we
   supply - see DEVEL/hooksdir/NHgithook.pm for details.

   We currently use the following hooks:
    post-checkout
    post-commit
    post-merge
   These are used to generate dat/gitinfo.txt which provides the data that
   ends up available through the game command #version and the command line
   option --version.

------------------------------------------------------------------------------