Author: ankit
Date: 2007-12-14 05:35:46 -0500 (Fri, 14 Dec 2007)
New Revision: 91270
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/AutotoolsContext.cs
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/ChangeLog
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/Set.cs
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/SolutionDeployer.cs
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/templates/configure.ac.template
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/templates/configure.template
Log:
Fix bug #347649
* AutotoolsContext.cs (AddRequiredPackages): Allow packages to be
specified per config.
(GetRequiredPackages): Per config.
(GetCommonRequiredPackages): Packages common to all configs.
* Set.cs (Intersect): New.
(Count): New.
(ToString): Override.
* SimpleProjectMakefileHandler.cs: Keep track of packages per config.
* SolutionDeployer.cs: Emit package requirements per config in
configure.ac and the configure script.
* templates/configure.ac.template: Update.
* templates/configure.template: Update to check per config packages.
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/AutotoolsContext.cs
===================================================================
--- trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/AutotoolsContext.cs
2007-12-14 06:29:47 UTC (rev 91269)
+++ trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/AutotoolsContext.cs
2007-12-14 10:35:46 UTC (rev 91270)
@@ -40,7 +40,8 @@
MakefileType makefileType;
Set<string> autoconfConfigFiles = new Set<string> ();
- Set<SystemPackage> referencedPackages = new
Set<SystemPackage>();
+ Dictionary<string, Set<SystemPackage>>
referencedPackagesByConfig = new Dictionary<string,Set<SystemPackage>> ();
+ Set<SystemPackage> commonPackages;
Set<string> globalFilesReferences = new Set<string>();
Set<string> compilers = new Set<string> ();
Set<string> builtProjects = new Set<string> ();
@@ -134,9 +135,12 @@
return dir;
}
- public void AddRequiredPackage (SystemPackage pkg)
+ public void AddRequiredPackages (string config,
Set<SystemPackage> pkgs)
{
- referencedPackages.Add (pkg);
+ if (!referencedPackagesByConfig.ContainsKey (config))
+ referencedPackagesByConfig [config] = new
Set<SystemPackage> ();
+
+ referencedPackagesByConfig [config].Union (pkgs);
}
public void AddAutoconfFile ( string file_name )
@@ -193,11 +197,40 @@
return generatedFiles;
}
- public IEnumerable<SystemPackage> GetRequiredPackages ()
+ public Set<SystemPackage> GetRequiredPackages (string config,
bool removeCommonPackages)
{
- return referencedPackages;
+ if (!referencedPackagesByConfig.ContainsKey (config))
+ return null;
+
+ if (removeCommonPackages)
+ referencedPackagesByConfig [config].Without
(GetCommonRequiredPackages ());
+ return referencedPackagesByConfig [config];
}
+ // Returns set of packages required by all configs
+ public Set<SystemPackage> GetCommonRequiredPackages ()
+ {
+ if (commonPackages != null)
+ return commonPackages;
+
+ commonPackages = new Set<SystemPackage> ();
+ int i = 0;
+ foreach (Set<SystemPackage> pkgSet in
referencedPackagesByConfig.Values) {
+ if (i == 0) {
+ // Use the first set as the starting one
+ foreach (SystemPackage p in pkgSet)
+ commonPackages.Add (p);
+ i ++;
+ continue;
+ }
+
+ commonPackages.Intersect (pkgSet);
+ if (commonPackages.Count == 0)
+ break;
+ }
+ return commonPackages;
+ }
+
public IEnumerable GetCommandChecks ()
{
return compilers;
Modified: trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/ChangeLog
2007-12-14 06:29:47 UTC (rev 91269)
+++ trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/ChangeLog
2007-12-14 10:35:46 UTC (rev 91270)
@@ -1,3 +1,19 @@
+2007-12-14 Ankit Jain <[EMAIL PROTECTED]>
+
+ Fix bug #347649
+ * AutotoolsContext.cs (AddRequiredPackages): Allow packages to be
+ specified per config.
+ (GetRequiredPackages): Per config.
+ (GetCommonRequiredPackages): Packages common to all configs.
+ * Set.cs (Intersect): New.
+ (Count): New.
+ (ToString): Override.
+ * SimpleProjectMakefileHandler.cs: Keep track of packages per config.
+ * SolutionDeployer.cs: Emit package requirements per config in
+ configure.ac and the configure script.
+ * templates/configure.ac.template: Update.
+ * templates/configure.template: Update to check per config packages.
+
2007-12-14 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* MonoDevelop.Autotools.mdp: Updated project files. The order of
extended
Modified: trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/Set.cs
===================================================================
--- trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/Set.cs
2007-12-14 06:29:47 UTC (rev 91269)
+++ trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/Set.cs
2007-12-14 10:35:46 UTC (rev 91270)
@@ -20,6 +20,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Text;
namespace MonoDevelop.Autotools
{
@@ -68,7 +69,18 @@
hashtable[o] = this;
}
}
-
+
+ public void Intersect (Set<T> set)
+ {
+ List<T> toRemove = new List<T> ();
+ foreach (T o in hashtable.Keys)
+ if (!set.Contains (o))
+ toRemove.Add (o);
+
+ foreach (T o in toRemove)
+ hashtable.Remove (o);
+ }
+
public void Without(Set<T> set)
{
foreach(T o in set) {
@@ -81,5 +93,19 @@
return hashtable.Count == 0;
}
}
+
+ public int Count {
+ get { return hashtable.Keys.Count; }
+ }
+
+ public override string ToString ()
+ {
+ StringBuilder sb = new StringBuilder ();
+ sb.Append ("[ ");
+ foreach (T o in hashtable.Keys)
+ sb.AppendFormat ("{0}, ", o.ToString ());
+ sb.Append (" ]");
+ return sb.ToString ();
+ }
}
}
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs
===================================================================
---
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs
2007-12-14 06:29:47 UTC (rev 91269)
+++
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs
2007-12-14 10:35:46 UTC (rev 91270)
@@ -1,7 +1,7 @@
/*
Copyright (C) 2006 Matthias Braun <[EMAIL PROTECTED]>
Scott Ellington <[EMAIL PROTECTED]>
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
@@ -66,6 +66,9 @@
// custom commands
StringBuilder customCommands;
+ // store all refs for easy access
+ Set<SystemPackage> pkgs;
+
public bool CanDeploy (CombineEntry entry, MakefileType type)
{
Project project = entry as Project;
@@ -217,6 +220,7 @@
conf_vars.AppendFormat
("#include $(srcdir)/custom-hooks.make\n\n");
}
+ bool buildEnabled;
List<ConfigSection> configSections = new
List<ConfigSection> ();
allDeployVars = new Dictionary<string,
DeployFile> ();
@@ -224,7 +228,7 @@
foreach (CombineConfiguration combineConfig in
ctx.TargetCombine.Configurations)
{
ctx.TargetCombine.ActiveConfiguration =
combineConfig;
- DotNetProjectConfiguration config =
GetProjectConfig (combineConfig.Name, project) as DotNetProjectConfiguration;
+ DotNetProjectConfiguration config =
GetProjectConfig (combineConfig.Name, project, out buildEnabled) as
DotNetProjectConfiguration;
if (config == null)
continue;
@@ -276,7 +280,7 @@
continue;
Project refp =
GetProjectFromName (reference.Reference, ctx.TargetCombine);
- DotNetProjectConfiguration dnpc
= GetProjectConfig (combineConfig.Name, refp) as DotNetProjectConfiguration;
+ DotNetProjectConfiguration dnpc
= GetProjectConfig (combineConfig.Name, refp, out buildEnabled) as
DotNetProjectConfiguration;
if ( dnpc == null )
throw new Exception (
GettextCatalog.GetString
("Could
not add reference to project '{0}'", refp.Name) );
@@ -318,6 +322,9 @@
if (config.CustomCommands.Count
> 0)
monitor.ReportWarning
(GettextCatalog.GetString ("Custom commands are not supported for autotools
based makefiles. Ignoring Ignoring.."));
}
+
+ if (buildEnabled && pkgs.Count > 0)
+ ctx.AddRequiredPackages
(combineConfig.Name, pkgs);
}
ctx.TargetCombine.ActiveConfiguration =
saveConfiguration;
@@ -443,10 +450,8 @@
{
StringWriter refWriter = new StringWriter();
StringWriter dllRefWriter = new StringWriter();
+ pkgs = new Set<SystemPackage> ();
- // store all refs for easy access
- Set<SystemPackage> pkgs = new Set<SystemPackage>();
-
// grab pkg-config references
foreach (ProjectReference reference in
project.ProjectReferences)
{
@@ -467,11 +472,11 @@
} else {
refWriter.Write
("\t-pkg:{0}", pkg.Name);
}
- ctx.AddRequiredPackage (pkg);
+ pkgs.Add (pkg);
}
else
{
- refWriter.WriteLine (" \\");
+ refWriter.WriteLine (" \\");
// store all refs for easy access
AssemblyName assembly =
Runtime.SystemAssemblyService.ParseAssemblyName (reference.Reference);
refWriter.Write ("\t" +
assembly.Name);
refWriter.Write ("");
@@ -676,15 +681,18 @@
}
// Get the Project config corresponding to its @parentConfig
- IConfiguration GetProjectConfig (string parentConfig,
CombineEntry entry)
+ internal static IConfiguration GetProjectConfig (string
parentConfig, CombineEntry entry, out bool enabled)
{
+ enabled = false;
CombineConfiguration combineConfig =
entry.ParentCombine.Configurations [parentConfig] as CombineConfiguration;
if (combineConfig == null)
return null;
foreach (CombineConfigurationEntry cce in
combineConfig.Entries) {
- if (cce.Entry == entry)
+ if (cce.Entry == entry) {
+ enabled = cce.Build;
return entry.Configurations
[cce.ConfigurationName];
+ }
}
return null;
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/SolutionDeployer.cs
===================================================================
--- trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/SolutionDeployer.cs
2007-12-14 06:29:47 UTC (rev 91269)
+++ trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/SolutionDeployer.cs
2007-12-14 10:35:46 UTC (rev 91270)
@@ -289,8 +289,9 @@
{
config_options.Append ( "if test -z
\"$CONFIG_REQUESTED\" ; then\n" );
// AppendConfigVariables ( combine, defaultConf,
config_options );
- config_options.AppendFormat ( "
AM_CONDITIONAL({0}, true)\nfi\n", "ENABLE_"
- +
context.EscapeAndUpperConfigName (defaultConf));
+ config_options.AppendFormat ( "
AM_CONDITIONAL(ENABLE_{0}, true)\n", context.EscapeAndUpperConfigName
(defaultConf));
+ config_options.AppendFormat
("\tenable_{0}=yes\n", context.EscapeAndUpperConfigName (defaultConf).ToLower
());
+ config_options.Append ("fi\n");
}
templateEngine.Variables ["CONFIG_OPTIONS"] =
config_options.ToString();
@@ -322,14 +323,23 @@
// build list of pkgconfig checks we must make
StringWriter packageChecks = new StringWriter();
- foreach (SystemPackage pkg in
context.GetRequiredPackages ())
- {
- string pkgvar =
AutotoolsContext.GetPkgConfigVariable (pkg.Name);
- packageChecks.Write("PKG_CHECK_MODULES([");
- packageChecks.Write(pkgvar);
- packageChecks.Write("], [");
- packageChecks.Write(pkg.Name);
- packageChecks.WriteLine("])");
+ packageChecks.WriteLine ("dnl package checks, common
for all configs");
+ Set<SystemPackage> commonPackages =
context.GetCommonRequiredPackages ();
+ foreach (SystemPackage pkg in commonPackages)
+
packageChecks.WriteLine("PKG_CHECK_MODULES([{0}], [{1}])",
AutotoolsContext.GetPkgConfigVariable (pkg.Name), pkg.Name);
+
+ packageChecks.WriteLine ("\ndnl package checks, per
config");
+ foreach (IConfiguration config in
combine.Configurations) {
+ Set<SystemPackage> pkgs =
context.GetRequiredPackages (config.Name, true);
+ if (pkgs == null || pkgs.Count == 0)
+ continue;
+
+ packageChecks.WriteLine (@"if test
""x$enable_{0}"" = ""xyes""; then",
+
context.EscapeAndUpperConfigName (config.Name).ToLower());
+
+ foreach (SystemPackage pkg in pkgs)
+
packageChecks.WriteLine("\tPKG_CHECK_MODULES([{0}], [{1}])",
AutotoolsContext.GetPkgConfigVariable (pkg.Name), pkg.Name);
+ packageChecks.WriteLine ("fi");
}
templateEngine.Variables["PACKAGE_CHECKS"] =
packageChecks.ToString();
templateEngine.Variables["SOLUTION_NAME"] =
solution_name;
@@ -361,18 +371,34 @@
sbConfig.AppendFormat (" {0}", config);
sbConfig.Append ("\"");
- // Build list of required packages
- StringBuilder sbPackages = new StringBuilder ();
- sbPackages.Append ("\"");
- foreach (SystemPackage pkg in ctx.GetRequiredPackages
())
- sbPackages.AppendFormat (" {0};{1}", pkg.Name,
pkg.Version);
- sbPackages.Append ("\"");
+ // Build list of packages required by all configs
+ StringBuilder commonPackages = new StringBuilder ();
+ commonPackages.Append ("common_packages=\"");
+ foreach (SystemPackage pkg in
context.GetCommonRequiredPackages ())
+ commonPackages.AppendFormat (" {0};{1}",
pkg.Name, pkg.Version);
+ commonPackages.Append ("\"");
+ // Build list of packages required per config
+ StringBuilder requiredPackages = new StringBuilder ();
+ foreach (IConfiguration config in
combine.Configurations) {
+ Set<SystemPackage> pkgs =
context.GetRequiredPackages (config.Name, true);
+ if (pkgs == null || pkgs.Count == 0)
+ continue;
+
+ if (requiredPackages.Length > 0)
+ requiredPackages.Append ("\n");
+ requiredPackages.AppendFormat
("required_packages_{0}=\"", context.EscapeAndUpperConfigName (config.Name));
+ foreach (SystemPackage pkg in pkgs)
+ requiredPackages.AppendFormat ("
{0};{1}", pkg.Name, pkg.Version);
+ requiredPackages.Append ("\"");
+ }
+
templateEngine.Variables ["VERSION"] = solution_version;
templateEngine.Variables ["PACKAGE"] =
AutotoolsContext.EscapeStringForAutoconf (combine.Name).ToLower ();
templateEngine.Variables ["DEFAULT_CONFIG"] =
ctx.EscapeAndUpperConfigName (defaultConf);
templateEngine.Variables ["CONFIGURATIONS"] =
sbConfig.ToString ();
- templateEngine.Variables ["REQUIRED_PACKAGES"] =
sbPackages.ToString ();
+ templateEngine.Variables ["COMMON_PACKAGES"] =
commonPackages.ToString ();
+ templateEngine.Variables ["REQUIRED_PACKAGES"] =
requiredPackages.ToString ();
Stream stream = context.GetTemplateStream
("configure.template");
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/templates/configure.ac.template
===================================================================
---
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/templates/configure.ac.template
2007-12-14 06:29:47 UTC (rev 91269)
+++
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/templates/configure.ac.template
2007-12-14 10:35:46 UTC (rev 91270)
@@ -14,10 +14,10 @@
%%COMPILER_CHECKS%%
+%%CONFIG_OPTIONS%%
+
%%PACKAGE_CHECKS%%
-%%CONFIG_OPTIONS%%
-
AC_CONFIG_FILES([
%%CONFIG_FILES%%
])
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/templates/configure.template
===================================================================
---
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/templates/configure.template
2007-12-14 06:29:47 UTC (rev 91269)
+++
trunk/monodevelop/main/src/addins/MonoDevelop.Autotools/templates/configure.template
2007-12-14 10:35:46 UTC (rev 91270)
@@ -4,7 +4,8 @@
prefix=/usr/local
config=%%DEFAULT_CONFIG%%
configurations=%%CONFIGURATIONS%%
-required_packages=%%REQUIRED_PACKAGES%%
+%%COMMON_PACKAGES%%
+%%REQUIRED_PACKAGES%%
usage ()
{
@@ -31,21 +32,29 @@
return 0
}
+check_package ()
+{
+ name=`echo $1 | cut -d\; -f1`
+ version=`echo $1 | cut -d\; -f2`
+
+ echo -n "Checking for package '$name'.." | tee -a config.log
+ pkg-config --atleast-version=$version $name
+ if [ $? -ne 0 ]; then
+ echo " ERROR: Package named '$name' >= $version not found." |
tee -a config.log
+ echo "Try adjusting your PKG_CONFIG_PATH environment variable."
| tee -a config.log
+ return 1
+ fi
+ echo " found." | tee -a config.log
+}
+
check_required_packages ()
{
echo "Looking for required packages" | tee config.log
- for pkg in $required_packages; do
- name=`echo $pkg | cut -d\; -f1`
- version=`echo $pkg | cut -d\; -f2`
-
- echo -n "Checking for package '$name'.." | tee -a config.log
- pkg-config --atleast-version=$version $name
- if [ $? -ne 0 ]; then
- echo " ERROR: Package named '$name' >= $version not
found." | tee -a config.log
- echo "Try adjusting your PKG_CONFIG_PATH environment
variable." | tee -a config.log
- return 1
- fi
- echo " found." | tee -a config.log
+ var=required_packages_$config
+ for pkg in $common_packages ${!var}; do
+ check_package $pkg
+ retval=$?
+ [ $retval -ne 0 ] && return $retval
done
return 0
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches