Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
First attempt to use a per-user directory for the module cache
Data is stored in Local Application Data\NieczaModuleCache, which Mono will
map to $HOME/.local/share/NieczaModuleCache.  The --obj-dir object actually
does something now (how long has it been broken?) and can be used to isolate
multiple instances of Niecza, and is used internally to make bootstrapping
work.

One known wart is that $*PERL<version> may become out of date because it is
only updated when the setting needs to be recompiled, and the build system
no longer always forces a recompilation of the user-wide setting.
  • Loading branch information
sorear committed Aug 23, 2012
1 parent 3826c2a commit 9fad9f7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
19 changes: 10 additions & 9 deletions Makefile
Expand Up @@ -21,18 +21,18 @@ srcunits=CClass CgOp Op OpHelpers Sig RxOp STD NieczaGrammar OptRxSimple \
Operator NieczaActions NieczaFrontendSTD NieczaPassSimplifier \
OptBeta NieczaPathSearch NieczaBackendDotnet NieczaCompiler GetOptLong

all: run/Niecza.exe obj/Run.Kernel.dll obj/Run.CORE.dll
all: run/Niecza.exe run/Run.Kernel.dll obj/Run.CORE.dll

$(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 $*
cd src && NIECZA_KEEP_IL=1 $(RUN_CLR) ../boot/run/Niecza.exe --obj-dir ../boot/obj -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_CLR) run/Niecza.exe --obj-dir obj -C CORE

run/Niecza.exe: .fetch-stamp $(patsubst %,boot/obj/Run.%.ser,$(srcunits)) src/niecza
cd src && NIECZA_KEEP_IL=1 $(RUN_CLR) ../boot/run/Niecza.exe -c niecza
cd src && NIECZA_KEEP_IL=1 $(RUN_CLR) ../boot/run/Niecza.exe --obj-dir ../boot/obj -c niecza
$(CP) boot/obj/Kernel.dll run/
$(CSC) /target:library /out:run/CompilerBlob.dll /r:Kernel \
/lib:run src/CompilerBlob.cs
Expand All @@ -51,13 +51,14 @@ boot/obj/Run.CORE.ser: .fetch-stamp
boot/obj/Run.CompilerBlob.dll: .fetch-stamp src/CompilerBlob.cs
$(CSC) /target:library /out:boot/obj/Run.CompilerBlob.dll /r:Run.Kernel \
/lib:boot/obj src/CompilerBlob.cs
obj/Run.Kernel.dll: $(patsubst %,lib/%,$(cskernel)) lib/unidata
$(CSC) /target:exe /out:obj/Run.Kernel.dll /lib:obj /unsafe+ \
run/Run.Kernel.dll: $(patsubst %,lib/%,$(cskernel)) lib/unidata
$(CSC) /target:exe /out:run/Run.Kernel.dll /lib:obj /unsafe+ \
/res:lib/unidata $(patsubst %,lib/%,$(cskernel))
obj/Kernel.dll: $(patsubst %,lib/%,$(cskernel)) lib/unidata
$(CSC) /target:exe /out:obj/Kernel.dll /lib:obj /unsafe+ \
/res:lib/unidata $(patsubst %,lib/%,$(cskernel))

obj/Run.Kernel.dll: run/Run.Kernel.dll
$(CP) $< $@

.PHONY: Niecza_pm
perl5: obj/Perl5Interpreter.dll obj/p5embed.so Niecza_pm
Expand All @@ -75,7 +76,7 @@ aot: all
mono --aot run/*.dll obj/Run.CORE.dll run/Niecza.exe

test: all
$(RUN_CLR) run/Niecza.exe -c test.pl
$(RUN_CLR) run/Niecza.exe --obj-dir obj -c test.pl
prove -e "$(RUN_CLR)" obj/Run.MAIN.exe

spectest: all
Expand Down Expand Up @@ -105,7 +106,7 @@ mknext: run/Niecza.exe obj/Run.Kernel.dll obj/Kernel.dll
cp -a src lib docs README.pod LICENSE Makefile test.pl next/
cp -a run lib next/boot/
cp obj/Run.Kernel.dll obj/Kernel.dll next/boot/obj/
NIECZA_KEEP_IL=1 $(RUN_CLR) next/boot/run/Niecza.exe -C $(libunits)
NIECZA_KEEP_IL=1 $(RUN_CLR) next/boot/run/Niecza.exe --obj-dir next/boot/obj -C $(libunits)

realclean: clean
@rm .fetch-stamp
Expand Down
4 changes: 3 additions & 1 deletion lib/CodeGen.cs
Expand Up @@ -4462,7 +4462,9 @@ public class DowncallReceiver : CallReceiver {
info["name"] = Builtins.MakeStr("niecza");
string vers = "(unknown)\n";
try {
vers = File.ReadAllText("VERSION");
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
Path.Combine("..", "VERSION"));
vers = File.ReadAllText(path);
} catch (Exception) {
// ignore
}
Expand Down
19 changes: 15 additions & 4 deletions src/CompilerBlob.cs
Expand Up @@ -63,7 +63,7 @@ public class Downcaller {
return null;
}
// Better, but still fudgy. Relies too much on path structure.
public static void InitSlave(Variable cb, Variable unit,
public static void InitSlave(Variable cb, P6any cmd_obj_dir, Variable unit,
Variable staticSub, Variable type, Variable param, Variable value) {
if (responder != null) return;

Expand All @@ -73,9 +73,20 @@ public class Downcaller {
ParamP = param.Fetch();
ValueP = value.Fetch();

obj_dir = Path.GetFullPath(Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
Path.Combine("..", "obj")));
obj_dir = Path.GetFullPath(cmd_obj_dir.IsDefined() ?
cmd_obj_dir.mo.mro_raw_Str.Get(cmd_obj_dir) :
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"NieczaModuleCache"));

Directory.CreateDirectory(obj_dir); // like mkdir -p

if (!File.Exists(Path.Combine(obj_dir, "Run.Kernel.dll"))) {
File.Copy(
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Run.Kernel.dll"),
Path.Combine(obj_dir, "Run.Kernel.dll")
);
}

AppDomain.CurrentDomain.AssemblyResolve += ObjLoader;

upcall_cb = cb;
Expand Down
2 changes: 1 addition & 1 deletion src/NieczaBackendDotnet.pm6
Expand Up @@ -67,7 +67,7 @@ class Value { ... }

method new(*%_) {
my $self = callsame;
Q:CgOp { (rnull (rawscall Niecza.Downcaller,CompilerBlob.InitSlave {&upcalled} {Unit} {StaticSub} {Type} {Param} {Value})) };
Q:CgOp { (rnull (rawscall Niecza.Downcaller,CompilerBlob.InitSlave {&upcalled} (@ {$self.obj_dir}) {Unit} {StaticSub} {Type} {Param} {Value})) };
downcall("safemode") if $self.safemode;
$self;
}
Expand Down
2 changes: 1 addition & 1 deletion src/niecza
Expand Up @@ -83,7 +83,7 @@ my @lib = $basedir.append("lib"), ".".IO.realpath;
my $lang = "CORE";
my $safe = False;
my $bcnd = "dotnet";
my $odir = $basedir.append("obj");
my $odir = Str; # backend auto-detect
my $verb = 0;
my @eval;
my $cmod = False;
Expand Down

0 comments on commit 9fad9f7

Please sign in to comment.