コード例 #1
0
ファイル: TestRunner.cs プロジェクト: am11/linker
        protected virtual void AddLinkOptions(TestCaseSandbox sandbox, ManagedCompilationResult compilationResult, LinkerArgumentBuilder builder, TestCaseMetadataProvider metadataProvider)
        {
            var caseDefinedOptions = metadataProvider.GetLinkerOptions(sandbox.InputDirectory);

            builder.AddOutputDirectory(sandbox.OutputDirectory);

            foreach (var rspFile in sandbox.ResponseFiles)
            {
                builder.AddResponseFile(rspFile);
            }

            foreach (var inputReference in sandbox.InputDirectory.Files())
            {
                var ext = inputReference.ExtensionWithDot;
                if (ext == ".dll" || ext == ".exe")
                {
                    builder.AddReference(inputReference);
                }
            }
            var coreAction = caseDefinedOptions.TrimMode ?? "skip";

            foreach (var extraReference in metadataProvider.GetExtraLinkerReferences())
            {
                builder.AddReference(extraReference);
                builder.AddAssemblyAction(coreAction, extraReference.FileNameWithoutExtension);
            }

            builder.ProcessOptions(caseDefinedOptions);

            builder.ProcessTestInputAssembly(compilationResult.InputAssemblyPath);
        }
コード例 #2
0
        protected virtual void AddLinkOptions(TestCaseSandbox sandbox, ManagedCompilationResult compilationResult, ILCompilerOptionsBuilder builder, TestCaseMetadataProvider metadataProvider)
        {
            var caseDefinedOptions = metadataProvider.GetLinkerOptions(sandbox.InputDirectory);

            builder.AddOutputDirectory(sandbox.OutputDirectory.Combine(compilationResult.InputAssemblyPath.FileNameWithoutExtension + ".obj"));

            foreach (var rspFile in sandbox.ResponseFiles)
            {
                builder.AddResponseFile(rspFile);
            }

            foreach (var inputReference in sandbox.InputDirectory.Files())
            {
                var ext = inputReference.ExtensionWithDot;
                if (ext == ".dll" || ext == ".exe")
                {
                    if (caseDefinedOptions.AssembliesAction.Contains(("link", inputReference.FileNameWithoutExtension)))
                    {
                        builder.AddLinkAssembly(inputReference);
                    }
                    else
                    {
                        builder.AddReference(inputReference);
                    }
                }
            }
コード例 #3
0
ファイル: TestRunner.cs プロジェクト: layomia/mono_linker
        protected virtual void AddLinkOptions(TestCaseSandbox sandbox, ManagedCompilationResult compilationResult, LinkerArgumentBuilder builder, TestCaseMetadaProvider metadataProvider)
        {
            var caseDefinedOptions = metadataProvider.GetLinkerOptions(sandbox.InputDirectory);

            builder.AddOutputDirectory(sandbox.OutputDirectory);
            foreach (var linkXmlFile in sandbox.LinkXmlFiles)
            {
                builder.AddLinkXmlFile(linkXmlFile);
            }

            foreach (var rspFile in sandbox.ResponseFiles)
            {
                builder.AddResponseFile(rspFile);
            }

            builder.AddSearchDirectory(sandbox.InputDirectory);
            foreach (var extraSearchDir in metadataProvider.GetExtraLinkerSearchDirectories())
            {
                builder.AddSearchDirectory(extraSearchDir);
            }

            builder.ProcessOptions(caseDefinedOptions);

            builder.ProcessTestInputAssembly(compilationResult.InputAssemblyPath);
        }
コード例 #4
0
 public ILCompilerTestCaseResult(TestCase testCase, NPath inputAssemblyPath, NPath expectationsAssemblyPath, TestCaseSandbox sandbox, TestCaseMetadataProvider metadataProvider, ManagedCompilationResult compilationResult, TestLogWriter logWriter)
 {
     TestCase                 = testCase;
     InputAssemblyPath        = inputAssemblyPath;
     ExpectationsAssemblyPath = expectationsAssemblyPath;
     Sandbox           = sandbox;
     MetadataProvider  = metadataProvider;
     CompilationResult = compilationResult;
     LogWriter         = logWriter;
 }
コード例 #5
0
 public LinkedTestCaseResult(TestCase testCase, NPath inputAssemblyPath, NPath outputAssemblyPath, NPath expectationsAssemblyPath, TestCaseSandbox sandbox, TestCaseMetadaProvider metadaProvider, ManagedCompilationResult compilationResult)
 {
     TestCase                 = testCase;
     InputAssemblyPath        = inputAssemblyPath;
     OutputAssemblyPath       = outputAssemblyPath;
     ExpectationsAssemblyPath = expectationsAssemblyPath;
     Sandbox           = sandbox;
     MetadataProvider  = metadaProvider;
     CompilationResult = compilationResult;
 }
コード例 #6
0
 public LinkedTestCaseResult(TestCase testCase, NPath inputAssemblyPath, NPath outputAssemblyPath, NPath expectationsAssemblyPath, TestCaseSandbox sandbox, TestCaseMetadataProvider metadataProvider, ManagedCompilationResult compilationResult, LinkerTestLogger logger, LinkerCustomizations customizations)
 {
     TestCase                 = testCase;
     InputAssemblyPath        = inputAssemblyPath;
     OutputAssemblyPath       = outputAssemblyPath;
     ExpectationsAssemblyPath = expectationsAssemblyPath;
     Sandbox           = sandbox;
     MetadataProvider  = metadataProvider;
     CompilationResult = compilationResult;
     Logger            = logger;
     Customizations    = customizations;
 }
コード例 #7
0
ファイル: TestRunner.cs プロジェクト: am11/linker
 protected virtual void PrepForLink(TestCaseSandbox sandbox, ManagedCompilationResult compilationResult)
 {
 }
コード例 #8
0
ファイル: TestRunner.cs プロジェクト: am11/linker
        private LinkedTestCaseResult Link(TestCase testCase, TestCaseSandbox sandbox, ManagedCompilationResult compilationResult, TestCaseMetadataProvider metadataProvider)
        {
            var linker = _factory.CreateLinker();
            var linkerCustomizations = CustomizeLinker(linker, metadataProvider);

            var builder = _factory.CreateLinkerArgumentBuilder(metadataProvider);

            AddLinkOptions(sandbox, compilationResult, builder, metadataProvider);

            LinkerTestLogger logger = new LinkerTestLogger();

            linker.Link(builder.ToArgs(), linkerCustomizations, logger);

            return(new LinkedTestCaseResult(testCase, compilationResult.InputAssemblyPath, sandbox.OutputDirectory.Combine(compilationResult.InputAssemblyPath.FileName), compilationResult.ExpectationsAssemblyPath, sandbox, metadataProvider, compilationResult, logger, linkerCustomizations));
        }
コード例 #9
0
        private LinkedTestCaseResult Link(TestCase testCase, TestCaseSandbox sandbox, ManagedCompilationResult compilationResult, TestCaseMetadaProvider metadataProvider)
        {
            var linker             = _factory.CreateLinker();
            var builder            = _factory.CreateLinkerArgumentBuilder();
            var caseDefinedOptions = metadataProvider.GetLinkerOptions();

            builder.AddOutputDirectory(sandbox.OutputDirectory);
            foreach (var linkXmlFile in sandbox.LinkXmlFiles)
            {
                builder.AddLinkXmlFile(linkXmlFile);
            }

            builder.AddSearchDirectory(sandbox.InputDirectory);
            foreach (var extraSearchDir in metadataProvider.GetExtraLinkerSearchDirectories())
            {
                builder.AddSearchDirectory(extraSearchDir);
            }

            builder.ProcessOptions(caseDefinedOptions);

            AddAdditionalLinkOptions(builder, metadataProvider);

            // TODO: Should be overridable
            builder.LinkFromAssembly(compilationResult.InputAssemblyPath.ToString());

            linker.Link(builder.ToArgs());

            return(new LinkedTestCaseResult(testCase, compilationResult.InputAssemblyPath, sandbox.OutputDirectory.Combine(compilationResult.InputAssemblyPath.FileName), compilationResult.ExpectationsAssemblyPath));
        }
コード例 #10
0
        private void PrepForLink(TestCaseSandbox sandbox, ManagedCompilationResult compilationResult)
        {
            var entryPointLinkXml = sandbox.InputDirectory.Combine("entrypoint.xml");

            LinkXmlHelpers.WriteXmlFileToPreserveEntryPoint(compilationResult.InputAssemblyPath, entryPointLinkXml);
        }
コード例 #11
0
        private ILCompilerTestCaseResult Link(TestCase testCase, TestCaseSandbox sandbox, ManagedCompilationResult compilationResult, TestCaseMetadataProvider metadataProvider)
        {
            var trimmer = _factory.CreateTrimmer();

            var builder = _factory.CreateTrimmerOptionsBuilder(metadataProvider);

            AddLinkOptions(sandbox, compilationResult, builder, metadataProvider);

            var logWriter = new TestLogWriter();

            trimmer.Trim(builder.Options, logWriter);

            return(new ILCompilerTestCaseResult(testCase, compilationResult.InputAssemblyPath, compilationResult.ExpectationsAssemblyPath, sandbox, metadataProvider, compilationResult, logWriter));
        }