void CreateConfigureScript(Solution solution, string defaultConf, AutotoolsContext ctx, IProgressMonitor monitor) { monitor.Log.WriteLine(GettextCatalog.GetString("Creating configure script")); TemplateEngine templateEngine = new TemplateEngine(); // Build list of configurations StringBuilder sbConfig = new StringBuilder(); sbConfig.Append("\""); foreach (string config in ctx.GetConfigurations()) { sbConfig.AppendFormat(" {0}", config); } sbConfig.Append("\""); // Build list of packages required by all configs string commonPackages = String.Format("common_packages=\"{0}\"", GetPackageListFromSet(context.GetCommonRequiredPackages())); // Build list of packages required per config StringBuilder requiredPackages = new StringBuilder(); foreach (SolutionConfiguration config in solution.Configurations) { Set <SystemPackage> pkgs = context.GetRequiredPackages(config.Id, true); if (pkgs == null || pkgs.Count == 0) { continue; } if (requiredPackages.Length > 0) { requiredPackages.Append("\n"); } requiredPackages.AppendFormat("required_packages_{0}=\"{1}\"", context.EscapeAndUpperConfigName(config.Id), GetPackageListFromSet(pkgs)); } templateEngine.Variables ["VERSION"] = solution_version; templateEngine.Variables ["PACKAGE"] = solution.Name.ToLower(); templateEngine.Variables ["DEFAULT_CONFIG"] = ctx.EscapeAndUpperConfigName(defaultConf); templateEngine.Variables ["CONFIGURATIONS"] = sbConfig.ToString(); templateEngine.Variables ["COMMON_PACKAGES"] = commonPackages.ToString(); templateEngine.Variables ["REQUIRED_PACKAGES"] = requiredPackages.ToString(); Stream stream = context.GetTemplateStream("configure.template"); string filename = Path.Combine(solution_dir, "configure"); StreamReader reader = new StreamReader(stream); StreamWriter writer = new StreamWriter(filename); templateEngine.Process(reader, writer); reader.Close(); writer.Close(); ctx.AddGeneratedFile(filename); if (PlatformID.Unix == Environment.OSVersion.Platform) { Syscall.chmod(filename, FilePermissions.S_IXOTH | FilePermissions.S_IROTH | FilePermissions.S_IRWXU | FilePermissions.S_IRWXG); } }
void CreateConfigureScript (Solution solution, string defaultConf, AutotoolsContext ctx, IProgressMonitor monitor) { monitor.Log.WriteLine ( GettextCatalog.GetString ("Creating configure script") ); TemplateEngine templateEngine = new TemplateEngine (); // Build list of configurations StringBuilder sbConfig = new StringBuilder (); sbConfig.Append ("\""); foreach (string config in ctx.GetConfigurations ()) sbConfig.AppendFormat (" {0}", config); sbConfig.Append ("\""); // Build list of packages required by all configs string commonPackages = String.Format ("common_packages=\"{0}\"", GetPackageListFromSet (context.GetCommonRequiredPackages ())); // Build list of packages required per config StringBuilder requiredPackages = new StringBuilder (); foreach (SolutionConfiguration config in solution.Configurations) { Set<SystemPackage> pkgs = context.GetRequiredPackages (config.Id, true); if (pkgs == null || pkgs.Count == 0) continue; if (requiredPackages.Length > 0) requiredPackages.Append ("\n"); requiredPackages.AppendFormat ("required_packages_{0}=\"{1}\"", context.EscapeAndUpperConfigName (config.Id), GetPackageListFromSet (pkgs)); } templateEngine.Variables ["VERSION"] = solution_version; templateEngine.Variables ["PACKAGE"] = solution.Name.ToLower (); templateEngine.Variables ["DEFAULT_CONFIG"] = ctx.EscapeAndUpperConfigName (defaultConf); templateEngine.Variables ["CONFIGURATIONS"] = sbConfig.ToString (); templateEngine.Variables ["COMMON_PACKAGES"] = commonPackages.ToString (); templateEngine.Variables ["REQUIRED_PACKAGES"] = requiredPackages.ToString (); Stream stream = context.GetTemplateStream ("configure.template"); string filename = Path.Combine (solution_dir, "configure"); StreamReader reader = new StreamReader (stream); StreamWriter writer = new StreamWriter (filename); templateEngine.Process(reader, writer); reader.Close (); writer.Close (); ctx.AddGeneratedFile (filename); if (PlatformID.Unix == Environment.OSVersion.Platform) Syscall.chmod ( filename , FilePermissions.S_IXOTH | FilePermissions.S_IROTH | FilePermissions.S_IRWXU | FilePermissions.S_IRWXG ); }