コード例 #1
0
        private IEnumerable <NPath> CompileBeforeTestCaseAssemblies(NPath outputDirectory, NPath[] references, string[] defines, IList <NPath> removeFromLinkerInputAssemblies)
        {
            foreach (var setupCompileInfo in _metadataProvider.GetSetupCompileAssembliesBefore())
            {
                NPath outputFolder;
                if (setupCompileInfo.OutputSubFolder == null)
                {
                    outputFolder = outputDirectory;
                }
                else
                {
                    outputFolder = outputDirectory.Combine(setupCompileInfo.OutputSubFolder);
                    Directory.CreateDirectory(outputFolder.ToString());
                }

                var options = CreateOptionsForSupportingAssembly(
                    setupCompileInfo,
                    outputFolder,
                    CollectSetupBeforeSourcesFiles(setupCompileInfo),
                    references,
                    defines,
                    CollectSetupBeforeResourcesFiles(setupCompileInfo));
                var output = CompileAssembly(options);

                if (setupCompileInfo.RemoveFromLinkerInput)
                {
                    removeFromLinkerInputAssemblies.Add(output);
                }

                if (setupCompileInfo.AddAsReference)
                {
                    yield return(output);
                }
            }
        }
コード例 #2
0
        protected static NPath MakeSupportingAssemblyReferencePathAbsolute(NPath outputDirectory, string referenceFileName)
        {
            // Not a good idea to use a full path in a test, but maybe someone is trying to quickly test something locally
            if (Path.IsPathRooted(referenceFileName))
            {
                return(referenceFileName.ToNPath());
            }

#if NETCOREAPP
            if (referenceFileName.StartsWith("System.", StringComparison.Ordinal) ||
                referenceFileName.StartsWith("Mono.", StringComparison.Ordinal) ||
                referenceFileName.StartsWith("Microsoft.", StringComparison.Ordinal) ||
                referenceFileName == "netstandard.dll")
            {
                var frameworkDir = Path.GetFullPath(Path.GetDirectoryName(typeof(object).Assembly.Location));
                var filePath     = Path.Combine(frameworkDir, referenceFileName);

                if (File.Exists(filePath))
                {
                    return(filePath.ToNPath());
                }
            }
#endif

            var possiblePath = outputDirectory.Combine(referenceFileName);
            if (possiblePath.FileExists())
            {
                return(possiblePath);
            }

            return(referenceFileName.ToNPath());
        }
コード例 #3
0
        public NPath CompileTestIn(NPath outputDirectory, string outputName, IEnumerable <string> sourceFiles, string[] commonReferences, string[] mainAssemblyReferences, IEnumerable <string> defines, NPath[] resources, string[] additionalArguments)
        {
            var originalCommonReferences = commonReferences.Select(r => r.ToNPath()).ToArray();
            var originalDefines          = defines?.ToArray() ?? new string [0];

            Prepare(outputDirectory);

            var compiledReferences    = CompileBeforeTestCaseAssemblies(outputDirectory, originalCommonReferences, originalDefines).ToArray();
            var allTestCaseReferences = originalCommonReferences
                                        .Concat(compiledReferences)
                                        .Concat(mainAssemblyReferences.Select(r => r.ToNPath()))
                                        .ToArray();

            var options = CreateOptionsForTestCase(
                outputDirectory.Combine(outputName),
                sourceFiles.Select(s => s.ToNPath()).ToArray(),
                allTestCaseReferences,
                originalDefines,
                resources,
                additionalArguments);
            var testAssembly = CompileAssembly(options);


            // The compile after step is used by tests to mess around with the input to the linker.  Generally speaking, it doesn't seem like we would ever want to mess with the
            // expectations assemblies because this would undermine our ability to inspect them for expected results during ResultChecking.  The UnityLinker UnresolvedHandling tests depend on this
            // behavior of skipping the after test compile
            if (outputDirectory != _sandbox.ExpectationsDirectory)
            {
                CompileAfterTestCaseAssemblies(outputDirectory, originalCommonReferences, originalDefines);
            }

            return(testAssembly);
        }
コード例 #4
0
        public IntegrationTestEnvironment(ICacheContainer cacheContainer,
                                          NPath repoPath,
                                          NPath solutionDirectory,
                                          NPath?environmentPath     = null,
                                          bool enableTrace          = false,
                                          bool initializeRepository = true)
        {
            defaultEnvironment = new DefaultEnvironment(cacheContainer);

            defaultEnvironment.FileSystem.SetCurrentDirectory(repoPath);
            environmentPath = environmentPath ??
                              defaultEnvironment.UserCachePath.EnsureDirectoryExists("IntegrationTests");

            UserCachePath   = environmentPath.Value.Combine("User");
            SystemCachePath = environmentPath.Value.Combine("System");

            var installPath = solutionDirectory.Parent.Parent.Combine("src", "GitHub.Api");

            Initialize(UnityVersion, installPath, solutionDirectory, NPath.Default, repoPath.Combine("Assets"));

            InitializeRepository(initializeRepository ? (NPath?)repoPath : null);

            this.enableTrace = enableTrace;

            if (enableTrace)
            {
                logger.Trace("EnvironmentPath: \"{0}\" SolutionDirectory: \"{1}\" ExtensionInstallPath: \"{2}\"",
                             environmentPath, solutionDirectory, ExtensionInstallPath);
            }
        }
コード例 #5
0
        public IntegrationTestEnvironment(NPath repoPath, NPath solutionDirectory, NPath environmentPath = null,
                                          bool enableTrace = false)
        {
            defaultEnvironment = new DefaultEnvironment();
            defaultEnvironment.FileSystem.SetCurrentDirectory(repoPath);
            environmentPath = environmentPath ??
                              defaultEnvironment.GetSpecialFolder(Environment.SpecialFolder.LocalApplicationData)
                              .ToNPath()
                              .EnsureDirectoryExists(ApplicationInfo.ApplicationName + "-IntegrationTests");

            integrationTestEnvironmentPath = environmentPath;
            UserCachePath   = integrationTestEnvironmentPath.Combine("User");
            SystemCachePath = integrationTestEnvironmentPath.Combine("System");

            var installPath = solutionDirectory.Parent.Parent.Combine("src", "GitHub.Api");

            Initialize(UnityVersion, installPath, solutionDirectory, repoPath.Combine("Assets"));
            InitializeRepository();

            this.enableTrace = enableTrace;

            if (enableTrace)
            {
                logger.Trace("EnvironmentPath: \"{0}\" SolutionDirectory: \"{1}\" ExtensionInstallPath: \"{2}\"",
                             environmentPath, solutionDirectory, ExtensionInstallPath);
            }
        }
コード例 #6
0
        public IntegrationTestEnvironment(ICacheContainer cacheContainer,
                                          NPath repoPath,
                                          NPath solutionDirectory,
                                          CreateEnvironmentOptions options = null,
                                          bool enableTrace          = false,
                                          bool initializeRepository = true)
        {
            this.enableTrace = enableTrace;

            options = options ?? new CreateEnvironmentOptions(NPath.SystemTemp.Combine(ApplicationInfo.ApplicationName, "IntegrationTests"));

            defaultEnvironment = new DefaultEnvironment(cacheContainer);
            defaultEnvironment.FileSystem.SetCurrentDirectory(repoPath);

            var environmentPath = options.UserProfilePath;

            LocalAppData    = environmentPath.Combine("User");
            UserCachePath   = LocalAppData.Combine("Cache");
            CommonAppData   = environmentPath.Combine("System");
            SystemCachePath = CommonAppData.Combine("Cache");

            var installPath = solutionDirectory.Parent.Parent.Parent.Combine("src", "com.unity.git.api", "Api");

            Initialize(UnityVersion, installPath, solutionDirectory, NPath.Default, repoPath.Combine("Assets"));

            InitializeRepository(initializeRepository ? (NPath?)repoPath : null);

            GitDefaultInstallation = new GitInstaller.GitInstallDetails(UserCachePath, this);

            if (enableTrace)
            {
                logger.Trace("EnvironmentPath: \"{0}\" SolutionDirectory: \"{1}\" ExtensionInstallPath: \"{2}\"",
                             environmentPath, solutionDirectory, ExtensionInstallPath);
            }
        }
コード例 #7
0
        public virtual IEnumerable <string> GetReferencedAssemblies(NPath workingDirectory)
        {
            foreach (var fileName in GetReferenceValues())
            {
                if (fileName.StartsWith("System.", StringComparison.Ordinal) || fileName.StartsWith("Mono.", StringComparison.Ordinal) || fileName.StartsWith("Microsoft.", StringComparison.Ordinal))
                {
#if NETCOREAPP
                    // Try to find the assembly alongside the host's framework dependencies
                    var frameworkDir = Path.GetDirectoryName(typeof(object).Assembly.Location);
                    var filePath     = Path.Combine(frameworkDir, fileName);
                    if (File.Exists(filePath))
                    {
                        yield return(filePath);
                    }
                    else
                    {
                        yield return(fileName);
                    }
#else
                    yield return(fileName);
#endif
                }
                else
                {
                    // Drop any relative path information.  Sandboxing will have taken care of copying the reference to the directory
                    yield return(workingDirectory.Combine(Path.GetFileName(fileName)));
                }
            }
        }
コード例 #8
0
        public void OneTimeSetup()
        {
            Unity.VersionControl.Git.Guard.InUnitTestRunner = true;
            LogHelper.LogAdapter = new MultipleLogAdapter(new FileLogAdapter($"..\\{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}-tasksystem-tests.log"));
            //LogHelper.TracingEnabled = true;
            TaskManager = new TaskManager();
            var syncContext = new ThreadSynchronizationContext(Token);

            TaskManager.UIScheduler = new SynchronizationContextTaskScheduler(syncContext);

            var env = new DefaultEnvironment(new CacheContainer());

            TestBasePath = NPath.CreateTempDirectory("integration tests");
            env.FileSystem.SetCurrentDirectory(TestBasePath);
            env.Initialize("5.6", TestBasePath, TestBasePath, TestBasePath, TestBasePath.Combine("Assets"));

            var repo = Substitute.For <IRepository>();

            repo.LocalPath.Returns(TestBasePath);
            env.Repository = repo;

            var platform = new Platform(env);

            ProcessManager = new ProcessManager(env, platform.GitEnvironment, Token);
            var processEnv = platform.GitEnvironment;
            var installer  = new GitInstaller(env, ProcessManager, TaskManager.Token);
            var state      = installer.FindSystemGit(new GitInstaller.GitInstallationState());

            env.GitInstallationState = state;
        }
コード例 #9
0
        static void AddActions(DotNetAssembly[] inputAssemblies, NPath targetDirectory, NativeProgramConfiguration nativeProgramConfiguration)
        {
            var linkerAssembly = new DotNetAssembly(Distribution.Path.Combine("build/UnityLinker.exe"), Framework.Framework471);
            var linker         = new DotNetRunnableProgram(linkerAssembly);

            var outputDir       = targetDirectory;
            var isFrameworkNone = inputAssemblies.First().Framework == Framework.FrameworkNone;

            var rootAssemblies = inputAssemblies.Where(a => a.Path.HasExtension("exe")).Concat(new[] { inputAssemblies.First() }).Distinct();

            var linkerArguments = new List <string>
            {
                $"--out={outputDir.InQuotes()}",
                "--use-dots-options",
                "--dotnetprofile=" + (isFrameworkNone ? "unitytiny" : "unityaot"),
                "--rule-set=experimental", // This will enable modification of method bodies to further reduce size.
                inputAssemblies.Select(a => $"--include-directory={a.Path.Parent.InQuotes()}")
            };

            linkerArguments.AddRange(rootAssemblies.Select(rootAssembly => $"--include-public-assembly={rootAssembly.Path.InQuotes()}"));

//            foreach (var inputDirectory in inputFiles.Select(f => f.Path.Parent).Distinct())
//                linkerArguments.Add($"--include-directory={inputDirectory.InQuotes()}");

            NPath bclDir = Il2CppDependencies.Path.Combine("MonoBleedingEdge/builds/monodistribution/lib/mono/unityaot");

            if (!isFrameworkNone)
            {
                linkerArguments.Add($"--search-directory={bclDir.InQuotes()}");
            }

            var targetPlatform = GetTargetPlatformForLinker(nativeProgramConfiguration.Platform);

            if (!string.IsNullOrEmpty(targetPlatform))
            {
                linkerArguments.Add($"--platform={targetPlatform}");
            }

            var targetArchitecture = GetTargetArchitectureForLinker(nativeProgramConfiguration.ToolChain.Architecture);

            if (!string.IsNullOrEmpty(targetPlatform))
            {
                linkerArguments.Add($"--architecture={targetArchitecture}");
            }

            //          var targetFiles = Unity.BuildTools.EnumerableExtensions.Prepend(nonMainOutputs, mainTargetFile);
            //          targetFiles = targetFiles.Append(bcl);
            var targetFiles = inputAssemblies.SelectMany(a => a.Paths).Select(i => targetDirectory.Combine(i.FileName)).ToArray();

            Backend.Current.AddAction(
                "UnityLinker",
                targetFiles: targetFiles,
                inputs: inputAssemblies.SelectMany(a => a.Paths).Concat(linkerAssembly.Paths).ToArray(),
                executableStringFor: linker.InvocationString,
                commandLineArguments: linkerArguments.ToArray(),
                allowUnwrittenOutputFiles: false,
                allowUnexpectedOutput: false,
                allowedOutputSubstrings: new[] { "Output action" });
        }
コード例 #10
0
        protected async Task <IEnvironment> Initialize(NPath repoPath, NPath environmentPath = null,
                                                       bool enableEnvironmentTrace           = false, bool initializeRepository = true, Action <RepositoryManager> onRepositoryManagerCreated = null)
        {
            TaskManager             = new TaskManager();
            SyncContext             = new ThreadSynchronizationContext(TaskManager.Token);
            TaskManager.UIScheduler = new SynchronizationContextTaskScheduler(SyncContext);

            //TODO: Mock CacheContainer
            ICacheContainer cacheContainer = Substitute.For <ICacheContainer>();

            Environment = new IntegrationTestEnvironment(cacheContainer, repoPath, SolutionDirectory, environmentPath, enableEnvironmentTrace);

            var gitSetup = new GitInstaller(Environment, TaskManager.Token);
            await gitSetup.SetupIfNeeded();

            Environment.GitExecutablePath = gitSetup.GitExecutablePath;

            Platform = new Platform(Environment);

            GitEnvironment = Platform.GitEnvironment;
            ProcessManager = new ProcessManager(Environment, GitEnvironment, TaskManager.Token);

            Platform.Initialize(ProcessManager, TaskManager);

            GitClient = new GitClient(Environment, ProcessManager, TaskManager);

            var repositoryManager = GitHub.Unity.RepositoryManager.CreateInstance(Platform, TaskManager, GitClient, repoPath);

            onRepositoryManagerCreated?.Invoke(repositoryManager);

            RepositoryManager = repositoryManager;
            RepositoryManager.Initialize();

            if (initializeRepository)
            {
                Environment.Repository = new Repository(repoPath, cacheContainer);
                Environment.Repository.Initialize(RepositoryManager);
            }

            RepositoryManager.Start();

            DotGitPath = repoPath.Combine(".git");

            if (DotGitPath.FileExists())
            {
                DotGitPath =
                    DotGitPath.ReadAllLines()
                    .Where(x => x.StartsWith("gitdir:"))
                    .Select(x => x.Substring(7).Trim().ToNPath())
                    .First();
            }

            BranchesPath = DotGitPath.Combine("refs", "heads");
            RemotesPath  = DotGitPath.Combine("refs", "remotes");
            DotGitIndex  = DotGitPath.Combine("index");
            DotGitHead   = DotGitPath.Combine("HEAD");
            DotGitConfig = DotGitPath.Combine("config");
            return(Environment);
        }
コード例 #11
0
ファイル: Il2Cpp.bee.cs プロジェクト: isaveu/SimpleUIDemo
    public static NPath CopyIL2CPPMetadataFile(NPath destination, DotNetAssembly inputAssembly)
    {
        var target = destination.Combine("Data/Metadata/global-metadata.dat");

        CopyTool.Instance().Setup(target,
                                  Il2CppTargetDirForAssembly(inputAssembly).Combine("Data", "Metadata", "global-metadata.dat"));
        return(target);
    }
コード例 #12
0
        public override BuiltNativeProgram DeployTo(NPath targetDirectory, Dictionary <IDeployable, IDeployable> alreadyDeployed = null)
        {
            // TODO: path should depend on toolchain (armv7/arm64)
            var libDirectory = targetDirectory.Combine("gradle/src/main/jniLibs/armeabi-v7a");
            var result       = base.DeployTo(libDirectory, alreadyDeployed);

            return(new Executable(PackageApp(targetDirectory, result.Path)));
        }
コード例 #13
0
        private static CppCodeWriter GetMetadataCodeWriter(NPath outputDir, string tableName)
        {
            string[]         append = new string[] { $"Il2Cpp{tableName}Table.cpp" };
            SourceCodeWriter writer = new SourceCodeWriter(outputDir.Combine(append));

            IncludeWriter.WriteRegistrationIncludes(writer);
            return(writer);
        }
コード例 #14
0
        public static NPath[] GetUtilsSourceFiles(NativeProgramConfiguration npc, NPath MonoSourceDir)
        {
            var files = new List <NPath>();

            files.AddRange(PosixMonoSourceFileList.GetUtilsSourceFiles(npc, MonoSourceDir));
            files.AddRange(new[]
            {
                MonoSourceDir.Combine("mono/utils/mach-support.c"),
                MonoSourceDir.Combine("mono/utils/mono-dl-darwin.c"),
                MonoSourceDir.Combine("mono/utils/mono-log-darwin.c"),
                MonoSourceDir.Combine("mono/utils/mono-threads-mach.c"),
                MonoSourceDir.Combine("mono/utils/mono-threads-mach-helper.c")
            });

            if (npc.ToolChain.Architecture is x64Architecture)
            {
                files.Add(MonoSourceDir.Combine("mono/utils/mach-support-amd64.c"));
            }

            if (npc.ToolChain.Architecture is x86Architecture)
            {
                files.Add(MonoSourceDir.Combine("mono/utils/mach-support-x86.c"));
            }

            return(files.ToArray());
        }
コード例 #15
0
 private static void CopyAllFilesFrom(NPath fromPath, NPath toPath)
 {
     foreach (var file in fromPath.Files(true))
     {
         CopyTool.Instance().Setup(
             toPath.Combine(file.RelativeTo(fromPath)).MakeAbsolute(),
             file.MakeAbsolute());
     }
 }
コード例 #16
0
        public static NPath[] GetUtilsSourceFiles(NativeProgramConfiguration npc, NPath MonoSourceDir)
        {
            var files = new List <NPath>();

            files.AddRange(UnityMonoSourceFileList.GetUtilsSourceFiles(npc, MonoSourceDir));
            files.Add(MonoSourceDir.Combine("mono/utils/mono-log-darwin.c"));

            return(files.ToArray());
        }
コード例 #17
0
        public TestCaseSandbox(TestCase testCase, NPath rootTemporaryDirectory, string namePrefix)
        {
            _testCase = testCase;

            var rootDirectory = rootTemporaryDirectory.Combine(string.IsNullOrEmpty(namePrefix) ? "linker_tests" : namePrefix);

            var locationRelativeToRoot = testCase.SourceFile.Parent.RelativeTo(testCase.RootCasesDirectory);
            var suiteDirectory         = rootDirectory.Combine(locationRelativeToRoot);

            _directory = suiteDirectory.Combine(testCase.SourceFile.FileNameWithoutExtension);

            _directory.DeleteContents();

            InputDirectory        = _directory.Combine("input").EnsureDirectoryExists();
            OutputDirectory       = _directory.Combine("output").EnsureDirectoryExists();
            ExpectationsDirectory = _directory.Combine("expectations").EnsureDirectoryExists();
            ResourcesDirectory    = _directory.Combine("resources").EnsureDirectoryExists();
        }
コード例 #18
0
ファイル: NiceIO.cs プロジェクト: lin5/Unity
 public static IEnumerable <NPath> Move(this IEnumerable <NPath> self, NPath dest)
 {
     if (dest.IsRelative)
     {
         throw new ArgumentException("When moving multiple files, the destination cannot be a relative path");
     }
     dest.EnsureDirectoryExists();
     return(self.Select(p => p.Move(dest.Combine(p.FileName))).ToArray());
 }
コード例 #19
0
        private static void WriteSelectedConfigFile(NPath directory, string selectedConfig)
        {
            var file = directory.Combine("selectedconfig.json").MakeAbsolute();

            file.UpdateAllText(JsonSerialization.Serialize(new SelectedConfigJson()
            {
                Config = selectedConfig
            }));
        }
コード例 #20
0
        public static NPath[] GetMetadataSourceFiles(NativeProgramConfiguration npc, NPath MonoSourceDir)
        {
            var files = new List <NPath>();

            files.AddRange(PosixMonoSourceFileList.GetMetadataSourceFiles(npc, MonoSourceDir));
            files.Add(MonoSourceDir.Combine("mono/metadata/w32process-unix-osx.c"));

            return(files.ToArray());
        }
コード例 #21
0
        public static NPath[] GetUtilsSourceFiles(NativeProgramConfiguration npc, NPath MonoSourceDir)
        {
            var files = new List <NPath>();

            files.AddRange(WindowsSharedMonoSourceFileList.GetUtilsSourceFiles(npc, MonoSourceDir));
            files.Add(MonoSourceDir.Combine("mono/utils/mono-dl-windows-uwp.c"));

            return(files.ToArray());
        }
コード例 #22
0
 public static NPath[] GetMetadataDebuggerSourceFiles(NativeProgramConfiguration npc, NPath MonoSourceDir)
 {
     return(new[]
     {
         MonoSourceDir.Combine("mono/metadata/console-unity.c"),
         MonoSourceDir.Combine("mono/metadata/file-mmap-unity.c"),
         MonoSourceDir.Combine("mono/metadata/w32error-unity.c"),
         MonoSourceDir.Combine("mono/metadata/w32event-unity.c"),
         MonoSourceDir.Combine("mono/metadata/w32file-unity.c"),
         MonoSourceDir.Combine("mono/metadata/w32mutex-unity.c"),
         MonoSourceDir.Combine("mono/metadata/w32process-unity.c"),
         MonoSourceDir.Combine("mono/metadata/w32semaphore-unity.c"),
         MonoSourceDir.Combine("mono/metadata/w32socket-unity.c")
     });
 }
コード例 #23
0
        private static void WriteBeeBatchFile(NPath directory)
        {
            var file = directory.Combine("bee");

            // Then write out some helper bee/bee.cmd scripts
            using (StreamWriter sw = new StreamWriter(file.ToString()))
            {
                sw.NewLine = "\n";
                #if UNITY_EDITOR_LINUX
                sw.WriteLine($@"#!/bin/bash");
                #else
                // sh is not good enough for printf, but on mac it'll be either zsh or bash
                sw.WriteLine($@"#!/bin/sh");
                #endif
                sw.WriteLine();
                sw.WriteLine("MONO=");
                sw.WriteLine($@"BEE=""$PWD/{BeePath.RelativeTo(directory).ToString(SlashMode.Forward)}""");
                sw.WriteLine("BEE=$(printf %q \"$BEE\")");
                sw.WriteLine($@"if [ ""$APPDATA"" == """" ] ; then");
                sw.WriteLine("    MONO=mono");
                sw.WriteLine("fi");
                sw.WriteLine("cmdToRun=\"${MONO} ${BEE} $*\"");
                sw.WriteLine("if [ $# -eq 0 ]; then");
                sw.WriteLine("    eval \"${cmdToRun} -t\"");
                sw.WriteLine("  else");
                sw.WriteLine("    eval \"${cmdToRun}\"");
                sw.WriteLine("fi");
            }

#if !UNITY_EDITOR_WIN
            System.Diagnostics.Process.Start("chmod", $"+x \"{file.ToString()}\"")
            .WaitForExit();
#endif

            var cmdFile = directory.Combine("bee.cmd");
            using (StreamWriter sw = new StreamWriter(cmdFile.ToString()))
            {
                sw.NewLine = "\n";
                sw.WriteLine("@ECHO OFF");
                sw.WriteLine($@"set bee=%~dp0{BeePath.RelativeTo(directory).ToString(SlashMode.Backward)}");
                sw.WriteLine($@"if [%1] == [] (%bee% -t) else (%bee% %*)");
            }
        }
コード例 #24
0
        static Il2CppDependencies()
        {
            NPath path = CommonPaths.Il2CppRoot.ParentContaining("il2cpp-dependencies");

            if (path != null)
            {
                string[] append = new string[] { "il2cpp-dependencies" };
                _root = path.Combine(append);
            }
        }
コード例 #25
0
        public virtual void Populate(TestCaseMetadaProvider metadataProvider)
        {
            _testCase.SourceFile.Copy(_directory);

            if (_testCase.HasLinkXmlFile)
            {
                _testCase.LinkXmlFile.Copy(InputDirectory);
            }

            CopyToInputAndExpectations(GetExpectationsAssemblyPath());

            foreach (var dep in metadataProvider.AdditionalFilesToSandbox())
            {
                var destination = _directory.Combine(dep.DestinationFileName);
                dep.Source.FileMustExist().Copy(destination);

                // In a few niche tests we need to copy pre-built assemblies directly into the input directory.
                // When this is done, we also need to copy them into the expectations directory so that if they are used
                // as references we can still compile the expectations version of the assemblies
                if (destination.Parent == InputDirectory)
                {
                    dep.Source.Copy(ExpectationsDirectory.Combine(destination.RelativeTo(InputDirectory)));
                }
            }

            foreach (var res in metadataProvider.GetResources())
            {
                res.Source.FileMustExist().Copy(ResourcesDirectory.Combine(res.DestinationFileName));
            }

            foreach (var compileRefInfo in metadataProvider.GetSetupCompileAssembliesBefore())
            {
                var destination = BeforeReferenceSourceDirectoryFor(compileRefInfo.OutputName).EnsureDirectoryExists();
                compileRefInfo.SourceFiles.Copy(destination);
            }

            foreach (var compileRefInfo in metadataProvider.GetSetupCompileAssembliesAfter())
            {
                var destination = AfterReferenceSourceDirectoryFor(compileRefInfo.OutputName).EnsureDirectoryExists();
                compileRefInfo.SourceFiles.Copy(destination);
            }
        }
コード例 #26
0
        public virtual IEnumerable <string> GetReferencedAssemblies(NPath workingDirectory)
        {
            yield return(workingDirectory.Combine("Mono.Linker.Tests.Cases.Expectations.dll").ToString());

            yield return("mscorlib.dll");

            foreach (var referenceAttr in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(ReferenceAttribute)))
            {
                yield return((string)referenceAttr.ConstructorArguments.First().Value);
            }
        }
コード例 #27
0
 public void Write(NPath outputDir)
 {
     string[] append = new string[] { "driver.cpp" };
     using (SourceCodeWriter writer = new SourceCodeWriter(outputDir.Combine(append)))
     {
         this.WriteIncludes(writer);
         this.WriteMainInvoker(writer);
         this.WriteEntryPoint(writer);
         this.WritePlatformSpecificEntryPoints(writer);
     }
 }
コード例 #28
0
        static void WriteBeeConfigFile(NPath directory)
        {
            var file = directory.Combine("bee.config");

            file.UpdateAllText(JsonSerialization.Serialize(new BeeConfig
            {
                BuildProgramBuildProgramFiles = new List <string>
                {
                    Path.GetFullPath("Packages/com.unity.tiny/DotsPlayer/bee~/BuildProgramBuildProgramSources")
                }
            }));
        }
コード例 #29
0
        public NPath ReferenceSourcesFilePathFor(NPath classLibraryAssemblyDirectory, string profileName)
        {
            var classLibNameForSourcesFile = SourcesUtils.ClassLibSourcesFileNameOnDiskFromParentDirectory(classLibraryAssemblyDirectory);
            var normalNamingScheme         = $"{profileName}_{classLibNameForSourcesFile}.dll.sources";

            var normalNamingPath = classLibraryAssemblyDirectory.Combine(normalNamingScheme);

            if (normalNamingPath.FileExists())
            {
                return(normalNamingPath);
            }

            var alternateNamingPath = classLibraryAssemblyDirectory.Combine($"{classLibNameForSourcesFile}.dll.sources");

            if (alternateNamingPath.FileExists())
            {
                return(alternateNamingPath);
            }

            return(normalNamingPath);
        }
コード例 #30
0
    private static NPath DoShaderC(NPath inputDir, NPath outputDir, string shaderName, string fsORvs, string backend, string extraArgs)
    {
        var thisOutput = outputDir.Combine($"{fsORvs}_{shaderName}_{backend}.raw");

        Backend.Current.AddAction("Shaderc",
                                  new[] { thisOutput },
                                  new[] { inputDir.Combine($"{fsORvs}_{shaderName}.sc"), inputDir.Combine("varying.def.sc") },
                                  "shaderc.exe",
                                  $"-f {shaderName}/{fsORvs}_{shaderName}.sc -o {outputDir.Combine($"{fsORvs}_{shaderName}_{backend}.raw")} {extraArgs} --varyingdef {shaderName}/varying.def.sc"
                                  .Split(' ').ToArray());
        return(thisOutput);
    }