src/parser/.nit.sablecc3.dump
src/parser/parser_abs.patch
src/parser/parser_nodes.nit.rej
+src/nit_version.nit
c_src/*.o
c_src/*.cksum
@echo '***************************************************************'
mkdir .nit_compile 2> /dev/null || true
cp c_src/* .nit_compile
+ src/git-gen-version.sh
c_src/nitc ${NITCOPT} -o bin/nitc -O src/nitc.nit
bin/nitdoc: bin/nitc
@echo '***************************************************************'
@echo '* Compile nitdoc from NIT source files *'
@echo '***************************************************************'
+ src/git-gen-version.sh
bin/nitc ${NITCOPT} -o bin/nitdoc -O src/nitdoc.nit
doc/stdlib/index.html: bin/nitdoc
import mmloader
import syntax
+import nit_version
class AbstractCompiler
special ToolContext
do
process_options
+ if opt_version.value then
+ print "{tool_name} version {nit_version}"
+ exit(0)
+ end
+
if opt_help.value then
print "usage: {tool_name} [options] file..."
option_context.usage
--- /dev/null
+#!/bin/sh
+
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2008 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This program is used to generate version number from git refs.
+# The version number is stored in a dedicated Nit module.
+
+gen_version() {
+cat > nit_version.nit<<END
+# This file was generated by git-gen-version.sh
+package nit_version
+meth nit_version: String do return "$*"
+END
+echo "Version $*"
+}
+
+# Are we in the nitc.nit directory?
+if [ ! -f nitc.nit ]; then
+ if [ -f src/nitc.nit ]; then
+ cd src
+ else
+ echo "Error: no nitc.nit found." >&2
+ exit 1
+ fi
+fi
+
+VN=$(git describe --tags --always HEAD)
+if [ -z "$VN" ]; then
+ VN="undefined"
+fi
+if [ -n "$1" ]; then
+ VN="${VN}_$1"
+fi
+if [ -n "$(git diff HEAD)" ]; then
+ VN="${VN}_dirty"
+fi
+
+gen_version "$VN"
# Option --help
readable attr _opt_help: OptionBool = new OptionBool("Show Help (This screen)", "-h", "-?", "--help")
+ # Option --version
+ readable attr _opt_version: OptionBool = new OptionBool("Show version and exit", "--version")
+
init
do
super
- option_context.add_option(opt_warn, opt_path, opt_log, opt_only_parse, opt_only_metamodel, opt_help)
+ option_context.add_option(opt_warn, opt_path, opt_log, opt_only_parse, opt_only_metamodel, opt_help, opt_version)
end
# Parse and process the options given on the command line
*) echo "unknown mode $name"; exit 1;;
esac
+./git-gen-version.sh "$name"
+
echo ${NITC} ${NITCOPTS} ${opts} "$@"
${NITC} ${NITCOPTS} ${opts} "$@"