public SourceBuilder(BuildRules Rules, string SourcePathRoot) { rules = Rules; sourcePathRoot = SourcePathRoot; intermediateModulePath = BuildSystem.IntermediateDirectory + Rules.TargetName + EnvironmentHelper.PathSeparator; generatedFilesPath = intermediateModulePath + "Generated" + EnvironmentHelper.PathSeparator; if (rules.LibraryUseType != BuildRules.LibraryUseTypes.UseOnly) { //if (Directory.Exists(intermediateModulePath)) // Directory.Delete(intermediateModulePath, true); //Directory.CreateDirectory(intermediateModulePath); if (!Directory.Exists(generatedFilesPath)) { Directory.CreateDirectory(generatedFilesPath); } } compiler = new Compiler(); compiler.ErrorRaised += ErrorRaised; }
private bool BuildRulesLibrary() { if (rulesLibrary != null) { foreach (SourceBuilder builder in sourceBuilders.Values) { builder.State = SourceBuilder.States.NotBuilt; } return(true); } const string ProjectName = "Modules"; string projectDir = intermediateDirectory + ProjectName + EnvironmentHelper.PathSeparator; if (!Directory.Exists(projectDir)) { Directory.CreateDirectory(projectDir); } CSProjectFileGenerator csproj = new CSProjectFileGenerator(); csproj.FrameworkVersion = CSProjectFileGenerator.FrameworkVersions.v4_5; csproj.AssemblyName = ProjectName; csproj.OutputPath = projectDir + "Build" + EnvironmentHelper.PathSeparator; csproj.OutputType = ProjectFileGenerator.OutputTypes.DynamicLinkLibrary; csproj.AddReferenceBinaryFile(Assembly.GetExecutingAssembly().Location); string[] files = FileSystemUtilites.GetAllFiles(processDirectory, "*" + BuildRules.FilePostfix); DateTime startTime = DateTime.Now; ConsoleHelper.WriteLineInfo("Building rules starts at " + startTime.ToString()); ConsoleHelper.WriteLineInfo("Found rules :"); foreach (string rules in files) { buildRulesPath.Add(rules); csproj.AddCompileFile(rules); ConsoleHelper.WriteLineInfo("\t" + Path.GetFileName(rules)); } if (buildRulesPath.Count == 0) { return(false); } string csprojPath = projectDir + ProjectName + ".csproj"; csproj.Generate(csprojPath); bool wasSuccessful = false; if (compiler.BuildProjectFile(csprojPath)) { rulesLibrary = Assembly.LoadFile(csproj.OutputPath + ProjectName + ".dll"); wasSuccessful = true; } foreach (string buildRule in buildRulesPath) { string fileName = Path.GetFileNameWithoutExtension(buildRule); string typeName = fileName.Replace(".", ""); Type type = rulesLibrary.GetType(typeName); if (type == null) { ConsoleHelper.WriteLineWarning("In " + fileName + ", type " + typeName + " doesn't exists, building it will be ignore"); continue; } BuildRules rules = (BuildRules)Activator.CreateInstance(type); sourceBuilders[rules.TargetName] = new SourceBuilder(rules, Path.GetDirectoryName(buildRule) + EnvironmentHelper.PathSeparator); } ConsoleHelper.WriteLineInfo("Building rules takes " + (DateTime.Now - startTime).ToHHMMSS()); return(wasSuccessful); }
private static string GetAPIPreprocessor(BuildRules Rules, bool IsImport) { return(GetEmptyAPIPreprocessor(Rules) + "__declspec(dll" + (IsImport ? "import" : "export") + ")"); }
private static string GetEmptyAPIPreprocessor(BuildRules Rules) { return(Rules.TargetName.ToUpper() + "_API="); }