Ejemplo n.º 1
0
        public void TestConcurrencyReadWriteAccess2()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{99D73F8B-587A-4869-97AE-4A7185D88AC9}");
            var inputDep = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1"));

            var buildStepList1 = new ListBuildStep
                {
                    new ListBuildStep { new InputOutputCommand { Delay = 100, Source = inputDep, OutputUrl = "/db/url1", InputDependencies = { inputDep } } },
                    new WaitBuildStep(),
                    new InputOutputCommand { Delay = 1500, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/dump1", InputDependencies = { inputDep } },
                };
            var buildStepList2 = new ListBuildStep
                {
                    new ListBuildStep { new InputOutputCommand { Delay = 100, Source = inputDep, OutputUrl = "/db/url1", InputDependencies = { inputDep } } },
                    new WaitBuildStep(),
                    new InputOutputCommand { Delay = 1500, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/dump2", InputDependencies = { inputDep } },
                };

            var builder = Utils.CreateBuilder();
            builder.ThreadCount = 1;
            builder.Root.Add(buildStepList1);
            builder.Root.Add(buildStepList2);

            Utils.StartCapturingLog();
            var buildResult = builder.Run(Builder.Mode.Build);
            Assert.That(buildResult, Is.EqualTo(BuildResultCode.Successful));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Discard the current <see cref="Root"/> build step and initialize a new empty one.
 /// </summary>
 public void Reset()
 {
     Root = new ListBuildStep();
     stepCounter.Clear();
 }
Ejemplo n.º 3
0
 public void Execute(ListBuildStep root)
 {
     // Execute the command C# makefile
     Type type = compilerResult.CompiledAssembly.GetType("BuildScript");
     if (type != null)
     {
         object makefile = Activator.CreateInstance(type);
         MethodInfo executeMethod = type.GetMethod("Execute", BindingFlags.Public | BindingFlags.Instance);
         executeMethod.Invoke(makefile, new object[] { null, root });
     }
 }
Ejemplo n.º 4
0
        public Builder(ILogger logger, string buildPath, string buildProfile, string indexName)
        {
            if (buildPath == null) throw new ArgumentNullException(nameof(buildPath));

            MonitorPipeNames = new List<string>();
            startTime = DateTime.Now;
            this.buildProfile = buildProfile;
            this.indexName = indexName;
            var entryAssembly = Assembly.GetEntryAssembly();
            SlaveBuilderPath = Path.Combine(
                AppDomain.CurrentDomain.BaseDirectory,
                entryAssembly != null ? Path.GetFileName(entryAssembly.Location) : "SiliconStudio.Assets.CompilerApp.exe"); // TODO: Hardcoded value of CompilerApp
            Logger = logger;
            this.buildPath = buildPath;
            Root = new ListBuildStep();
            ioMonitor = new CommandIOMonitor(Logger);
            ThreadCount = Environment.ProcessorCount;
            MaxParallelProcesses = ThreadCount;
            BuilderId = Guid.NewGuid();
            InitialVariables = new Dictionary<string, string>();
        }
Ejemplo n.º 5
0
        public Builder(ILogger logger, string buildPath, string buildProfile, string indexName)
        {
            if (buildPath == null) throw new ArgumentNullException(nameof(buildPath));

            MonitorPipeNames = new List<string>();
            startTime = DateTime.Now;
            this.buildProfile = buildProfile;
            this.indexName = indexName;
            var entryAssembly = Assembly.GetEntryAssembly();
            SlaveBuilderPath = Path.Combine(
                AppDomain.CurrentDomain.BaseDirectory,
                entryAssembly != null ? Path.GetFileName(entryAssembly.Location) : "SiliconStudio.Assets.CompilerApp.exe"); // TODO: Hardcoded value of CompilerApp
            Logger = logger;
            this.buildPath = buildPath;
            Root = new ListBuildStep();
            ioMonitor = new CommandIOMonitor(Logger);
            ThreadCount = Environment.ProcessorCount;
            MaxParallelProcesses = ThreadCount;
            BuilderId = Guid.NewGuid();
            InitialVariables = new Dictionary<string, string>();

            SetupBuildPath(buildPath, indexName);

            var objectDatabase = IndexFileCommand.ObjectDatabase;

            // Check current database version, and erase it if too old
            int currentVersion = 0;
            var versionFile = Path.Combine(VirtualFileSystem.GetAbsolutePath(VirtualFileSystem.ApplicationDatabasePath), "version");
            if (File.Exists(versionFile))
            {
                try
                {
                    var versionText = File.ReadAllText(versionFile);
                    currentVersion = int.Parse(versionText);
                }
                catch (Exception e)
                {
                    e.Ignore();
                }
            }

            if (currentVersion != ExpectedVersion)
            {
                var looseObjects = objectDatabase.EnumerateLooseObjects().ToArray();

                if (looseObjects.Length > 0)
                {
                    Logger.Info("Database version number has been updated from {0} to {1}, erasing all objects...", currentVersion, ExpectedVersion);

                    // Database version has been updated, let's clean it
                    foreach (var objectId in looseObjects)
                    {
                        try
                        {
                            objectDatabase.Delete(objectId);
                        }
                        catch (IOException)
                        {
                        }
                    }
                }

                // Create directory
                File.WriteAllText(versionFile, ExpectedVersion.ToString(CultureInfo.InvariantCulture));
            }

            // Prepare data base directories
            AssetManager.GetFileProvider = () => IndexFileCommand.DatabaseFileProvider;
            var databasePathSplits = VirtualFileSystem.ApplicationDatabasePath.Split('/');
            var accumulatorPath = "/";
            foreach (var pathPart in databasePathSplits.Where(x=>x!=""))
            {
                accumulatorPath += pathPart + "/";
                VirtualFileSystem.CreateDirectory(accumulatorPath);

                accumulatorPath += "";
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoggerResult" /> class.
 /// </summary>
 /// <param name="moduleName">Name of the module.</param>
 public AssetCompilerResult(string moduleName = null) : base(moduleName)
 {
     BuildSteps = new ListBuildStep();
 }
Ejemplo n.º 7
0
 public PrecompiledAssetBuildUnit(AssetBuildUnitIdentifier identifier, ListBuildStep buildStep, bool mergeInCommonDatabase = false)
     : base(identifier)
 {
     this.buildStep             = buildStep;
     this.mergeInCommonDatabase = mergeInCommonDatabase;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoggerResult" /> class.
 /// </summary>
 /// <param name="moduleName">Name of the module.</param>
 public AssetCompilerResult(string moduleName = null) : base(moduleName)
 {
     BuildSteps = new ListBuildStep();
 }