Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Embed version information into builds

  • Loading branch information...
commit 77e27724521a779c3763c7044d587ce90602a7c7 1 parent c17e94b
@sorear authored
Showing with 23 additions and 1 deletion.
  1. +2 −1  Makefile
  2. +21 −0 lib/CodeGen.cs
View
3  Makefile
@@ -20,12 +20,13 @@ srcunits=CClass CgOp Op OpHelpers Sig RxOp STD NieczaGrammar OptRxSimple \
OptBeta NieczaPathSearch NieczaBackendDotnet NieczaCompiler GetOptLong
all: run/Niecza.exe obj/Run.Kernel.dll obj/Run.CORE.dll
- @git describe --tags > VERSION
$(patsubst %,boot/obj/Run.%.ser,$(srcunits)): boot/obj/Run.%.ser: .fetch-stamp src/%.pm6 boot/obj/Run.CORE.ser
cd src && NIECZA_KEEP_IL=1 $(RUN_CLR) ../boot/run/Niecza.exe -C $*
+# hack - put VERSION info in place so the setting build can embed it
obj/Run.CORE.dll: run/Niecza.exe obj/Run.Kernel.dll lib/CORE.setting
+ @git describe --tags > VERSION
$(RUN_CLR) run/Niecza.exe -C CORE
run/Niecza.exe: .fetch-stamp $(patsubst %,boot/obj/Run.%.ser,$(srcunits)) src/niecza
View
21 lib/CodeGen.cs
@@ -4175,6 +4175,27 @@ public class DowncallReceiver : CallReceiver {
if (n.outer != null && n.outer.unit == ru)
n.outer.children.Add(n);
ru.our_subs.Add(n);
+
+ if (outer == null) {
+ /* Hack - embed build information */
+ var li = new LIConstant();
+ var info = new VarHash();
+ info["name"] = Builtins.MakeStr("niecza");
+ string vers = "(unknown)\n";
+ try {
+ vers = File.ReadAllText("VERSION");
+ } catch (Exception) {
+ // ignore
+ }
+ info["version"] = Builtins.MakeStr(
+ vers.Substring(0, vers.Length - 1));
+ info["build-time"] = Builtins.now();
+
+ li.value = Kernel.BoxAnyMO(info, Kernel.HashMO);
+
+ n.AddLexical("$?PERL", li);
+ }
+
return new Handle(n);
} else if (cmd == "add_my_name") {
STable type = (STable)Handle.Unbox(args[6]);
Please sign in to comment.
Something went wrong with that request. Please try again.