Esempio n. 1
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>();
        }
Esempio n. 2
0
 public Builder(ILogger logger, string buildPath, string buildProfile, string indexName)
 {
     MonitorPipeNames  = new List <string>();
     startTime         = DateTime.Now;
     this.buildProfile = buildProfile;
     this.indexName    = indexName;
     Logger            = logger;
     this.buildPath    = buildPath ?? throw new ArgumentNullException(nameof(buildPath));
     Root                 = new ListBuildStep();
     ioMonitor            = new CommandIOMonitor(Logger);
     ThreadCount          = Environment.ProcessorCount;
     MaxParallelProcesses = ThreadCount;
     BuilderId            = Guid.NewGuid();
     InitialVariables     = new Dictionary <string, string>();
 }
Esempio n. 3
0
        public Builder(string buildPath, string buildProfile, string indexFilename, string inputHashesFilename, ILogger logger)
        {
            if (buildPath == null)
            {
                throw new ArgumentNullException("buildPath");
            }
            if (indexFilename == null)
            {
                throw new ArgumentNullException("indexFilename");
            }
            if (inputHashesFilename == null)
            {
                throw new ArgumentNullException("inputHashesFilename");
            }

            MonitorPipeNames   = new List <string>();
            startTime          = DateTime.Now;
            this.buildProfile  = buildProfile;
            this.indexFilename = indexFilename;
            var entryAssembly = Assembly.GetEntryAssembly();

            SlaveBuilderPath         = entryAssembly != null ? entryAssembly.Location : "";
            Logger                   = logger;
            this.inputHashesFilename = inputHashesFilename;
            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);

            var objectDatabase = IndexFileCommand.ObjectDatabase;

            // Check current database version, and erase it if too old
            int currentVersion = 0;
            var versionFile    = Path.Combine(VirtualFileSystem.GetAbsolutePath(DatabasePath), "version");

            if (File.Exists(versionFile))
            {
                try
                {
                    var versionText = File.ReadAllText(versionFile);
                    currentVersion = int.Parse(versionText);
                }
                catch (Exception)
                {
                }
            }

            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());
            }

            // Prepare data base directories
            AssetManager.GetFileProvider = () => IndexFileCommand.DatabaseFileProvider.Value;
            var databasePathSplits = DatabasePath.Split('/');
            var accumulatorPath    = "/";

            foreach (var pathPart in databasePathSplits.Where(x => x != ""))
            {
                accumulatorPath += pathPart + "/";
                VirtualFileSystem.CreateDirectory(accumulatorPath);

                accumulatorPath += "";
            }
        }
Esempio 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>();
        }
Esempio 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 += "";
            }
        }