Skip to content
This repository was archived by the owner on Nov 11, 2024. It is now read-only.

Commit b8b3296

Browse files
author
Alex Rønne Petersen
committed
Improvements to the build system.
* Add `install`/`uninstall` targets. * Less hacky release archive creation. * Apply some DRY throughout. * Don't use the `sdb` script to run tests.
1 parent edf7486 commit b8b3296

File tree

5 files changed

+87
-39
lines changed

5 files changed

+87
-39
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
bin/*
22
dep/*
3+
rel/*
34

45
*.dll
56
*.exe

Makefile

+57-20
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ CP ?= cp
2929
ECHO ?= echo
3030
FSHARPC ?= fsharpc
3131
GENDARME ?= gendarme
32+
INSTALL ?= install
3233
MCS ?= mcs
3334
MKDIR ?= mkdir
3435
PKG_CONFIG ?= pkg-config
36+
PREFIX ?= /usr/local
3537
SED ?= sed
3638
TAR ?= tar
3739
XBUILD ?= xbuild
@@ -47,7 +49,6 @@ ifeq ($(MODE), Debug)
4749
MCS_FLAGS += -debug
4850
else
4951
override xb_mode = net_4_0_Release
50-
override mono_opt =
5152

5253
FSHARPC_FLAGS += --optimize
5354
MCS_FLAGS += -optimize
@@ -56,19 +57,18 @@ endif
5657
FSHARPC_FLAGS += --nologo --warnaserror
5758
GENDARME_FLAGS += --severity all --confidence all
5859
MCS_FLAGS += -langversion:experimental -unsafe -warnaserror
59-
XBUILD_FLAGS += /verbosity:quiet /property:Configuration=$(xb_mode)
60+
XBUILD_FLAGS += /nologo /property:Configuration=$(xb_mode) /verbosity:quiet
6061

6162
FSHARPC_TEST_FLAGS += --debug+ --nologo --warnaserror
6263
MCS_TEST_FLAGS += -debug -langversion:experimental -unsafe -warnaserror
6364

64-
.PHONY: all check clean clean-check clean-deps gendarme update-deps
65+
.PHONY: all check clean clean-check clean-deps clean-release gendarme install release uninstall update-deps
6566

6667
override results = \
67-
LICENSE \
68-
README \
6968
sdb.exe \
7069
sdb.exe.config \
71-
sdb
70+
sdb \
71+
sdb-dev
7272

7373
all: $(addprefix bin/, $(results))
7474

@@ -104,7 +104,7 @@ override tests = \
104104
$(addprefix chk/fs/, $(addsuffix .mdb, $(fs_tests)))
105105

106106
check: chk/check.exe $(addprefix bin/, $(results)) $(tests)
107-
$(CD) chk && MONO_PATH=. $(MONO_PREFIX)/bin/mono check.exe
107+
$(CD) chk && MONO_PATH=. $(MONO_PREFIX)/bin/mono $(notdir $<)
108108

109109
clean:
110110
$(RM) -r bin
@@ -116,9 +116,40 @@ clean-check:
116116
clean-deps:
117117
$(CD) dep/debugger-libs && $(XBUILD) $(XBUILD_FLAGS) /target:Clean
118118

119+
clean-release:
120+
$(RM) -r rel
121+
119122
gendarme: bin/sdb.exe
120123
$(GENDARME) $(GENDARME_FLAGS) --log bin/sdb.log $<
121124

125+
install: $(addprefix bin/, $(results))
126+
$(INSTALL) -m755 -d $(PREFIX)/lib/sdb
127+
$(INSTALL) -m755 bin/ICSharpCode.NRefactory.dll $(PREFIX)/lib/sdb
128+
$(INSTALL) -m755 bin/ICSharpCode.NRefactory.CSharp.dll $(PREFIX)/lib/sdb
129+
$(INSTALL) -m755 bin/Mono.Cecil.dll $(PREFIX)/lib/sdb
130+
$(INSTALL) -m755 bin/Mono.Cecil.Mdb.dll $(PREFIX)/lib/sdb
131+
$(INSTALL) -m755 bin/Mono.Debugger.Soft.dll $(PREFIX)/lib/sdb
132+
$(INSTALL) -m755 bin/Mono.Debugging.dll $(PREFIX)/lib/sdb
133+
$(INSTALL) -m755 bin/Mono.Debugging.Soft.dll $(PREFIX)/lib/sdb
134+
$(INSTALL) -m755 bin/sdb.exe $(PREFIX)/lib/sdb
135+
$(INSTALL) -m755 bin/sdb.exe.config $(PREFIX)/lib/sdb
136+
$(INSTALL) -m755 -d $(PREFIX)/bin
137+
$(INSTALL) -m755 bin/sdb $(PREFIX)/bin
138+
139+
release: rel/sdb.tar.gz
140+
141+
uninstall:
142+
$(RM) $(PREFIX)/lib/sdb/ICSharpCode.NRefactory.dll
143+
$(RM) $(PREFIX)/lib/sdb/ICSharpCode.NRefactory.CSharp.dll
144+
$(RM) $(PREFIX)/lib/sdb/Mono.Cecil.dll
145+
$(RM) $(PREFIX)/lib/sdb/Mono.Cecil.Mdb.dll
146+
$(RM) $(PREFIX)/lib/sdb/Mono.Debugger.Soft.dll
147+
$(RM) $(PREFIX)/lib/sdb/Mono.Debugging.dll
148+
$(RM) $(PREFIX)/lib/sdb/Mono.Debugging.Soft.dll
149+
$(RM) $(PREFIX)/lib/sdb/sdb.exe
150+
$(RM) $(PREFIX)/lib/sdb/sdb.exe.config
151+
$(RM) $(PREFIX)/bin/sdb
152+
122153
override refs = \
123154
ICSharpCode.NRefactory.dll \
124155
ICSharpCode.NRefactory.CSharp.dll \
@@ -196,32 +227,38 @@ override srcs = \
196227
src/State.cs \
197228
src/Utilities.cs
198229

199-
bin/sdb.exe: $(srcs) $(addprefix bin/, $(refs)) mono.snk
200-
$(MCS) $(MCS_FLAGS) -keyfile:mono.snk -lib:bin -out:bin/sdb.exe -target:exe -r:Mono.Posix $(addprefix -r:, $(refs)) $(srcs)
230+
bin/sdb.exe: mono.snk $(srcs) $(addprefix bin/, $(refs))
231+
$(MCS) $(MCS_FLAGS) -keyfile:$< -lib:bin -out:$@ -target:exe -r:Mono.Posix $(addprefix -r:, $(refs)) $(srcs)
201232

202233
bin/sdb.exe.config: sdb.exe.config
203234
$(MKDIR) -p bin
204235
$(CP) $< $@
205236

206237
bin/sdb: sdb.in
207238
$(MKDIR) -p bin
208-
$(SED) s/__MONO_OPTIONS__/$(mono_opt)/ $< > $@
239+
$(SED) -e s+__LIB_PATH_EXTRA__+/../lib/sdb+ -e s+__MONO_OPTIONS_EXTRA__+$(mono_opt)+ $< > $@
209240
$(CHMOD) +x $@
210241

211-
bin/LICENSE: LICENSE
242+
bin/sdb-dev: sdb.in
212243
$(MKDIR) -p bin
213-
$(CP) $< $@
214-
215-
bin/README: README.md
216-
$(MKDIR) -p bin
217-
$(CP) $< $@
244+
$(SED) -e s+__LIB_PATH_EXTRA__++ -e s+__MONO_OPTIONS_EXTRA__+$(mono_opt)+ $< > $@
245+
$(CHMOD) +x $@
218246

219247
chk/check.exe: chk/check.fs mono.snk
220-
$(FSHARPC) $(FSHARPC_FLAGS) --keyfile:mono.snk --out:$@ --target:exe chk/check.fs
248+
$(FSHARPC) $(FSHARPC_FLAGS) --keyfile:mono.snk --out:$@ --target:exe $<
221249

222-
sdb.tar.gz: $(addprefix bin/, $(results))
223-
$(RM) sdb.tar.gz
224-
$(CD) bin && $(TAR) -zcf ../sdb.tar.gz $(results) $(refs)
250+
override artifacts = \
251+
README.md \
252+
LICENSE \
253+
$(addprefix bin/, $(refs)) \
254+
bin/sdb.exe \
255+
bin/sdb.exe.config
256+
257+
rel/sdb.tar.gz: sdb.in $(artifacts)
258+
$(MKDIR) -p rel
259+
$(CP) $(artifacts) rel
260+
$(CP) bin/sdb-dev rel/sdb
261+
$(CD) rel && $(TAR) -zcf $(notdir $@) $(notdir $(artifacts)) sdb
225262

226263
update-deps:
227264
$(ECHO) "/* DO NOT EDIT - OVERWRITTEN BY MAKEFILE */\n" > src/Options.cs

README.md

+24-17
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,24 @@ installed Mono framework.
1212

1313
First, clone the submodules:
1414

15-
$ git submodule update --init --recursive
15+
$ git submodule update --init --recursive
1616

1717
To build, run:
1818

1919
$ make
2020

21-
This compiles SDB and its dependencies, and puts everything in the `bin`
22-
directory. This directory can be moved around freely; when executed, the `sdb`
23-
script will set up the environment so all the dependency assemblies are found.
21+
If the build succeeds, you can install SDB with:
2422

25-
You could, for example, just add the `bin` directory to your `PATH`:
23+
$ make install
24+
25+
(You may need to invoke it with `sudo` or some such command.)
26+
27+
You can also run SDB from within the build directory by appending it to `PATH`
28+
and invoking `sdb-dev`. This is mainly intended for development of SDB itself.
29+
An example:
2630

2731
$ export PATH=`pwd`/bin:$PATH
28-
$ sdb
32+
$ sdb-dev
2933
Welcome to the Mono soft debugger (sdb 1.0.5058.39468)
3034
Type 'help' for a list of commands or 'quit' to exit
3135

@@ -35,10 +39,9 @@ You can run the SDB test suite with:
3539

3640
$ make check
3741

38-
It's generally a good idea to do that to ensure that SDB works correctly on
39-
your system before you start using it.
42+
(This requires an F# installation.)
4043

41-
The following variables can be set in your environment or on the Make command
44+
The following variables can be set in your environment or on the `make` command
4245
line to affect the build:
4346

4447
* `CAT`: Path to the `cat` POSIX utility.
@@ -51,24 +54,24 @@ line to affect the build:
5154
* `FSHARPC_TEST_FLAGS`: Flags to pass to the F# compiler for tests.
5255
* `GENDARME`: Which Gendarme executable to use (optional).
5356
* `GENDARME_FLAGS`: Flags to pass to Gendarme.
57+
* `INSTALL`: Path to the `install` POSIX utility.
5458
* `MCS`: Which C# compiler executable to use.
5559
* `MCS_FLAGS`: Flags to pass to the C# compiler.
5660
* `MCS_TEST_FLAGS`: Flags to pass to the C# compiler for tests.
5761
* `MKDIR`: Path to the `mkdir` POSIX utility.
5862
* `PKG_CONFIG`: Path to the `pkg-config` utility.
63+
* `RM`: Path to the `rm` POSIX utility.
5964
* `SED`: Path to the `sed` POSIX utility.
6065
* `TAR`: Path to the `tar` POSIX utility.
6166
* `XBUILD`: Which XBuild executable to use.
6267
* `XBUILD_FLAGS`: Flags to pass to XBuild.
6368

64-
Note that the F# tools are only necessary to run the test suite. Gendarme is
65-
also optional and is mostly used by the SDB developers. `tar` is also only used
66-
to package SDB releases.
67-
6869
Additionally, `MODE` can be set to `Debug` (default) or `Release` to indicate
69-
the kind of build desired.
70+
the kind of build desired. `PREFIX` can be set to specify the path that the
71+
`install` and `uninstall` targets should operate within (defaults to
72+
`/usr/local`).
7073

71-
Finally, `MONO_PREFIX` and `MONO_BINARY` can be set to tell the test runner
74+
Finally, `MONO_PREFIX` and `MONO_BINARY` can be set to tell the `check` target
7275
which Mono executable should be used. See the description of `RuntimePrefix`
7376
and `RuntimeExecutable` further down for more information.
7477

@@ -247,7 +250,8 @@ that is tagged with `CommandAttribute` will be instantiated at startup time and
247250
put into the root command list.
248251

249252
For SDB to find custom commands, they should be compiled into `.dll` assemblies
250-
and put in `~/.sdb` (or some other directory specified in `SDB_PATH`).
253+
and put in `~/.sdb` (or some other directory specified in `SDB_PATH`). Plugin
254+
assemblies can also be loaded manually with the `plugin` command.
251255

252256
Here's an example of compiling and using a test plugin:
253257

@@ -282,7 +286,7 @@ Here's an example of compiling and using a test plugin:
282286
Log.Info("Hello! I received: {0}", args);
283287
}
284288
}
285-
$ mcs -debug -t:library test.cs -r:`which sdb`.exe -out:$HOME/.sdb/test.dll
289+
$ mcs -debug -t:library test.cs -r:$(dirname $(which sdb))/../lib/sdb/sdb.exe -out:$HOME/.sdb/test.dll
286290
$ sdb
287291
Welcome to the Mono soft debugger (sdb 1.0.5061.14716)
288292
Type 'help' for a list of commands or 'quit' to exit
@@ -295,3 +299,6 @@ Here's an example of compiling and using a test plugin:
295299

296300
(sdb) mycmd foo bar baz
297301
Hello! I received: foo bar baz
302+
303+
You can look at SDB's own command classes for some examples of things that you
304+
can do in your commands.

chk/check.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ let runTest () =
6363
Console.WriteLine("{0} {1} {0}", delim, testName)
6464
Console.WriteLine()
6565

66-
let psi = ProcessStartInfo(Path.Combine("..", "bin", "sdb"),
66+
let psi = ProcessStartInfo(Path.Combine("..", "bin", "sdb.exe"),
6767
Arguments = testArgs,
6868
CreateNoWindow = true,
6969
RedirectStandardError = true,

sdb.in

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
#!/usr/bin/env bash
2-
MONO_PATH=`dirname $0`:$MONO_PATH exec "`which mono`" __MONO_OPTIONS__ $MONO_OPTIONS `dirname $0`/sdb.exe "$@"
2+
MONO_PATH="`dirname $0`__LIB_PATH_EXTRA__:$MONO_PATH" \
3+
exec "`which mono`" __MONO_OPTIONS_EXTRA__ $MONO_OPTIONS \
4+
"`dirname $0`__LIB_PATH_EXTRA__/sdb.exe" \
5+
"$@"

0 commit comments

Comments
 (0)