Permalink
Browse files

Store generated code in build/

  • Loading branch information...
1 parent 9a33e36 commit 2e8433abf5c13e00ee1afcda607eb4167f2e4782 @sorear committed Aug 19, 2010
Showing with 72 additions and 67 deletions.
  1. +0 −30 .gitignore
  2. +34 −12 CompilerDriver.pm
  3. +1 −1 Decl.pm
  4. +34 −23 Niecza.proj
  5. +1 −0 build/.gitignore
  6. +2 −1 niecza_eval
View
@@ -1,35 +1,5 @@
-MAIN.cs
-MAIN.exe
-Kernel.dll
-Kernel.dll.so
-PerlTask.dll
-SAFE.dll
-SAFE.dll.so
-SAFE.cs
-SAFE_ast.store
-CORE.dll
-CORE.dll.so
-CORE.cs
-CORE_ast.store
-Test.dll
-Test.dll.so
-Test.cs
-Test_ast.store
-Threads.dll
-Threads.dll.so
-Threads.cs
-Threads_ast.store
-MONKEY_TYPING.dll
-MONKEY_TYPING.dll.so
-MONKEY_TYPING.cs
-MONKEY_TYPING_ast.store
-RegexEngine.dll
-RegexEngine.so
-RegexEngine.cs
-RegexEngine_ast.store
*.swp
*.pmc
-syml
.STD_build_stamp
.STD_checkout_stamp
STD_checkout
View
@@ -8,7 +8,7 @@ use Sub::Exporter -setup => {
};
use Time::HiRes 'time';
-
+use File::Basename;
use autodie ':all';
open ::NIECZA_OUT, ">&", \*STDOUT;
@@ -30,8 +30,21 @@ use Storable;
use Niecza::Grammar ();
use Niecza::Actions ();
-# TODO
-my $builddir = File::Spec->curdir;
+my $builddir;
+{
+ my $libdir = dirname($INC{'CompilerDriver.pm'});
+ $builddir = File::Spec->catdir($libdir, "build");
+}
+File::Path::make_path($builddir);
+
+sub build_file { File::Spec->catfile($builddir, $_[1]) }
+
+sub metadata_for {
+ my ($cl, $unit) = @_;
+ $unit =~ s/::/./g;
+
+ Storable::retrieve(File::Spec->catfile($builddir, "$unit.store"))
+}
{
package
@@ -100,7 +113,7 @@ sub compile {
$::UNITNAME =~ s|[\\/]|.|g;
$STD::ALL = {};
- $::SETTING_RESUME = retrieve($args{lang} . '.store')->{setting}
+ $::SETTING_RESUME = CompilerDriver->metadata_for($args{lang})->{setting}
unless $args{lang} eq 'NULL';
$::UNITDEPS{$args{lang}} = 1 if $args{lang} ne 'NULL';
@@ -109,6 +122,9 @@ sub compile {
my $ast;
my $basename = $::UNITNAME || 'MAIN';
+ my $csfile = File::Spec->catfile($builddir, "$basename.cs");
+ my $outname = File::Spec->catfile($builddir,
+ $basename . ($args{main} ? ".exe" : ".dll"));
my @phases = (
[ 'parse', sub {
@@ -124,7 +140,7 @@ sub compile {
[ 'to_anf', sub { $ast->to_anf } ],
[ 'writecs', sub {
- open ::NIECZA_OUT, ">", "$basename.cs";
+ open ::NIECZA_OUT, ">", $csfile;
binmode ::NIECZA_OUT, ":utf8";
print ::NIECZA_OUT <<EOH;
using System;
@@ -137,18 +153,24 @@ EOH
if ($::SETTING_RESUME || $::niecza_mod_symbols) {
my $blk = { setting => $::SETTING_RESUME,
syml => $::niecza_mod_symbols };
- store $blk, "$basename.store";
+ store $blk, File::Spec->catfile($builddir, "$basename.store");
}
- $ast = undef; } ],
+ $ast = undef;
+ } ],
[ 'gmcs', sub {
delete $::UNITDEPS{$basename};
- system "gmcs", ($args{main} ? () : ("/target:library")),
+ my @args = ("gmcs",
+ ($args{main} ? () : ("/target:library")),
+ "/lib:$builddir",
"/r:Kernel.dll", (map { "/r:$_.dll" } sort keys %::UNITDEPS),
- "/out:${basename}." . ($args{main} ? 'exe' : 'dll'),
- "${basename}.cs"; } ],
+ "/out:$outname",
+ $csfile);
+ print STDERR "@args\n" if $args{stagetime};
+ system @args;
+ } ],
[ 'aot', sub {
- system "mono", "--aot", "${basename}." .
- ($args{main} ? 'exe' : 'dll'); } ]);
+ system "mono", "--aot", $outname;
+ } ]);
for my $p (@phases) {
next if $p->[0] eq 'aot' && !$args{aot};
View
@@ -482,7 +482,7 @@ use CgOp;
sub preinit_code {
my ($self, $body) = @_;
- my $scope = Storable::retrieve($self->unit . ".store")->{setting};
+ my $scope = CompilerDriver->metadata_for($self->unit)->{setting};
CodeGen->know_module($self->unit);
CgOp::prog(
View
@@ -1,6 +1,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="2.0">
- <UsingTask TaskName="Perl" AssemblyFile="PerlTask.dll"/>
+ <UsingTask TaskName="Perl" AssemblyFile="build\PerlTask.dll"/>
<PropertyGroup>
<!-- Tool paths -->
<Subversion>svn</Subversion>
@@ -28,50 +28,61 @@
<Target Name="Test" DependsOnTargets="CORE.dll;Test.dll;WriteVersion;PerlTask">
<Perl Code="use CompilerDriver ':all'; compile(stopafter => 'writecs', lang => 'CORE', main => 1, file => 'test.pl');"/>
- <Csc Sources="MAIN.cs" TargetType="exe" OutputAssembly="MAIN.exe"
+ <Csc Sources="build\MAIN.cs" TargetType="exe" AdditionalLibPaths="build"
+ OutputAssembly="build\MAIN.exe"
References="Test.dll;SAFE.dll;CORE.dll;Kernel.dll"/>
- <Exec Command="prove -e mono MAIN.exe"/>
+ <Exec Command="prove -e mono build\MAIN.exe"/>
</Target>
<Target Name="WriteVersion">
<Exec Command="git describe --always &gt; VERSION"/>
</Target>
<!-- Libraries -->
- <Target Name="Kernel.dll" Inputs="Kernel.cs;Cursor.cs" Outputs="Kernel.dll">
+ <Target Name="Kernel.dll" Inputs="Kernel.cs;Cursor.cs"
+ Outputs="build\Kernel.dll">
<Csc Sources="Kernel.cs;Cursor.cs" TargetType="library"
- OutputAssembly="Kernel.dll"/>
- <Exec Condition="$(UseAOT) == 'Y'" Command="mono --aot Kernel.dll"/>
+ OutputAssembly="build\Kernel.dll"/>
+ <Exec Condition="$(UseAOT) == 'Y'"
+ Command="mono --aot build\Kernel.dll"/>
</Target>
- <Target Name="CORE.cs" Inputs="@(CompilerPerl);SAFE.store;CORE.setting" Outputs="CORE.cs;CORE.store" DependsOnTargets="BuildSTD;SAFE.cs;Grammar;PerlTask">
+ <Target Name="CORE.cs" Inputs="@(CompilerPerl);build\SAFE.store;CORE.setting" Outputs="build\CORE.cs;build\CORE.store" DependsOnTargets="BuildSTD;SAFE.cs;Grammar;PerlTask">
<Perl Code="use CompilerDriver ':all'; compile(stopafter => 'writecs', lang => 'SAFE', file => 'CORE.setting');"/>
</Target>
- <Target Name="SAFE.cs" Inputs="@(CompilerPerl);SAFE.setting" Outputs="SAFE.cs;SAFE.store" DependsOnTargets="BuildSTD;Grammar;PerlTask">
+ <Target Name="SAFE.cs" Inputs="@(CompilerPerl);SAFE.setting"
+ Outputs="build\SAFE.cs;build\SAFE.store"
+ DependsOnTargets="BuildSTD;Grammar;PerlTask">
<Perl Code="use CompilerDriver ':all'; compile(stopafter => 'writecs', lang => 'NULL', file => 'SAFE.setting');"/>
</Target>
- <Target Name="Test.cs" Inputs="@(CompilerPerl);CORE.store;Test.pm6" Outputs="Test.cs;Test.store" DependsOnTargets="CORE.cs;BuildSTD;Grammar;PerlTask">
+ <Target Name="Test.cs" Inputs="@(CompilerPerl);build\CORE.store;Test.pm6"
+ Outputs="build\Test.cs;build\Test.store"
+ DependsOnTargets="CORE.cs;BuildSTD;Grammar;PerlTask">
<Perl Code="use CompilerDriver ':all'; compile(stopafter => 'writecs', lang => 'CORE', file => 'Test.pm6');"/>
</Target>
- <Target Name="CORE.dll" Inputs="CORE.cs;SAFE.dll;Kernel.dll" Outputs="CORE.dll" DependsOnTargets="CORE.cs;SAFE.dll;Kernel.dll">
- <Csc Sources="CORE.cs" TargetType="library"
- OutputAssembly="CORE.dll" References="SAFE.dll;Kernel.dll"/>
- <Exec Condition="$(UseAOT) == 'Y'" Command="mono --aot CORE.dll"/>
+ <Target Name="CORE.dll" Inputs="build\CORE.cs;build\SAFE.dll;build\Kernel.dll" Outputs="build\CORE.dll" DependsOnTargets="CORE.cs;SAFE.dll;Kernel.dll">
+ <Csc Sources="build\CORE.cs" TargetType="library"
+ AdditionalLibPaths="build" OutputAssembly="build\CORE.dll"
+ References="SAFE.dll;Kernel.dll"/>
+ <Exec Condition="$(UseAOT) == 'Y'" Command="mono --aot build\CORE.dll"/>
</Target>
- <Target Name="SAFE.dll" Inputs="SAFE.cs;Kernel.dll" Outputs="SAFE.dll" DependsOnTargets="SAFE.cs;Kernel.dll">
- <Csc Sources="SAFE.cs" TargetType="library"
- OutputAssembly="SAFE.dll" References="Kernel.dll"/>
- <Exec Condition="$(UseAOT) == 'Y'" Command="mono --aot SAFE.dll"/>
+ <Target Name="SAFE.dll" Inputs="build\SAFE.cs;build\Kernel.dll"
+ Outputs="build\SAFE.dll" DependsOnTargets="SAFE.cs;Kernel.dll">
+ <Csc Sources="build\SAFE.cs" TargetType="library"
+ AdditionalLibPaths="build" OutputAssembly="build\SAFE.dll"
+ References="Kernel.dll"/>
+ <Exec Condition="$(UseAOT) == 'Y'" Command="mono --aot build\SAFE.dll"/>
</Target>
- <Target Name="Test.dll" Inputs="Test.cs;CORE.dll;Kernel.dll" Outputs="Test.dll" DependsOnTargets="Test.cs;CORE.dll;Kernel.dll">
- <Csc Sources="Test.cs" TargetType="library"
- OutputAssembly="Test.dll" References="CORE.dll;SAFE.dll;Kernel.dll"/>
- <Exec Condition="$(UseAOT) == 'Y'" Command="mono --aot Test.dll"/>
+ <Target Name="Test.dll" Inputs="build\Test.cs;build\CORE.dll;build\Kernel.dll" Outputs="build\Test.dll" DependsOnTargets="Test.cs;CORE.dll;Kernel.dll">
+ <Csc Sources="build\Test.cs" TargetType="library"
+ AdditionalLibPaths="build" OutputAssembly="build\Test.dll"
+ References="CORE.dll;SAFE.dll;Kernel.dll"/>
+ <Exec Condition="$(UseAOT) == 'Y'" Command="mono --aot build\Test.dll"/>
</Target>
<!-- Proper compiler bits -->
@@ -112,9 +123,9 @@
ContinueOnError="true"/>
</Target>
- <Target Name="PerlTask" Inputs="PerlTask.cs" Outputs="PerlTask.dll">
+ <Target Name="PerlTask" Inputs="PerlTask.cs" Outputs="build\PerlTask.dll">
<Csc Sources="PerlTask.cs" TargetType="library"
- OutputAssembly="PerlTask.dll"
+ OutputAssembly="build\PerlTask.dll"
References="Microsoft.Build.Framework.dll;Microsoft.Build.Utilities.dll"/>
</Target>
</Project>
View
@@ -0,0 +1 @@
+*
View
@@ -53,7 +53,8 @@ $lang = 'SAFE' if $safe;
sub run {
compile(main => !$module, stopafter => $stopafter, aot => $aot,
stagetime => $stagestats, lang => $lang, safe => $safe, @_);
- system 'mono MAIN.exe' if !$module && !$stopafter;
+ system 'mono', CompilerDriver->build_file('MAIN.exe')
+ if !$module && !$stopafter;
}
if (@ARGV) {

0 comments on commit 2e8433a

Please sign in to comment.