本文整理汇总了C#中Premake.Tests.Framework.Project类的典型用法代码示例。如果您正苦于以下问题:C# Project类的具体用法?C# Project怎么用?C# Project使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Project类属于Premake.Tests.Framework命名空间,在下文中一共展示了Project类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareTo
public void CompareTo(Project actual)
{
Test(this.ID, actual.ID, "Project ID");
Test(this.Name, actual.Name, "Project name");
Test(this.Path, actual.Path, "Project path");
this.Package.CompareTo(actual.Package);
}
示例2: Add
public void Add(Project project)
{
foreach (string name in project.Configuration)
{
Configuration config = new Configuration();
config.Name = name;
List.Add(config);
}
}
示例3: Test_Setup
public void Test_Setup()
{
_script = Script.MakeBasic("exe", "c++");
_expects = new Project();
_expects.Package.Add(1);
_parser = new GnuParser();
}
示例4: Test_Setup
public void Test_Setup()
{
_script = Script.MakeBasic("exe", "c++");
_expects = new Project();
_expects.Package.Add(1);
_expects.Package[0].Config.Add(2);
_parser = new Vs2003Parser();
}
示例5: Test_Setup
public void Test_Setup()
{
_script = Script.MakeBasic("exe", "c#");
_expects = new Project();
_expects.Package.Add(2);
_expects.Package[0].Config.Add(2);
_expects.Package[1].Config.Add(2);
_parser = new MonoDevParser();
}
示例6: Test_Setup
public void Test_Setup()
{
_script = Script.MakeBasic("dll", "c++");
_script.Append("project.bindir = 'bin'");
_script.Append("project.libdir = 'lib'");
_expects = new Project();
_expects.Package.Add(1);
_expects.Package[0].Config.Add(2);
_parser = new Vs6Parser();
}
示例7: Parse
public override void Parse(Project project, string filename)
{
/* File header */
Begin(filename + ".workspace");
Match("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>");
Match("<CodeBlocks_workspace_file>");
Match("\t<Workspace title=\"" + project.Name + "\">");
Hashtable packageDependencies = new Hashtable();
while (!Match("\t</Workspace>", true))
{
string[] matches = Regex("\t\t<Project filename=\"(.+?)\"(.*)>");
Package package = new Package();
project.Package.Add(package);
package.Name = Path.GetFileNameWithoutExtension(matches[0]);
package.Path = Path.GetDirectoryName(matches[0]);
package.ScriptName = Path.GetFileName(matches[0]);
ArrayList deps = new ArrayList();
while (!Match("\t\t</Project>", true))
{
matches = Regex("\t\t\t<Depends filename=\"(.+?)\" />");
deps.Add(Path.GetFileNameWithoutExtension(matches[0]));
}
packageDependencies.Add(package, deps.ToArray(typeof(string)));
}
Match("</CodeBlocks_workspace_file>");
foreach (Package package in project.Package)
{
filename = Path.Combine(Path.Combine(project.Path, package.Path), package.ScriptName);
ParseCpp(project, package, filename);
foreach (Configuration cfg in package.Config)
cfg.Dependencies = (string[])packageDependencies[package];
}
}
示例8: ParseCpp
private void ParseCpp(Project project, Package package, string filename)
{
Begin(filename);
Match("<?xml version=\"1.0\" encoding=\"Windows-1252\"?>");
Match("<VisualStudioProject");
Match("\tProjectType=\"Visual C++\"");
Match("\tVersion=\"8.00\"");
Match("\tName=\"" + package.Name + "\"");
string[] matches = Regex("\tProjectGUID=\"{([A-F0-9-]+)}\"");
if (matches[0] != package.ID)
throw new FormatException("Solution (" + package.ID + ") and project (" + matches[0] + ") GUIDs don't match");
Match("\tRootNamespace=\"" + package.Name + "\"");
Match("\tKeyword=\"Win32Proj\"");
Match("\t>");
Match("\t<Platforms>");
Match("\t\t<Platform");
Match("\t\t\tName=\"Win32\"");
Match("\t\t/>");
Match("\t</Platforms>");
Match("\t<ToolFiles>");
Match("\t</ToolFiles>");
Match("\t<Configurations>");
foreach (Configuration config in package.Config)
{
ArrayList buildFlags = new ArrayList();
Match("\t\t<Configuration");
Match("\t\t\tName=\"" + config.Name + "|Win32\"");
matches = Regex("\t\t\tOutputDirectory=\"(.+)\"");
config.OutDir = matches[0];
matches = Regex("\t\t\tIntermediateDirectory=\"(.+)\"");
config.ObjDir = matches[0];
matches = Regex("\t\t\tConfigurationType=\"([0-9])\"");
switch (int.Parse(matches[0]))
{
case 1: config.Kind = "exe"; break;
case 2: config.Kind = "dll"; break;
case 4: config.Kind = "lib"; break;
default:
throw new FormatException("Unrecognized value: ConfigurationType=\"" + matches[0] + "\"");
}
if (config.Kind == "lib")
config.LibDir = config.OutDir;
else
config.BinDir = config.OutDir;
matches = Regex("\t\t\tCharacterSet=\"([1-2])\"");
if (matches[0] == "1")
buildFlags.Add("unicode");
Match("\t\t\t>");
Match("\t\t\t<Tool");
Match("\t\t\t\tName=\"VCPreBuildEventTool\"");
Match("\t\t\t/>");
Match("\t\t\t<Tool");
Match("\t\t\t\tName=\"VCCustomBuildTool\"");
Match("\t\t\t/>");
Match("\t\t\t<Tool");
Match("\t\t\t\tName=\"VCXMLDataGeneratorTool\"");
Match("\t\t\t/>");
Match("\t\t\t<Tool");
Match("\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"");
Match("\t\t\t/>");
Match("\t\t\t<Tool");
Match("\t\t\t\tName=\"VCMIDLTool\"");
Match("\t\t\t/>");
Match("\t\t\t<Tool");
Match("\t\t\t\tName=\"VCCLCompilerTool\"");
matches = Regex("\t\t\t\tAdditionalOptions=\"(.+)\"", true);
config.BuildOptions = (matches != null) ? matches[0] : String.Empty;
matches = Regex("\t\t\t\tOptimization=\"([0-9])\"");
int optimization = int.Parse(matches[0]);
switch (optimization)
{
case 0: break;
case 1: buildFlags.Add("optimize-size"); break;
case 2: buildFlags.Add("optimize-speed"); break;
case 3: buildFlags.Add("optimize"); break;
default:
throw new FormatException("Unrecognized value: Optimization=\"" + matches[0] + "\"");
}
//.........这里部分代码省略.........
示例9: ParseCpp
private void ParseCpp(Project project, Package package, string filename)
{
Begin(filename);
Match("# Microsoft Developer Studio Project File - Name=\"" + package.Name + "\" - Package Owner=<4>");
Match("# Microsoft Developer Studio Generated Build File, Format Version 6.00");
Match("# ** DO NOT EDIT **");
Match("");
string[] matches = Regex("# TARGTYPE (.+)");
switch (matches[0])
{
case "\"Win32 (x86) Application\" 0x0101":
package.Kind = "winexe";
break;
case "\"Win32 (x86) Console Application\" 0x0103":
package.Kind = "exe";
break;
case "\"Win32 (x86) Dynamic-Link Library\" 0x0102":
package.Kind = "dll";
break;
case "\"Win32 (x86) Static Library\" 0x0104":
package.Kind = "lib";
break;
default:
throw new FormatException("Unrecognized target type: '" + matches[0] + "'");
}
string baseKind = matches[0].Substring(0, matches[0].Length - 7);
Match("");
matches = Regex("CFG=" + package.Name + " - (.+)");
string defaultConfig = matches[0];
Match("!MESSAGE This is not a valid makefile. To build this project using NMAKE,");
Match("!MESSAGE use the Export Makefile command and run");
Match("!MESSAGE ");
Match("!MESSAGE NMAKE /f \"" + package.Name + ".mak\".");
Match("!MESSAGE ");
Match("!MESSAGE You can specify a configuration when running NMAKE");
Match("!MESSAGE by defining the macro CFG on the command line. For example:");
Match("!MESSAGE ");
Match("!MESSAGE NMAKE /f \"" + package.Name + ".mak\" CFG=\"" + package.Name + " - " + defaultConfig + "\"");
Match("!MESSAGE ");
Match("!MESSAGE Possible choices for configuration are:");
Match("!MESSAGE ");
baseKind = baseKind.Replace("(", "\\(");
baseKind = baseKind.Replace(")", "\\)");
while (!Match("!MESSAGE ", true))
{
matches = Regex("!MESSAGE \"" + package.Name + " - ([^\"]+)\" \\(based on " + baseKind + "\\)");
Configuration config = new Configuration();
config.Name = matches[0];
config.Dependencies = new string[0];
package.Config.Add(config);
}
Match("");
/* Verify configurations */
if (project.Configuration.Count == 0)
{
foreach (Configuration config in package.Config)
project.Configuration.Add(config.Name);
}
else
{
foreach (Configuration config in package.Config)
if (!project.Configuration.Contains(config.Name))
throw new FormatException("Config '" + config.Name + "' not found in project");
}
Match("# Begin Project");
Match("# PROP AllowPerConfigDependencies 0");
Match("# PROP Scc_ProjName \"\"");
Match("# PROP Scc_LocalPath \"\"");
Match("CPP=cl.exe");
if (package.Kind != "lib")
Match("MTL=midl.exe");
Match("RSC=rc.exe");
Match("");
bool first = true;
foreach (Configuration config in package.Config)
{
ArrayList bldflags = new ArrayList();
ArrayList lnkflags = new ArrayList();
ArrayList defines = new ArrayList();
ArrayList incpaths = new ArrayList();
ArrayList links = new ArrayList();
ArrayList libpaths = new ArrayList();
string cond = (first) ? "!IF" : "!ELSEIF";
first = false;
Match(cond + " \"$(CFG)\" == \"" + package.Name + " - " + config.Name + "\"");
Match("");
Match("# PROP BASE Use_MFC 0");
matches = Regex("# PROP BASE Use_Debug_Libraries ([0-1])");
//.........这里部分代码省略.........
示例10: Parse
public override void Parse(Project project, string filename)
{
/* File header */
Begin(filename + ".dsw");
Match("Microsoft Developer Studio Workspace File, Format Version 6.00");
Match("# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!");
Match("");
Match("###############################################################################");
Match("");
Hashtable dependencies = new Hashtable();
string[] matches;
while (!Match("Global:", true))
{
Package package = new Package();
project.Package.Add(package);
matches = Regex("Project: \"(.+)\"=(.+) - Package Owner=<4>");
package.Name = matches[0];
package.Path = Path.GetDirectoryName(matches[1]);
package.ScriptName = Path.GetFileName(matches[1]);
package.Language = "c++";
Match("");
Match("Package=<5>");
Match("{{{");
Match("}}}");
Match("");
Match("Package=<4>");
Match("{{{");
/* Get the package dependencies, cache until I have configs */
ArrayList deps = new ArrayList();
while (Match(" Begin Project Dependency", true))
{
matches = Regex(" Project_Dep_Name (.+)");
deps.Add(matches[0]);
Match(" End Project Dependency");
}
dependencies[package] = (string[])deps.ToArray(typeof(string));
Match("}}}");
Match("");
Match("###############################################################################");
Match("");
}
Match("");
Match("Package=<5>");
Match("{{{");
Match("}}}");
Match("");
Match("Package=<3>");
Match("{{{");
Match("}}}");
Match("");
Match("###############################################################################");
Match("");
foreach (Package package in project.Package)
{
filename = Path.Combine(Path.Combine(project.Path, package.Path), package.ScriptName);
switch (package.Language)
{
case "c++":
ParseCpp(project, package, filename);
break;
default:
throw new NotImplementedException("Loading of " + package.Language + " packages not implemented");
}
ArrayList temp = new ArrayList();
foreach (Configuration config in package.Config)
{
config.Dependencies = (string[])dependencies[package];
temp.Add(config);
}
/* VS6 stores configs in reverse order */
temp.Reverse();
for (int i = 0; i < package.Config.Count; ++i)
package.Config[i] = (Configuration)temp[i];
}
}
示例11: ParsePackageHeader
private void ParsePackageHeader(Project project, Package package, string filename)
{
Begin(filename);
string[] matches = Regex("# (.+?) (.+?) Makefile autogenerated by premake");
package.Language = matches[0].ToLower();
switch (matches[1])
{
case "Console Executable": package.Kind = "exe"; break;
case "Windowed Executable": package.Kind = "winexe"; break;
case "Shared Library": package.Kind = "dll"; break;
case "Static Library": package.Kind = "lib"; break;
case "ASP.NET": package.Kind = "aspnet"; break;
}
Match("# Don't edit this file! Instead edit `premake.lua` then rerun `make`");
Match("");
Match("ifndef CONFIG");
Match(" CONFIG=" + project.Configuration[0]);
Match("endif");
Match("");
if (package.Language == "c++" || package.Language == "c")
ParseCpp(project, package);
else
ParseManaged(project, package);
}
示例12: Parse
public abstract void Parse(Project project, string filename);
示例13: ParseUserFile
private void ParseUserFile(Project project, Package package, string filename)
{
Begin(filename + ".user");
Match("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">");
Match(" <PropertyGroup>");
string[] matches = Regex(" <ReferencePath>(.+)</ReferencePath>");
matches = matches[0].Split(';');
string[] libpaths = new string[matches.Length - 1];
/* VS.NET stores reference directories as absolute paths, so I need
* to do some ugly trickery here */
string[] bindir = matches[matches.Length - 1].Split('\\');
for (int i = 0; i < matches.Length - 1; ++i)
{
string[] thisdir = matches[i].Split('\\');
int j = 0;
while (j < bindir.Length && j < thisdir.Length && bindir[j] == thisdir[j])
++j;
string path = "";
for (int k = j + 1; k < bindir.Length; ++k)
path += "..\\";
for (int k = j; k < thisdir.Length; ++k)
path += thisdir[k] + '\\';
libpaths[i] = path.Substring(0, path.Length - 1);
libpaths[i] = libpaths[i].Replace("/", "\\");
}
foreach (Configuration config in package.Config)
{
config.LibPaths = libpaths;
}
Match(" </PropertyGroup>");
Match("</Project>");
}
示例14: Parse
public override void Parse(Project project, string filename)
{
string root = Path.GetDirectoryName(filename);
if (root != String.Empty)
root += Path.DirectorySeparatorChar;
Begin(root + "Makefile");
/* File header */
Match("# Makefile autogenerated by premake");
Match("# Don't edit this file! Instead edit `premake.lua` then rerun `make`");
Match("# Options:");
/* Project configurations */
string[] matches = Regex("# CONFIG=\\[(.+)\\]");
matches = matches[0].Split('|');
foreach (string config in matches)
project.Configuration.Add(config);
Match("");
Match("ifndef CONFIG");
Match(" CONFIG=" + project.Configuration[0]);
Match("endif");
Match("");
Match("export CONFIG");
Match("");
/* Package list */
matches = Regex(".PHONY: all clean (.+)");
matches = matches[0].Split(' ');
foreach (string name in matches)
{
Package package = new Package(project);
project.Package.Add(package);
package.Name = name;
}
Match("");
Match("all: " + String.Join(" ", matches));
Match("");
/* The premake script dependency...need a way to test this! */
string path = Path.Combine(project.Path, "premake.lua");
Regex("Makefile: (.+)");
Match("\[email protected] ==== Regenerating Makefiles ====");
Regex("\[email protected] --file \\$\\^ (.+)");
Match("");
foreach (Package package in project.Package)
{
matches = Regex(package.Name + ":(.*)");
foreach (Configuration config in package.Config)
{
config.Dependencies = matches[0].Trim().Split(' ');
}
Match("\[email protected] ==== Building " + package.Name + " ====");
/* Pull out the package path */
matches = Regex("\[email protected]\\$\\(MAKE\\) --no-print-directory -C (.+)");
int split = matches[0].IndexOf(" -f ");
if (split > 0)
{
package.Path = matches[0].Substring(0, split);
package.ScriptName = matches[0].Substring(split + 4);
}
else
{
package.Path = matches[0];
package.ScriptName = "Makefile";
}
Match("");
}
Match("clean:");
foreach (Package package in project.Package)
{
Regex("\[email protected]\\$\\(MAKE\\) --no-print-directory -C " + package.Path + "(.*)clean$");
}
/* Parse the individual packages */
foreach (Package package in project.Package)
{
filename = Path.Combine(Path.Combine(project.Path, package.Path), package.ScriptName);
ParsePackageHeader(project, package, filename);
}
}
示例15: Parse
public override void Parse(Project project, string filename)
{
Begin(filename + ".mds");
string[] matches = Regex("<Combine name=\"(.+)\" fileversion=\"2.0\">");
project.Name = matches[0];
matches = Regex(" <Configurations active=\"(.+)\">");
string active = matches[0];
// Parse configurations
while (!Match(" </Configurations>", true))
{
matches = Regex(" <Configuration name=\"(.+)\" ctype=\"CombineConfiguration\">");
Configuration config = new Configuration();
config.Name = matches[0];
project.Configuration.Add(matches[0]);
int i = 0;
while (!Match(" </Configuration>", true))
{
matches = Regex(" <Entry build=\"True\" name=\"(.+?)\" configuration=\"" + active + "\" />");
if (i == project.Package.Count)
{
Package package = new Package();
package.Name = matches[0];
project.Package.Add(package);
}
else
{
if (project.Package[i].Name != matches[0])
throw new FormatException("Package name should be " + project.Package[i] + ", is " + matches[0]);
}
}
}
foreach (Package package in project.Package)
{
foreach (string name in project.Configuration)
{
Configuration config = new Configuration();
config.Name = name;
package.Config.Add(config);
}
}
// Parse startup entries
Match(" <StartMode startupentry=\"" + project.Package[0].Name + "\" single=\"True\">");
foreach (Package package in project.Package)
{
Match(" <Execute type=\"None\" entry=\"" + package.Name + "\" />");
}
Match(" </StartMode>");
// Parse project entries
Match(" <Entries>");
foreach (Package package in project.Package)
{
matches = Regex(" <Entry filename=\"(.+)\" />");
/* Pull out directory, but keep the path separators intact (no translation) */
package.Path = matches[0].Substring(0, Path.GetDirectoryName(matches[0]).Length);
package.ScriptName = Path.GetFileName(matches[0]);
}
Match(" </Entries>");
Match("</Combine>");
foreach (Package package in project.Package)
{
string pkgfilename = Path.Combine(Path.Combine(project.Path, package.Path), package.ScriptName);
ParsePackage(project, package, pkgfilename);
/* SHARPDEV_DEPENDENCY_BUG: Dependencies are set correctly here! */
#if SHARPDEV_DEPENDENCY_BUG
Console.WriteLine(package.Name + ": ");
foreach (Configuration config in package.Config)
{
Console.WriteLine(" " + config.Name + ": " + config.Dependencies.Length);
}
#endif
}
}