Add prebuild source files
This commit is contained in:
parent
cbcd8b2bd3
commit
4f5e7942e1
86 changed files with 18185 additions and 0 deletions
971
src/Core/Targets/AutotoolsTarget.cs
Normal file
971
src/Core/Targets/AutotoolsTarget.cs
Normal file
|
@ -0,0 +1,971 @@
|
|||
#region BSD License
|
||||
|
||||
/*
|
||||
|
||||
Copyright (c) 2004 - 2008
|
||||
Matthew Holmes (matthew@wildfiregames.com),
|
||||
Dan Moorehead (dan05a@gmail.com),
|
||||
Dave Hudson (jendave@yahoo.com),
|
||||
C.J. Adams-Collier (cjac@colliertech.org),
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region MIT X11 license
|
||||
|
||||
/*
|
||||
Portions of this file authored by Lluis Sanchez Gual
|
||||
|
||||
Copyright (C) 2006 Novell, Inc (http://www.novell.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using System.Xml.Xsl;
|
||||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Interfaces;
|
||||
using Prebuild.Core.Nodes;
|
||||
using Prebuild.Core.Parse;
|
||||
using Prebuild.Core.Utilities;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
public enum ClrVersion
|
||||
{
|
||||
Default,
|
||||
Net_1_1,
|
||||
Net_2_0
|
||||
}
|
||||
|
||||
public class SystemPackage
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
|
||||
public string Version { get; private set; }
|
||||
|
||||
public string Description { get; private set; }
|
||||
|
||||
public ClrVersion TargetVersion { get; private set; }
|
||||
|
||||
// The package is part of the mono SDK
|
||||
public bool IsCorePackage => Name == "mono";
|
||||
|
||||
// The package has been registered by an add-in, and is not installed
|
||||
// in the system.
|
||||
public bool IsInternalPackage { get; private set; }
|
||||
|
||||
public string[] Assemblies { get; private set; }
|
||||
|
||||
public void Initialize(string name,
|
||||
string version,
|
||||
string description,
|
||||
string[] assemblies,
|
||||
ClrVersion targetVersion,
|
||||
bool isInternal)
|
||||
{
|
||||
IsInternalPackage = isInternal;
|
||||
Name = name;
|
||||
Version = version;
|
||||
Assemblies = assemblies;
|
||||
Description = description;
|
||||
TargetVersion = targetVersion;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("autotools")]
|
||||
public class AutotoolsTarget : ITarget
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private Kernel m_Kernel;
|
||||
private XmlDocument autotoolsDoc;
|
||||
private XmlUrlResolver xr;
|
||||
private readonly Dictionary<string, SystemPackage> assemblyPathToPackage = new();
|
||||
private readonly Dictionary<string, string> assemblyFullNameToPath = new();
|
||||
private readonly Dictionary<string, SystemPackage> packagesHash = new();
|
||||
private readonly List<SystemPackage> packages = new();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private static void mkdirDashP(string dirName)
|
||||
{
|
||||
var di = new DirectoryInfo(dirName);
|
||||
if (di.Exists)
|
||||
return;
|
||||
|
||||
var parentDirName = Path.GetDirectoryName(dirName);
|
||||
var parentDi = new DirectoryInfo(parentDirName);
|
||||
if (!parentDi.Exists)
|
||||
mkdirDashP(parentDirName);
|
||||
|
||||
di.Create();
|
||||
}
|
||||
|
||||
private static void chkMkDir(string dirName)
|
||||
{
|
||||
var di =
|
||||
new DirectoryInfo(dirName);
|
||||
|
||||
if (!di.Exists)
|
||||
di.Create();
|
||||
}
|
||||
|
||||
private void transformToFile(string filename, XsltArgumentList argList, string nodeName)
|
||||
{
|
||||
// Create an XslTransform for this file
|
||||
var templateTransformer = new XslTransform();
|
||||
|
||||
// Load up the template
|
||||
var templateNode = autotoolsDoc.SelectSingleNode(nodeName + "/*");
|
||||
//templateTransformer.Load(templateNode.CreateNavigator(), xr, e);
|
||||
templateTransformer.Load(templateNode.CreateNavigator(), xr);
|
||||
// Create a writer for the transformed template
|
||||
var templateWriter = new XmlTextWriter(filename, null);
|
||||
|
||||
// Perform transformation, writing the file
|
||||
templateTransformer.Transform(m_Kernel.CurrentDoc, argList, templateWriter, xr);
|
||||
}
|
||||
|
||||
private static string NormalizeAsmName(string name)
|
||||
{
|
||||
var i = name.IndexOf(", PublicKeyToken=null");
|
||||
if (i != -1)
|
||||
return name.Substring(0, i).Trim();
|
||||
return name;
|
||||
}
|
||||
|
||||
private void AddAssembly(string assemblyfile, SystemPackage package)
|
||||
{
|
||||
if (!File.Exists(assemblyfile))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
var an = AssemblyName.GetAssemblyName(assemblyfile);
|
||||
assemblyFullNameToPath[NormalizeAsmName(an.FullName)] = assemblyfile;
|
||||
assemblyPathToPackage[assemblyfile] = package;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static List<string> GetAssembliesWithLibInfo(string line, string file)
|
||||
{
|
||||
var references = new List<string>();
|
||||
var libdirs = new List<string>();
|
||||
var retval = new List<string>();
|
||||
foreach (var piece in line.Split(' '))
|
||||
if (piece.ToLower().Trim().StartsWith("/r:") || piece.ToLower().Trim().StartsWith("-r:"))
|
||||
references.Add(ProcessPiece(piece.Substring(3).Trim(), file));
|
||||
else if (piece.ToLower().Trim().StartsWith("/lib:") || piece.ToLower().Trim().StartsWith("-lib:"))
|
||||
libdirs.Add(ProcessPiece(piece.Substring(5).Trim(), file));
|
||||
|
||||
foreach (var refrnc in references)
|
||||
foreach (var libdir in libdirs)
|
||||
if (File.Exists(libdir + Path.DirectorySeparatorChar + refrnc))
|
||||
retval.Add(libdir + Path.DirectorySeparatorChar + refrnc);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
private static List<string> GetAssembliesWithoutLibInfo(string line, string file)
|
||||
{
|
||||
var references = new List<string>();
|
||||
foreach (var reference in line.Split(' '))
|
||||
if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:"))
|
||||
{
|
||||
var final_ref = reference.Substring(3).Trim();
|
||||
references.Add(ProcessPiece(final_ref, file));
|
||||
}
|
||||
|
||||
return references;
|
||||
}
|
||||
|
||||
private static string ProcessPiece(string piece, string pcfile)
|
||||
{
|
||||
var start = piece.IndexOf("${");
|
||||
if (start == -1)
|
||||
return piece;
|
||||
|
||||
var end = piece.IndexOf("}");
|
||||
if (end == -1)
|
||||
return piece;
|
||||
|
||||
var variable = piece.Substring(start + 2, end - start - 2);
|
||||
var interp = GetVariableFromPkgConfig(variable, Path.GetFileNameWithoutExtension(pcfile));
|
||||
return ProcessPiece(piece.Replace("${" + variable + "}", interp), pcfile);
|
||||
}
|
||||
|
||||
private static string GetVariableFromPkgConfig(string var, string pcfile)
|
||||
{
|
||||
var psi = new ProcessStartInfo("pkg-config");
|
||||
psi.RedirectStandardOutput = true;
|
||||
psi.UseShellExecute = false;
|
||||
psi.Arguments = string.Format("--variable={0} {1}", var, pcfile);
|
||||
var p = new Process();
|
||||
p.StartInfo = psi;
|
||||
p.Start();
|
||||
var ret = p.StandardOutput.ReadToEnd().Trim();
|
||||
p.WaitForExit();
|
||||
if (string.IsNullOrEmpty(ret))
|
||||
return string.Empty;
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void ParsePCFile(string pcfile)
|
||||
{
|
||||
// Don't register the package twice
|
||||
var pname = Path.GetFileNameWithoutExtension(pcfile);
|
||||
if (packagesHash.ContainsKey(pname))
|
||||
return;
|
||||
|
||||
List<string> fullassemblies = null;
|
||||
var version = "";
|
||||
var desc = "";
|
||||
|
||||
var package = new SystemPackage();
|
||||
|
||||
using (var reader = new StreamReader(pcfile))
|
||||
{
|
||||
string line;
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
var lowerLine = line.ToLower();
|
||||
if (lowerLine.StartsWith("libs:") && lowerLine.IndexOf(".dll") != -1)
|
||||
{
|
||||
var choppedLine = line.Substring(5).Trim();
|
||||
if (choppedLine.IndexOf("-lib:") != -1 || choppedLine.IndexOf("/lib:") != -1)
|
||||
fullassemblies = GetAssembliesWithLibInfo(choppedLine, pcfile);
|
||||
else
|
||||
fullassemblies = GetAssembliesWithoutLibInfo(choppedLine, pcfile);
|
||||
}
|
||||
else if (lowerLine.StartsWith("version:"))
|
||||
{
|
||||
// "version:".Length == 8
|
||||
version = line.Substring(8).Trim();
|
||||
}
|
||||
else if (lowerLine.StartsWith("description:"))
|
||||
{
|
||||
// "description:".Length == 12
|
||||
desc = line.Substring(12).Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fullassemblies == null)
|
||||
return;
|
||||
|
||||
foreach (var assembly in fullassemblies) AddAssembly(assembly, package);
|
||||
|
||||
package.Initialize(pname,
|
||||
version,
|
||||
desc,
|
||||
fullassemblies.ToArray(),
|
||||
ClrVersion.Default,
|
||||
false);
|
||||
packages.Add(package);
|
||||
packagesHash[pname] = package;
|
||||
}
|
||||
|
||||
private void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver)
|
||||
{
|
||||
var package = new SystemPackage();
|
||||
var list = new List<string>();
|
||||
|
||||
var dir = Path.Combine(prefix, version);
|
||||
if (!Directory.Exists(dir)) return;
|
||||
|
||||
foreach (var assembly in Directory.GetFiles(dir, "*.dll"))
|
||||
{
|
||||
AddAssembly(assembly, package);
|
||||
list.Add(assembly);
|
||||
}
|
||||
|
||||
package.Initialize("mono",
|
||||
version,
|
||||
"The Mono runtime",
|
||||
list.ToArray(),
|
||||
ver,
|
||||
false);
|
||||
packages.Add(package);
|
||||
}
|
||||
|
||||
private void RunInitialization()
|
||||
{
|
||||
string versionDir;
|
||||
|
||||
if (Environment.Version.Major == 1)
|
||||
versionDir = "1.0";
|
||||
else
|
||||
versionDir = "2.0";
|
||||
|
||||
//Pull up assemblies from the installed mono system.
|
||||
var prefix = Path.GetDirectoryName(typeof(int).Assembly.Location);
|
||||
|
||||
if (prefix.IndexOf(Path.Combine("mono", versionDir)) == -1)
|
||||
prefix = Path.Combine(prefix, "mono");
|
||||
else
|
||||
prefix = Path.GetDirectoryName(prefix);
|
||||
|
||||
RegisterSystemAssemblies(prefix, "1.0", ClrVersion.Net_1_1);
|
||||
RegisterSystemAssemblies(prefix, "2.0", ClrVersion.Net_2_0);
|
||||
|
||||
var search_dirs = Environment.GetEnvironmentVariable("PKG_CONFIG_PATH");
|
||||
var libpath = Environment.GetEnvironmentVariable("PKG_CONFIG_LIBPATH");
|
||||
|
||||
if (string.IsNullOrEmpty(libpath))
|
||||
{
|
||||
var path_dirs = Environment.GetEnvironmentVariable("PATH");
|
||||
foreach (var pathdir in path_dirs.Split(Path.PathSeparator))
|
||||
{
|
||||
if (pathdir == null)
|
||||
continue;
|
||||
if (File.Exists(pathdir + Path.DirectorySeparatorChar + "pkg-config"))
|
||||
{
|
||||
libpath = Path.Combine(pathdir, "..");
|
||||
libpath = Path.Combine(libpath, "lib");
|
||||
libpath = Path.Combine(libpath, "pkgconfig");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
search_dirs += Path.PathSeparator + libpath;
|
||||
if (!string.IsNullOrEmpty(search_dirs))
|
||||
{
|
||||
var scanDirs = new List<string>();
|
||||
foreach (var potentialDir in search_dirs.Split(Path.PathSeparator))
|
||||
if (!scanDirs.Contains(potentialDir))
|
||||
scanDirs.Add(potentialDir);
|
||||
foreach (var pcdir in scanDirs)
|
||||
{
|
||||
if (pcdir == null)
|
||||
continue;
|
||||
|
||||
if (Directory.Exists(pcdir))
|
||||
foreach (var pcfile in Directory.GetFiles(pcdir, "*.pc"))
|
||||
ParsePCFile(pcfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteCombine(SolutionNode solution)
|
||||
{
|
||||
#region "Create Solution directory if it doesn't exist"
|
||||
|
||||
var solutionDir = Path.Combine(solution.FullPath,
|
||||
Path.Combine("autotools",
|
||||
solution.Name));
|
||||
chkMkDir(solutionDir);
|
||||
|
||||
#endregion
|
||||
|
||||
#region "Write Solution-level files"
|
||||
|
||||
var argList = new XsltArgumentList();
|
||||
argList.AddParam("solutionName", "", solution.Name);
|
||||
// $solutionDir is $rootDir/$solutionName/
|
||||
transformToFile(Path.Combine(solutionDir, "configure.ac"),
|
||||
argList, "/Autotools/SolutionConfigureAc");
|
||||
transformToFile(Path.Combine(solutionDir, "Makefile.am"),
|
||||
argList, "/Autotools/SolutionMakefileAm");
|
||||
transformToFile(Path.Combine(solutionDir, "autogen.sh"),
|
||||
argList, "/Autotools/SolutionAutogenSh");
|
||||
|
||||
#endregion
|
||||
|
||||
foreach (var project in solution.ProjectsTableOrder)
|
||||
{
|
||||
m_Kernel.Log.Write(string.Format("Writing project: {0}",
|
||||
project.Name));
|
||||
WriteProject(solution, project);
|
||||
}
|
||||
}
|
||||
|
||||
private static string FindFileReference(string refName,
|
||||
ProjectNode project)
|
||||
{
|
||||
foreach (var refPath in project.ReferencePaths)
|
||||
{
|
||||
var fullPath =
|
||||
Helper.MakeFilePath(refPath.Path, refName, "dll");
|
||||
|
||||
if (File.Exists(fullPath)) return fullPath;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the XML doc file.
|
||||
/// </summary>
|
||||
/// <param name="project">The project.</param>
|
||||
/// <param name="conf">The conf.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
|
||||
{
|
||||
if (conf == null) throw new ArgumentNullException("conf");
|
||||
if (project == null) throw new ArgumentNullException("project");
|
||||
var docFile = (string)conf.Options["XmlDocFile"];
|
||||
// if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
|
||||
// {
|
||||
// return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
|
||||
// }
|
||||
return docFile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Normalizes the path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns></returns>
|
||||
public static string NormalizePath(string path)
|
||||
{
|
||||
if (path == null) return "";
|
||||
|
||||
StringBuilder tmpPath;
|
||||
|
||||
if (Preprocessor.GetOS() == "Win32")
|
||||
{
|
||||
tmpPath = new StringBuilder(path.Replace('\\', '/'));
|
||||
tmpPath.Replace("/", @"\\");
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpPath = new StringBuilder(path.Replace('\\', '/'));
|
||||
tmpPath = tmpPath.Replace('/', Path.DirectorySeparatorChar);
|
||||
}
|
||||
|
||||
return tmpPath.ToString();
|
||||
}
|
||||
|
||||
private void WriteProject(SolutionNode solution, ProjectNode project)
|
||||
{
|
||||
var solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name));
|
||||
var projectDir = Path.Combine(solutionDir, project.Name);
|
||||
var projectVersion = project.Version;
|
||||
var hasAssemblyConfig = false;
|
||||
chkMkDir(projectDir);
|
||||
|
||||
List<string>
|
||||
compiledFiles = new(),
|
||||
contentFiles = new(),
|
||||
embeddedFiles = new(),
|
||||
binaryLibs = new(),
|
||||
pkgLibs = new(),
|
||||
systemLibs = new(),
|
||||
runtimeLibs = new(),
|
||||
extraDistFiles = new(),
|
||||
localCopyTargets = new();
|
||||
|
||||
// If there exists a .config file for this assembly, copy
|
||||
// it to the project folder
|
||||
|
||||
// TODO: Support copying .config.osx files
|
||||
// TODO: support processing the .config file for native library deps
|
||||
var projectAssemblyName = project.Name;
|
||||
if (project.AssemblyName != null)
|
||||
projectAssemblyName = project.AssemblyName;
|
||||
|
||||
if (File.Exists(Path.Combine(project.FullPath, projectAssemblyName) + ".dll.config"))
|
||||
{
|
||||
hasAssemblyConfig = true;
|
||||
File.Copy(Path.Combine(project.FullPath, projectAssemblyName + ".dll.config"),
|
||||
Path.Combine(projectDir, projectAssemblyName + ".dll.config"), true);
|
||||
extraDistFiles.Add(project.AssemblyName + ".dll.config");
|
||||
}
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
if (conf.Options.KeyFile != string.Empty)
|
||||
{
|
||||
// Copy snk file into the project's directory
|
||||
// Use the snk from the project directory directly
|
||||
var source = Path.Combine(project.FullPath, conf.Options.KeyFile);
|
||||
var keyFile = conf.Options.KeyFile;
|
||||
var re = new Regex(".*/");
|
||||
keyFile = re.Replace(keyFile, "");
|
||||
|
||||
var dest = Path.Combine(projectDir, keyFile);
|
||||
// Tell the user if there's a problem copying the file
|
||||
try
|
||||
{
|
||||
mkdirDashP(Path.GetDirectoryName(dest));
|
||||
File.Copy(source, dest, true);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy compiled, embedded and content files into the project's directory
|
||||
foreach (var filename in project.Files)
|
||||
{
|
||||
var source = Path.Combine(project.FullPath, filename);
|
||||
var dest = Path.Combine(projectDir, filename);
|
||||
|
||||
/*
|
||||
if (filename.Contains("AssemblyInfo.cs"))
|
||||
{
|
||||
// If we've got an AssemblyInfo.cs, pull the version number from it
|
||||
string[] sources = { source };
|
||||
string[] args = { "" };
|
||||
Microsoft.CSharp.CSharpCodeProvider cscp =
|
||||
new Microsoft.CSharp.CSharpCodeProvider();
|
||||
|
||||
string tempAssemblyFile = Path.Combine(Path.GetTempPath(), project.Name + "-temp.dll");
|
||||
System.CodeDom.Compiler.CompilerParameters cparam =
|
||||
new System.CodeDom.Compiler.CompilerParameters(args, tempAssemblyFile);
|
||||
|
||||
System.CodeDom.Compiler.CompilerResults cr =
|
||||
cscp.CompileAssemblyFromFile(cparam, sources);
|
||||
|
||||
foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors)
|
||||
Console.WriteLine("Error! '{0}'", error.ErrorText);
|
||||
|
||||
try
|
||||
{
|
||||
string projectFullName = cr.CompiledAssembly.FullName;
|
||||
Regex verRegex = new Regex("Version=([\\d\\.]+)");
|
||||
Match verMatch = verRegex.Match(projectFullName);
|
||||
if (verMatch.Success)
|
||||
projectVersion = verMatch.Groups[1].Value;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Couldn't compile AssemblyInfo.cs");
|
||||
}
|
||||
|
||||
// Clean up the temp file
|
||||
try
|
||||
{
|
||||
if (File.Exists(tempAssemblyFile))
|
||||
File.Delete(tempAssemblyFile);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Error! '{0}'", e);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
// Tell the user if there's a problem copying the file
|
||||
try
|
||||
{
|
||||
mkdirDashP(Path.GetDirectoryName(dest));
|
||||
File.Copy(source, dest, true);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
|
||||
switch (project.Files.GetBuildAction(filename))
|
||||
{
|
||||
case BuildAction.Compile:
|
||||
compiledFiles.Add(filename);
|
||||
break;
|
||||
case BuildAction.Content:
|
||||
contentFiles.Add(filename);
|
||||
extraDistFiles.Add(filename);
|
||||
break;
|
||||
case BuildAction.EmbeddedResource:
|
||||
embeddedFiles.Add(filename);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Set up references
|
||||
for (var refNum = 0; refNum < project.References.Count; refNum++)
|
||||
{
|
||||
var refr = project.References[refNum];
|
||||
var refAssembly = Assembly.Load(refr.Name);
|
||||
|
||||
/* Determine which pkg-config (.pc) file refers to
|
||||
this assembly */
|
||||
|
||||
SystemPackage package = null;
|
||||
|
||||
if (packagesHash.ContainsKey(refr.Name))
|
||||
{
|
||||
package = packagesHash[refr.Name];
|
||||
}
|
||||
else
|
||||
{
|
||||
var assemblyFullName = string.Empty;
|
||||
if (refAssembly != null)
|
||||
assemblyFullName = refAssembly.FullName;
|
||||
|
||||
var assemblyFileName = string.Empty;
|
||||
if (assemblyFullName != string.Empty &&
|
||||
assemblyFullNameToPath.ContainsKey(assemblyFullName)
|
||||
)
|
||||
assemblyFileName =
|
||||
assemblyFullNameToPath[assemblyFullName];
|
||||
|
||||
if (assemblyFileName != string.Empty &&
|
||||
assemblyPathToPackage.ContainsKey(assemblyFileName)
|
||||
)
|
||||
package = assemblyPathToPackage[assemblyFileName];
|
||||
}
|
||||
|
||||
/* If we know the .pc file and it is not "mono"
|
||||
(already in the path), add a -pkg: argument */
|
||||
|
||||
if (package != null &&
|
||||
package.Name != "mono" &&
|
||||
!pkgLibs.Contains(package.Name)
|
||||
)
|
||||
pkgLibs.Add(package.Name);
|
||||
|
||||
var fileRef =
|
||||
FindFileReference(refr.Name, (ProjectNode)refr.Parent);
|
||||
|
||||
if (refr.LocalCopy ||
|
||||
solution.ProjectsTable.ContainsKey(refr.Name) ||
|
||||
fileRef != null ||
|
||||
refr.Path != null
|
||||
)
|
||||
{
|
||||
/* Attempt to copy the referenced lib to the
|
||||
project's directory */
|
||||
|
||||
var filename = refr.Name + ".dll";
|
||||
var source = filename;
|
||||
if (refr.Path != null)
|
||||
source = Path.Combine(refr.Path, source);
|
||||
source = Path.Combine(project.FullPath, source);
|
||||
var dest = Path.Combine(projectDir, filename);
|
||||
|
||||
/* Since we depend on this binary dll to build, we
|
||||
* will add a compile- time dependency on the
|
||||
* copied dll, and add the dll to the list of
|
||||
* files distributed with this package
|
||||
*/
|
||||
|
||||
binaryLibs.Add(refr.Name + ".dll");
|
||||
extraDistFiles.Add(refr.Name + ".dll");
|
||||
|
||||
// TODO: Support copying .config.osx files
|
||||
// TODO: Support for determining native dependencies
|
||||
if (File.Exists(source + ".config"))
|
||||
{
|
||||
File.Copy(source + ".config", Path.GetDirectoryName(dest), true);
|
||||
extraDistFiles.Add(refr.Name + ".dll.config");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
File.Copy(source, dest, true);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
if (solution.ProjectsTable.ContainsKey(refr.Name))
|
||||
{
|
||||
/* If an assembly is referenced, marked for
|
||||
* local copy, in the list of projects for
|
||||
* this solution, but does not exist, put a
|
||||
* target into the Makefile.am to build the
|
||||
* assembly and copy it to this project's
|
||||
* directory
|
||||
*/
|
||||
|
||||
var sourcePrj =
|
||||
solution.ProjectsTable[refr.Name];
|
||||
|
||||
var target =
|
||||
string.Format("{0}:\n" +
|
||||
"\t$(MAKE) -C ../{1}\n" +
|
||||
"\tln ../{2}/$@ $@\n",
|
||||
filename,
|
||||
sourcePrj.Name,
|
||||
sourcePrj.Name);
|
||||
|
||||
localCopyTargets.Add(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!pkgLibs.Contains(refr.Name))
|
||||
{
|
||||
// Else, let's assume it's in the GAC or the lib path
|
||||
var assemName = string.Empty;
|
||||
var index = refr.Name.IndexOf(",");
|
||||
|
||||
if (index > 0)
|
||||
assemName = refr.Name.Substring(0, index);
|
||||
else
|
||||
assemName = refr.Name;
|
||||
|
||||
m_Kernel.Log.Write(string.Format(
|
||||
"Warning: Couldn't find an appropriate assembly " +
|
||||
"for reference:\n'{0}'", refr.Name
|
||||
));
|
||||
systemLibs.Add(assemName);
|
||||
}
|
||||
}
|
||||
|
||||
const string lineSep = " \\\n\t";
|
||||
var compiledFilesString = string.Empty;
|
||||
if (compiledFiles.Count > 0)
|
||||
compiledFilesString =
|
||||
lineSep + string.Join(lineSep, compiledFiles.ToArray());
|
||||
|
||||
var embeddedFilesString = "";
|
||||
if (embeddedFiles.Count > 0)
|
||||
embeddedFilesString =
|
||||
lineSep + string.Join(lineSep, embeddedFiles.ToArray());
|
||||
|
||||
var contentFilesString = "";
|
||||
if (contentFiles.Count > 0)
|
||||
contentFilesString =
|
||||
lineSep + string.Join(lineSep, contentFiles.ToArray());
|
||||
|
||||
var extraDistFilesString = "";
|
||||
if (extraDistFiles.Count > 0)
|
||||
extraDistFilesString =
|
||||
lineSep + string.Join(lineSep, extraDistFiles.ToArray());
|
||||
|
||||
var pkgLibsString = "";
|
||||
if (pkgLibs.Count > 0)
|
||||
pkgLibsString =
|
||||
lineSep + string.Join(lineSep, pkgLibs.ToArray());
|
||||
|
||||
var binaryLibsString = "";
|
||||
if (binaryLibs.Count > 0)
|
||||
binaryLibsString =
|
||||
lineSep + string.Join(lineSep, binaryLibs.ToArray());
|
||||
|
||||
var systemLibsString = "";
|
||||
if (systemLibs.Count > 0)
|
||||
systemLibsString =
|
||||
lineSep + string.Join(lineSep, systemLibs.ToArray());
|
||||
|
||||
var localCopyTargetsString = "";
|
||||
if (localCopyTargets.Count > 0)
|
||||
localCopyTargetsString =
|
||||
string.Join("\n", localCopyTargets.ToArray());
|
||||
|
||||
var monoPath = "";
|
||||
foreach (var runtimeLib in runtimeLibs) monoPath += ":`pkg-config --variable=libdir " + runtimeLib + "`";
|
||||
|
||||
// Add the project name to the list of transformation
|
||||
// parameters
|
||||
var argList = new XsltArgumentList();
|
||||
argList.AddParam("projectName", "", project.Name);
|
||||
argList.AddParam("solutionName", "", solution.Name);
|
||||
argList.AddParam("assemblyName", "", projectAssemblyName);
|
||||
argList.AddParam("compiledFiles", "", compiledFilesString);
|
||||
argList.AddParam("embeddedFiles", "", embeddedFilesString);
|
||||
argList.AddParam("contentFiles", "", contentFilesString);
|
||||
argList.AddParam("extraDistFiles", "", extraDistFilesString);
|
||||
argList.AddParam("pkgLibs", "", pkgLibsString);
|
||||
argList.AddParam("binaryLibs", "", binaryLibsString);
|
||||
argList.AddParam("systemLibs", "", systemLibsString);
|
||||
argList.AddParam("monoPath", "", monoPath);
|
||||
argList.AddParam("localCopyTargets", "", localCopyTargetsString);
|
||||
argList.AddParam("projectVersion", "", projectVersion);
|
||||
argList.AddParam("hasAssemblyConfig", "", hasAssemblyConfig ? "true" : "");
|
||||
|
||||
// Transform the templates
|
||||
transformToFile(Path.Combine(projectDir, "configure.ac"), argList, "/Autotools/ProjectConfigureAc");
|
||||
transformToFile(Path.Combine(projectDir, "Makefile.am"), argList, "/Autotools/ProjectMakefileAm");
|
||||
transformToFile(Path.Combine(projectDir, "autogen.sh"), argList, "/Autotools/ProjectAutogenSh");
|
||||
|
||||
if (project.Type == ProjectType.Library)
|
||||
transformToFile(Path.Combine(projectDir, project.Name + ".pc.in"), argList, "/Autotools/ProjectPcIn");
|
||||
if (project.Type == ProjectType.Exe || project.Type == ProjectType.WinExe)
|
||||
transformToFile(Path.Combine(projectDir, project.Name.ToLower() + ".in"), argList,
|
||||
"/Autotools/ProjectWrapperScriptIn");
|
||||
}
|
||||
|
||||
private void CleanProject(ProjectNode project)
|
||||
{
|
||||
m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
|
||||
var projectFile = Helper.MakeFilePath(project.FullPath, "Include", "am");
|
||||
Helper.DeleteIfExists(projectFile);
|
||||
}
|
||||
|
||||
private void CleanSolution(SolutionNode solution)
|
||||
{
|
||||
m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name);
|
||||
|
||||
var slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am");
|
||||
Helper.DeleteIfExists(slnFile);
|
||||
|
||||
slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in");
|
||||
Helper.DeleteIfExists(slnFile);
|
||||
|
||||
slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac");
|
||||
Helper.DeleteIfExists(slnFile);
|
||||
|
||||
slnFile = Helper.MakeFilePath(solution.FullPath, "configure");
|
||||
Helper.DeleteIfExists(slnFile);
|
||||
|
||||
slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile");
|
||||
Helper.DeleteIfExists(slnFile);
|
||||
|
||||
foreach (var project in solution.Projects) CleanProject(project);
|
||||
|
||||
m_Kernel.Log.Write("");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITarget Members
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public void Write(Kernel kern)
|
||||
{
|
||||
if (kern == null) throw new ArgumentNullException("kern");
|
||||
m_Kernel = kern;
|
||||
m_Kernel.Log.Write("Parsing system pkg-config files");
|
||||
RunInitialization();
|
||||
|
||||
const string streamName = "autotools.xml";
|
||||
var fqStreamName = string.Format("Prebuild.data.{0}", streamName);
|
||||
|
||||
// Retrieve stream for the autotools template XML
|
||||
var autotoolsStream = Assembly.GetExecutingAssembly()
|
||||
.GetManifestResourceStream(fqStreamName);
|
||||
|
||||
if (autotoolsStream == null)
|
||||
{
|
||||
/*
|
||||
* try without the default namespace prepended, in
|
||||
* case prebuild.exe assembly was compiled with
|
||||
* something other than Visual Studio .NET
|
||||
*/
|
||||
|
||||
autotoolsStream = Assembly.GetExecutingAssembly()
|
||||
.GetManifestResourceStream(streamName);
|
||||
if (autotoolsStream == null)
|
||||
{
|
||||
var errStr =
|
||||
string.Format("Could not find embedded resource file:\n" +
|
||||
"'{0}' or '{1}'", streamName, fqStreamName);
|
||||
|
||||
m_Kernel.Log.Write(errStr);
|
||||
|
||||
throw new TargetException(errStr);
|
||||
}
|
||||
}
|
||||
|
||||
// Create an XML URL Resolver with default credentials
|
||||
xr = new XmlUrlResolver();
|
||||
xr.Credentials = CredentialCache.DefaultCredentials;
|
||||
|
||||
// Load the autotools XML
|
||||
autotoolsDoc = new XmlDocument();
|
||||
autotoolsDoc.Load(autotoolsStream);
|
||||
|
||||
/* rootDir is the filesystem location where the Autotools
|
||||
* build tree will be created - for now we'll make it
|
||||
* $PWD/autotools
|
||||
*/
|
||||
|
||||
var pwd = Directory.GetCurrentDirectory();
|
||||
//string pwd = System.Environment.GetEnvironmentVariable("PWD");
|
||||
//if (pwd.Length != 0)
|
||||
//{
|
||||
var rootDir = Path.Combine(pwd, "autotools");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// pwd = Assembly.GetExecutingAssembly()
|
||||
//}
|
||||
chkMkDir(rootDir);
|
||||
|
||||
foreach (var solution in kern.Solutions)
|
||||
{
|
||||
m_Kernel.Log.Write(string.Format("Writing solution: {0}",
|
||||
solution.Name));
|
||||
WriteCombine(solution);
|
||||
}
|
||||
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public virtual void Clean(Kernel kern)
|
||||
{
|
||||
if (kern == null) throw new ArgumentNullException("kern");
|
||||
m_Kernel = kern;
|
||||
foreach (var sol in kern.Solutions) CleanSolution(sol);
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name => "autotools";
|
||||
|
||||
#endregion
|
||||
}
|
100
src/Core/Targets/DebugTarget.cs
Normal file
100
src/Core/Targets/DebugTarget.cs
Normal file
|
@ -0,0 +1,100 @@
|
|||
#region BSD License
|
||||
|
||||
/*
|
||||
Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
and the following disclaimer in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* The name of the author may not be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region CVS Information
|
||||
|
||||
/*
|
||||
* $Source$
|
||||
* $Author: jendave $
|
||||
* $Date: 2006-09-20 03:42:51 -0400 (Wed, 20 Sep 2006) $
|
||||
* $Revision: 164 $
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#if (DEBUG && _DEBUG_TARGET)
|
||||
namespace Prebuild.Core.Targets
|
||||
{
|
||||
[Target("debug")]
|
||||
public class DebugTarget : ITarget
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private Kernel m_Kernel = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITarget Members
|
||||
|
||||
public void Write()
|
||||
{
|
||||
foreach(SolutionNode s in m_Kernel.Solutions)
|
||||
{
|
||||
Console.WriteLine("Solution [ {0}, {1} ]", s.Name, s.Path);
|
||||
foreach(string file in s.Files)
|
||||
{
|
||||
Console.WriteLine("\tFile [ {0} ]", file);
|
||||
}
|
||||
|
||||
foreach(ProjectNode proj in s.Projects)
|
||||
{
|
||||
Console.WriteLine("\tProject [ {0}, {1}. {2} ]", proj.Name, proj.Path, proj.Language);
|
||||
foreach(string file in proj.Files)
|
||||
Console.WriteLine("\t\tFile [ {0} ]", file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Clean()
|
||||
{
|
||||
Console.WriteLine("Not implemented");
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "debug";
|
||||
}
|
||||
}
|
||||
|
||||
public Kernel Kernel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Kernel;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Kernel = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
450
src/Core/Targets/MakefileTarget.cs
Normal file
450
src/Core/Targets/MakefileTarget.cs
Normal file
|
@ -0,0 +1,450 @@
|
|||
#region BSD License
|
||||
|
||||
/*
|
||||
Copyright (c) 2004 Crestez Leonard (cleonard@go.ro)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
and the following disclaimer in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* The name of the author may not be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
using System.IO;
|
||||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Interfaces;
|
||||
using Prebuild.Core.Nodes;
|
||||
using Prebuild.Core.Utilities;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
[Target("makefile")]
|
||||
public class MakefileTarget : ITarget
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private Kernel m_Kernel;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
// This converts a path relative to the path of a project to
|
||||
// a path relative to the solution path.
|
||||
private string NicePath(ProjectNode proj, string path)
|
||||
{
|
||||
string res;
|
||||
var solution = (SolutionNode)proj.Parent;
|
||||
res = Path.Combine(Helper.NormalizePath(proj.FullPath, '/'), Helper.NormalizePath(path, '/'));
|
||||
res = Helper.NormalizePath(res, '/');
|
||||
res = res.Replace("/./", "/");
|
||||
while (res.IndexOf("/../") >= 0)
|
||||
{
|
||||
var a = res.IndexOf("/../");
|
||||
var b = res.LastIndexOf("/", a - 1);
|
||||
res = res.Remove(b, a - b + 3);
|
||||
}
|
||||
|
||||
res = Helper.MakePathRelativeTo(solution.FullPath, res);
|
||||
if (res.StartsWith("./"))
|
||||
res = res.Substring(2, res.Length - 2);
|
||||
res = Helper.NormalizePath(res, '/');
|
||||
return res;
|
||||
}
|
||||
|
||||
private void WriteProjectFiles(StreamWriter f, SolutionNode solution, ProjectNode project)
|
||||
{
|
||||
// Write list of source code files
|
||||
f.WriteLine("SOURCES_{0} = \\", project.Name);
|
||||
foreach (var file in project.Files)
|
||||
if (project.Files.GetBuildAction(file) == BuildAction.Compile)
|
||||
f.WriteLine("\t{0} \\", NicePath(project, file));
|
||||
f.WriteLine();
|
||||
|
||||
// Write list of resource files
|
||||
f.WriteLine("RESOURCES_{0} = \\", project.Name);
|
||||
foreach (var file in project.Files)
|
||||
if (project.Files.GetBuildAction(file) == BuildAction.EmbeddedResource)
|
||||
{
|
||||
var path = NicePath(project, file);
|
||||
f.WriteLine("\t-resource:{0},{1} \\", path, Path.GetFileName(path));
|
||||
}
|
||||
|
||||
f.WriteLine();
|
||||
|
||||
// There's also Content and None in BuildAction.
|
||||
// What am I supposed to do with that?
|
||||
}
|
||||
|
||||
private string FindFileReference(string refName, ProjectNode project)
|
||||
{
|
||||
foreach (var refPath in project.ReferencePaths)
|
||||
{
|
||||
var fullPath = NicePath(project, Helper.MakeFilePath(refPath.Path, refName, "dll"));
|
||||
if (File.Exists(fullPath))
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void WriteProjectReferences(StreamWriter f, SolutionNode solution, ProjectNode project)
|
||||
{
|
||||
f.WriteLine("REFERENCES_{0} = \\", project.Name);
|
||||
foreach (var refr in project.References)
|
||||
{
|
||||
string path;
|
||||
// Project references change with configurations.
|
||||
if (solution.ProjectsTable.ContainsKey(refr.Name))
|
||||
continue;
|
||||
path = FindFileReference(refr.Name, project);
|
||||
if (path != null)
|
||||
f.WriteLine("\t-r:{0} \\", path);
|
||||
else
|
||||
f.WriteLine("\t-r:{0} \\", refr.Name);
|
||||
}
|
||||
|
||||
f.WriteLine();
|
||||
}
|
||||
|
||||
private void WriteProjectDependencies(StreamWriter f, SolutionNode solution, ProjectNode project)
|
||||
{
|
||||
f.WriteLine("DEPENDENCIES_{0} = \\", project.Name);
|
||||
f.WriteLine("\t$(SOURCES_{0}) \\", project.Name);
|
||||
foreach (var file in project.Files)
|
||||
if (project.Files.GetBuildAction(file) == BuildAction.EmbeddedResource)
|
||||
f.WriteLine("\t{0} \\", NicePath(project, file));
|
||||
f.WriteLine();
|
||||
}
|
||||
|
||||
private string ProjectTypeToExtension(ProjectType t)
|
||||
{
|
||||
if (t == ProjectType.Exe || t == ProjectType.WinExe)
|
||||
return "exe";
|
||||
if (t == ProjectType.Library)
|
||||
return "dll";
|
||||
throw new FatalException("Bad ProjectType: {0}", t);
|
||||
}
|
||||
|
||||
private string ProjectTypeToTarget(ProjectType t)
|
||||
{
|
||||
if (t == ProjectType.Exe)
|
||||
return "exe";
|
||||
if (t == ProjectType.WinExe)
|
||||
return "winexe";
|
||||
if (t == ProjectType.Library)
|
||||
return "library";
|
||||
throw new FatalException("Bad ProjectType: {0}", t);
|
||||
}
|
||||
|
||||
private string ProjectOutput(ProjectNode project, ConfigurationNode config)
|
||||
{
|
||||
string filepath;
|
||||
filepath = Helper.MakeFilePath((string)config.Options["OutputPath"],
|
||||
project.AssemblyName, ProjectTypeToExtension(project.Type));
|
||||
return NicePath(project, filepath);
|
||||
}
|
||||
|
||||
// Returns true if two configs in one project have the same output.
|
||||
private bool ProjectClashes(ProjectNode project)
|
||||
{
|
||||
foreach (var conf1 in project.Configurations)
|
||||
foreach (var conf2 in project.Configurations)
|
||||
if (ProjectOutput(project, conf1) == ProjectOutput(project, conf2) && conf1 != conf2)
|
||||
{
|
||||
m_Kernel.Log.Write("Warning: Configurations {0} and {1} for project {2} output the same file",
|
||||
conf1.Name, conf2.Name, project.Name);
|
||||
m_Kernel.Log.Write("Warning: I'm going to use some timestamps(extra empty files).");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void WriteProject(StreamWriter f, SolutionNode solution, ProjectNode project)
|
||||
{
|
||||
f.WriteLine("# This is for project {0}", project.Name);
|
||||
f.WriteLine();
|
||||
|
||||
WriteProjectFiles(f, solution, project);
|
||||
WriteProjectReferences(f, solution, project);
|
||||
WriteProjectDependencies(f, solution, project);
|
||||
|
||||
var clash = ProjectClashes(project);
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
var outpath = ProjectOutput(project, conf);
|
||||
var filesToClean = outpath;
|
||||
|
||||
if (clash)
|
||||
{
|
||||
f.WriteLine("{0}-{1}: .{0}-{1}-timestamp", project.Name, conf.Name);
|
||||
f.WriteLine();
|
||||
f.Write(".{0}-{1}-timestamp: $(DEPENDENCIES_{0})", project.Name, conf.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
f.WriteLine("{0}-{1}: {2}", project.Name, conf.Name, outpath);
|
||||
f.WriteLine();
|
||||
f.Write("{2}: $(DEPENDENCIES_{0})", project.Name, conf.Name, outpath);
|
||||
}
|
||||
|
||||
// Dependencies on other projects.
|
||||
foreach (var refr in project.References)
|
||||
if (solution.ProjectsTable.ContainsKey(refr.Name))
|
||||
{
|
||||
var refProj = solution.ProjectsTable[refr.Name];
|
||||
if (ProjectClashes(refProj))
|
||||
f.Write(" .{0}-{1}-timestamp", refProj.Name, conf.Name);
|
||||
else
|
||||
f.Write(" {0}", ProjectOutput(refProj, conf));
|
||||
}
|
||||
|
||||
f.WriteLine();
|
||||
|
||||
// make directory for output.
|
||||
if (Path.GetDirectoryName(outpath) != "") f.WriteLine("\tmkdir -p {0}", Path.GetDirectoryName(outpath));
|
||||
// mcs command line.
|
||||
f.Write("\tgmcs", project.Name);
|
||||
f.Write(" -warn:{0}", conf.Options["WarningLevel"]);
|
||||
if ((bool)conf.Options["DebugInformation"])
|
||||
f.Write(" -debug");
|
||||
if ((bool)conf.Options["AllowUnsafe"])
|
||||
f.Write(" -unsafe");
|
||||
if ((bool)conf.Options["CheckUnderflowOverflow"])
|
||||
f.Write(" -checked");
|
||||
if (project.StartupObject != "")
|
||||
f.Write(" -main:{0}", project.StartupObject);
|
||||
if ((string)conf.Options["CompilerDefines"] != "")
|
||||
f.Write(" -define:\"{0}\"", conf.Options["CompilerDefines"]);
|
||||
|
||||
f.Write(" -target:{0} -out:{1}", ProjectTypeToTarget(project.Type), outpath);
|
||||
|
||||
// Build references to other projects. Now that sux.
|
||||
// We have to reference the other project in the same conf.
|
||||
foreach (var refr in project.References)
|
||||
if (solution.ProjectsTable.ContainsKey(refr.Name))
|
||||
{
|
||||
ProjectNode refProj;
|
||||
refProj = solution.ProjectsTable[refr.Name];
|
||||
f.Write(" -r:{0}", ProjectOutput(refProj, conf));
|
||||
}
|
||||
|
||||
f.Write(" $(REFERENCES_{0})", project.Name);
|
||||
f.Write(" $(RESOURCES_{0})", project.Name);
|
||||
f.Write(" $(SOURCES_{0})", project.Name);
|
||||
f.WriteLine();
|
||||
|
||||
// Copy references with localcopy.
|
||||
foreach (var refr in project.References)
|
||||
if (refr.LocalCopy)
|
||||
{
|
||||
string outPath, srcPath, destPath;
|
||||
outPath = Helper.NormalizePath((string)conf.Options["OutputPath"]);
|
||||
if (solution.ProjectsTable.ContainsKey(refr.Name))
|
||||
{
|
||||
ProjectNode refProj;
|
||||
refProj = solution.ProjectsTable[refr.Name];
|
||||
srcPath = ProjectOutput(refProj, conf);
|
||||
destPath = Path.Combine(outPath, Path.GetFileName(srcPath));
|
||||
destPath = NicePath(project, destPath);
|
||||
if (srcPath != destPath)
|
||||
{
|
||||
f.WriteLine("\tcp -f {0} {1}", srcPath, destPath);
|
||||
filesToClean += " " + destPath;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
srcPath = FindFileReference(refr.Name, project);
|
||||
if (srcPath != null)
|
||||
{
|
||||
destPath = Path.Combine(outPath, Path.GetFileName(srcPath));
|
||||
destPath = NicePath(project, destPath);
|
||||
f.WriteLine("\tcp -f {0} {1}", srcPath, destPath);
|
||||
filesToClean += " " + destPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (clash)
|
||||
{
|
||||
filesToClean += string.Format(" .{0}-{1}-timestamp", project.Name, conf.Name);
|
||||
f.WriteLine("\ttouch .{0}-{1}-timestamp", project.Name, conf.Name);
|
||||
f.Write("\trm -rf");
|
||||
foreach (var otherConf in project.Configurations)
|
||||
if (otherConf != conf)
|
||||
f.WriteLine(" .{0}-{1}-timestamp", project.Name, otherConf.Name);
|
||||
f.WriteLine();
|
||||
}
|
||||
|
||||
f.WriteLine();
|
||||
f.WriteLine("{0}-{1}-clean:", project.Name, conf.Name);
|
||||
f.WriteLine("\trm -rf {0}", filesToClean);
|
||||
f.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteIntro(StreamWriter f, SolutionNode solution)
|
||||
{
|
||||
f.WriteLine("# Makefile for {0} generated by Prebuild ( http://dnpb.sf.net )", solution.Name);
|
||||
f.WriteLine("# Do not edit.");
|
||||
f.WriteLine("#");
|
||||
|
||||
f.Write("# Configurations:");
|
||||
foreach (var conf in solution.Configurations)
|
||||
f.Write(" {0}", conf.Name);
|
||||
f.WriteLine();
|
||||
|
||||
f.WriteLine("# Projects:");
|
||||
foreach (var proj in solution.Projects)
|
||||
f.WriteLine("#\t{0}", proj.Name);
|
||||
|
||||
f.WriteLine("#");
|
||||
f.WriteLine("# Building:");
|
||||
f.WriteLine("#\t\"make\" to build everything under the default(first) configuration");
|
||||
f.WriteLine("#\t\"make CONF\" to build every project under configuration CONF");
|
||||
f.WriteLine("#\t\"make PROJ\" to build project PROJ under the default(first) configuration");
|
||||
f.WriteLine("#\t\"make PROJ-CONF\" to build project PROJ under configuration CONF");
|
||||
f.WriteLine("#");
|
||||
f.WriteLine("# Cleaning (removing results of build):");
|
||||
f.WriteLine("#\t\"make clean\" to clean everything, that's what you probably want");
|
||||
f.WriteLine("#\t\"make CONF\" to clean everything for a configuration");
|
||||
f.WriteLine("#\t\"make PROJ\" to clean everything for a project");
|
||||
f.WriteLine("#\t\"make PROJ-CONF\" to clea project PROJ under configuration CONF");
|
||||
f.WriteLine();
|
||||
}
|
||||
|
||||
private void WritePhony(StreamWriter f, SolutionNode solution)
|
||||
{
|
||||
var defconf = "";
|
||||
foreach (var conf in solution.Configurations)
|
||||
{
|
||||
defconf = conf.Name;
|
||||
break;
|
||||
}
|
||||
|
||||
f.Write(".PHONY: all");
|
||||
foreach (var proj in solution.Projects)
|
||||
f.Write(" {0} {0}-clean", proj.Name);
|
||||
foreach (var conf in solution.Configurations)
|
||||
f.Write(" {0} {0}-clean", conf.Name);
|
||||
foreach (var proj in solution.Projects)
|
||||
foreach (var conf in solution.Configurations)
|
||||
f.Write(" {0}-{1} {0}-{1}-clean", proj.Name, conf.Name);
|
||||
f.WriteLine();
|
||||
f.WriteLine();
|
||||
|
||||
f.WriteLine("all: {0}", defconf);
|
||||
f.WriteLine();
|
||||
|
||||
f.Write("clean:");
|
||||
foreach (var conf in solution.Configurations)
|
||||
f.Write(" {0}-clean", conf.Name);
|
||||
f.WriteLine();
|
||||
f.WriteLine();
|
||||
|
||||
foreach (var conf in solution.Configurations)
|
||||
{
|
||||
f.Write("{0}: ", conf.Name);
|
||||
foreach (var proj in solution.Projects)
|
||||
f.Write(" {0}-{1}", proj.Name, conf.Name);
|
||||
f.WriteLine();
|
||||
f.WriteLine();
|
||||
|
||||
f.Write("{0}-clean: ", conf.Name);
|
||||
foreach (var proj in solution.Projects)
|
||||
f.Write(" {0}-{1}-clean", proj.Name, conf.Name);
|
||||
f.WriteLine();
|
||||
f.WriteLine();
|
||||
}
|
||||
|
||||
foreach (var proj in solution.Projects)
|
||||
{
|
||||
f.WriteLine("{0}: {0}-{1}", proj.Name, defconf);
|
||||
f.WriteLine();
|
||||
|
||||
f.Write("{0}-clean:", proj.Name);
|
||||
foreach (var conf in proj.Configurations)
|
||||
f.Write(" {0}-{1}-clean", proj.Name, conf.Name);
|
||||
f.WriteLine();
|
||||
f.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteSolution(SolutionNode solution)
|
||||
{
|
||||
m_Kernel.Log.Write("Creating makefile for {0}", solution.Name);
|
||||
m_Kernel.CurrentWorkingDirectory.Push();
|
||||
|
||||
var file = "Makefile"; // Helper.MakeFilePath(solution.FullPath, solution.Name, "make");
|
||||
var f = new StreamWriter(file);
|
||||
|
||||
Helper.SetCurrentDir(Path.GetDirectoryName(file));
|
||||
|
||||
using (f)
|
||||
{
|
||||
WriteIntro(f, solution);
|
||||
WritePhony(f, solution);
|
||||
|
||||
foreach (var project in solution.Projects)
|
||||
{
|
||||
m_Kernel.Log.Write("...Creating Project: {0}", project.Name);
|
||||
WriteProject(f, solution, project);
|
||||
}
|
||||
}
|
||||
|
||||
m_Kernel.Log.Write("");
|
||||
m_Kernel.CurrentWorkingDirectory.Pop();
|
||||
}
|
||||
|
||||
private void CleanSolution(SolutionNode solution)
|
||||
{
|
||||
m_Kernel.Log.Write("Cleaning makefile for {0}", solution.Name);
|
||||
|
||||
var file = Helper.MakeFilePath(solution.FullPath, solution.Name, "make");
|
||||
Helper.DeleteIfExists(file);
|
||||
|
||||
m_Kernel.Log.Write("");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITarget Members
|
||||
|
||||
public void Write(Kernel kern)
|
||||
{
|
||||
m_Kernel = kern;
|
||||
foreach (var solution in kern.Solutions)
|
||||
WriteSolution(solution);
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
public virtual void Clean(Kernel kern)
|
||||
{
|
||||
m_Kernel = kern;
|
||||
foreach (var sol in kern.Solutions)
|
||||
CleanSolution(sol);
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
public string Name => "makefile";
|
||||
|
||||
#endregion
|
||||
}
|
463
src/Core/Targets/MonoDevelopTarget.cs
Normal file
463
src/Core/Targets/MonoDevelopTarget.cs
Normal file
|
@ -0,0 +1,463 @@
|
|||
#region BSD License
|
||||
|
||||
/*
|
||||
Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
and the following disclaimer in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* The name of the author may not be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Interfaces;
|
||||
using Prebuild.Core.Nodes;
|
||||
using Prebuild.Core.Utilities;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("monodev")]
|
||||
public class MonoDevelopTarget : ITarget
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private Kernel m_Kernel;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private static string PrependPath(string path)
|
||||
{
|
||||
var tmpPath = Helper.NormalizePath(path, '/');
|
||||
var regex = new Regex(@"(\w):/(\w+)");
|
||||
var match = regex.Match(tmpPath);
|
||||
if (match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
|
||||
tmpPath = Helper.NormalizePath(tmpPath);
|
||||
else
|
||||
tmpPath = Helper.NormalizePath("./" + tmpPath);
|
||||
|
||||
return tmpPath;
|
||||
}
|
||||
|
||||
private static string BuildReference(SolutionNode solution, ReferenceNode refr)
|
||||
{
|
||||
var ret = "<ProjectReference type=\"";
|
||||
if (solution.ProjectsTable.ContainsKey(refr.Name))
|
||||
{
|
||||
ret += "Project\"";
|
||||
ret += " localcopy=\"" + refr.LocalCopy + "\" refto=\"" + refr.Name + "\" />";
|
||||
}
|
||||
else
|
||||
{
|
||||
var project = (ProjectNode)refr.Parent;
|
||||
var fileRef = FindFileReference(refr.Name, project);
|
||||
|
||||
if (refr.Path != null || fileRef != null)
|
||||
{
|
||||
ret += "Assembly\" refto=\"";
|
||||
|
||||
var finalPath = refr.Path != null ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef;
|
||||
|
||||
ret += finalPath;
|
||||
ret += "\" localcopy=\"" + refr.LocalCopy + "\" />";
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret += "Gac\"";
|
||||
ret += " localcopy=\"" + refr.LocalCopy + "\"";
|
||||
ret += " refto=\"";
|
||||
try
|
||||
{
|
||||
/*
|
||||
Day changed to 28 Mar 2007
|
||||
...
|
||||
08:09 < cj> is there anything that replaces Assembly.LoadFromPartialName() ?
|
||||
08:09 < jonp> no
|
||||
08:10 < jonp> in their infinite wisdom [sic], microsoft decided that the
|
||||
ability to load any assembly version by-name was an inherently
|
||||
bad idea
|
||||
08:11 < cj> I'm thinking of a bunch of four-letter words right now...
|
||||
08:11 < cj> security through making it difficult for the developer!!!
|
||||
08:12 < jonp> just use the Obsolete API
|
||||
08:12 < jonp> it should still work
|
||||
08:12 < cj> alrighty.
|
||||
08:12 < jonp> you just get warnings when using it
|
||||
*/
|
||||
var assem = Assembly.Load(refr.Name);
|
||||
ret += assem.FullName;
|
||||
//ret += refr.Name;
|
||||
}
|
||||
catch (NullReferenceException e)
|
||||
{
|
||||
e.ToString();
|
||||
ret += refr.Name;
|
||||
}
|
||||
|
||||
ret += "\" />";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static string FindFileReference(string refName, ProjectNode project)
|
||||
{
|
||||
foreach (var refPath in project.ReferencePaths)
|
||||
{
|
||||
var fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
|
||||
|
||||
if (File.Exists(fullPath)) return fullPath;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the XML doc file.
|
||||
/// </summary>
|
||||
/// <param name="project">The project.</param>
|
||||
/// <param name="conf">The conf.</param>
|
||||
/// <returns></returns>
|
||||
public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf)
|
||||
{
|
||||
if (conf == null) throw new ArgumentNullException("conf");
|
||||
if (project == null) throw new ArgumentNullException("project");
|
||||
var docFile = (string)conf.Options["XmlDocFile"];
|
||||
if (docFile != null && docFile.Length == 0) //default to assembly name if not specified
|
||||
return "False";
|
||||
return "True";
|
||||
}
|
||||
|
||||
private void WriteProject(SolutionNode solution, ProjectNode project)
|
||||
{
|
||||
var csComp = "Mcs";
|
||||
var netRuntime = "Mono";
|
||||
if (project.Runtime == ClrRuntime.Microsoft)
|
||||
{
|
||||
csComp = "Csc";
|
||||
netRuntime = "MsNet";
|
||||
}
|
||||
|
||||
var projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp");
|
||||
var ss = new StreamWriter(projFile);
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Push();
|
||||
Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
|
||||
|
||||
using (ss)
|
||||
{
|
||||
ss.WriteLine(
|
||||
"<Project name=\"{0}\" description=\"\" standardNamespace=\"{1}\" newfilesearch=\"None\" enableviewstate=\"True\" fileversion=\"2.0\" language=\"C#\" clr-version=\"Net_2_0\" ctype=\"DotNetProject\">",
|
||||
project.Name,
|
||||
project.RootNamespace
|
||||
);
|
||||
|
||||
var count = 0;
|
||||
|
||||
ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig);
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"DotNetProjectConfiguration\">", conf.Name);
|
||||
ss.Write(" <Output");
|
||||
ss.Write(" directory=\"{0}\"",
|
||||
Helper.EndPath(Helper.NormalizePath(".\\" + conf.Options["OutputPath"])));
|
||||
ss.Write(" assembly=\"{0}\"", project.AssemblyName);
|
||||
ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]);
|
||||
//ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
|
||||
//ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
|
||||
if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
|
||||
ss.Write(" executeBeforeBuild=\"{0}\"",
|
||||
Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString()));
|
||||
else
|
||||
ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
|
||||
if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
|
||||
ss.Write(" executeAfterBuild=\"{0}\"",
|
||||
Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString()));
|
||||
else
|
||||
ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
|
||||
ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
|
||||
ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
|
||||
ss.WriteLine(" />");
|
||||
|
||||
ss.Write(" <Build");
|
||||
ss.Write(" debugmode=\"True\"");
|
||||
if (project.Type == ProjectType.WinExe)
|
||||
ss.Write(" target=\"{0}\"", ProjectType.Exe.ToString());
|
||||
else
|
||||
ss.Write(" target=\"{0}\"", project.Type);
|
||||
ss.WriteLine(" />");
|
||||
|
||||
ss.Write(" <Execution");
|
||||
ss.Write(" runwithwarnings=\"{0}\"", !conf.Options.WarningsAsErrors);
|
||||
ss.Write(" consolepause=\"True\"");
|
||||
ss.Write(" runtime=\"{0}\"", netRuntime);
|
||||
ss.Write(" clr-version=\"Net_2_0\"");
|
||||
ss.WriteLine(" />");
|
||||
|
||||
ss.Write(" <CodeGeneration");
|
||||
ss.Write(" compiler=\"{0}\"", csComp);
|
||||
ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]);
|
||||
ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]);
|
||||
ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]);
|
||||
ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]);
|
||||
ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]);
|
||||
ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]);
|
||||
ss.Write(" mainclass=\"{0}\"", project.StartupObject);
|
||||
ss.Write(" target=\"{0}\"", project.Type);
|
||||
ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]);
|
||||
ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf));
|
||||
ss.Write(" win32Icon=\"{0}\"", project.AppIcon);
|
||||
ss.Write(" ctype=\"CSharpCompilerParameters\"");
|
||||
ss.WriteLine(" />");
|
||||
ss.WriteLine(" </Configuration>");
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
ss.WriteLine(" </Configurations>");
|
||||
|
||||
ss.Write(" <DeploymentInformation");
|
||||
ss.Write(" target=\"\"");
|
||||
ss.Write(" script=\"\"");
|
||||
ss.Write(" strategy=\"File\"");
|
||||
ss.WriteLine(">");
|
||||
ss.WriteLine(" <excludeFiles />");
|
||||
ss.WriteLine(" </DeploymentInformation>");
|
||||
|
||||
ss.WriteLine(" <Contents>");
|
||||
foreach (var file in project.Files)
|
||||
{
|
||||
string buildAction;
|
||||
var dependson = "";
|
||||
var resource_id = "";
|
||||
var copyToOutput = "";
|
||||
|
||||
switch (project.Files.GetBuildAction(file))
|
||||
{
|
||||
case BuildAction.None:
|
||||
buildAction = "Nothing";
|
||||
break;
|
||||
|
||||
case BuildAction.Content:
|
||||
buildAction = "Exclude";
|
||||
break;
|
||||
|
||||
case BuildAction.EmbeddedResource:
|
||||
buildAction = "EmbedAsResource";
|
||||
break;
|
||||
|
||||
default:
|
||||
buildAction = "Compile";
|
||||
break;
|
||||
}
|
||||
|
||||
if (project.Files.GetCopyToOutput(file) != CopyToOutput.Never)
|
||||
buildAction = "FileCopy";
|
||||
|
||||
// Sort of a hack, we try and resolve the path and make it relative, if we can.
|
||||
var extension = Path.GetExtension(file);
|
||||
var designer_format = string.Format(".Designer{0}", extension);
|
||||
|
||||
if (file.EndsWith(designer_format))
|
||||
{
|
||||
var basename = file.Substring(0, file.LastIndexOf(designer_format));
|
||||
string[] extensions = { ".cs", ".resx", ".settings" };
|
||||
|
||||
foreach (var ext in extensions)
|
||||
if (project.Files.Contains(basename + ext))
|
||||
{
|
||||
dependson = string.Format(" dependson=\"{0}{1}\"", basename, ext);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (extension == ".resx")
|
||||
{
|
||||
buildAction = "EmbedAsResource";
|
||||
var basename = file.Substring(0, file.LastIndexOf(".resx"));
|
||||
|
||||
// Visual Studio type resx + form dependency
|
||||
if (project.Files.Contains(basename + ".cs"))
|
||||
dependson = string.Format(" dependson=\"{0}{1}\"", basename, ".cs");
|
||||
|
||||
// We need to specify a resources file name to avoid MissingManifestResourceExceptions
|
||||
// in libraries that are built.
|
||||
resource_id = string.Format(" resource_id=\"{0}.{1}.resources\"",
|
||||
project.AssemblyName, basename.Replace("/", "."));
|
||||
}
|
||||
|
||||
switch (project.Files.GetCopyToOutput(file))
|
||||
{
|
||||
case CopyToOutput.Always:
|
||||
copyToOutput = " copyToOutputDirectory=\"Always\"";
|
||||
break;
|
||||
case CopyToOutput.PreserveNewest:
|
||||
copyToOutput = " copyToOutputDirectory=\"PreserveNewest\"";
|
||||
break;
|
||||
}
|
||||
|
||||
// Sort of a hack, we try and resolve the path and make it relative, if we can.
|
||||
var filePath = PrependPath(file);
|
||||
ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\"{2}{3}{4} />",
|
||||
filePath, buildAction, dependson, resource_id, copyToOutput);
|
||||
}
|
||||
|
||||
ss.WriteLine(" </Contents>");
|
||||
|
||||
ss.WriteLine(" <References>");
|
||||
foreach (var refr in project.References) ss.WriteLine(" {0}", BuildReference(solution, refr));
|
||||
ss.WriteLine(" </References>");
|
||||
|
||||
|
||||
ss.WriteLine("</Project>");
|
||||
}
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Pop();
|
||||
}
|
||||
|
||||
private void WriteCombine(SolutionNode solution)
|
||||
{
|
||||
m_Kernel.Log.Write("Creating MonoDevelop combine and project files");
|
||||
foreach (var project in solution.Projects)
|
||||
if (m_Kernel.AllowProject(project.FilterGroups))
|
||||
{
|
||||
m_Kernel.Log.Write("...Creating project: {0}", project.Name);
|
||||
WriteProject(solution, project);
|
||||
}
|
||||
|
||||
m_Kernel.Log.Write("");
|
||||
var combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds");
|
||||
var ss = new StreamWriter(combFile);
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Push();
|
||||
Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
|
||||
|
||||
var count = 0;
|
||||
|
||||
using (ss)
|
||||
{
|
||||
ss.WriteLine("<Combine name=\"{0}\" fileversion=\"2.0\" description=\"\">", solution.Name);
|
||||
|
||||
count = 0;
|
||||
foreach (var conf in solution.Configurations)
|
||||
{
|
||||
if (count == 0) ss.WriteLine(" <Configurations active=\"{0}\">", conf.Name);
|
||||
|
||||
ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"CombineConfiguration\">", conf.Name);
|
||||
foreach (var project in solution.Projects)
|
||||
ss.WriteLine(" <Entry configuration=\"{1}\" build=\"True\" name=\"{0}\" />", project.Name,
|
||||
conf.Name);
|
||||
ss.WriteLine(" </Configuration>");
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
ss.WriteLine(" </Configurations>");
|
||||
|
||||
count = 0;
|
||||
|
||||
foreach (var project in solution.Projects)
|
||||
{
|
||||
if (count == 0)
|
||||
ss.WriteLine(" <StartMode startupentry=\"{0}\" single=\"True\">", project.Name);
|
||||
|
||||
ss.WriteLine(" <Execute type=\"None\" entry=\"{0}\" />", project.Name);
|
||||
count++;
|
||||
}
|
||||
|
||||
ss.WriteLine(" </StartMode>");
|
||||
|
||||
ss.WriteLine(" <Entries>");
|
||||
foreach (var project in solution.Projects)
|
||||
{
|
||||
var path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
|
||||
ss.WriteLine(" <Entry filename=\"{0}\" />",
|
||||
Helper.MakeFilePath(path, project.Name, "mdp"));
|
||||
}
|
||||
|
||||
ss.WriteLine(" </Entries>");
|
||||
|
||||
ss.WriteLine("</Combine>");
|
||||
}
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Pop();
|
||||
}
|
||||
|
||||
private void CleanProject(ProjectNode project)
|
||||
{
|
||||
m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
|
||||
var projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp");
|
||||
Helper.DeleteIfExists(projectFile);
|
||||
}
|
||||
|
||||
private void CleanSolution(SolutionNode solution)
|
||||
{
|
||||
m_Kernel.Log.Write("Cleaning MonoDevelop combine and project files for", solution.Name);
|
||||
|
||||
var slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds");
|
||||
Helper.DeleteIfExists(slnFile);
|
||||
|
||||
foreach (var project in solution.Projects) CleanProject(project);
|
||||
|
||||
m_Kernel.Log.Write("");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITarget Members
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public void Write(Kernel kern)
|
||||
{
|
||||
if (kern == null) throw new ArgumentNullException("kern");
|
||||
m_Kernel = kern;
|
||||
foreach (var solution in kern.Solutions) WriteCombine(solution);
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public virtual void Clean(Kernel kern)
|
||||
{
|
||||
if (kern == null) throw new ArgumentNullException("kern");
|
||||
m_Kernel = kern;
|
||||
foreach (var sol in kern.Solutions) CleanSolution(sol);
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name => "sharpdev";
|
||||
|
||||
#endregion
|
||||
}
|
715
src/Core/Targets/NAntTarget.cs
Normal file
715
src/Core/Targets/NAntTarget.cs
Normal file
|
@ -0,0 +1,715 @@
|
|||
#region BSD License
|
||||
|
||||
/*
|
||||
Copyright (c) 2004 - 2008
|
||||
Matthew Holmes (matthew@wildfiregames.com),
|
||||
Dan Moorehead (dan05a@gmail.com),
|
||||
C.J. Adams-Collier (cjac@colliertech.org),
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Interfaces;
|
||||
using Prebuild.Core.Nodes;
|
||||
using Prebuild.Core.Utilities;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("nant")]
|
||||
public class NAntTarget : ITarget
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private Kernel m_Kernel;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private static string PrependPath(string path)
|
||||
{
|
||||
var tmpPath = Helper.NormalizePath(path, '/');
|
||||
var regex = new Regex(@"(\w):/(\w+)");
|
||||
var match = regex.Match(tmpPath);
|
||||
//if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
|
||||
//{
|
||||
tmpPath = Helper.NormalizePath(tmpPath);
|
||||
//}
|
||||
// else
|
||||
// {
|
||||
// tmpPath = Helper.NormalizePath("./" + tmpPath);
|
||||
// }
|
||||
|
||||
return tmpPath;
|
||||
}
|
||||
|
||||
private static string BuildReference(SolutionNode solution, ProjectNode currentProject, ReferenceNode refr)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(refr.Path)) return refr.Path;
|
||||
|
||||
if (solution.ProjectsTable.ContainsKey(refr.Name))
|
||||
{
|
||||
var projectRef = solution.ProjectsTable[refr.Name];
|
||||
var finalPath =
|
||||
Helper.NormalizePath(refr.Name + GetProjectExtension(projectRef), '/');
|
||||
return finalPath;
|
||||
}
|
||||
|
||||
var project = (ProjectNode)refr.Parent;
|
||||
|
||||
// Do we have an explicit file reference?
|
||||
var fileRef = FindFileReference(refr.Name, project);
|
||||
if (fileRef != null) return fileRef;
|
||||
|
||||
// Is there an explicit path in the project ref?
|
||||
if (refr.Path != null)
|
||||
return Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/');
|
||||
|
||||
// No, it's an extensionless GAC ref, but nant needs the .dll extension anyway
|
||||
return refr.Name + ".dll";
|
||||
}
|
||||
|
||||
public static string GetRefFileName(string refName)
|
||||
{
|
||||
if (ExtensionSpecified(refName))
|
||||
return refName;
|
||||
return refName + ".dll";
|
||||
}
|
||||
|
||||
private static bool ExtensionSpecified(string refName)
|
||||
{
|
||||
return refName.EndsWith(".dll") || refName.EndsWith(".exe");
|
||||
}
|
||||
|
||||
private static string GetProjectExtension(ProjectNode project)
|
||||
{
|
||||
var extension = ".dll";
|
||||
if (project.Type == ProjectType.Exe || project.Type == ProjectType.WinExe) extension = ".exe";
|
||||
return extension;
|
||||
}
|
||||
|
||||
private static string FindFileReference(string refName, ProjectNode project)
|
||||
{
|
||||
foreach (var refPath in project.ReferencePaths)
|
||||
{
|
||||
var fullPath = Helper.MakeFilePath(refPath.Path, refName);
|
||||
|
||||
if (File.Exists(fullPath)) return fullPath;
|
||||
|
||||
fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
|
||||
|
||||
if (File.Exists(fullPath)) return fullPath;
|
||||
|
||||
fullPath = Helper.MakeFilePath(refPath.Path, refName, "exe");
|
||||
|
||||
if (File.Exists(fullPath)) return fullPath;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the XML doc file.
|
||||
/// </summary>
|
||||
/// <param name="project">The project.</param>
|
||||
/// <param name="conf">The conf.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
|
||||
{
|
||||
if (conf == null) throw new ArgumentNullException("conf");
|
||||
if (project == null) throw new ArgumentNullException("project");
|
||||
var docFile = (string)conf.Options["XmlDocFile"];
|
||||
// if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
|
||||
// {
|
||||
// return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
|
||||
// }
|
||||
return docFile;
|
||||
}
|
||||
|
||||
private void WriteProject(SolutionNode solution, ProjectNode project)
|
||||
{
|
||||
var projFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build");
|
||||
var ss = new StreamWriter(projFile);
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Push();
|
||||
Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
|
||||
var hasDoc = false;
|
||||
|
||||
using (ss)
|
||||
{
|
||||
ss.WriteLine("<?xml version=\"1.0\" ?>");
|
||||
ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name);
|
||||
ss.WriteLine(" <target name=\"{0}\">", "build");
|
||||
ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />");
|
||||
ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />");
|
||||
ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\" flatten=\"true\">");
|
||||
ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">");
|
||||
foreach (var refr in project.References)
|
||||
if (refr.LocalCopy)
|
||||
ss.WriteLine(" <include name=\"{0}",
|
||||
Helper.NormalizePath(
|
||||
Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)) +
|
||||
"\" />", '/'));
|
||||
|
||||
ss.WriteLine(" </fileset>");
|
||||
ss.WriteLine(" </copy>");
|
||||
if (project.ConfigFile != null && project.ConfigFile.Length != 0)
|
||||
{
|
||||
ss.Write(" <copy file=\"" + project.ConfigFile +
|
||||
"\" tofile=\"${project::get-base-directory()}/${build.dir}/${project::get-name()}");
|
||||
|
||||
if (project.Type == ProjectType.Library)
|
||||
ss.Write(".dll.config\"");
|
||||
else
|
||||
ss.Write(".exe.config\"");
|
||||
ss.WriteLine(" />");
|
||||
}
|
||||
|
||||
// Add the content files to just be copied
|
||||
ss.WriteLine(" {0}", "<copy todir=\"${project::get-base-directory()}/${build.dir}\">");
|
||||
ss.WriteLine(" {0}", "<fileset basedir=\".\">");
|
||||
|
||||
foreach (var file in project.Files)
|
||||
{
|
||||
// Ignore if we aren't content
|
||||
if (project.Files.GetBuildAction(file) != BuildAction.Content)
|
||||
continue;
|
||||
|
||||
// Create a include tag
|
||||
ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
|
||||
}
|
||||
|
||||
ss.WriteLine(" {0}", "</fileset>");
|
||||
ss.WriteLine(" {0}", "</copy>");
|
||||
|
||||
ss.Write(" <csc ");
|
||||
ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower());
|
||||
ss.Write(" debug=\"{0}\"", "${build.debug}");
|
||||
ss.Write(" platform=\"${build.platform}\"");
|
||||
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
if (conf.Options.KeyFile != "")
|
||||
{
|
||||
ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
ss.Write(" warnaserror=\"{0}\"", conf.Options.WarningsAsErrors);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]);
|
||||
break;
|
||||
}
|
||||
|
||||
ss.Write(" main=\"{0}\"", project.StartupObject);
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
if (GetXmlDocFile(project, conf) != "")
|
||||
{
|
||||
ss.Write(" doc=\"{0}\"",
|
||||
"${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
|
||||
hasDoc = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}");
|
||||
if (project.Type == ProjectType.Library)
|
||||
ss.Write(".dll\"");
|
||||
else
|
||||
ss.Write(".exe\"");
|
||||
if (project.AppIcon != null && project.AppIcon.Length != 0)
|
||||
ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/'));
|
||||
// This disables a very different behavior between VS and NAnt. With Nant,
|
||||
// If you have using System.Xml; it will ensure System.Xml.dll is referenced,
|
||||
// but not in VS. This will force the behaviors to match, so when it works
|
||||
// in nant, it will work in VS.
|
||||
ss.Write(" noconfig=\"true\"");
|
||||
ss.WriteLine(">");
|
||||
ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace);
|
||||
foreach (var file in project.Files)
|
||||
switch (project.Files.GetBuildAction(file))
|
||||
{
|
||||
case BuildAction.EmbeddedResource:
|
||||
ss.WriteLine(" {0}",
|
||||
"<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
|
||||
break;
|
||||
default:
|
||||
if (project.Files.GetSubType(file) != SubType.Code &&
|
||||
project.Files.GetSubType(file) != SubType.Settings)
|
||||
ss.WriteLine(" <include name=\"{0}\" />",
|
||||
file.Substring(0, file.LastIndexOf('.')) + ".resx");
|
||||
break;
|
||||
}
|
||||
//if (project.Files.GetSubType(file).ToString() != "Code")
|
||||
//{
|
||||
// ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
|
||||
|
||||
ss.WriteLine(" </resources>");
|
||||
ss.WriteLine(" <sources failonempty=\"true\">");
|
||||
foreach (var file in project.Files)
|
||||
switch (project.Files.GetBuildAction(file))
|
||||
{
|
||||
case BuildAction.Compile:
|
||||
ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
|
||||
break;
|
||||
}
|
||||
|
||||
ss.WriteLine(" </sources>");
|
||||
ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">");
|
||||
ss.WriteLine(" <lib>");
|
||||
ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />");
|
||||
foreach (var refPath in project.ReferencePaths)
|
||||
ss.WriteLine(" <include name=\"${project::get-base-directory()}/" +
|
||||
refPath.Path.TrimEnd('/', '\\') + "\" />");
|
||||
ss.WriteLine(" </lib>");
|
||||
foreach (var refr in project.References)
|
||||
{
|
||||
var path = Helper.NormalizePath(
|
||||
Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/');
|
||||
if (refr.Path != null)
|
||||
{
|
||||
if (ExtensionSpecified(refr.Name))
|
||||
ss.WriteLine(" <include name=\"" + path + refr.Name + "\"/>");
|
||||
else
|
||||
ss.WriteLine(" <include name=\"" + path + refr.Name + ".dll\"/>");
|
||||
}
|
||||
else
|
||||
{
|
||||
ss.WriteLine(" <include name=\"" + path + "\" />");
|
||||
}
|
||||
}
|
||||
|
||||
ss.WriteLine(" </references>");
|
||||
|
||||
ss.WriteLine(" </csc>");
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
if (!string.IsNullOrEmpty(conf.Options.OutputPath))
|
||||
{
|
||||
var targetDir = Helper.NormalizePath(conf.Options.OutputPath, '/');
|
||||
|
||||
ss.WriteLine(
|
||||
" <echo message=\"Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/" +
|
||||
targetDir + "\" />");
|
||||
|
||||
ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/" + targetDir + "\"/>");
|
||||
|
||||
ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/" + targetDir + "\">");
|
||||
ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}/${build.dir}/\" >");
|
||||
ss.WriteLine(" <include name=\"*.dll\"/>");
|
||||
ss.WriteLine(" <include name=\"*.exe\"/>");
|
||||
ss.WriteLine(" <include name=\"*.mdb\" if='${build.debug}'/>");
|
||||
ss.WriteLine(" <include name=\"*.pdb\" if='${build.debug}'/>");
|
||||
ss.WriteLine(" </fileset>");
|
||||
ss.WriteLine(" </copy>");
|
||||
break;
|
||||
}
|
||||
|
||||
ss.WriteLine(" </target>");
|
||||
|
||||
ss.WriteLine(" <target name=\"clean\">");
|
||||
ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
|
||||
ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
|
||||
ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">");
|
||||
if (hasDoc)
|
||||
{
|
||||
ss.WriteLine(" <property name=\"doc.target\" value=\"\" />");
|
||||
ss.WriteLine(" <if test=\"${platform::is-unix()}\">");
|
||||
ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />");
|
||||
ss.WriteLine(" </if>");
|
||||
ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">");
|
||||
ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">");
|
||||
ss.Write(" <include name=\"${build.dir}/${project::get-name()}");
|
||||
if (project.Type == ProjectType.Library)
|
||||
ss.WriteLine(".dll\" />");
|
||||
else
|
||||
ss.WriteLine(".exe\" />");
|
||||
|
||||
ss.WriteLine(" </assemblies>");
|
||||
ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">");
|
||||
ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>");
|
||||
ss.WriteLine(" </summaries>");
|
||||
ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">");
|
||||
ss.WriteLine(" <include name=\"${build.dir}\" />");
|
||||
// foreach(ReferenceNode refr in project.References)
|
||||
// {
|
||||
// string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/');
|
||||
// if (path != "")
|
||||
// {
|
||||
// ss.WriteLine(" <include name=\"{0}\" />", path);
|
||||
// }
|
||||
// }
|
||||
ss.WriteLine(" </referencepaths>");
|
||||
ss.WriteLine(" <documenters>");
|
||||
ss.WriteLine(" <documenter name=\"MSDN\">");
|
||||
ss.WriteLine(
|
||||
" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />");
|
||||
ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />");
|
||||
ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />");
|
||||
ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />");
|
||||
ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />");
|
||||
ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />");
|
||||
ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />");
|
||||
ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />");
|
||||
ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />");
|
||||
ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />");
|
||||
ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />");
|
||||
ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />");
|
||||
ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />");
|
||||
ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />");
|
||||
ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />");
|
||||
ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />");
|
||||
ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />");
|
||||
ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />");
|
||||
ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />");
|
||||
ss.WriteLine(" </documenter>");
|
||||
ss.WriteLine(" </documenters>");
|
||||
ss.WriteLine(" </ndoc>");
|
||||
}
|
||||
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine("</project>");
|
||||
}
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Pop();
|
||||
}
|
||||
|
||||
private void WriteCombine(SolutionNode solution)
|
||||
{
|
||||
m_Kernel.Log.Write("Creating NAnt build files");
|
||||
foreach (var project in solution.Projects)
|
||||
if (m_Kernel.AllowProject(project.FilterGroups))
|
||||
{
|
||||
m_Kernel.Log.Write("...Creating project: {0}", project.Name);
|
||||
WriteProject(solution, project);
|
||||
}
|
||||
|
||||
m_Kernel.Log.Write("");
|
||||
var combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
|
||||
var ss = new StreamWriter(combFile);
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Push();
|
||||
Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
|
||||
|
||||
using (ss)
|
||||
{
|
||||
ss.WriteLine("<?xml version=\"1.0\" ?>");
|
||||
ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name);
|
||||
ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>");
|
||||
ss.WriteLine();
|
||||
|
||||
//ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />");
|
||||
//ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />");
|
||||
ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />");
|
||||
ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />");
|
||||
ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />");
|
||||
ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />");
|
||||
|
||||
// Use the active configuration, which is the first configuration name in the prebuild file.
|
||||
var emittedConfigurations = new Dictionary<string, string>();
|
||||
|
||||
ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", solution.ActiveConfig);
|
||||
ss.WriteLine();
|
||||
|
||||
foreach (var conf in solution.Configurations)
|
||||
{
|
||||
// If the name isn't in the emitted configurations, we give a high level target to the
|
||||
// platform specific on. This lets "Debug" point to "Debug-AnyCPU".
|
||||
if (!emittedConfigurations.ContainsKey(conf.Name))
|
||||
{
|
||||
// Add it to the dictionary so we only emit one.
|
||||
emittedConfigurations.Add(conf.Name, conf.Platform);
|
||||
|
||||
// Write out the target block.
|
||||
ss.WriteLine(" <target name=\"{0}\" description=\"{0}|{1}\" depends=\"{0}-{1}\">", conf.Name,
|
||||
conf.Platform);
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
}
|
||||
|
||||
// Write out the target for the configuration.
|
||||
ss.WriteLine(" <target name=\"{0}-{1}\" description=\"{0}|{1}\">", conf.Name, conf.Platform);
|
||||
ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
|
||||
ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />",
|
||||
conf.Options["DebugInformation"].ToString().ToLower());
|
||||
ss.WriteLine("\t\t <property name=\"build.platform\" value=\"{0}\" />", conf.Platform);
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
}
|
||||
|
||||
ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">");
|
||||
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">");
|
||||
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"net-3.5\" description=\"Sets framework to .NET 3.5\">");
|
||||
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-3.5\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">");
|
||||
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">");
|
||||
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"mono-3.5\" description=\"Sets framework to mono 3.5\">");
|
||||
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-3.5\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"init\" description=\"\">");
|
||||
ss.WriteLine(" <call target=\"${project.config}\" />");
|
||||
ss.WriteLine(" <property name=\"sys.os.platform\"");
|
||||
ss.WriteLine(" value=\"${platform::get-name()}\"");
|
||||
ss.WriteLine(" />");
|
||||
ss.WriteLine(" <echo message=\"Platform ${sys.os.platform}\" />");
|
||||
ss.WriteLine(" <property name=\"build.dir\" value=\"${bin.dir}/${project.config}\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
|
||||
// sdague - ok, this is an ugly hack, but what it lets
|
||||
// us do is native include of files into the nant
|
||||
// created files from all .nant/*include files. This
|
||||
// lets us keep using prebuild, but allows for
|
||||
// extended nant targets to do build and the like.
|
||||
|
||||
try
|
||||
{
|
||||
var re = new Regex(".include$");
|
||||
var nantdir = new DirectoryInfo(".nant");
|
||||
foreach (var item in nantdir.GetFileSystemInfos())
|
||||
if (item is DirectoryInfo)
|
||||
{
|
||||
}
|
||||
else if (item is FileInfo)
|
||||
{
|
||||
if (re.Match(item.FullName) !=
|
||||
Match.Empty)
|
||||
{
|
||||
Console.WriteLine("Including file: " + item.FullName);
|
||||
|
||||
using (var fs = new FileStream(item.FullName,
|
||||
FileMode.Open,
|
||||
FileAccess.Read,
|
||||
FileShare.None))
|
||||
{
|
||||
using (var sr = new StreamReader(fs))
|
||||
{
|
||||
ss.WriteLine("<!-- included from {0} -->", item.FullName);
|
||||
while (sr.Peek() != -1) ss.WriteLine(sr.ReadLine());
|
||||
ss.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
// ss.WriteLine(" <include buildfile=\".nant/local.include\" />");
|
||||
// ss.WriteLine(" <target name=\"zip\" description=\"\">");
|
||||
// ss.WriteLine(" <zip zipfile=\"{0}-{1}.zip\">", solution.Name, solution.Version);
|
||||
// ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">");
|
||||
|
||||
// ss.WriteLine(" <include name=\"${project::get-base-directory()}/**/*.cs\" />");
|
||||
// // ss.WriteLine(" <include name=\"${project.main.dir}/**/*\" />");
|
||||
// ss.WriteLine(" </fileset>");
|
||||
// ss.WriteLine(" </zip>");
|
||||
// ss.WriteLine(" <echo message=\"Building zip target\" />");
|
||||
// ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
|
||||
ss.WriteLine(" <target name=\"clean\" description=\"\">");
|
||||
ss.WriteLine(" <echo message=\"Deleting all builds from all configurations\" />");
|
||||
//ss.WriteLine(" <delete dir=\"${dist.dir}\" failonerror=\"false\" />");
|
||||
if (solution.Cleanup != null && solution.Cleanup.CleanFiles.Count > 0)
|
||||
foreach (var cleanFile in solution.Cleanup.CleanFiles)
|
||||
{
|
||||
ss.WriteLine(" <delete failonerror=\"false\">");
|
||||
ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">");
|
||||
ss.WriteLine(" <include name=\"{0}/*\"/>", cleanFile.Pattern);
|
||||
ss.WriteLine(" <include name=\"{0}\"/>", cleanFile.Pattern);
|
||||
ss.WriteLine(" </fileset>");
|
||||
ss.WriteLine(" </delete>");
|
||||
}
|
||||
|
||||
ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
|
||||
foreach (var project in solution.Projects)
|
||||
{
|
||||
var path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
|
||||
ss.Write(" <nant buildfile=\"{0}\"",
|
||||
Helper.NormalizePath(
|
||||
Helper.MakeFilePath(path, project.Name + GetProjectExtension(project), "build"), '/'));
|
||||
ss.WriteLine(" target=\"clean\" />");
|
||||
}
|
||||
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"build\" depends=\"init\" description=\"\">");
|
||||
|
||||
foreach (var project in solution.ProjectsTableOrder)
|
||||
{
|
||||
var path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
|
||||
ss.Write(" <nant buildfile=\"{0}\"",
|
||||
Helper.NormalizePath(
|
||||
Helper.MakeFilePath(path, project.Name + GetProjectExtension(project), "build"), '/'));
|
||||
ss.WriteLine(" target=\"build\" />");
|
||||
}
|
||||
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(
|
||||
" <target name=\"build-release\" depends=\"Release, init, build\" description=\"Builds in Release mode\" />");
|
||||
ss.WriteLine();
|
||||
ss.WriteLine(
|
||||
" <target name=\"build-debug\" depends=\"Debug, init, build\" description=\"Builds in Debug mode\" />");
|
||||
ss.WriteLine();
|
||||
//ss.WriteLine(" <target name=\"package\" depends=\"clean, doc, copyfiles, zip\" description=\"Builds in Release mode\" />");
|
||||
ss.WriteLine(" <target name=\"package\" depends=\"clean, doc\" description=\"Builds all\" />");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"doc\" depends=\"build-release\">");
|
||||
ss.WriteLine(" <echo message=\"Generating all documentation from all builds\" />");
|
||||
foreach (var project in solution.Projects)
|
||||
{
|
||||
var path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
|
||||
ss.Write(" <nant buildfile=\"{0}\"",
|
||||
Helper.NormalizePath(
|
||||
Helper.MakeFilePath(path, project.Name + GetProjectExtension(project), "build"), '/'));
|
||||
ss.WriteLine(" target=\"doc\" />");
|
||||
}
|
||||
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
ss.WriteLine("</project>");
|
||||
}
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Pop();
|
||||
}
|
||||
|
||||
private void CleanProject(ProjectNode project)
|
||||
{
|
||||
m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
|
||||
var projectFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build");
|
||||
Helper.DeleteIfExists(projectFile);
|
||||
}
|
||||
|
||||
private void CleanSolution(SolutionNode solution)
|
||||
{
|
||||
m_Kernel.Log.Write("Cleaning NAnt build files for", solution.Name);
|
||||
|
||||
var slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
|
||||
Helper.DeleteIfExists(slnFile);
|
||||
|
||||
foreach (var project in solution.Projects) CleanProject(project);
|
||||
|
||||
m_Kernel.Log.Write("");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITarget Members
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public void Write(Kernel kern)
|
||||
{
|
||||
if (kern == null) throw new ArgumentNullException("kern");
|
||||
m_Kernel = kern;
|
||||
foreach (var solution in kern.Solutions) WriteCombine(solution);
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public virtual void Clean(Kernel kern)
|
||||
{
|
||||
if (kern == null) throw new ArgumentNullException("kern");
|
||||
m_Kernel = kern;
|
||||
foreach (var sol in kern.Solutions) CleanSolution(sol);
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name => "nant";
|
||||
|
||||
#endregion
|
||||
}
|
70
src/Core/Targets/SharpDevelop2Target.cs
Normal file
70
src/Core/Targets/SharpDevelop2Target.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
#region BSD License
|
||||
|
||||
/*
|
||||
Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
and the following disclaimer in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* The name of the author may not be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
using Prebuild.Core.Attributes;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("sharpdev2")]
|
||||
public class SharpDevelop2Target : VS2005Target
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public override string VersionName => "SharpDevelop2";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public override void Write(Kernel kern)
|
||||
{
|
||||
base.Write(kern);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public override void Clean(Kernel kern)
|
||||
{
|
||||
base.Clean(kern);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name => "sharpdev2";
|
||||
|
||||
#endregion
|
||||
}
|
380
src/Core/Targets/SharpDevelopTarget.cs
Normal file
380
src/Core/Targets/SharpDevelopTarget.cs
Normal file
|
@ -0,0 +1,380 @@
|
|||
#region BSD License
|
||||
|
||||
/*
|
||||
Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
and the following disclaimer in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* The name of the author may not be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Interfaces;
|
||||
using Prebuild.Core.Nodes;
|
||||
using Prebuild.Core.Utilities;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("sharpdev")]
|
||||
public class SharpDevelopTarget : ITarget
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private Kernel m_Kernel;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private static string PrependPath(string path)
|
||||
{
|
||||
var tmpPath = Helper.NormalizePath(path, '/');
|
||||
var regex = new Regex(@"(\w):/(\w+)");
|
||||
var match = regex.Match(tmpPath);
|
||||
if (match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
|
||||
tmpPath = Helper.NormalizePath(tmpPath);
|
||||
else
|
||||
tmpPath = Helper.NormalizePath("./" + tmpPath);
|
||||
|
||||
return tmpPath;
|
||||
}
|
||||
|
||||
private static string BuildReference(SolutionNode solution, ReferenceNode refr)
|
||||
{
|
||||
var ret = "<Reference type=\"";
|
||||
if (solution.ProjectsTable.ContainsKey(refr.Name))
|
||||
{
|
||||
ret += "Project\" refto=\"" + refr.Name;
|
||||
ret += "\" localcopy=\"" + refr.LocalCopy + "\" />";
|
||||
}
|
||||
else
|
||||
{
|
||||
var project = (ProjectNode)refr.Parent;
|
||||
var fileRef = FindFileReference(refr.Name, project);
|
||||
|
||||
if (refr.Path != null || fileRef != null)
|
||||
{
|
||||
ret += "Assembly\" refto=\"";
|
||||
|
||||
var finalPath = refr.Path != null ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef;
|
||||
|
||||
ret += finalPath;
|
||||
ret += "\" localcopy=\"" + refr.LocalCopy + "\" />";
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret += "Gac\" refto=\"";
|
||||
try
|
||||
{
|
||||
//Assembly assem = Assembly.Load(refr.Name);
|
||||
ret += refr.Name; // assem.FullName;
|
||||
}
|
||||
catch (NullReferenceException e)
|
||||
{
|
||||
e.ToString();
|
||||
ret += refr.Name;
|
||||
}
|
||||
|
||||
ret += "\" localcopy=\"" + refr.LocalCopy + "\" />";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static string FindFileReference(string refName, ProjectNode project)
|
||||
{
|
||||
foreach (var refPath in project.ReferencePaths)
|
||||
{
|
||||
var fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
|
||||
|
||||
if (File.Exists(fullPath)) return fullPath;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the XML doc file.
|
||||
/// </summary>
|
||||
/// <param name="project">The project.</param>
|
||||
/// <param name="conf">The conf.</param>
|
||||
/// <returns></returns>
|
||||
public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf)
|
||||
{
|
||||
if (conf == null) throw new ArgumentNullException("conf");
|
||||
if (project == null) throw new ArgumentNullException("project");
|
||||
var docFile = (string)conf.Options["XmlDocFile"];
|
||||
if (docFile != null && docFile.Length == 0) //default to assembly name if not specified
|
||||
return "False";
|
||||
return "True";
|
||||
}
|
||||
|
||||
private void WriteProject(SolutionNode solution, ProjectNode project)
|
||||
{
|
||||
var csComp = "Csc";
|
||||
var netRuntime = "MsNet";
|
||||
if (project.Runtime == ClrRuntime.Mono)
|
||||
{
|
||||
csComp = "Mcs";
|
||||
netRuntime = "Mono";
|
||||
}
|
||||
|
||||
var projFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx");
|
||||
var ss = new StreamWriter(projFile);
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Push();
|
||||
Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
|
||||
|
||||
using (ss)
|
||||
{
|
||||
ss.WriteLine(
|
||||
"<Project name=\"{0}\" standardNamespace=\"{1}\" description=\"\" newfilesearch=\"None\" enableviewstate=\"True\" version=\"1.1\" projecttype=\"C#\">",
|
||||
project.Name,
|
||||
project.RootNamespace
|
||||
);
|
||||
|
||||
ss.WriteLine(" <Contents>");
|
||||
foreach (var file in project.Files)
|
||||
{
|
||||
var buildAction = "Compile";
|
||||
switch (project.Files.GetBuildAction(file))
|
||||
{
|
||||
case BuildAction.None:
|
||||
buildAction = "Nothing";
|
||||
break;
|
||||
|
||||
case BuildAction.Content:
|
||||
buildAction = "Exclude";
|
||||
break;
|
||||
|
||||
case BuildAction.EmbeddedResource:
|
||||
buildAction = "EmbedAsResource";
|
||||
break;
|
||||
|
||||
default:
|
||||
buildAction = "Compile";
|
||||
break;
|
||||
}
|
||||
|
||||
// Sort of a hack, we try and resolve the path and make it relative, if we can.
|
||||
var filePath = PrependPath(file);
|
||||
ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />",
|
||||
filePath, buildAction);
|
||||
}
|
||||
|
||||
ss.WriteLine(" </Contents>");
|
||||
|
||||
ss.WriteLine(" <References>");
|
||||
foreach (var refr in project.References) ss.WriteLine(" {0}", BuildReference(solution, refr));
|
||||
ss.WriteLine(" </References>");
|
||||
|
||||
ss.Write(" <DeploymentInformation");
|
||||
ss.Write(" target=\"\"");
|
||||
ss.Write(" script=\"\"");
|
||||
ss.Write(" strategy=\"File\"");
|
||||
ss.WriteLine(" />");
|
||||
|
||||
var count = 0;
|
||||
|
||||
ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig);
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
ss.Write(" <Configuration");
|
||||
ss.Write(" runwithwarnings=\"True\"");
|
||||
ss.Write(" name=\"{0}\"", conf.Name);
|
||||
ss.WriteLine(">");
|
||||
ss.Write(" <CodeGeneration");
|
||||
ss.Write(" runtime=\"{0}\"", netRuntime);
|
||||
ss.Write(" compiler=\"{0}\"", csComp);
|
||||
ss.Write(" compilerversion=\"\"");
|
||||
ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]);
|
||||
ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]);
|
||||
ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]);
|
||||
ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]);
|
||||
ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]);
|
||||
ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]);
|
||||
ss.Write(" mainclass=\"{0}\"", project.StartupObject);
|
||||
ss.Write(" target=\"{0}\"", project.Type);
|
||||
ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]);
|
||||
ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf));
|
||||
ss.Write(" win32Icon=\"{0}\"", Helper.NormalizePath(".\\" + project.AppIcon));
|
||||
ss.Write(" noconfig=\"{0}\"", "False");
|
||||
ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]);
|
||||
ss.WriteLine(" />");
|
||||
|
||||
ss.Write(" <Execution");
|
||||
ss.Write(" commandlineparameters=\"\"");
|
||||
ss.Write(" consolepause=\"True\"");
|
||||
ss.WriteLine(" />");
|
||||
|
||||
ss.Write(" <Output");
|
||||
ss.Write(" directory=\".\\{0}\"", Helper.NormalizePath(conf.Options["OutputPath"].ToString()));
|
||||
ss.Write(" assembly=\"{0}\"", project.AssemblyName);
|
||||
ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]);
|
||||
if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
|
||||
ss.Write(" executeBeforeBuild=\"{0}\"",
|
||||
Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString()));
|
||||
else
|
||||
ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
|
||||
if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
|
||||
ss.Write(" executeAfterBuild=\"{0}\"",
|
||||
Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString()));
|
||||
else
|
||||
ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
|
||||
ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
|
||||
ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
|
||||
ss.WriteLine(" />");
|
||||
ss.WriteLine(" </Configuration>");
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
ss.WriteLine(" </Configurations>");
|
||||
ss.WriteLine("</Project>");
|
||||
}
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Pop();
|
||||
}
|
||||
|
||||
private void WriteCombine(SolutionNode solution)
|
||||
{
|
||||
m_Kernel.Log.Write("Creating SharpDevelop combine and project files");
|
||||
foreach (var project in solution.Projects)
|
||||
if (m_Kernel.AllowProject(project.FilterGroups))
|
||||
{
|
||||
m_Kernel.Log.Write("...Creating project: {0}", project.Name);
|
||||
WriteProject(solution, project);
|
||||
}
|
||||
|
||||
m_Kernel.Log.Write("");
|
||||
var combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx");
|
||||
var ss = new StreamWriter(combFile);
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Push();
|
||||
Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
|
||||
|
||||
using (ss)
|
||||
{
|
||||
ss.WriteLine("<Combine fileversion=\"1.0\" name=\"{0}\" description=\"\">", solution.Name);
|
||||
|
||||
var count = 0;
|
||||
foreach (var project in solution.Projects)
|
||||
{
|
||||
if (count == 0)
|
||||
ss.WriteLine(" <StartMode startupentry=\"{0}\" single=\"True\">", project.Name);
|
||||
|
||||
ss.WriteLine(" <Execute entry=\"{0}\" type=\"None\" />", project.Name);
|
||||
count++;
|
||||
}
|
||||
|
||||
ss.WriteLine(" </StartMode>");
|
||||
|
||||
ss.WriteLine(" <Entries>");
|
||||
foreach (var project in solution.Projects)
|
||||
{
|
||||
var path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
|
||||
ss.WriteLine(" <Entry filename=\"{0}\" />",
|
||||
Helper.MakeFilePath(path, project.Name, "prjx"));
|
||||
}
|
||||
|
||||
ss.WriteLine(" </Entries>");
|
||||
|
||||
count = 0;
|
||||
foreach (var conf in solution.Configurations)
|
||||
{
|
||||
if (count == 0) ss.WriteLine(" <Configurations active=\"{0}\">", conf.Name);
|
||||
|
||||
ss.WriteLine(" <Configuration name=\"{0}\">", conf.Name);
|
||||
foreach (var project in solution.Projects)
|
||||
ss.WriteLine(" <Entry name=\"{0}\" configurationname=\"{1}\" build=\"True\" />", project.Name,
|
||||
conf.Name);
|
||||
ss.WriteLine(" </Configuration>");
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
ss.WriteLine(" </Configurations>");
|
||||
ss.WriteLine("</Combine>");
|
||||
}
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Pop();
|
||||
}
|
||||
|
||||
private void CleanProject(ProjectNode project)
|
||||
{
|
||||
m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
|
||||
var projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx");
|
||||
Helper.DeleteIfExists(projectFile);
|
||||
}
|
||||
|
||||
private void CleanSolution(SolutionNode solution)
|
||||
{
|
||||
m_Kernel.Log.Write("Cleaning SharpDevelop combine and project files for", solution.Name);
|
||||
|
||||
var slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx");
|
||||
Helper.DeleteIfExists(slnFile);
|
||||
|
||||
foreach (var project in solution.Projects) CleanProject(project);
|
||||
|
||||
m_Kernel.Log.Write("");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITarget Members
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public void Write(Kernel kern)
|
||||
{
|
||||
if (kern == null) throw new ArgumentNullException("kern");
|
||||
m_Kernel = kern;
|
||||
foreach (var solution in kern.Solutions) WriteCombine(solution);
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public virtual void Clean(Kernel kern)
|
||||
{
|
||||
if (kern == null) throw new ArgumentNullException("kern");
|
||||
m_Kernel = kern;
|
||||
foreach (var sol in kern.Solutions) CleanSolution(sol);
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name => "sharpdev";
|
||||
|
||||
#endregion
|
||||
}
|
137
src/Core/Targets/ToolInfo.cs
Normal file
137
src/Core/Targets/ToolInfo.cs
Normal file
|
@ -0,0 +1,137 @@
|
|||
using System;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public struct ToolInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the GUID.
|
||||
/// </summary>
|
||||
/// <value>The GUID.</value>
|
||||
public string Guid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the file extension.
|
||||
/// </summary>
|
||||
/// <value>The file extension.</value>
|
||||
public string FileExtension { get; set; }
|
||||
|
||||
public string LanguageExtension
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Name)
|
||||
{
|
||||
case "C#":
|
||||
return ".cs";
|
||||
case "VisualBasic":
|
||||
return ".vb";
|
||||
case "Boo":
|
||||
return ".boo";
|
||||
default:
|
||||
return ".cs";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the XML tag.
|
||||
/// </summary>
|
||||
/// <value>The XML tag.</value>
|
||||
public string XmlTag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the import project property.
|
||||
/// </summary>
|
||||
/// <value>The ImportProject tag.</value>
|
||||
public string ImportProject { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ToolInfo" /> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="guid">The GUID.</param>
|
||||
/// <param name="fileExtension">The file extension.</param>
|
||||
/// <param name="xml">The XML.</param>
|
||||
/// <param name="importProject">The import project.</param>
|
||||
public ToolInfo(string name, string guid, string fileExtension, string xml, string importProject)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Guid = guid;
|
||||
this.FileExtension = fileExtension;
|
||||
XmlTag = xml;
|
||||
this.ImportProject = importProject;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ToolInfo" /> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="guid">The GUID.</param>
|
||||
/// <param name="fileExtension">The file extension.</param>
|
||||
/// <param name="xml">The XML.</param>
|
||||
public ToolInfo(string name, string guid, string fileExtension, string xml)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Guid = guid;
|
||||
this.FileExtension = fileExtension;
|
||||
XmlTag = xml;
|
||||
ImportProject = "$(MSBuildBinPath)\\Microsoft." + xml + ".Targets";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equals operator
|
||||
/// </summary>
|
||||
/// <param name="obj">ToolInfo to compare</param>
|
||||
/// <returns>true if toolInfos are equal</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null) throw new ArgumentNullException("obj");
|
||||
if (obj.GetType() != typeof(ToolInfo))
|
||||
return false;
|
||||
|
||||
var c = (ToolInfo)obj;
|
||||
return Name == c.Name && Guid == c.Guid && FileExtension == c.FileExtension && ImportProject == c.ImportProject;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equals operator
|
||||
/// </summary>
|
||||
/// <param name="c1">ToolInfo to compare</param>
|
||||
/// <param name="c2">ToolInfo to compare</param>
|
||||
/// <returns>True if toolInfos are equal</returns>
|
||||
public static bool operator ==(ToolInfo c1, ToolInfo c2)
|
||||
{
|
||||
return c1.Name == c2.Name && c1.Guid == c2.Guid && c1.FileExtension == c2.FileExtension &&
|
||||
c1.ImportProject == c2.ImportProject && c1.XmlTag == c2.XmlTag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Not equals operator
|
||||
/// </summary>
|
||||
/// <param name="c1">ToolInfo to compare</param>
|
||||
/// <param name="c2">ToolInfo to compare</param>
|
||||
/// <returns>True if toolInfos are not equal</returns>
|
||||
public static bool operator !=(ToolInfo c1, ToolInfo c2)
|
||||
{
|
||||
return !(c1 == c2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hash Code
|
||||
/// </summary>
|
||||
/// <returns>Hash code</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Name.GetHashCode() ^ Guid.GetHashCode() ^ FileExtension.GetHashCode() ^ ImportProject.GetHashCode() ^
|
||||
XmlTag.GetHashCode();
|
||||
}
|
||||
}
|
79
src/Core/Targets/VS2002Target.cs
Normal file
79
src/Core/Targets/VS2002Target.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
#region BSD License
|
||||
|
||||
/*
|
||||
Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
and the following disclaimer in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* The name of the author may not be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
using Prebuild.Core.Attributes;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("vs2002")]
|
||||
public class VS2002Target : VS2003Target
|
||||
{
|
||||
#region Private Methods
|
||||
|
||||
private void SetVS2002()
|
||||
{
|
||||
SolutionVersion = "7.00";
|
||||
ProductVersion = "7.0.9254";
|
||||
SchemaVersion = "1.0";
|
||||
VersionName = "2002";
|
||||
Version = VSVersion.VS70;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public override void Write(Kernel kern)
|
||||
{
|
||||
SetVS2002();
|
||||
base.Write(kern);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public override void Clean(Kernel kern)
|
||||
{
|
||||
SetVS2002();
|
||||
base.Clean(kern);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name => "vs2002";
|
||||
|
||||
#endregion
|
||||
}
|
485
src/Core/Targets/VS2003Target.cs
Normal file
485
src/Core/Targets/VS2003Target.cs
Normal file
|
@ -0,0 +1,485 @@
|
|||
#region BSD License
|
||||
|
||||
/*
|
||||
Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
and the following disclaimer in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* The name of the author may not be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Interfaces;
|
||||
using Prebuild.Core.Nodes;
|
||||
using Prebuild.Core.Utilities;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
[Target("vs2003")]
|
||||
public class VS2003Target : ITarget
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VS2003Target" /> class.
|
||||
/// </summary>
|
||||
public VS2003Target()
|
||||
{
|
||||
m_Tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP");
|
||||
m_Tools["VB.NET"] = new ToolInfo("VB.NET", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
private readonly Dictionary<string, ToolInfo> m_Tools = new();
|
||||
private Kernel m_Kernel;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the solution version.
|
||||
/// </summary>
|
||||
/// <value>The solution version.</value>
|
||||
protected string SolutionVersion { get; set; } = "8.00";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the product version.
|
||||
/// </summary>
|
||||
/// <value>The product version.</value>
|
||||
protected string ProductVersion { get; set; } = "7.10.3077";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the schema version.
|
||||
/// </summary>
|
||||
/// <value>The schema version.</value>
|
||||
protected string SchemaVersion { get; set; } = "2.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the version.
|
||||
/// </summary>
|
||||
/// <value>The name of the version.</value>
|
||||
protected string VersionName { get; set; } = "2003";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
/// <value>The version.</value>
|
||||
protected VSVersion Version { get; set; } = VSVersion.VS71;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private string MakeRefPath(ProjectNode project)
|
||||
{
|
||||
var ret = "";
|
||||
foreach (var node in project.ReferencePaths)
|
||||
try
|
||||
{
|
||||
var fullPath = Helper.ResolvePath(node.Path);
|
||||
if (ret.Length < 1)
|
||||
ret = fullPath;
|
||||
else
|
||||
ret += ";" + fullPath;
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
m_Kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void WriteProject(SolutionNode solution, ProjectNode project)
|
||||
{
|
||||
if (!m_Tools.ContainsKey(project.Language))
|
||||
throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
|
||||
|
||||
var toolInfo = m_Tools[project.Language];
|
||||
var projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
|
||||
var ps = new StreamWriter(projectFile);
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Push();
|
||||
Helper.SetCurrentDir(Path.GetDirectoryName(projectFile));
|
||||
|
||||
using (ps)
|
||||
{
|
||||
ps.WriteLine("<VisualStudioProject>");
|
||||
ps.WriteLine(" <{0}", toolInfo.XmlTag);
|
||||
ps.WriteLine("\t\t\t\tProjectType = \"Local\"");
|
||||
ps.WriteLine("\t\t\t\tProductVersion = \"{0}\"", ProductVersion);
|
||||
ps.WriteLine("\t\t\t\tSchemaVersion = \"{0}\"", SchemaVersion);
|
||||
ps.WriteLine("\t\t\t\tProjectGuid = \"{{{0}}}\"", project.Guid.ToString().ToUpper());
|
||||
ps.WriteLine("\t\t>");
|
||||
|
||||
ps.WriteLine("\t\t\t\t<Build>");
|
||||
ps.WriteLine(" <Settings");
|
||||
ps.WriteLine("\t\t\t\t ApplicationIcon = \"{0}\"", project.AppIcon);
|
||||
ps.WriteLine("\t\t\t\t AssemblyKeyContainerName = \"\"");
|
||||
ps.WriteLine("\t\t\t\t AssemblyName = \"{0}\"", project.AssemblyName);
|
||||
ps.WriteLine("\t\t\t\t AssemblyOriginatorKeyFile = \"\"");
|
||||
ps.WriteLine("\t\t\t\t DefaultClientScript = \"JScript\"");
|
||||
ps.WriteLine("\t\t\t\t DefaultHTMLPageLayout = \"Grid\"");
|
||||
ps.WriteLine("\t\t\t\t DefaultTargetSchema = \"IE50\"");
|
||||
ps.WriteLine("\t\t\t\t DelaySign = \"false\"");
|
||||
|
||||
if (Version == VSVersion.VS70) ps.WriteLine("\t\t\t\t NoStandardLibraries = \"false\"");
|
||||
|
||||
ps.WriteLine("\t\t\t\t OutputType = \"{0}\"", project.Type);
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
|
||||
ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"",
|
||||
Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString()));
|
||||
else
|
||||
ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", conf.Options["PreBuildEvent"]);
|
||||
if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
|
||||
ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"",
|
||||
Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString()));
|
||||
else
|
||||
ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", conf.Options["PostBuildEvent"]);
|
||||
if (conf.Options["RunPostBuildEvent"] == null)
|
||||
ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", "OnBuildSuccess");
|
||||
else
|
||||
ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", conf.Options["RunPostBuildEvent"]);
|
||||
break;
|
||||
}
|
||||
|
||||
ps.WriteLine("\t\t\t\t RootNamespace = \"{0}\"", project.RootNamespace);
|
||||
ps.WriteLine("\t\t\t\t StartupObject = \"{0}\"", project.StartupObject);
|
||||
ps.WriteLine("\t\t >");
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
ps.WriteLine("\t\t\t\t <Config");
|
||||
ps.WriteLine("\t\t\t\t Name = \"{0}\"", conf.Name);
|
||||
ps.WriteLine("\t\t\t\t AllowUnsafeBlocks = \"{0}\"",
|
||||
conf.Options["AllowUnsafe"].ToString().ToLower());
|
||||
ps.WriteLine("\t\t\t\t BaseAddress = \"{0}\"", conf.Options["BaseAddress"]);
|
||||
ps.WriteLine("\t\t\t\t CheckForOverflowUnderflow = \"{0}\"",
|
||||
conf.Options["CheckUnderflowOverflow"].ToString().ToLower());
|
||||
ps.WriteLine("\t\t\t\t ConfigurationOverrideFile = \"\"");
|
||||
ps.WriteLine("\t\t\t\t DefineConstants = \"{0}\"", conf.Options["CompilerDefines"]);
|
||||
ps.WriteLine("\t\t\t\t DocumentationFile = \"{0}\"",
|
||||
GetXmlDocFile(project, conf)); //default to the assembly name
|
||||
ps.WriteLine("\t\t\t\t DebugSymbols = \"{0}\"",
|
||||
conf.Options["DebugInformation"].ToString().ToLower());
|
||||
ps.WriteLine("\t\t\t\t FileAlignment = \"{0}\"", conf.Options["FileAlignment"]);
|
||||
ps.WriteLine("\t\t\t\t IncrementalBuild = \"{0}\"",
|
||||
conf.Options["IncrementalBuild"].ToString().ToLower());
|
||||
|
||||
if (Version == VSVersion.VS71)
|
||||
{
|
||||
ps.WriteLine("\t\t\t\t NoStdLib = \"{0}\"", conf.Options["NoStdLib"].ToString().ToLower());
|
||||
ps.WriteLine("\t\t\t\t NoWarn = \"{0}\"",
|
||||
conf.Options["SuppressWarnings"].ToString().ToLower());
|
||||
}
|
||||
|
||||
ps.WriteLine("\t\t\t\t Optimize = \"{0}\"", conf.Options["OptimizeCode"].ToString().ToLower());
|
||||
ps.WriteLine(" OutputPath = \"{0}\"",
|
||||
Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString())));
|
||||
ps.WriteLine(" RegisterForComInterop = \"{0}\"",
|
||||
conf.Options["RegisterComInterop"].ToString().ToLower());
|
||||
ps.WriteLine(" RemoveIntegerChecks = \"{0}\"",
|
||||
conf.Options["RemoveIntegerChecks"].ToString().ToLower());
|
||||
ps.WriteLine(" TreatWarningsAsErrors = \"{0}\"",
|
||||
conf.Options["WarningsAsErrors"].ToString().ToLower());
|
||||
ps.WriteLine(" WarningLevel = \"{0}\"", conf.Options["WarningLevel"]);
|
||||
ps.WriteLine(" />");
|
||||
}
|
||||
|
||||
ps.WriteLine(" </Settings>");
|
||||
|
||||
ps.WriteLine(" <References>");
|
||||
foreach (var refr in project.References)
|
||||
{
|
||||
ps.WriteLine(" <Reference");
|
||||
ps.WriteLine(" Name = \"{0}\"", refr.Name);
|
||||
ps.WriteLine(" AssemblyName = \"{0}\"", refr.Name);
|
||||
|
||||
if (solution.ProjectsTable.ContainsKey(refr.Name))
|
||||
{
|
||||
var refProject = solution.ProjectsTable[refr.Name];
|
||||
ps.WriteLine(" Project = \"{{{0}}}\"", refProject.Guid.ToString().ToUpper());
|
||||
ps.WriteLine(" Package = \"{0}\"", toolInfo.Guid.ToUpper());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (refr.Path != null)
|
||||
ps.WriteLine(" HintPath = \"{0}\"",
|
||||
Helper.MakeFilePath(refr.Path, refr.Name, "dll"));
|
||||
}
|
||||
|
||||
if (refr.LocalCopySpecified) ps.WriteLine(" Private = \"{0}\"", refr.LocalCopy);
|
||||
|
||||
ps.WriteLine(" />");
|
||||
}
|
||||
|
||||
ps.WriteLine(" </References>");
|
||||
|
||||
ps.WriteLine(" </Build>");
|
||||
ps.WriteLine(" <Files>");
|
||||
|
||||
ps.WriteLine(" <Include>");
|
||||
|
||||
foreach (var file in project.Files)
|
||||
{
|
||||
var fileName = file.Replace(".\\", "");
|
||||
ps.WriteLine(" <File");
|
||||
ps.WriteLine(" RelPath = \"{0}\"", fileName);
|
||||
ps.WriteLine(" SubType = \"{0}\"", project.Files.GetSubType(file));
|
||||
ps.WriteLine(" BuildAction = \"{0}\"", project.Files.GetBuildAction(file));
|
||||
ps.WriteLine(" />");
|
||||
|
||||
if (project.Files.GetSubType(file) != SubType.Code &&
|
||||
project.Files.GetSubType(file) != SubType.Settings)
|
||||
{
|
||||
ps.WriteLine(" <File");
|
||||
ps.WriteLine(" RelPath = \"{0}\"",
|
||||
fileName.Substring(0, fileName.LastIndexOf('.')) + ".resx");
|
||||
var slash = fileName.LastIndexOf('\\');
|
||||
if (slash == -1)
|
||||
ps.WriteLine(" DependentUpon = \"{0}\"", fileName);
|
||||
else
|
||||
ps.WriteLine(" DependentUpon = \"{0}\"",
|
||||
fileName.Substring(slash + 1, fileName.Length - slash - 1));
|
||||
ps.WriteLine(" BuildAction = \"{0}\"", "EmbeddedResource");
|
||||
ps.WriteLine(" />");
|
||||
}
|
||||
}
|
||||
|
||||
ps.WriteLine(" </Include>");
|
||||
|
||||
ps.WriteLine(" </Files>");
|
||||
ps.WriteLine(" </{0}>", toolInfo.XmlTag);
|
||||
ps.WriteLine("</VisualStudioProject>");
|
||||
}
|
||||
|
||||
ps = new StreamWriter(projectFile + ".user");
|
||||
using (ps)
|
||||
{
|
||||
ps.WriteLine("<VisualStudioProject>");
|
||||
ps.WriteLine(" <{0}>", toolInfo.XmlTag);
|
||||
ps.WriteLine(" <Build>");
|
||||
|
||||
ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project));
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
ps.WriteLine(" <Config");
|
||||
ps.WriteLine(" Name = \"{0}\"", conf.Name);
|
||||
ps.WriteLine(" />");
|
||||
}
|
||||
|
||||
ps.WriteLine(" </Settings>");
|
||||
|
||||
ps.WriteLine(" </Build>");
|
||||
ps.WriteLine(" </{0}>", toolInfo.XmlTag);
|
||||
ps.WriteLine("</VisualStudioProject>");
|
||||
}
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Pop();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the XML doc file.
|
||||
/// </summary>
|
||||
/// <param name="project">The project.</param>
|
||||
/// <param name="conf">The conf.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
|
||||
{
|
||||
if (conf == null) throw new ArgumentNullException("conf");
|
||||
if (project == null) throw new ArgumentNullException("project");
|
||||
// if(!(bool)conf.Options["GenerateXmlDocFile"]) //default to none, if the generate option is false
|
||||
// {
|
||||
// return string.Empty;
|
||||
// }
|
||||
|
||||
//default to "AssemblyName.xml"
|
||||
//string defaultValue = Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
|
||||
//return (string)conf.Options["XmlDocFile", defaultValue];
|
||||
|
||||
//default to no XmlDocFile file
|
||||
return (string)conf.Options["XmlDocFile", ""];
|
||||
}
|
||||
|
||||
private void WriteSolution(SolutionNode solution)
|
||||
{
|
||||
m_Kernel.Log.Write("Creating Visual Studio {0} solution and project files", VersionName);
|
||||
|
||||
foreach (var project in solution.Projects)
|
||||
if (m_Kernel.AllowProject(project.FilterGroups))
|
||||
{
|
||||
m_Kernel.Log.Write("...Creating project: {0}", project.Name);
|
||||
WriteProject(solution, project);
|
||||
}
|
||||
|
||||
m_Kernel.Log.Write("");
|
||||
var solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
|
||||
var ss = new StreamWriter(solutionFile);
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Push();
|
||||
Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile));
|
||||
|
||||
using (ss)
|
||||
{
|
||||
ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", SolutionVersion);
|
||||
foreach (var project in solution.Projects)
|
||||
{
|
||||
if (!m_Tools.ContainsKey(project.Language))
|
||||
throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
|
||||
|
||||
var toolInfo = m_Tools[project.Language];
|
||||
|
||||
var path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
|
||||
ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"",
|
||||
toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name,
|
||||
toolInfo.FileExtension), project.Guid.ToString().ToUpper());
|
||||
|
||||
ss.WriteLine("\tProjectSection(ProjectDependencies) = postProject");
|
||||
ss.WriteLine("\tEndProjectSection");
|
||||
|
||||
ss.WriteLine("EndProject");
|
||||
}
|
||||
|
||||
ss.WriteLine("Global");
|
||||
|
||||
ss.WriteLine("\tGlobalSection(SolutionConfiguration) = preSolution");
|
||||
foreach (var conf in solution.Configurations) ss.WriteLine("\t\t{0} = {0}", conf.Name);
|
||||
ss.WriteLine("\tEndGlobalSection");
|
||||
|
||||
ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution");
|
||||
foreach (var project in solution.Projects)
|
||||
for (var i = 0; i < project.References.Count; i++)
|
||||
{
|
||||
var refr = project.References[i];
|
||||
if (solution.ProjectsTable.ContainsKey(refr.Name))
|
||||
{
|
||||
var refProject = solution.ProjectsTable[refr.Name];
|
||||
ss.WriteLine("\t\t({{{0}}}).{1} = ({{{2}}})",
|
||||
project.Guid.ToString().ToUpper()
|
||||
, i,
|
||||
refProject.Guid.ToString().ToUpper()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ss.WriteLine("\tEndGlobalSection");
|
||||
|
||||
ss.WriteLine("\tGlobalSection(ProjectConfiguration) = postSolution");
|
||||
foreach (var project in solution.Projects)
|
||||
foreach (var conf in solution.Configurations)
|
||||
{
|
||||
ss.WriteLine("\t\t{{{0}}}.{1}.ActiveCfg = {1}|.NET",
|
||||
project.Guid.ToString().ToUpper(),
|
||||
conf.Name);
|
||||
|
||||
ss.WriteLine("\t\t{{{0}}}.{1}.Build.0 = {1}|.NET",
|
||||
project.Guid.ToString().ToUpper(),
|
||||
conf.Name);
|
||||
}
|
||||
|
||||
ss.WriteLine("\tEndGlobalSection");
|
||||
|
||||
if (solution.Files != null)
|
||||
{
|
||||
ss.WriteLine("\tGlobalSection(SolutionItems) = postSolution");
|
||||
foreach (var file in solution.Files) ss.WriteLine("\t\t{0} = {0}", file);
|
||||
ss.WriteLine("\tEndGlobalSection");
|
||||
}
|
||||
|
||||
ss.WriteLine("\tGlobalSection(ExtensibilityGlobals) = postSolution");
|
||||
ss.WriteLine("\tEndGlobalSection");
|
||||
ss.WriteLine("\tGlobalSection(ExtensibilityAddIns) = postSolution");
|
||||
ss.WriteLine("\tEndGlobalSection");
|
||||
|
||||
ss.WriteLine("EndGlobal");
|
||||
}
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Pop();
|
||||
}
|
||||
|
||||
private void CleanProject(ProjectNode project)
|
||||
{
|
||||
m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
|
||||
|
||||
var toolInfo = m_Tools[project.Language];
|
||||
var projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
|
||||
var userFile = projectFile + ".user";
|
||||
|
||||
Helper.DeleteIfExists(projectFile);
|
||||
Helper.DeleteIfExists(userFile);
|
||||
}
|
||||
|
||||
private void CleanSolution(SolutionNode solution)
|
||||
{
|
||||
m_Kernel.Log.Write("Cleaning Visual Studio {0} solution and project files", VersionName, solution.Name);
|
||||
|
||||
var slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
|
||||
var suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo");
|
||||
|
||||
Helper.DeleteIfExists(slnFile);
|
||||
Helper.DeleteIfExists(suoFile);
|
||||
|
||||
foreach (var project in solution.Projects) CleanProject(project);
|
||||
|
||||
m_Kernel.Log.Write("");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITarget Members
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public virtual void Write(Kernel kern)
|
||||
{
|
||||
if (kern == null) throw new ArgumentNullException("kern");
|
||||
m_Kernel = kern;
|
||||
foreach (var sol in m_Kernel.Solutions) WriteSolution(sol);
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public virtual void Clean(Kernel kern)
|
||||
{
|
||||
if (kern == null) throw new ArgumentNullException("kern");
|
||||
m_Kernel = kern;
|
||||
foreach (var sol in m_Kernel.Solutions) CleanSolution(sol);
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public virtual string Name => "vs2003";
|
||||
|
||||
#endregion
|
||||
}
|
99
src/Core/Targets/VS2005Target.cs
Normal file
99
src/Core/Targets/VS2005Target.cs
Normal file
|
@ -0,0 +1,99 @@
|
|||
#region BSD License
|
||||
|
||||
/*
|
||||
Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
and the following disclaimer in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* The name of the author may not be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Nodes;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("vs2005")]
|
||||
public class VS2005Target : VSGenericTarget
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VS2005Target" /> class.
|
||||
/// </summary>
|
||||
public VS2005Target()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Inner Classes
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
public override string SolutionTag => "# Visual Studio 2005";
|
||||
|
||||
protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the solution version.
|
||||
/// </summary>
|
||||
/// <value>The solution version.</value>
|
||||
public override string SolutionVersion { get; } = "9.00";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the product version.
|
||||
/// </summary>
|
||||
/// <value>The product version.</value>
|
||||
public override string ProductVersion { get; } = "8.0.50727";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the schema version.
|
||||
/// </summary>
|
||||
/// <value>The schema version.</value>
|
||||
public override string SchemaVersion { get; } = "2.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the version.
|
||||
/// </summary>
|
||||
/// <value>The name of the version.</value>
|
||||
public override string VersionName { get; } = "Visual C# 2005";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
/// <value>The version.</value>
|
||||
public override VSVersion Version { get; } = VSVersion.VS80;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name { get; } = "vs2005";
|
||||
|
||||
#endregion
|
||||
}
|
76
src/Core/Targets/VS2008Target.cs
Normal file
76
src/Core/Targets/VS2008Target.cs
Normal file
|
@ -0,0 +1,76 @@
|
|||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Nodes;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("vs2008")]
|
||||
public class VS2008Target : VSGenericTarget
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VS2005Target" /> class.
|
||||
/// </summary>
|
||||
public VS2008Target()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the solution version.
|
||||
/// </summary>
|
||||
/// <value>The solution version.</value>
|
||||
public override string SolutionVersion { get; } = "10.00";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the product version.
|
||||
/// </summary>
|
||||
/// <value>The product version.</value>
|
||||
public override string ProductVersion { get; } = "9.0.21022";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the schema version.
|
||||
/// </summary>
|
||||
/// <value>The schema version.</value>
|
||||
public override string SchemaVersion { get; } = "2.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the version.
|
||||
/// </summary>
|
||||
/// <value>The name of the version.</value>
|
||||
public override string VersionName { get; } = "Visual Studio 2008";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
/// <value>The version.</value>
|
||||
public override VSVersion Version { get; } = VSVersion.VS90;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name { get; } = "vs2008";
|
||||
|
||||
protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
|
||||
{
|
||||
switch (frameworkVersion)
|
||||
{
|
||||
case FrameworkVersion.v3_5:
|
||||
return "ToolsVersion=\"3.5\"";
|
||||
case FrameworkVersion.v3_0:
|
||||
return "ToolsVersion=\"3.0\"";
|
||||
default:
|
||||
return "ToolsVersion=\"2.0\"";
|
||||
}
|
||||
}
|
||||
|
||||
public override string SolutionTag => "# Visual Studio 2008";
|
||||
|
||||
#endregion
|
||||
}
|
83
src/Core/Targets/VS2010Target.cs
Normal file
83
src/Core/Targets/VS2010Target.cs
Normal file
|
@ -0,0 +1,83 @@
|
|||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Nodes;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("vs2010")]
|
||||
public class VS2010Target : VSGenericTarget
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VS2005Target" /> class.
|
||||
/// </summary>
|
||||
public VS2010Target()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the solution version.
|
||||
/// </summary>
|
||||
/// <value>The solution version.</value>
|
||||
public override string SolutionVersion { get; } = "11.00";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the product version.
|
||||
/// </summary>
|
||||
/// <value>The product version.</value>
|
||||
public override string ProductVersion { get; } = "9.0.30729";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the schema version.
|
||||
/// </summary>
|
||||
/// <value>The schema version.</value>
|
||||
public override string SchemaVersion { get; } = "2.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the version.
|
||||
/// </summary>
|
||||
/// <value>The name of the version.</value>
|
||||
public override string VersionName { get; } = "Visual Studio 2010";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
/// <value>The version.</value>
|
||||
public override VSVersion Version { get; } = VSVersion.VS10;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name { get; } = "vs2010";
|
||||
|
||||
protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
|
||||
{
|
||||
switch (frameworkVersion)
|
||||
{
|
||||
case FrameworkVersion.v4_5_1:
|
||||
case FrameworkVersion.v4_5:
|
||||
case FrameworkVersion.v4_0:
|
||||
case FrameworkVersion.v3_5:
|
||||
return "ToolsVersion=\"4.0\"";
|
||||
case FrameworkVersion.v3_0:
|
||||
return "ToolsVersion=\"3.0\"";
|
||||
default:
|
||||
return "ToolsVersion=\"2.0\"";
|
||||
}
|
||||
}
|
||||
|
||||
public override string SolutionTag => "# Visual Studio 2010";
|
||||
|
||||
#endregion
|
||||
}
|
89
src/Core/Targets/VS2012Target.cs
Normal file
89
src/Core/Targets/VS2012Target.cs
Normal file
|
@ -0,0 +1,89 @@
|
|||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Nodes;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("vs2012")]
|
||||
public class VS2012Target : VSGenericTarget
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VS2005Target" /> class.
|
||||
/// </summary>
|
||||
public VS2012Target()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the solution version.
|
||||
/// </summary>
|
||||
/// <value>The solution version.</value>
|
||||
public override string SolutionVersion { get; } = "12.00";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the product version.
|
||||
/// </summary>
|
||||
/// <value>The product version.</value>
|
||||
public override string ProductVersion { get; } = "11.0.61030.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the schema version.
|
||||
/// </summary>
|
||||
/// <value>The schema version.</value>
|
||||
public override string SchemaVersion { get; } = "2.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the version.
|
||||
/// </summary>
|
||||
/// <value>The name of the version.</value>
|
||||
public override string VersionName { get; } = "Visual Studio 2012";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
/// <value>The version.</value>
|
||||
public override VSVersion Version { get; } = VSVersion.VS11;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name { get; } = "vs2012";
|
||||
|
||||
protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
|
||||
{
|
||||
switch (frameworkVersion)
|
||||
{
|
||||
case FrameworkVersion.v4_7_1:
|
||||
case FrameworkVersion.v4_7:
|
||||
case FrameworkVersion.v4_6_2:
|
||||
case FrameworkVersion.v4_6_1:
|
||||
case FrameworkVersion.v4_6:
|
||||
return "ToolsVersion=\"14.0\"";
|
||||
case FrameworkVersion.v4_5_1:
|
||||
case FrameworkVersion.v4_5:
|
||||
case FrameworkVersion.v4_0:
|
||||
case FrameworkVersion.v3_5:
|
||||
return "ToolsVersion=\"4.0\"";
|
||||
case FrameworkVersion.v3_0:
|
||||
return "ToolsVersion=\"3.0\"";
|
||||
default:
|
||||
return "ToolsVersion=\"2.0\"";
|
||||
}
|
||||
}
|
||||
|
||||
public override string SolutionTag => "# Visual Studio 2012";
|
||||
|
||||
#endregion
|
||||
}
|
87
src/Core/Targets/VS2013Target.cs
Normal file
87
src/Core/Targets/VS2013Target.cs
Normal file
|
@ -0,0 +1,87 @@
|
|||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Nodes;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("vs2013")]
|
||||
public class VS2013Target : VSGenericTarget
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VS2005Target" /> class.
|
||||
/// </summary>
|
||||
public VS2013Target()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the solution version.
|
||||
/// </summary>
|
||||
/// <value>The solution version.</value>
|
||||
public override string SolutionVersion { get; } = "12.00";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the product version.
|
||||
/// </summary>
|
||||
/// <value>The product version.</value>
|
||||
public override string ProductVersion { get; } = "12.0.31101";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the schema version.
|
||||
/// </summary>
|
||||
/// <value>The schema version.</value>
|
||||
public override string SchemaVersion { get; } = "2.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the version.
|
||||
/// </summary>
|
||||
/// <value>The name of the version.</value>
|
||||
public override string VersionName { get; } = "Visual Studio 2013";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
/// <value>The version.</value>
|
||||
public override VSVersion Version { get; } = VSVersion.VS12;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name { get; } = "vs2013";
|
||||
|
||||
protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
|
||||
{
|
||||
switch (frameworkVersion)
|
||||
{
|
||||
case FrameworkVersion.v4_6_1:
|
||||
case FrameworkVersion.v4_6:
|
||||
return "ToolsVersion=\"14.0\"";
|
||||
case FrameworkVersion.v4_5_1:
|
||||
case FrameworkVersion.v4_5:
|
||||
return "ToolsVersion=\"12.0\"";
|
||||
case FrameworkVersion.v4_0:
|
||||
case FrameworkVersion.v3_5:
|
||||
return "ToolsVersion=\"4.0\"";
|
||||
case FrameworkVersion.v3_0:
|
||||
return "ToolsVersion=\"3.0\"";
|
||||
default:
|
||||
return "ToolsVersion=\"2.0\"";
|
||||
}
|
||||
}
|
||||
|
||||
public override string SolutionTag => "# Visual Studio 2013";
|
||||
|
||||
#endregion
|
||||
}
|
93
src/Core/Targets/VS2015Target.cs
Normal file
93
src/Core/Targets/VS2015Target.cs
Normal file
|
@ -0,0 +1,93 @@
|
|||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Nodes;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("vs2015")]
|
||||
public class VS2015Target : VSGenericTarget
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VS2012Target" /> class.
|
||||
/// </summary>
|
||||
public VS2015Target()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the solution version.
|
||||
/// </summary>
|
||||
/// <value>The solution version.</value>
|
||||
public override string SolutionVersion { get; } = "12.00";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the product version.
|
||||
/// </summary>
|
||||
/// <value>The product version.</value>
|
||||
public override string ProductVersion { get; } = "14.0.23107.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the schema version.
|
||||
/// </summary>
|
||||
/// <value>The schema version.</value>
|
||||
public override string SchemaVersion { get; } = "2.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the version.
|
||||
/// </summary>
|
||||
/// <value>The name of the version.</value>
|
||||
public override string VersionName { get; } = "Visual Studio 14";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
/// <value>The version.</value>
|
||||
public override VSVersion Version { get; } = VSVersion.VS15;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name { get; } = "vs2015";
|
||||
|
||||
protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
|
||||
{
|
||||
switch (frameworkVersion)
|
||||
{
|
||||
case FrameworkVersion.v4_8:
|
||||
case FrameworkVersion.v4_7_2:
|
||||
case FrameworkVersion.v4_7_1:
|
||||
case FrameworkVersion.v4_7:
|
||||
case FrameworkVersion.v4_6_2:
|
||||
case FrameworkVersion.v4_6_1:
|
||||
case FrameworkVersion.v4_6:
|
||||
return "ToolsVersion=\"14.0\"";
|
||||
case FrameworkVersion.v4_5_2:
|
||||
return "ToolsVersion=\"12.0\"";
|
||||
case FrameworkVersion.v4_5_1:
|
||||
case FrameworkVersion.v4_5:
|
||||
case FrameworkVersion.v4_0:
|
||||
case FrameworkVersion.v3_5:
|
||||
return "ToolsVersion=\"4.0\"";
|
||||
case FrameworkVersion.v3_0:
|
||||
return "ToolsVersion=\"3.0\"";
|
||||
default:
|
||||
return "ToolsVersion=\"2.0\"";
|
||||
}
|
||||
}
|
||||
|
||||
public override string SolutionTag => "# Visual Studio 14";
|
||||
|
||||
#endregion
|
||||
}
|
94
src/Core/Targets/VS2017Target.cs
Normal file
94
src/Core/Targets/VS2017Target.cs
Normal file
|
@ -0,0 +1,94 @@
|
|||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Nodes;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("vs2017")]
|
||||
public class VS2017Target : VSGenericTarget
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VS2012Target" /> class.
|
||||
/// </summary>
|
||||
public VS2017Target()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the solution version.
|
||||
/// </summary>
|
||||
/// <value>The solution version.</value>
|
||||
public override string SolutionVersion { get; } = "12.00";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the product version.
|
||||
/// </summary>
|
||||
/// <value>The product version.</value>
|
||||
public override string ProductVersion { get; } = "15.9.50";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the schema version.
|
||||
/// </summary>
|
||||
/// <value>The schema version.</value>
|
||||
public override string SchemaVersion { get; } = "2.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the version.
|
||||
/// </summary>
|
||||
/// <value>The name of the version.</value>
|
||||
public override string VersionName { get; } = "Visual Studio 17";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
/// <value>The version.</value>
|
||||
public override VSVersion Version { get; } = VSVersion.VS17;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name { get; } = "vs2017";
|
||||
|
||||
protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
|
||||
{
|
||||
switch (frameworkVersion)
|
||||
{
|
||||
case FrameworkVersion.v4_8:
|
||||
case FrameworkVersion.v4_7_2:
|
||||
case FrameworkVersion.v4_7_1:
|
||||
case FrameworkVersion.v4_7:
|
||||
return "ToolsVersion=\"15.0\"";
|
||||
case FrameworkVersion.v4_6_2:
|
||||
case FrameworkVersion.v4_6_1:
|
||||
case FrameworkVersion.v4_6:
|
||||
return "ToolsVersion=\"14.0\"";
|
||||
case FrameworkVersion.v4_5_2:
|
||||
return "ToolsVersion=\"12.0\"";
|
||||
case FrameworkVersion.v4_5_1:
|
||||
case FrameworkVersion.v4_5:
|
||||
case FrameworkVersion.v4_0:
|
||||
case FrameworkVersion.v3_5:
|
||||
return "ToolsVersion=\"4.0\"";
|
||||
case FrameworkVersion.v3_0:
|
||||
return "ToolsVersion=\"3.0\"";
|
||||
default:
|
||||
return "ToolsVersion=\"2.0\"";
|
||||
}
|
||||
}
|
||||
|
||||
public override string SolutionTag => "# Visual Studio 17";
|
||||
|
||||
#endregion
|
||||
}
|
99
src/Core/Targets/VS2019Target.cs
Normal file
99
src/Core/Targets/VS2019Target.cs
Normal file
|
@ -0,0 +1,99 @@
|
|||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Nodes;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("vs2019")]
|
||||
public class VS2019Target : VSGenericTarget
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VS2012Target" /> class.
|
||||
/// </summary>
|
||||
public VS2019Target()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the solution version.
|
||||
/// </summary>
|
||||
/// <value>The solution version.</value>
|
||||
public override string SolutionVersion { get; } = "12.00";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the product version.
|
||||
/// </summary>
|
||||
/// <value>The product version.</value>
|
||||
public override string ProductVersion { get; } = "16.7.3";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the schema version.
|
||||
/// </summary>
|
||||
/// <value>The schema version.</value>
|
||||
public override string SchemaVersion { get; } = "2.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the version.
|
||||
/// </summary>
|
||||
/// <value>The name of the version.</value>
|
||||
public override string VersionName { get; } = "Visual Studio 19";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
/// <value>The version.</value>
|
||||
public override VSVersion Version { get; } = VSVersion.VS19;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name { get; } = "vs2019";
|
||||
|
||||
protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
|
||||
{
|
||||
switch (frameworkVersion)
|
||||
{
|
||||
case FrameworkVersion.netstandard2_0:
|
||||
case FrameworkVersion.net5_0:
|
||||
case FrameworkVersion.net6_0:
|
||||
case FrameworkVersion.net7_0:
|
||||
case FrameworkVersion.v4_8:
|
||||
case FrameworkVersion.v4_7_2:
|
||||
return "ToolsVersion=\"16.0\"";
|
||||
case FrameworkVersion.v4_7_1:
|
||||
case FrameworkVersion.v4_7:
|
||||
return "ToolsVersion=\"15.0\"";
|
||||
case FrameworkVersion.v4_6_2:
|
||||
case FrameworkVersion.v4_6_1:
|
||||
case FrameworkVersion.v4_6:
|
||||
return "ToolsVersion=\"14.0\"";
|
||||
case FrameworkVersion.v4_5_2:
|
||||
return "ToolsVersion=\"12.0\"";
|
||||
case FrameworkVersion.v4_5_1:
|
||||
case FrameworkVersion.v4_5:
|
||||
case FrameworkVersion.v4_0:
|
||||
case FrameworkVersion.v3_5:
|
||||
return "ToolsVersion=\"4.0\"";
|
||||
case FrameworkVersion.v3_0:
|
||||
return "ToolsVersion=\"3.0\"";
|
||||
default:
|
||||
return "ToolsVersion=\"2.0\"";
|
||||
}
|
||||
}
|
||||
|
||||
public override string SolutionTag => "# Visual Studio 19";
|
||||
|
||||
#endregion
|
||||
}
|
100
src/Core/Targets/VS2022Target.cs
Normal file
100
src/Core/Targets/VS2022Target.cs
Normal file
|
@ -0,0 +1,100 @@
|
|||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Nodes;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("vs2022")]
|
||||
public class VS2022Target : VSGenericTarget
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VS2012Target" /> class.
|
||||
/// </summary>
|
||||
public VS2022Target()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the solution version.
|
||||
/// </summary>
|
||||
/// <value>The solution version.</value>
|
||||
public override string SolutionVersion { get; } = "12.00";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the product version.
|
||||
/// </summary>
|
||||
/// <value>The product version.</value>
|
||||
public override string ProductVersion { get; } = "117.3.2";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the schema version.
|
||||
/// </summary>
|
||||
/// <value>The schema version.</value>
|
||||
public override string SchemaVersion { get; } = "2.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the version.
|
||||
/// </summary>
|
||||
/// <value>The name of the version.</value>
|
||||
public override string VersionName { get; } = "Visual Studio Version 17";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
/// <value>The version.</value>
|
||||
public override VSVersion Version { get; } = VSVersion.VS22;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name { get; } = "vs2022";
|
||||
|
||||
protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
|
||||
{
|
||||
switch (frameworkVersion)
|
||||
{
|
||||
case FrameworkVersion.net5_0:
|
||||
case FrameworkVersion.net6_0:
|
||||
case FrameworkVersion.net7_0:
|
||||
return "ToolsVersion=\"17.0\"";
|
||||
case FrameworkVersion.netstandard2_0:
|
||||
case FrameworkVersion.v4_8:
|
||||
case FrameworkVersion.v4_7_2:
|
||||
return "ToolsVersion=\"16.0\"";
|
||||
case FrameworkVersion.v4_7_1:
|
||||
case FrameworkVersion.v4_7:
|
||||
return "ToolsVersion=\"15.0\"";
|
||||
case FrameworkVersion.v4_6_2:
|
||||
case FrameworkVersion.v4_6_1:
|
||||
case FrameworkVersion.v4_6:
|
||||
return "ToolsVersion=\"14.0\"";
|
||||
case FrameworkVersion.v4_5_2:
|
||||
return "ToolsVersion=\"12.0\"";
|
||||
case FrameworkVersion.v4_5_1:
|
||||
case FrameworkVersion.v4_5:
|
||||
case FrameworkVersion.v4_0:
|
||||
case FrameworkVersion.v3_5:
|
||||
return "ToolsVersion=\"4.0\"";
|
||||
case FrameworkVersion.v3_0:
|
||||
return "ToolsVersion=\"3.0\"";
|
||||
default:
|
||||
return "ToolsVersion=\"2.0\"";
|
||||
}
|
||||
}
|
||||
|
||||
public override string SolutionTag => "# Visual Studio 22";
|
||||
|
||||
#endregion
|
||||
}
|
1477
src/Core/Targets/VSGenericTarget.cs
Normal file
1477
src/Core/Targets/VSGenericTarget.cs
Normal file
File diff suppressed because it is too large
Load diff
76
src/Core/Targets/VSVersion.cs
Normal file
76
src/Core/Targets/VSVersion.cs
Normal file
|
@ -0,0 +1,76 @@
|
|||
#region BSD License
|
||||
|
||||
/*
|
||||
Copyright (c) 2008-2009 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com), John Anderson (sontek@gmail.com)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
and the following disclaimer in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* The name of the author may not be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public enum VSVersion
|
||||
{
|
||||
/// <summary>
|
||||
/// Visual Studio 2002
|
||||
/// </summary>
|
||||
VS70,
|
||||
|
||||
/// <summary>
|
||||
/// Visual Studio 2003
|
||||
/// </summary>
|
||||
VS71,
|
||||
|
||||
/// <summary>
|
||||
/// Visual Studio 2005
|
||||
/// </summary>
|
||||
VS80,
|
||||
|
||||
/// <summary>
|
||||
/// Visual Studio 2008
|
||||
/// </summary>
|
||||
VS90,
|
||||
|
||||
/// <summary>
|
||||
/// Visual Studio 2010
|
||||
/// </summary>
|
||||
VS10,
|
||||
|
||||
/// <summary>
|
||||
/// Visual Studio 2012
|
||||
/// </summary>
|
||||
VS11,
|
||||
|
||||
/// <summary>
|
||||
/// Visual Studio 2013
|
||||
/// </summary>
|
||||
VS12,
|
||||
|
||||
/// <summary>
|
||||
/// Visual Studio 2015
|
||||
/// </summary>
|
||||
VS15,
|
||||
VS17,
|
||||
VS19,
|
||||
VS22
|
||||
}
|
565
src/Core/Targets/XcodeTarget.cs
Normal file
565
src/Core/Targets/XcodeTarget.cs
Normal file
|
@ -0,0 +1,565 @@
|
|||
#region BSD License
|
||||
|
||||
/*
|
||||
Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
and the following disclaimer in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* The name of the author may not be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Interfaces;
|
||||
using Prebuild.Core.Nodes;
|
||||
using Prebuild.Core.Utilities;
|
||||
|
||||
namespace Prebuild.Core.Targets;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Target("xcode")]
|
||||
public class XcodeTarget : ITarget
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private Kernel m_Kernel;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private static string PrependPath(string path)
|
||||
{
|
||||
var tmpPath = Helper.NormalizePath(path, '/');
|
||||
var regex = new Regex(@"(\w):/(\w+)");
|
||||
var match = regex.Match(tmpPath);
|
||||
//if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
|
||||
//{
|
||||
tmpPath = Helper.NormalizePath(tmpPath);
|
||||
//}
|
||||
// else
|
||||
// {
|
||||
// tmpPath = Helper.NormalizePath("./" + tmpPath);
|
||||
// }
|
||||
|
||||
return tmpPath;
|
||||
}
|
||||
|
||||
private static string BuildReference(SolutionNode solution, ReferenceNode refr)
|
||||
{
|
||||
var ret = "";
|
||||
if (solution.ProjectsTable.ContainsKey(refr.Name))
|
||||
{
|
||||
var project = solution.ProjectsTable[refr.Name];
|
||||
var fileRef = FindFileReference(refr.Name, project);
|
||||
var finalPath =
|
||||
Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/${build.dir}/", refr.Name, "dll"), '/');
|
||||
ret += finalPath;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
var project = (ProjectNode)refr.Parent;
|
||||
var fileRef = FindFileReference(refr.Name, project);
|
||||
|
||||
if (refr.Path != null || fileRef != null)
|
||||
{
|
||||
var finalPath = refr.Path != null
|
||||
? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/')
|
||||
: fileRef;
|
||||
ret += finalPath;
|
||||
return ret;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//Assembly assem = Assembly.Load(refr.Name);
|
||||
//if (assem != null)
|
||||
//{
|
||||
//ret += (refr.Name + ".dll");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
ret += refr.Name + ".dll";
|
||||
//}
|
||||
}
|
||||
catch (NullReferenceException e)
|
||||
{
|
||||
e.ToString();
|
||||
ret += refr.Name + ".dll";
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr)
|
||||
{
|
||||
var ret = "";
|
||||
if (solution.ProjectsTable.ContainsKey(refr.Name))
|
||||
{
|
||||
var project = solution.ProjectsTable[refr.Name];
|
||||
var fileRef = FindFileReference(refr.Name, project);
|
||||
var finalPath = Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/');
|
||||
ret += finalPath;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
var project = (ProjectNode)refr.Parent;
|
||||
var fileRef = FindFileReference(refr.Name, project);
|
||||
|
||||
if (refr.Path != null || fileRef != null)
|
||||
{
|
||||
var finalPath = refr.Path != null ? Helper.NormalizePath(refr.Path, '/') : fileRef;
|
||||
ret += finalPath;
|
||||
return ret;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var assem = Assembly.Load(refr.Name);
|
||||
if (assem != null)
|
||||
ret += "";
|
||||
else
|
||||
ret += "";
|
||||
}
|
||||
catch (NullReferenceException e)
|
||||
{
|
||||
e.ToString();
|
||||
ret += "";
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static string FindFileReference(string refName, ProjectNode project)
|
||||
{
|
||||
foreach (var refPath in project.ReferencePaths)
|
||||
{
|
||||
var fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
|
||||
|
||||
if (File.Exists(fullPath)) return fullPath;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the XML doc file.
|
||||
/// </summary>
|
||||
/// <param name="project">The project.</param>
|
||||
/// <param name="conf">The conf.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
|
||||
{
|
||||
if (conf == null) throw new ArgumentNullException("conf");
|
||||
if (project == null) throw new ArgumentNullException("project");
|
||||
var docFile = (string)conf.Options["XmlDocFile"];
|
||||
// if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
|
||||
// {
|
||||
// return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
|
||||
// }
|
||||
return docFile;
|
||||
}
|
||||
|
||||
private void WriteProject(SolutionNode solution, ProjectNode project)
|
||||
{
|
||||
var projFile = Helper.MakeFilePath(project.FullPath,
|
||||
project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build");
|
||||
var ss = new StreamWriter(projFile);
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Push();
|
||||
Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
|
||||
var hasDoc = false;
|
||||
|
||||
using (ss)
|
||||
{
|
||||
ss.WriteLine("<?xml version=\"1.0\" ?>");
|
||||
ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name);
|
||||
ss.WriteLine(" <target name=\"{0}\">", "build");
|
||||
ss.WriteLine(
|
||||
" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />");
|
||||
ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />");
|
||||
ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\">");
|
||||
ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">");
|
||||
foreach (var refr in project.References)
|
||||
if (refr.LocalCopy)
|
||||
ss.WriteLine(" <include name=\"{0}",
|
||||
Helper.NormalizePath(
|
||||
Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr)) + "\" />",
|
||||
'/'));
|
||||
ss.WriteLine(" </fileset>");
|
||||
ss.WriteLine(" </copy>");
|
||||
ss.Write(" <csc");
|
||||
ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower());
|
||||
ss.Write(" debug=\"{0}\"", "${build.debug}");
|
||||
foreach (var conf in project.Configurations)
|
||||
if (conf.Options.KeyFile != "")
|
||||
{
|
||||
ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var conf in project.Configurations)
|
||||
{
|
||||
if (GetXmlDocFile(project, conf) != "")
|
||||
{
|
||||
ss.Write(" doc=\"{0}\"",
|
||||
"${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
|
||||
hasDoc = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}");
|
||||
if (project.Type == ProjectType.Library)
|
||||
ss.Write(".dll\"");
|
||||
else
|
||||
ss.Write(".exe\"");
|
||||
if (project.AppIcon != null && project.AppIcon.Length != 0)
|
||||
ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/'));
|
||||
ss.WriteLine(">");
|
||||
ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace);
|
||||
foreach (var file in project.Files)
|
||||
switch (project.Files.GetBuildAction(file))
|
||||
{
|
||||
case BuildAction.EmbeddedResource:
|
||||
ss.WriteLine(" {0}",
|
||||
"<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
|
||||
break;
|
||||
default:
|
||||
if (project.Files.GetSubType(file) != SubType.Code &&
|
||||
project.Files.GetSubType(file) != SubType.Settings)
|
||||
ss.WriteLine(" <include name=\"{0}\" />",
|
||||
file.Substring(0, file.LastIndexOf('.')) + ".resx");
|
||||
break;
|
||||
}
|
||||
//if (project.Files.GetSubType(file).ToString() != "Code")
|
||||
//{
|
||||
// ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
|
||||
|
||||
ss.WriteLine(" </resources>");
|
||||
ss.WriteLine(" <sources failonempty=\"true\">");
|
||||
foreach (var file in project.Files)
|
||||
switch (project.Files.GetBuildAction(file))
|
||||
{
|
||||
case BuildAction.Compile:
|
||||
ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') +
|
||||
"\" />");
|
||||
break;
|
||||
}
|
||||
|
||||
ss.WriteLine(" </sources>");
|
||||
ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">");
|
||||
ss.WriteLine(" <lib>");
|
||||
ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />");
|
||||
ss.WriteLine(" <include name=\"${project::get-base-directory()}/${build.dir}\" />");
|
||||
ss.WriteLine(" </lib>");
|
||||
foreach (var refr in project.References)
|
||||
ss.WriteLine(" <include name=\"{0}",
|
||||
Helper.NormalizePath(
|
||||
Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr)) + "\" />", '/'));
|
||||
ss.WriteLine(" </references>");
|
||||
|
||||
ss.WriteLine(" </csc>");
|
||||
ss.WriteLine(" </target>");
|
||||
|
||||
ss.WriteLine(" <target name=\"clean\">");
|
||||
ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
|
||||
ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
|
||||
ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">");
|
||||
if (hasDoc)
|
||||
{
|
||||
ss.WriteLine(" <property name=\"doc.target\" value=\"\" />");
|
||||
ss.WriteLine(" <if test=\"${platform::is-unix()}\">");
|
||||
ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />");
|
||||
ss.WriteLine(" </if>");
|
||||
ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">");
|
||||
ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">");
|
||||
ss.Write(" <include name=\"${build.dir}/${project::get-name()}");
|
||||
if (project.Type == ProjectType.Library)
|
||||
ss.WriteLine(".dll\" />");
|
||||
else
|
||||
ss.WriteLine(".exe\" />");
|
||||
|
||||
ss.WriteLine(" </assemblies>");
|
||||
ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">");
|
||||
ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>");
|
||||
ss.WriteLine(" </summaries>");
|
||||
ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">");
|
||||
ss.WriteLine(" <include name=\"${build.dir}\" />");
|
||||
//foreach(ReferenceNode refr in project.References)
|
||||
//{
|
||||
// string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/');
|
||||
// if (path != "")
|
||||
// {
|
||||
// ss.WriteLine(" <include name=\"{0}\" />", path);
|
||||
// }
|
||||
//}
|
||||
ss.WriteLine(" </referencepaths>");
|
||||
ss.WriteLine(" <documenters>");
|
||||
ss.WriteLine(" <documenter name=\"MSDN\">");
|
||||
ss.WriteLine(
|
||||
" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />");
|
||||
ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />");
|
||||
ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />");
|
||||
ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />");
|
||||
ss.WriteLine(
|
||||
" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />");
|
||||
ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />");
|
||||
ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />");
|
||||
ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />");
|
||||
ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />");
|
||||
ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />");
|
||||
ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />");
|
||||
ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />");
|
||||
ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />");
|
||||
ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />");
|
||||
ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />");
|
||||
ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />");
|
||||
ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />");
|
||||
ss.WriteLine(
|
||||
" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />");
|
||||
ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />");
|
||||
ss.WriteLine(" </documenter>");
|
||||
ss.WriteLine(" </documenters>");
|
||||
ss.WriteLine(" </ndoc>");
|
||||
}
|
||||
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine("</project>");
|
||||
}
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Pop();
|
||||
}
|
||||
|
||||
private void WriteCombine(SolutionNode solution)
|
||||
{
|
||||
m_Kernel.Log.Write("Creating Xcode build files");
|
||||
foreach (var project in solution.Projects)
|
||||
if (m_Kernel.AllowProject(project.FilterGroups))
|
||||
{
|
||||
m_Kernel.Log.Write("...Creating project: {0}", project.Name);
|
||||
WriteProject(solution, project);
|
||||
}
|
||||
|
||||
m_Kernel.Log.Write("");
|
||||
var directoryInfo = new DirectoryInfo(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj"));
|
||||
if (!directoryInfo.Exists) directoryInfo.Create();
|
||||
var combFile = Helper.MakeFilePath(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj"), "project",
|
||||
"pbxproj");
|
||||
var ss = new StreamWriter(combFile);
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Push();
|
||||
Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
|
||||
|
||||
using (ss)
|
||||
{
|
||||
ss.WriteLine("<?xml version=\"1.0\" ?>");
|
||||
ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name);
|
||||
ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>");
|
||||
ss.WriteLine();
|
||||
|
||||
//ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />");
|
||||
//ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />");
|
||||
ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />");
|
||||
ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />");
|
||||
ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />");
|
||||
ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />");
|
||||
|
||||
foreach (var conf in solution.Configurations)
|
||||
{
|
||||
// Set the project.config to a non-debug configuration
|
||||
if (conf.Options["DebugInformation"].ToString().ToLower() != "true")
|
||||
ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
|
||||
ss.WriteLine();
|
||||
ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name);
|
||||
ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
|
||||
ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />",
|
||||
conf.Options["DebugInformation"].ToString().ToLower());
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
}
|
||||
|
||||
ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">");
|
||||
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">");
|
||||
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">");
|
||||
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">");
|
||||
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"init\" description=\"\">");
|
||||
ss.WriteLine(" <call target=\"${project.config}\" />");
|
||||
ss.WriteLine(" <sysinfo />");
|
||||
ss.WriteLine(" <echo message=\"Platform ${sys.os.platform}\" />");
|
||||
ss.WriteLine(" <property name=\"build.dir\" value=\"${bin.dir}/${project.config}\" />");
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"clean\" description=\"\">");
|
||||
ss.WriteLine(" <echo message=\"Deleting all builds from all configurations\" />");
|
||||
//ss.WriteLine(" <delete dir=\"${dist.dir}\" failonerror=\"false\" />");
|
||||
ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
|
||||
ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
|
||||
//foreach(ProjectNode project in solution.Projects)
|
||||
//{
|
||||
// string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
|
||||
// ss.Write(" <nant buildfile=\"{0}\"",
|
||||
// Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"),'/'));
|
||||
// ss.WriteLine(" target=\"clean\" />");
|
||||
//}
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"build\" depends=\"init\" description=\"\">");
|
||||
|
||||
foreach (var project in solution.ProjectsTableOrder)
|
||||
{
|
||||
var path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
|
||||
ss.Write(" <nant buildfile=\"{0}\"",
|
||||
Helper.NormalizePath(
|
||||
Helper.MakeFilePath(path,
|
||||
project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/'));
|
||||
ss.WriteLine(" target=\"build\" />");
|
||||
}
|
||||
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(
|
||||
" <target name=\"build-release\" depends=\"Release, init, build\" description=\"Builds in Release mode\" />");
|
||||
ss.WriteLine();
|
||||
ss.WriteLine(
|
||||
" <target name=\"build-debug\" depends=\"Debug, init, build\" description=\"Builds in Debug mode\" />");
|
||||
ss.WriteLine();
|
||||
//ss.WriteLine(" <target name=\"package\" depends=\"clean, doc, copyfiles, zip\" description=\"Builds in Release mode\" />");
|
||||
ss.WriteLine(" <target name=\"package\" depends=\"clean, doc\" description=\"Builds all\" />");
|
||||
ss.WriteLine();
|
||||
|
||||
ss.WriteLine(" <target name=\"doc\" depends=\"build-release\">");
|
||||
ss.WriteLine(" <echo message=\"Generating all documentation from all builds\" />");
|
||||
foreach (var project in solution.Projects)
|
||||
{
|
||||
var path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
|
||||
ss.Write(" <nant buildfile=\"{0}\"",
|
||||
Helper.NormalizePath(
|
||||
Helper.MakeFilePath(path,
|
||||
project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/'));
|
||||
ss.WriteLine(" target=\"doc\" />");
|
||||
}
|
||||
|
||||
ss.WriteLine(" </target>");
|
||||
ss.WriteLine();
|
||||
ss.WriteLine("</project>");
|
||||
}
|
||||
|
||||
m_Kernel.CurrentWorkingDirectory.Pop();
|
||||
}
|
||||
|
||||
private void CleanProject(ProjectNode project)
|
||||
{
|
||||
m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
|
||||
var projectFile = Helper.MakeFilePath(project.FullPath,
|
||||
project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build");
|
||||
Helper.DeleteIfExists(projectFile);
|
||||
}
|
||||
|
||||
private void CleanSolution(SolutionNode solution)
|
||||
{
|
||||
m_Kernel.Log.Write("Cleaning Xcode build files for", solution.Name);
|
||||
|
||||
var slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
|
||||
Helper.DeleteIfExists(slnFile);
|
||||
|
||||
foreach (var project in solution.Projects) CleanProject(project);
|
||||
|
||||
m_Kernel.Log.Write("");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITarget Members
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public void Write(Kernel kern)
|
||||
{
|
||||
if (kern == null) throw new ArgumentNullException("kern");
|
||||
m_Kernel = kern;
|
||||
foreach (var solution in kern.Solutions) WriteCombine(solution);
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans the specified kern.
|
||||
/// </summary>
|
||||
/// <param name="kern">The kern.</param>
|
||||
public virtual void Clean(Kernel kern)
|
||||
{
|
||||
if (kern == null) throw new ArgumentNullException("kern");
|
||||
m_Kernel = kern;
|
||||
foreach (var sol in kern.Solutions) CleanSolution(sol);
|
||||
m_Kernel = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name => "xcode";
|
||||
|
||||
#endregion
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue