From 7e65590a55ba575d0086bdfc25addaf1051d799b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 11 Sep 2010 01:13:08 +0100 Subject: Update Prebuild.exe with Prebuild r323 + an existing OpenSim specific nant hack to correctly clean up chosen OpenSim exes and dlls in bin/ on a "nant clean" Source code is included for reference. This can go away again once Prebuild is updated with a more general mechanism for cleaning up files. The Prebuild source code here can be built with nant, or regnerated for other tools using the prebuild at {root}/bin/Prebuild.exe --- Prebuild/src/Core/.svn/all-wcprops | 29 + Prebuild/src/Core/.svn/dir-prop-base | 5 + Prebuild/src/Core/.svn/entries | 182 ++++ .../Core/.svn/prop-base/FatalException.cs.svn-base | 9 + .../src/Core/.svn/prop-base/Kernel.cs.svn-base | 9 + .../prop-base/UnknownLanguageException.cs.svn-base | 9 + .../.svn/prop-base/WarningException.cs.svn-base | 9 + .../Core/.svn/text-base/FatalException.cs.svn-base | 85 ++ .../src/Core/.svn/text-base/Kernel.cs.svn-base | 832 +++++++++++++++ .../text-base/UnknownLanguageException.cs.svn-base | 63 ++ .../.svn/text-base/WarningException.cs.svn-base | 84 ++ Prebuild/src/Core/Attributes/.svn/all-wcprops | 23 + Prebuild/src/Core/Attributes/.svn/dir-prop-base | 5 + Prebuild/src/Core/Attributes/.svn/entries | 130 +++ .../.svn/prop-base/DataNodeAttribute.cs.svn-base | 9 + .../.svn/prop-base/OptionNodeAttribute.cs.svn-base | 9 + .../.svn/prop-base/TargetAttribute.cs.svn-base | 9 + .../.svn/text-base/DataNodeAttribute.cs.svn-base | 72 ++ .../.svn/text-base/OptionNodeAttribute.cs.svn-base | 71 ++ .../.svn/text-base/TargetAttribute.cs.svn-base | 71 ++ Prebuild/src/Core/Attributes/DataNodeAttribute.cs | 72 ++ .../src/Core/Attributes/OptionNodeAttribute.cs | 71 ++ Prebuild/src/Core/Attributes/TargetAttribute.cs | 71 ++ Prebuild/src/Core/FatalException.cs | 85 ++ Prebuild/src/Core/Interfaces/.svn/all-wcprops | 17 + Prebuild/src/Core/Interfaces/.svn/dir-prop-base | 5 + Prebuild/src/Core/Interfaces/.svn/entries | 96 ++ .../.svn/prop-base/IDataNode.cs.svn-base | 9 + .../Interfaces/.svn/prop-base/ITarget.cs.svn-base | 9 + .../.svn/text-base/IDataNode.cs.svn-base | 47 + .../Interfaces/.svn/text-base/ITarget.cs.svn-base | 51 + Prebuild/src/Core/Interfaces/IDataNode.cs | 47 + Prebuild/src/Core/Interfaces/ITarget.cs | 51 + Prebuild/src/Core/Kernel.cs | 832 +++++++++++++++ Prebuild/src/Core/Nodes/.svn/all-wcprops | 119 +++ Prebuild/src/Core/Nodes/.svn/dir-prop-base | 5 + Prebuild/src/Core/Nodes/.svn/entries | 674 ++++++++++++ .../.svn/prop-base/ConfigurationNode.cs.svn-base | 9 + .../Core/Nodes/.svn/prop-base/DataNode.cs.svn-base | 9 + .../Nodes/.svn/prop-base/ExcludeNode.cs.svn-base | 9 + .../Core/Nodes/.svn/prop-base/FileNode.cs.svn-base | 9 + .../Nodes/.svn/prop-base/FilesNode.cs.svn-base | 9 + .../Nodes/.svn/prop-base/MatchNode.cs.svn-base | 9 + .../Nodes/.svn/prop-base/OptionsNode.cs.svn-base | 9 + .../Nodes/.svn/prop-base/ProcessNode.cs.svn-base | 9 + .../Nodes/.svn/prop-base/ProjectNode.cs.svn-base | 9 + .../Nodes/.svn/prop-base/ReferenceNode.cs.svn-base | 9 + .../.svn/prop-base/ReferencePathNode.cs.svn-base | 9 + .../Nodes/.svn/prop-base/SolutionNode.cs.svn-base | 9 + .../Nodes/.svn/text-base/AuthorNode.cs.svn-base | 87 ++ .../.svn/text-base/CleanFilesNode.cs.svn-base | 80 ++ .../Nodes/.svn/text-base/CleanupNode.cs.svn-base | 85 ++ .../.svn/text-base/ConfigurationNode.cs.svn-base | 225 ++++ .../ConfigurationNodeCollection.cs.svn-base | 71 ++ .../Core/Nodes/.svn/text-base/DataNode.cs.svn-base | 117 +++ .../.svn/text-base/DatabaseProjectNode.cs.svn-base | 93 ++ .../text-base/DatabaseReferenceNode.cs.svn-base | 63 ++ .../.svn/text-base/DescriptionNode.cs.svn-base | 87 ++ .../Nodes/.svn/text-base/ExcludeNode.cs.svn-base | 89 ++ .../Core/Nodes/.svn/text-base/FileNode.cs.svn-base | 285 ++++++ .../Nodes/.svn/text-base/FilesNode.cs.svn-base | 204 ++++ .../Nodes/.svn/text-base/MatchNode.cs.svn-base | 367 +++++++ .../Nodes/.svn/text-base/OptionsNode.cs.svn-base | 634 ++++++++++++ .../Nodes/.svn/text-base/ProcessNode.cs.svn-base | 108 ++ .../Nodes/.svn/text-base/ProjectNode.cs.svn-base | 579 +++++++++++ .../Nodes/.svn/text-base/ReferenceNode.cs.svn-base | 144 +++ .../.svn/text-base/ReferencePathNode.cs.svn-base | 97 ++ .../Nodes/.svn/text-base/SolutionNode.cs.svn-base | 382 +++++++ Prebuild/src/Core/Nodes/AuthorNode.cs | 87 ++ Prebuild/src/Core/Nodes/CleanFilesNode.cs | 80 ++ Prebuild/src/Core/Nodes/CleanupNode.cs | 85 ++ Prebuild/src/Core/Nodes/ConfigurationNode.cs | 225 ++++ .../src/Core/Nodes/ConfigurationNodeCollection.cs | 71 ++ Prebuild/src/Core/Nodes/DataNode.cs | 117 +++ Prebuild/src/Core/Nodes/DatabaseProjectNode.cs | 93 ++ Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs | 63 ++ Prebuild/src/Core/Nodes/DescriptionNode.cs | 87 ++ Prebuild/src/Core/Nodes/ExcludeNode.cs | 89 ++ Prebuild/src/Core/Nodes/FileNode.cs | 285 ++++++ Prebuild/src/Core/Nodes/FilesNode.cs | 204 ++++ Prebuild/src/Core/Nodes/MatchNode.cs | 367 +++++++ Prebuild/src/Core/Nodes/OptionsNode.cs | 634 ++++++++++++ Prebuild/src/Core/Nodes/ProcessNode.cs | 108 ++ Prebuild/src/Core/Nodes/ProjectNode.cs | 579 +++++++++++ Prebuild/src/Core/Nodes/ReferenceNode.cs | 144 +++ Prebuild/src/Core/Nodes/ReferencePathNode.cs | 97 ++ Prebuild/src/Core/Nodes/SolutionNode.cs | 382 +++++++ Prebuild/src/Core/Parse/.svn/all-wcprops | 17 + Prebuild/src/Core/Parse/.svn/dir-prop-base | 5 + Prebuild/src/Core/Parse/.svn/entries | 96 ++ .../Parse/.svn/prop-base/IfContext.cs.svn-base | 9 + .../Parse/.svn/prop-base/Preprocessor.cs.svn-base | 9 + .../Parse/.svn/text-base/IfContext.cs.svn-base | 154 +++ .../Parse/.svn/text-base/Preprocessor.cs.svn-base | 652 ++++++++++++ Prebuild/src/Core/Parse/IfContext.cs | 154 +++ Prebuild/src/Core/Parse/Preprocessor.cs | 652 ++++++++++++ Prebuild/src/Core/Targets/.NAntTarget.cs.swp | Bin 0 -> 49152 bytes Prebuild/src/Core/Targets/.svn/all-wcprops | 101 ++ Prebuild/src/Core/Targets/.svn/dir-prop-base | 5 + Prebuild/src/Core/Targets/.svn/entries | 572 +++++++++++ .../Targets/.svn/prop-base/DebugTarget.cs.svn-base | 9 + .../.svn/prop-base/MakefileTarget.cs.svn-base | 9 + .../.svn/prop-base/MonoDevelopTarget.cs.svn-base | 9 + .../Targets/.svn/prop-base/NAntTarget.cs.svn-base | 9 + .../.svn/prop-base/SharpDevelopTarget.cs.svn-base | 9 + .../.svn/prop-base/VS2002Target.cs.svn-base | 9 + .../.svn/prop-base/VS2003Target.cs.svn-base | 9 + .../.svn/prop-base/VS2005Target.cs.svn-base | 9 + .../Targets/.svn/prop-base/XcodeTarget.cs.svn-base | 9 + .../.svn/text-base/AutotoolsTarget.cs.svn-base | 1070 ++++++++++++++++++++ .../Targets/.svn/text-base/DebugTarget.cs.svn-base | 102 ++ .../.svn/text-base/MakefileTarget.cs.svn-base | 469 +++++++++ .../.svn/text-base/MonoDevelopTarget.cs.svn-base | 515 ++++++++++ .../Targets/.svn/text-base/NAntTarget.cs.svn-base | 776 ++++++++++++++ .../.svn/text-base/SharpDevelop2Target.cs.svn-base | 82 ++ .../.svn/text-base/SharpDevelopTarget.cs.svn-base | 425 ++++++++ .../Targets/.svn/text-base/ToolInfo.cs.svn-base | 197 ++++ .../.svn/text-base/VS2002Target.cs.svn-base | 87 ++ .../.svn/text-base/VS2003Target.cs.svn-base | 593 +++++++++++ .../.svn/text-base/VS2005Target.cs.svn-base | 147 +++ .../.svn/text-base/VS2008Target.cs.svn-base | 127 +++ .../.svn/text-base/VS2010Target.cs.svn-base | 138 +++ .../.svn/text-base/VSGenericTarget.cs.svn-base | 922 +++++++++++++++++ .../Targets/.svn/text-base/VSVersion.cs.svn-base | 54 + .../Targets/.svn/text-base/XcodeTarget.cs.svn-base | 594 +++++++++++ Prebuild/src/Core/Targets/AutotoolsTarget.cs | 1070 ++++++++++++++++++++ Prebuild/src/Core/Targets/DebugTarget.cs | 102 ++ Prebuild/src/Core/Targets/MakefileTarget.cs | 469 +++++++++ Prebuild/src/Core/Targets/MonoDevelopTarget.cs | 515 ++++++++++ Prebuild/src/Core/Targets/NAntTarget.cs | 792 +++++++++++++++ Prebuild/src/Core/Targets/SharpDevelop2Target.cs | 82 ++ Prebuild/src/Core/Targets/SharpDevelopTarget.cs | 425 ++++++++ Prebuild/src/Core/Targets/ToolInfo.cs | 197 ++++ Prebuild/src/Core/Targets/VS2002Target.cs | 87 ++ Prebuild/src/Core/Targets/VS2003Target.cs | 593 +++++++++++ Prebuild/src/Core/Targets/VS2005Target.cs | 147 +++ Prebuild/src/Core/Targets/VS2008Target.cs | 127 +++ Prebuild/src/Core/Targets/VS2010Target.cs | 138 +++ Prebuild/src/Core/Targets/VSGenericTarget.cs | 922 +++++++++++++++++ Prebuild/src/Core/Targets/VSVersion.cs | 54 + Prebuild/src/Core/Targets/XcodeTarget.cs | 594 +++++++++++ Prebuild/src/Core/UnknownLanguageException.cs | 63 ++ Prebuild/src/Core/Utilities/.svn/all-wcprops | 29 + Prebuild/src/Core/Utilities/.svn/dir-prop-base | 5 + Prebuild/src/Core/Utilities/.svn/entries | 164 +++ .../prop-base/CommandLineCollection.cs.svn-base | 9 + .../.svn/prop-base/CurrentDirectory.cs.svn-base | 9 + .../Utilities/.svn/prop-base/Helper.cs.svn-base | 9 + .../Core/Utilities/.svn/prop-base/Log.cs.svn-base | 9 + .../text-base/CommandLineCollection.cs.svn-base | 152 +++ .../.svn/text-base/CurrentDirectory.cs.svn-base | 68 ++ .../Utilities/.svn/text-base/Helper.cs.svn-base | 575 +++++++++++ .../Core/Utilities/.svn/text-base/Log.cs.svn-base | 276 +++++ .../src/Core/Utilities/CommandLineCollection.cs | 152 +++ Prebuild/src/Core/Utilities/CurrentDirectory.cs | 68 ++ Prebuild/src/Core/Utilities/Helper.cs | 575 +++++++++++ Prebuild/src/Core/Utilities/Log.cs | 276 +++++ Prebuild/src/Core/WarningException.cs | 84 ++ 158 files changed, 29320 insertions(+) create mode 100644 Prebuild/src/Core/.svn/all-wcprops create mode 100644 Prebuild/src/Core/.svn/dir-prop-base create mode 100644 Prebuild/src/Core/.svn/entries create mode 100644 Prebuild/src/Core/.svn/prop-base/FatalException.cs.svn-base create mode 100644 Prebuild/src/Core/.svn/prop-base/Kernel.cs.svn-base create mode 100644 Prebuild/src/Core/.svn/prop-base/UnknownLanguageException.cs.svn-base create mode 100644 Prebuild/src/Core/.svn/prop-base/WarningException.cs.svn-base create mode 100644 Prebuild/src/Core/.svn/text-base/FatalException.cs.svn-base create mode 100644 Prebuild/src/Core/.svn/text-base/Kernel.cs.svn-base create mode 100644 Prebuild/src/Core/.svn/text-base/UnknownLanguageException.cs.svn-base create mode 100644 Prebuild/src/Core/.svn/text-base/WarningException.cs.svn-base create mode 100644 Prebuild/src/Core/Attributes/.svn/all-wcprops create mode 100644 Prebuild/src/Core/Attributes/.svn/dir-prop-base create mode 100644 Prebuild/src/Core/Attributes/.svn/entries create mode 100644 Prebuild/src/Core/Attributes/.svn/prop-base/DataNodeAttribute.cs.svn-base create mode 100644 Prebuild/src/Core/Attributes/.svn/prop-base/OptionNodeAttribute.cs.svn-base create mode 100644 Prebuild/src/Core/Attributes/.svn/prop-base/TargetAttribute.cs.svn-base create mode 100644 Prebuild/src/Core/Attributes/.svn/text-base/DataNodeAttribute.cs.svn-base create mode 100644 Prebuild/src/Core/Attributes/.svn/text-base/OptionNodeAttribute.cs.svn-base create mode 100644 Prebuild/src/Core/Attributes/.svn/text-base/TargetAttribute.cs.svn-base create mode 100644 Prebuild/src/Core/Attributes/DataNodeAttribute.cs create mode 100644 Prebuild/src/Core/Attributes/OptionNodeAttribute.cs create mode 100644 Prebuild/src/Core/Attributes/TargetAttribute.cs create mode 100644 Prebuild/src/Core/FatalException.cs create mode 100644 Prebuild/src/Core/Interfaces/.svn/all-wcprops create mode 100644 Prebuild/src/Core/Interfaces/.svn/dir-prop-base create mode 100644 Prebuild/src/Core/Interfaces/.svn/entries create mode 100644 Prebuild/src/Core/Interfaces/.svn/prop-base/IDataNode.cs.svn-base create mode 100644 Prebuild/src/Core/Interfaces/.svn/prop-base/ITarget.cs.svn-base create mode 100644 Prebuild/src/Core/Interfaces/.svn/text-base/IDataNode.cs.svn-base create mode 100644 Prebuild/src/Core/Interfaces/.svn/text-base/ITarget.cs.svn-base create mode 100644 Prebuild/src/Core/Interfaces/IDataNode.cs create mode 100644 Prebuild/src/Core/Interfaces/ITarget.cs create mode 100644 Prebuild/src/Core/Kernel.cs create mode 100644 Prebuild/src/Core/Nodes/.svn/all-wcprops create mode 100644 Prebuild/src/Core/Nodes/.svn/dir-prop-base create mode 100644 Prebuild/src/Core/Nodes/.svn/entries create mode 100644 Prebuild/src/Core/Nodes/.svn/prop-base/ConfigurationNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/prop-base/DataNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/prop-base/ExcludeNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/prop-base/FileNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/prop-base/FilesNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/prop-base/MatchNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/prop-base/OptionsNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/prop-base/ProcessNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/prop-base/ProjectNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/prop-base/ReferenceNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/prop-base/ReferencePathNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/prop-base/SolutionNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/AuthorNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/CleanFilesNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/CleanupNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/ConfigurationNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/ConfigurationNodeCollection.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/DataNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/DatabaseProjectNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/DatabaseReferenceNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/DescriptionNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/ExcludeNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/FileNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/FilesNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/MatchNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/OptionsNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/ProcessNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/ProjectNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/ReferenceNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/ReferencePathNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/.svn/text-base/SolutionNode.cs.svn-base create mode 100644 Prebuild/src/Core/Nodes/AuthorNode.cs create mode 100644 Prebuild/src/Core/Nodes/CleanFilesNode.cs create mode 100644 Prebuild/src/Core/Nodes/CleanupNode.cs create mode 100644 Prebuild/src/Core/Nodes/ConfigurationNode.cs create mode 100644 Prebuild/src/Core/Nodes/ConfigurationNodeCollection.cs create mode 100644 Prebuild/src/Core/Nodes/DataNode.cs create mode 100644 Prebuild/src/Core/Nodes/DatabaseProjectNode.cs create mode 100644 Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs create mode 100644 Prebuild/src/Core/Nodes/DescriptionNode.cs create mode 100644 Prebuild/src/Core/Nodes/ExcludeNode.cs create mode 100644 Prebuild/src/Core/Nodes/FileNode.cs create mode 100644 Prebuild/src/Core/Nodes/FilesNode.cs create mode 100644 Prebuild/src/Core/Nodes/MatchNode.cs create mode 100644 Prebuild/src/Core/Nodes/OptionsNode.cs create mode 100644 Prebuild/src/Core/Nodes/ProcessNode.cs create mode 100644 Prebuild/src/Core/Nodes/ProjectNode.cs create mode 100644 Prebuild/src/Core/Nodes/ReferenceNode.cs create mode 100644 Prebuild/src/Core/Nodes/ReferencePathNode.cs create mode 100644 Prebuild/src/Core/Nodes/SolutionNode.cs create mode 100644 Prebuild/src/Core/Parse/.svn/all-wcprops create mode 100644 Prebuild/src/Core/Parse/.svn/dir-prop-base create mode 100644 Prebuild/src/Core/Parse/.svn/entries create mode 100644 Prebuild/src/Core/Parse/.svn/prop-base/IfContext.cs.svn-base create mode 100644 Prebuild/src/Core/Parse/.svn/prop-base/Preprocessor.cs.svn-base create mode 100644 Prebuild/src/Core/Parse/.svn/text-base/IfContext.cs.svn-base create mode 100644 Prebuild/src/Core/Parse/.svn/text-base/Preprocessor.cs.svn-base create mode 100644 Prebuild/src/Core/Parse/IfContext.cs create mode 100644 Prebuild/src/Core/Parse/Preprocessor.cs create mode 100644 Prebuild/src/Core/Targets/.NAntTarget.cs.swp create mode 100644 Prebuild/src/Core/Targets/.svn/all-wcprops create mode 100644 Prebuild/src/Core/Targets/.svn/dir-prop-base create mode 100644 Prebuild/src/Core/Targets/.svn/entries create mode 100644 Prebuild/src/Core/Targets/.svn/prop-base/DebugTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/prop-base/MakefileTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/prop-base/MonoDevelopTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/prop-base/NAntTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/prop-base/SharpDevelopTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/prop-base/VS2002Target.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/prop-base/VS2003Target.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/prop-base/VS2005Target.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/prop-base/XcodeTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/AutotoolsTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/DebugTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/MakefileTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/MonoDevelopTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/NAntTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/SharpDevelop2Target.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/SharpDevelopTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/ToolInfo.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/VS2002Target.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/VS2003Target.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/VS2005Target.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/VS2008Target.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/VS2010Target.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/VSGenericTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/VSVersion.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/.svn/text-base/XcodeTarget.cs.svn-base create mode 100644 Prebuild/src/Core/Targets/AutotoolsTarget.cs create mode 100644 Prebuild/src/Core/Targets/DebugTarget.cs create mode 100644 Prebuild/src/Core/Targets/MakefileTarget.cs create mode 100644 Prebuild/src/Core/Targets/MonoDevelopTarget.cs create mode 100644 Prebuild/src/Core/Targets/NAntTarget.cs create mode 100644 Prebuild/src/Core/Targets/SharpDevelop2Target.cs create mode 100644 Prebuild/src/Core/Targets/SharpDevelopTarget.cs create mode 100644 Prebuild/src/Core/Targets/ToolInfo.cs create mode 100644 Prebuild/src/Core/Targets/VS2002Target.cs create mode 100644 Prebuild/src/Core/Targets/VS2003Target.cs create mode 100644 Prebuild/src/Core/Targets/VS2005Target.cs create mode 100644 Prebuild/src/Core/Targets/VS2008Target.cs create mode 100644 Prebuild/src/Core/Targets/VS2010Target.cs create mode 100644 Prebuild/src/Core/Targets/VSGenericTarget.cs create mode 100644 Prebuild/src/Core/Targets/VSVersion.cs create mode 100644 Prebuild/src/Core/Targets/XcodeTarget.cs create mode 100644 Prebuild/src/Core/UnknownLanguageException.cs create mode 100644 Prebuild/src/Core/Utilities/.svn/all-wcprops create mode 100644 Prebuild/src/Core/Utilities/.svn/dir-prop-base create mode 100644 Prebuild/src/Core/Utilities/.svn/entries create mode 100644 Prebuild/src/Core/Utilities/.svn/prop-base/CommandLineCollection.cs.svn-base create mode 100644 Prebuild/src/Core/Utilities/.svn/prop-base/CurrentDirectory.cs.svn-base create mode 100644 Prebuild/src/Core/Utilities/.svn/prop-base/Helper.cs.svn-base create mode 100644 Prebuild/src/Core/Utilities/.svn/prop-base/Log.cs.svn-base create mode 100644 Prebuild/src/Core/Utilities/.svn/text-base/CommandLineCollection.cs.svn-base create mode 100644 Prebuild/src/Core/Utilities/.svn/text-base/CurrentDirectory.cs.svn-base create mode 100644 Prebuild/src/Core/Utilities/.svn/text-base/Helper.cs.svn-base create mode 100644 Prebuild/src/Core/Utilities/.svn/text-base/Log.cs.svn-base create mode 100644 Prebuild/src/Core/Utilities/CommandLineCollection.cs create mode 100644 Prebuild/src/Core/Utilities/CurrentDirectory.cs create mode 100644 Prebuild/src/Core/Utilities/Helper.cs create mode 100644 Prebuild/src/Core/Utilities/Log.cs create mode 100644 Prebuild/src/Core/WarningException.cs (limited to 'Prebuild/src/Core') diff --git a/Prebuild/src/Core/.svn/all-wcprops b/Prebuild/src/Core/.svn/all-wcprops new file mode 100644 index 0000000..5da53cf --- /dev/null +++ b/Prebuild/src/Core/.svn/all-wcprops @@ -0,0 +1,29 @@ +K 25 +svn:wc:ra_dav:version-url +V 50 +/svnroot/dnpb/!svn/ver/323/trunk/Prebuild/src/Core +END +Kernel.cs +K 25 +svn:wc:ra_dav:version-url +V 60 +/svnroot/dnpb/!svn/ver/323/trunk/Prebuild/src/Core/Kernel.cs +END +UnknownLanguageException.cs +K 25 +svn:wc:ra_dav:version-url +V 77 +/svnroot/dnpb/!svn/ver/96/trunk/Prebuild/src/Core/UnknownLanguageException.cs +END +WarningException.cs +K 25 +svn:wc:ra_dav:version-url +V 70 +/svnroot/dnpb/!svn/ver/298/trunk/Prebuild/src/Core/WarningException.cs +END +FatalException.cs +K 25 +svn:wc:ra_dav:version-url +V 68 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/FatalException.cs +END diff --git a/Prebuild/src/Core/.svn/dir-prop-base b/Prebuild/src/Core/.svn/dir-prop-base new file mode 100644 index 0000000..a1989a0 --- /dev/null +++ b/Prebuild/src/Core/.svn/dir-prop-base @@ -0,0 +1,5 @@ +K 10 +svn:ignore +V 5 +*.swp +END diff --git a/Prebuild/src/Core/.svn/entries b/Prebuild/src/Core/.svn/entries new file mode 100644 index 0000000..8497de9 --- /dev/null +++ b/Prebuild/src/Core/.svn/entries @@ -0,0 +1,182 @@ +10 + +dir +323 +https://dnpb.svn.sourceforge.net/svnroot/dnpb/trunk/Prebuild/src/Core +https://dnpb.svn.sourceforge.net/svnroot/dnpb + + + +2010-09-10T17:51:36.189738Z +323 +jhurliman +has-props + + + + + + + + + + + + + +3355ff64-970d-0410-bbe8-d0fbd18be4fb + +Interfaces +dir + +Kernel.cs +file + + + + +2010-09-10T22:51:44.000000Z +0fc816c335568995dd3f89bd47452727 +2010-09-10T17:51:36.189738Z +323 +jhurliman +has-props + + + + + + + + + + + + + + + + + + + + +20883 + +Attributes +dir + +UnknownLanguageException.cs +file + + + + +2010-09-10T22:51:44.000000Z +5ecd3d9972f0d59ad6c2b37b81c9aa6d +2006-01-28T00:49:58.000000Z +71 +jendave +has-props + + + + + + + + + + + + + + + + + + + + +1764 + +Nodes +dir + +WarningException.cs +file + + + + +2010-09-10T22:51:44.000000Z +316bb4928be4041587e4f12a29f7ccd6 +2009-02-20T02:15:45.530129Z +298 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +2625 + +Targets +dir + +Parse +dir + +FatalException.cs +file + + + + +2010-09-10T22:51:44.000000Z +1a328443d0e4a2705efc142c1161959b +2009-02-19T06:47:52.218324Z +295 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +2776 + +Utilities +dir + diff --git a/Prebuild/src/Core/.svn/prop-base/FatalException.cs.svn-base b/Prebuild/src/Core/.svn/prop-base/FatalException.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/.svn/prop-base/FatalException.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/.svn/prop-base/Kernel.cs.svn-base b/Prebuild/src/Core/.svn/prop-base/Kernel.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/.svn/prop-base/Kernel.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/.svn/prop-base/UnknownLanguageException.cs.svn-base b/Prebuild/src/Core/.svn/prop-base/UnknownLanguageException.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/.svn/prop-base/UnknownLanguageException.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/.svn/prop-base/WarningException.cs.svn-base b/Prebuild/src/Core/.svn/prop-base/WarningException.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/.svn/prop-base/WarningException.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/.svn/text-base/FatalException.cs.svn-base b/Prebuild/src/Core/.svn/text-base/FatalException.cs.svn-base new file mode 100644 index 0000000..3487905 --- /dev/null +++ b/Prebuild/src/Core/.svn/text-base/FatalException.cs.svn-base @@ -0,0 +1,85 @@ +#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.Runtime.Serialization; + +namespace Prebuild.Core +{ + /// + /// + /// + [Serializable()] + public class FatalException : Exception + { + #region Constructors + + + /// + /// Initializes a new instance of the class. + /// + public FatalException() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The format. + /// The args. + public FatalException(string format, params object[] args) + : base(String.Format(format, args)) + { + } + + /// + /// Exception with specified string + /// + /// Exception message + public FatalException(string message): base(message) + { + } + + /// + /// + /// + /// + /// + public FatalException(string message, Exception exception) : base(message, exception) + { + } + + /// + /// + /// + /// + /// + protected FatalException(SerializationInfo info, StreamingContext context) : base( info, context ) + { + } + + #endregion + } +} diff --git a/Prebuild/src/Core/.svn/text-base/Kernel.cs.svn-base b/Prebuild/src/Core/.svn/text-base/Kernel.cs.svn-base new file mode 100644 index 0000000..67051d5 --- /dev/null +++ b/Prebuild/src/Core/.svn/text-base/Kernel.cs.svn-base @@ -0,0 +1,832 @@ +#region BSD License +/* +Copyright (c) 2004-2008 +Matthew Holmes (matthew@wildfiregames.com), +Dan Moorehead (dan05a@gmail.com), +Rob Loach (http://www.robloach.net), +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 + +#define NO_VALIDATE + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Xml; +using System.Xml.Schema; +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core +{ + /// + /// + /// + public class Kernel : IDisposable + { + #region Inner Classes + + private struct NodeEntry + { + public Type Type; + public DataNodeAttribute Attribute; + } + + #endregion + + #region Fields + + private static readonly Kernel m_Instance = new Kernel(); + + /// + /// This must match the version of the schema that is embeeded + /// + private const string m_SchemaVersion = "1.9"; + private const string m_Schema = "prebuild-" + m_SchemaVersion + ".xsd"; + private const string m_SchemaURI = "http://dnpb.sourceforge.net/schemas/" + m_Schema; + bool disposed; + private Version m_Version; + private const string m_Revision = ""; + private CommandLineCollection m_CommandLine; + private Log m_Log; + private CurrentDirectory m_CurrentWorkingDirectory; + private XmlSchemaCollection m_Schemas; + + private readonly Dictionary m_Targets = new Dictionary(); + private readonly Dictionary m_Nodes = new Dictionary(); + + readonly List m_Solutions = new List(); + string m_Target; + string m_Clean; + string[] m_RemoveDirectories; + XmlDocument m_CurrentDoc; + bool m_PauseAfterFinish; + string[] m_ProjectGroups; + + #endregion + + #region Constructors + + private Kernel() + { + } + + #endregion + + #region Properties + + /// + /// Gets a value indicating whether [pause after finish]. + /// + /// true if [pause after finish]; otherwise, false. + public bool PauseAfterFinish + { + get + { + return m_PauseAfterFinish; + } + } + + /// + /// Gets the instance. + /// + /// The instance. + public static Kernel Instance + { + get + { + return m_Instance; + } + } + + /// + /// Gets the version. + /// + /// The version. + public string Version + { + get + { + return String.Format("{0}.{1}.{2}{3}", m_Version.Major, m_Version.Minor, m_Version.Build, m_Revision); + } + } + + /// + /// Gets the command line. + /// + /// The command line. + public CommandLineCollection CommandLine + { + get + { + return m_CommandLine; + } + } + + /// + /// Gets the targets. + /// + /// The targets. + public Dictionary Targets + { + get + { + return m_Targets; + } + } + + /// + /// Gets the log. + /// + /// The log. + public Log Log + { + get + { + return m_Log; + } + } + + /// + /// Gets the current working directory. + /// + /// The current working directory. + public CurrentDirectory CurrentWorkingDirectory + { + get + { + return m_CurrentWorkingDirectory; + } + } + + /// + /// Gets the solutions. + /// + /// The solutions. + public List Solutions + { + get + { + return m_Solutions; + } + } + + /// + /// Gets the XmlDocument object representing the prebuild.xml + /// being processed + /// + /// The XmlDocument object + public XmlDocument CurrentDoc + { + get + { + return m_CurrentDoc; + } + } + + #endregion + + #region Private Methods + + private static void RemoveDirectories(string rootDir, string[] dirNames) + { + foreach(string dir in Directory.GetDirectories(rootDir)) + { + string simpleName = Path.GetFileName(dir); + + if(Array.IndexOf(dirNames, simpleName) != -1) + { + //delete if the name matches one of the directory names to delete + string fullDirPath = Path.GetFullPath(dir); + Directory.Delete(fullDirPath,true); + } + else//not a match, so check children + { + RemoveDirectories(dir,dirNames); + //recurse, checking children for them + } + } + } + +// private void RemoveDirectoryMatches(string rootDir, string dirPattern) +// { +// foreach(string dir in Directory.GetDirectories(rootDir)) +// { +// foreach(string match in Directory.GetDirectories(dir)) +// {//delete all child directories that match +// Directory.Delete(Path.GetFullPath(match),true); +// } +// //recure through the rest checking for nested matches to delete +// RemoveDirectoryMatches(dir,dirPattern); +// } +// } + + private void LoadSchema() + { + Assembly assembly = GetType().Assembly; + Stream stream = assembly.GetManifestResourceStream("Prebuild.data." + m_Schema); + if(stream == null) + { + //try without the default namespace prepending to it in case was compiled with SharpDevelop or MonoDevelop instead of Visual Studio .NET + stream = assembly.GetManifestResourceStream(m_Schema); + if(stream == null) + { + throw new System.Reflection.TargetException(string.Format("Could not find the scheme embedded resource file '{0}'.", m_Schema)); + } + } + XmlReader schema = new XmlTextReader(stream); + + m_Schemas = new XmlSchemaCollection(); + m_Schemas.Add(m_SchemaURI, schema); + } + + private void CacheVersion() + { + m_Version = Assembly.GetEntryAssembly().GetName().Version; + } + + private void CacheTargets(Assembly assm) + { + foreach(Type t in assm.GetTypes()) + { + TargetAttribute ta = (TargetAttribute)Helper.CheckType(t, typeof(TargetAttribute), typeof(ITarget)); + + if(ta == null) + continue; + + if (t.IsAbstract) + continue; + + ITarget target = (ITarget)assm.CreateInstance(t.FullName); + if (target == null) + { + throw new MissingMethodException("Could not create ITarget instance"); + } + + m_Targets[ta.Name] = target; + } + } + + private void CacheNodeTypes(Assembly assm) + { + foreach(Type t in assm.GetTypes()) + { + foreach (DataNodeAttribute dna in t.GetCustomAttributes(typeof(DataNodeAttribute), true)) + { + NodeEntry ne = new NodeEntry(); + ne.Type = t; + ne.Attribute = dna; + m_Nodes[dna.Name] = ne; + } + } + } + + private void LogBanner() + { + m_Log.Write("Prebuild v" + Version); + m_Log.Write("Copyright (c) 2004-2010"); + m_Log.Write("Matthew Holmes (matthew@wildfiregames.com),"); + m_Log.Write("Dan Moorehead (dan05a@gmail.com),"); + m_Log.Write("David Hudson (jendave@yahoo.com),"); + m_Log.Write("Rob Loach (http://www.robloach.net),"); + m_Log.Write("C.J. Adams-Collier (cjac@colliertech.org),"); + m_Log.Write("John Hurliman (john.hurliman@intel.com),"); + + m_Log.Write("See 'prebuild /usage' for help"); + m_Log.Write(); + } + + + + private void ProcessFile(string file) + { + ProcessFile(file, m_Solutions); + } + + public void ProcessFile(ProcessNode node, SolutionNode parent) + { + if (node.IsValid) + { + List list = new List(); + ProcessFile(node.Path, list); + + foreach (SolutionNode solution in list) + parent.SolutionsTable[solution.Name] = solution; + } + } + + /// + /// + /// + /// + /// + /// + public void ProcessFile(string file, IList solutions) + { + m_CurrentWorkingDirectory.Push(); + + string path = file; + try + { + try + { + path = Helper.ResolvePath(path); + } + catch(ArgumentException) + { + m_Log.Write("Could not open Prebuild file: " + path); + m_CurrentWorkingDirectory.Pop(); + return; + } + + Helper.SetCurrentDir(Path.GetDirectoryName(path)); + + XmlTextReader reader = new XmlTextReader(path); + + Core.Parse.Preprocessor pre = new Core.Parse.Preprocessor(); + + //register command line arguments as XML variables + IEnumerator> dict = m_CommandLine.GetEnumerator(); + while (dict.MoveNext()) + { + string name = dict.Current.Key.Trim(); + if (name.Length > 0) + pre.RegisterVariable(name, dict.Current.Value); + } + + string xml = pre.Process(reader);//remove script and evaulate pre-proccessing to get schema-conforming XML + + // See if the user put into a pseudo target of "prebuild:preprocessed-input" to indicate they want to see the + // output before the system processes it. + if (m_CommandLine.WasPassed("ppi")) + { + // Get the filename if there is one, otherwise use a default. + string ppiFile = m_CommandLine["ppi"]; + if (ppiFile == null || ppiFile.Trim().Length == 0) + { + ppiFile = "preprocessed-input.xml"; + } + + // Write out the string to the given stream. + try + { + using (StreamWriter ppiWriter = new StreamWriter(ppiFile)) + { + ppiWriter.WriteLine(xml); + } + } + catch(IOException ex) + { + Console.WriteLine("Could not write PPI file '{0}': {1}", ppiFile, ex.Message); + } + + // Finish processing this special tag. + return; + } + + m_CurrentDoc = new XmlDocument(); + try + { +#if NO_VALIDATE + XmlReader validator = XmlReader.Create(new StringReader(xml)); + m_CurrentDoc.Load(validator); +#else + XmlValidatingReader validator = new XmlValidatingReader(new XmlTextReader(new StringReader(xml))); + + //validate while reading from string into XmlDocument DOM structure in memory + foreach(XmlSchema schema in m_Schemas) + { + validator.Schemas.Add(schema); + } + m_CurrentDoc.Load(validator); +#endif + } + catch(XmlException e) + { + throw new XmlException(e.ToString()); + } + + //is there a purpose to writing it? An syntax/schema problem would have been found during pre.Process() and reported with details + if(m_CommandLine.WasPassed("ppo")) + { + string ppoFile = m_CommandLine["ppo"]; + if(ppoFile == null || ppoFile.Trim().Length < 1) + { + ppoFile = "preprocessed.xml"; + } + + StreamWriter writer = null; + try + { + writer = new StreamWriter(ppoFile); + writer.Write(xml); + } + catch(IOException ex) + { + Console.WriteLine("Could not write PPO file '{0}': {1}", ppoFile, ex.Message); + } + finally + { + if(writer != null) + { + writer.Close(); + } + } + return; + } + //start reading the xml config file + XmlElement rootNode = m_CurrentDoc.DocumentElement; + //string suggestedVersion = Helper.AttributeValue(rootNode,"version","1.0"); + Helper.CheckForOSVariables = Helper.ParseBoolean(rootNode,"checkOsVars",false); + + foreach(XmlNode node in rootNode.ChildNodes)//solutions or if pre-proc instructions + { + IDataNode dataNode = ParseNode(node, null); + if(dataNode is ProcessNode) + { + ProcessNode proc = (ProcessNode)dataNode; + if(proc.IsValid) + { + ProcessFile(proc.Path); + } + } + else if(dataNode is SolutionNode) + { + solutions.Add((SolutionNode)dataNode); + } + } + } + catch(XmlSchemaException xse) + { + m_Log.Write("XML validation error at line {0} in {1}:\n\n{2}", + xse.LineNumber, path, xse.Message); + } + finally + { + m_CurrentWorkingDirectory.Pop(); + } + } + + #endregion + + #region Public Methods + + /// + /// Allows the project. + /// + /// The project groups flags. + /// + public bool AllowProject(string projectGroupsFlags) + { + if(m_ProjectGroups != null && m_ProjectGroups.Length > 0) + { + if(projectGroupsFlags != null && projectGroupsFlags.Length == 0) + { + foreach(string group in projectGroupsFlags.Split('|')) + { + if(Array.IndexOf(m_ProjectGroups, group) != -1) //if included in the filter list + { + return true; + } + } + } + return false;//not included in the list or no groups specified for the project + } + return true;//no filter specified in the command line args + } + + /// + /// Gets the type of the node. + /// + /// The node. + /// + public Type GetNodeType(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + if(!m_Nodes.ContainsKey(node.Name)) + { + return null; + } + + NodeEntry ne = m_Nodes[node.Name]; + return ne.Type; + } + + /// + /// + /// + /// + /// + /// + public IDataNode ParseNode(XmlNode node, IDataNode parent) + { + return ParseNode(node, parent, null); + } + + //Create an instance of the data node type that is mapped to the name of the xml DOM node + /// + /// Parses the node. + /// + /// The node. + /// The parent. + /// The pre node. + /// + public IDataNode ParseNode(XmlNode node, IDataNode parent, IDataNode preNode) + { + IDataNode dataNode; + + try + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + if(preNode == null) + { + if(!m_Nodes.ContainsKey(node.Name)) + { + Console.WriteLine("WARNING: Unknown XML node: " + node.Name); + return null; + } + + NodeEntry ne = m_Nodes[node.Name]; + Type type = ne.Type; + //DataNodeAttribute dna = ne.Attribute; + + dataNode = (IDataNode)type.Assembly.CreateInstance(type.FullName); + if(dataNode == null) + { + throw new System.Reflection.TargetException("Could not create new parser instance: " + type.FullName); + } + } + else + dataNode = preNode; + + dataNode.Parent = parent; + dataNode.Parse(node); + } + catch(WarningException wex) + { + m_Log.Write(LogType.Warning, wex.Message); + return null; + } + catch(FatalException fex) + { + m_Log.WriteException(LogType.Error, fex); + throw; + } + catch(Exception ex) + { + m_Log.WriteException(LogType.Error, ex); + throw; + } + + return dataNode; + } + + /// + /// Initializes the specified target. + /// + /// The target. + /// The args. + public void Initialize(LogTargets target, string[] args) + { + CacheTargets(GetType().Assembly); + CacheNodeTypes(GetType().Assembly); + CacheVersion(); + + m_CommandLine = new CommandLineCollection(args); + + string logFile = null; + if(m_CommandLine.WasPassed("log")) + { + logFile = m_CommandLine["log"]; + + if(logFile != null && logFile.Length == 0) + { + logFile = "Prebuild.log"; + } + } + else + { + target = target & ~LogTargets.File; //dont output to a file + } + + m_Log = new Log(target, logFile); + LogBanner(); + + m_CurrentWorkingDirectory = new CurrentDirectory(); + + m_Target = m_CommandLine["target"]; + m_Clean = m_CommandLine["clean"]; + string removeDirs = m_CommandLine["removedir"]; + if(removeDirs != null && removeDirs.Length == 0) + { + m_RemoveDirectories = removeDirs.Split('|'); + } + + string flags = m_CommandLine["allowedgroups"];//allows filtering by specifying a pipe-delimited list of groups to include + if(flags != null && flags.Length == 0) + { + m_ProjectGroups = flags.Split('|'); + } + m_PauseAfterFinish = m_CommandLine.WasPassed("pause"); + + LoadSchema(); + } + + /// + /// Processes this instance. + /// + public void Process() + { + bool perfomedOtherTask = false; + if(m_RemoveDirectories != null && m_RemoveDirectories.Length > 0) + { + try + { + RemoveDirectories(".",m_RemoveDirectories); + } + catch(IOException e) + { + m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories); + m_Log.WriteException(LogType.Error,e); + } + catch(UnauthorizedAccessException e) + { + m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories); + m_Log.WriteException(LogType.Error,e); + } + perfomedOtherTask = true; + } + + if(m_Target != null && m_Clean != null) + { + m_Log.Write(LogType.Error, "The options /target and /clean cannot be passed together"); + return; + } + + if(m_Target == null && m_Clean == null) + { + if(perfomedOtherTask) //finished + { + return; + } + m_Log.Write(LogType.Error, "Must pass either /target or /clean to process a Prebuild file"); + return; + } + + string file = "./prebuild.xml"; + if(m_CommandLine.WasPassed("file")) + { + file = m_CommandLine["file"]; + } + + ProcessFile(file); + + string target = (m_Target != null ? m_Target.ToLower() : m_Clean.ToLower()); + bool clean = (m_Target == null); + if(clean && target != null && target.Length == 0) + { + target = "all"; + } + if(clean && target == "all")//default to all if no target was specified for clean + { + //check if they passed yes + if (!m_CommandLine.WasPassed("yes")) + { + Console.WriteLine("WARNING: This operation will clean ALL project files for all targets, are you sure? (y/n):"); + string ret = Console.ReadLine(); + if(ret == null) + { + return; + } + ret = ret.Trim().ToLower(); + if((ret.ToLower() != "y" && ret.ToLower() != "yes")) + { + return; + } + } + //clean all targets (just cleaning vs2002 target didn't clean nant) + foreach(ITarget targ in m_Targets.Values) + { + targ.Clean(this); + } + } + else + { + if (!m_Targets.ContainsKey(target)) { + m_Log.Write(LogType.Error, "Unknown Target \"{0}\"", target); + return; + } + ITarget targ = m_Targets[target]; + + if(clean) + { + targ.Clean(this); + } + else + { + targ.Write(this); + } + } + + m_Log.Flush(); + } + + #endregion + + #region IDisposable Members + + /// + /// + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Dispose objects + /// + /// + /// If true, it will dispose close the handle + /// + /// + /// Will dispose managed and unmanaged resources. + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + GC.SuppressFinalize(this); + if (m_Log != null) + { + m_Log.Close(); + m_Log = null; + } + } + } + disposed = true; + } + + /// + /// + /// + ~Kernel() + { + Dispose(false); + } + + /// + /// Closes and destroys this object + /// + /// + /// Same as Dispose(true) + /// + public void Close() + { + Dispose(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/.svn/text-base/UnknownLanguageException.cs.svn-base b/Prebuild/src/Core/.svn/text-base/UnknownLanguageException.cs.svn-base new file mode 100644 index 0000000..607b66c --- /dev/null +++ b/Prebuild/src/Core/.svn/text-base/UnknownLanguageException.cs.svn-base @@ -0,0 +1,63 @@ +/* + * $RCSfile$ + * Copyright (C) 2004, 2005 David Hudson (jendave@yahoo.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +using System; +using System.Runtime.Serialization; + +namespace Prebuild.Core +{ + /// + /// + [Serializable()] + public class UnknownLanguageException : Exception + { + /// + /// Basic exception. + /// + public UnknownLanguageException() + { + } + + /// + /// Exception with specified string + /// + /// Exception message + public UnknownLanguageException(string message): base(message) + { + } + + /// + /// + /// + /// + /// + public UnknownLanguageException(string message, Exception exception) : base(message, exception) + { + } + + /// + /// + /// + /// + /// + protected UnknownLanguageException(SerializationInfo info, StreamingContext context) : base( info, context ) + { + } + } +} diff --git a/Prebuild/src/Core/.svn/text-base/WarningException.cs.svn-base b/Prebuild/src/Core/.svn/text-base/WarningException.cs.svn-base new file mode 100644 index 0000000..b7c3668 --- /dev/null +++ b/Prebuild/src/Core/.svn/text-base/WarningException.cs.svn-base @@ -0,0 +1,84 @@ +#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.Runtime.Serialization; + +namespace Prebuild.Core +{ + /// + /// + /// + [Serializable] + public class WarningException : Exception + { + #region Constructors + + /// + /// + /// + public WarningException() + { + } + + /// + /// + /// + /// + /// + public WarningException(string format, params object[] args) + : base(String.Format(format, args)) + { + } + + /// + /// Exception with specified string + /// + /// Exception message + public WarningException(string message): base(message) + { + } + + /// + /// + /// + /// + /// + public WarningException(string message, Exception exception) : base(message, exception) + { + } + + /// + /// + /// + /// + /// + protected WarningException(SerializationInfo info, StreamingContext context) : base( info, context ) + { + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Attributes/.svn/all-wcprops b/Prebuild/src/Core/Attributes/.svn/all-wcprops new file mode 100644 index 0000000..bb28016 --- /dev/null +++ b/Prebuild/src/Core/Attributes/.svn/all-wcprops @@ -0,0 +1,23 @@ +K 25 +svn:wc:ra_dav:version-url +V 61 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/Attributes +END +OptionNodeAttribute.cs +K 25 +svn:wc:ra_dav:version-url +V 84 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs +END +DataNodeAttribute.cs +K 25 +svn:wc:ra_dav:version-url +V 82 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/Attributes/DataNodeAttribute.cs +END +TargetAttribute.cs +K 25 +svn:wc:ra_dav:version-url +V 80 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/Attributes/TargetAttribute.cs +END diff --git a/Prebuild/src/Core/Attributes/.svn/dir-prop-base b/Prebuild/src/Core/Attributes/.svn/dir-prop-base new file mode 100644 index 0000000..a1989a0 --- /dev/null +++ b/Prebuild/src/Core/Attributes/.svn/dir-prop-base @@ -0,0 +1,5 @@ +K 10 +svn:ignore +V 5 +*.swp +END diff --git a/Prebuild/src/Core/Attributes/.svn/entries b/Prebuild/src/Core/Attributes/.svn/entries new file mode 100644 index 0000000..1ce535e --- /dev/null +++ b/Prebuild/src/Core/Attributes/.svn/entries @@ -0,0 +1,130 @@ +10 + +dir +323 +https://dnpb.svn.sourceforge.net/svnroot/dnpb/trunk/Prebuild/src/Core/Attributes +https://dnpb.svn.sourceforge.net/svnroot/dnpb + + + +2009-02-19T06:47:52.218324Z +295 +kunnis +has-props + + + + + + + + + + + + + +3355ff64-970d-0410-bbe8-d0fbd18be4fb + +OptionNodeAttribute.cs +file + + + + +2010-09-10T22:51:44.000000Z +fe1b8740374f76dcb84f73de54376d48 +2009-02-19T06:47:52.218324Z +295 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +2240 + +DataNodeAttribute.cs +file + + + + +2010-09-10T22:51:44.000000Z +7988716ebc1c723842814e3eec197831 +2009-02-19T06:47:52.218324Z +295 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +2270 + +TargetAttribute.cs +file + + + + +2010-09-10T22:51:44.000000Z +766d4782c2b50f82a7c98e1eb968f42d +2009-02-19T06:47:52.218324Z +295 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +2194 + diff --git a/Prebuild/src/Core/Attributes/.svn/prop-base/DataNodeAttribute.cs.svn-base b/Prebuild/src/Core/Attributes/.svn/prop-base/DataNodeAttribute.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Attributes/.svn/prop-base/DataNodeAttribute.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Attributes/.svn/prop-base/OptionNodeAttribute.cs.svn-base b/Prebuild/src/Core/Attributes/.svn/prop-base/OptionNodeAttribute.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Attributes/.svn/prop-base/OptionNodeAttribute.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Attributes/.svn/prop-base/TargetAttribute.cs.svn-base b/Prebuild/src/Core/Attributes/.svn/prop-base/TargetAttribute.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Attributes/.svn/prop-base/TargetAttribute.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Attributes/.svn/text-base/DataNodeAttribute.cs.svn-base b/Prebuild/src/Core/Attributes/.svn/text-base/DataNodeAttribute.cs.svn-base new file mode 100644 index 0000000..f1938a2 --- /dev/null +++ b/Prebuild/src/Core/Attributes/.svn/text-base/DataNodeAttribute.cs.svn-base @@ -0,0 +1,72 @@ +#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.Specialized; + +namespace Prebuild.Core.Attributes +{ + /// + /// + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple=true)] + public sealed class DataNodeAttribute : Attribute + { + #region Fields + + private string m_Name = "unknown"; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The name. + public DataNodeAttribute(string name) + { + m_Name = name; + } + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Attributes/.svn/text-base/OptionNodeAttribute.cs.svn-base b/Prebuild/src/Core/Attributes/.svn/text-base/OptionNodeAttribute.cs.svn-base new file mode 100644 index 0000000..2d6a6a7 --- /dev/null +++ b/Prebuild/src/Core/Attributes/.svn/text-base/OptionNodeAttribute.cs.svn-base @@ -0,0 +1,71 @@ +#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; + +namespace Prebuild.Core.Attributes +{ + /// + /// + /// + [AttributeUsage(AttributeTargets.Field)] + public sealed class OptionNodeAttribute : Attribute + { + #region Fields + + private string m_NodeName; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// Name of the node. + public OptionNodeAttribute(string nodeName) + { + m_NodeName = nodeName; + } + + #endregion + + #region Properties + + /// + /// Gets the name of the node. + /// + /// The name of the node. + public string NodeName + { + get + { + return m_NodeName; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Attributes/.svn/text-base/TargetAttribute.cs.svn-base b/Prebuild/src/Core/Attributes/.svn/text-base/TargetAttribute.cs.svn-base new file mode 100644 index 0000000..5ad62ee --- /dev/null +++ b/Prebuild/src/Core/Attributes/.svn/text-base/TargetAttribute.cs.svn-base @@ -0,0 +1,71 @@ +#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; + +namespace Prebuild.Core.Attributes +{ + /// + /// + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] + public sealed class TargetAttribute : Attribute + { + #region Fields + + private string m_Name; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The name. + public TargetAttribute(string name) + { + m_Name = name; + } + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Attributes/DataNodeAttribute.cs b/Prebuild/src/Core/Attributes/DataNodeAttribute.cs new file mode 100644 index 0000000..f1938a2 --- /dev/null +++ b/Prebuild/src/Core/Attributes/DataNodeAttribute.cs @@ -0,0 +1,72 @@ +#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.Specialized; + +namespace Prebuild.Core.Attributes +{ + /// + /// + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple=true)] + public sealed class DataNodeAttribute : Attribute + { + #region Fields + + private string m_Name = "unknown"; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The name. + public DataNodeAttribute(string name) + { + m_Name = name; + } + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs b/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs new file mode 100644 index 0000000..2d6a6a7 --- /dev/null +++ b/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs @@ -0,0 +1,71 @@ +#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; + +namespace Prebuild.Core.Attributes +{ + /// + /// + /// + [AttributeUsage(AttributeTargets.Field)] + public sealed class OptionNodeAttribute : Attribute + { + #region Fields + + private string m_NodeName; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// Name of the node. + public OptionNodeAttribute(string nodeName) + { + m_NodeName = nodeName; + } + + #endregion + + #region Properties + + /// + /// Gets the name of the node. + /// + /// The name of the node. + public string NodeName + { + get + { + return m_NodeName; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Attributes/TargetAttribute.cs b/Prebuild/src/Core/Attributes/TargetAttribute.cs new file mode 100644 index 0000000..5ad62ee --- /dev/null +++ b/Prebuild/src/Core/Attributes/TargetAttribute.cs @@ -0,0 +1,71 @@ +#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; + +namespace Prebuild.Core.Attributes +{ + /// + /// + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] + public sealed class TargetAttribute : Attribute + { + #region Fields + + private string m_Name; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The name. + public TargetAttribute(string name) + { + m_Name = name; + } + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/FatalException.cs b/Prebuild/src/Core/FatalException.cs new file mode 100644 index 0000000..3487905 --- /dev/null +++ b/Prebuild/src/Core/FatalException.cs @@ -0,0 +1,85 @@ +#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.Runtime.Serialization; + +namespace Prebuild.Core +{ + /// + /// + /// + [Serializable()] + public class FatalException : Exception + { + #region Constructors + + + /// + /// Initializes a new instance of the class. + /// + public FatalException() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The format. + /// The args. + public FatalException(string format, params object[] args) + : base(String.Format(format, args)) + { + } + + /// + /// Exception with specified string + /// + /// Exception message + public FatalException(string message): base(message) + { + } + + /// + /// + /// + /// + /// + public FatalException(string message, Exception exception) : base(message, exception) + { + } + + /// + /// + /// + /// + /// + protected FatalException(SerializationInfo info, StreamingContext context) : base( info, context ) + { + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Interfaces/.svn/all-wcprops b/Prebuild/src/Core/Interfaces/.svn/all-wcprops new file mode 100644 index 0000000..0359de2 --- /dev/null +++ b/Prebuild/src/Core/Interfaces/.svn/all-wcprops @@ -0,0 +1,17 @@ +K 25 +svn:wc:ra_dav:version-url +V 61 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/Interfaces +END +ITarget.cs +K 25 +svn:wc:ra_dav:version-url +V 72 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/Interfaces/ITarget.cs +END +IDataNode.cs +K 25 +svn:wc:ra_dav:version-url +V 74 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/Interfaces/IDataNode.cs +END diff --git a/Prebuild/src/Core/Interfaces/.svn/dir-prop-base b/Prebuild/src/Core/Interfaces/.svn/dir-prop-base new file mode 100644 index 0000000..a1989a0 --- /dev/null +++ b/Prebuild/src/Core/Interfaces/.svn/dir-prop-base @@ -0,0 +1,5 @@ +K 10 +svn:ignore +V 5 +*.swp +END diff --git a/Prebuild/src/Core/Interfaces/.svn/entries b/Prebuild/src/Core/Interfaces/.svn/entries new file mode 100644 index 0000000..0ff8913 --- /dev/null +++ b/Prebuild/src/Core/Interfaces/.svn/entries @@ -0,0 +1,96 @@ +10 + +dir +323 +https://dnpb.svn.sourceforge.net/svnroot/dnpb/trunk/Prebuild/src/Core/Interfaces +https://dnpb.svn.sourceforge.net/svnroot/dnpb + + + +2009-02-19T06:47:52.218324Z +295 +kunnis +has-props + + + + + + + + + + + + + +3355ff64-970d-0410-bbe8-d0fbd18be4fb + +ITarget.cs +file + + + + +2010-09-10T22:51:44.000000Z +52c732d42919f00330b2c4ed8b6360f8 +2009-02-19T06:47:52.218324Z +295 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +1984 + +IDataNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +0ff6737b55b9bc4c63f9143c367a7e62 +2009-02-19T06:47:52.218324Z +295 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +1900 + diff --git a/Prebuild/src/Core/Interfaces/.svn/prop-base/IDataNode.cs.svn-base b/Prebuild/src/Core/Interfaces/.svn/prop-base/IDataNode.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Interfaces/.svn/prop-base/IDataNode.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Interfaces/.svn/prop-base/ITarget.cs.svn-base b/Prebuild/src/Core/Interfaces/.svn/prop-base/ITarget.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Interfaces/.svn/prop-base/ITarget.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Interfaces/.svn/text-base/IDataNode.cs.svn-base b/Prebuild/src/Core/Interfaces/.svn/text-base/IDataNode.cs.svn-base new file mode 100644 index 0000000..986dd2d --- /dev/null +++ b/Prebuild/src/Core/Interfaces/.svn/text-base/IDataNode.cs.svn-base @@ -0,0 +1,47 @@ +#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.Xml; + +namespace Prebuild.Core.Interfaces +{ + /// + /// + /// + public interface IDataNode + { + /// + /// Gets or sets the parent. + /// + /// The parent. + IDataNode Parent { get; set; } + /// + /// Parses the specified node. + /// + /// The node. + void Parse(XmlNode node); + } +} diff --git a/Prebuild/src/Core/Interfaces/.svn/text-base/ITarget.cs.svn-base b/Prebuild/src/Core/Interfaces/.svn/text-base/ITarget.cs.svn-base new file mode 100644 index 0000000..47115c6 --- /dev/null +++ b/Prebuild/src/Core/Interfaces/.svn/text-base/ITarget.cs.svn-base @@ -0,0 +1,51 @@ +#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; + +namespace Prebuild.Core.Interfaces +{ + /// + /// + /// + public interface ITarget + { + /// + /// Writes the specified kern. + /// + /// The kern. + void Write(Kernel kern); + /// + /// Cleans the specified kern. + /// + /// The kern. + void Clean(Kernel kern); + /// + /// Gets the name. + /// + /// The name. + string Name { get; } + } +} \ No newline at end of file diff --git a/Prebuild/src/Core/Interfaces/IDataNode.cs b/Prebuild/src/Core/Interfaces/IDataNode.cs new file mode 100644 index 0000000..986dd2d --- /dev/null +++ b/Prebuild/src/Core/Interfaces/IDataNode.cs @@ -0,0 +1,47 @@ +#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.Xml; + +namespace Prebuild.Core.Interfaces +{ + /// + /// + /// + public interface IDataNode + { + /// + /// Gets or sets the parent. + /// + /// The parent. + IDataNode Parent { get; set; } + /// + /// Parses the specified node. + /// + /// The node. + void Parse(XmlNode node); + } +} diff --git a/Prebuild/src/Core/Interfaces/ITarget.cs b/Prebuild/src/Core/Interfaces/ITarget.cs new file mode 100644 index 0000000..47115c6 --- /dev/null +++ b/Prebuild/src/Core/Interfaces/ITarget.cs @@ -0,0 +1,51 @@ +#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; + +namespace Prebuild.Core.Interfaces +{ + /// + /// + /// + public interface ITarget + { + /// + /// Writes the specified kern. + /// + /// The kern. + void Write(Kernel kern); + /// + /// Cleans the specified kern. + /// + /// The kern. + void Clean(Kernel kern); + /// + /// Gets the name. + /// + /// The name. + string Name { get; } + } +} \ No newline at end of file diff --git a/Prebuild/src/Core/Kernel.cs b/Prebuild/src/Core/Kernel.cs new file mode 100644 index 0000000..67051d5 --- /dev/null +++ b/Prebuild/src/Core/Kernel.cs @@ -0,0 +1,832 @@ +#region BSD License +/* +Copyright (c) 2004-2008 +Matthew Holmes (matthew@wildfiregames.com), +Dan Moorehead (dan05a@gmail.com), +Rob Loach (http://www.robloach.net), +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 + +#define NO_VALIDATE + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Xml; +using System.Xml.Schema; +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core +{ + /// + /// + /// + public class Kernel : IDisposable + { + #region Inner Classes + + private struct NodeEntry + { + public Type Type; + public DataNodeAttribute Attribute; + } + + #endregion + + #region Fields + + private static readonly Kernel m_Instance = new Kernel(); + + /// + /// This must match the version of the schema that is embeeded + /// + private const string m_SchemaVersion = "1.9"; + private const string m_Schema = "prebuild-" + m_SchemaVersion + ".xsd"; + private const string m_SchemaURI = "http://dnpb.sourceforge.net/schemas/" + m_Schema; + bool disposed; + private Version m_Version; + private const string m_Revision = ""; + private CommandLineCollection m_CommandLine; + private Log m_Log; + private CurrentDirectory m_CurrentWorkingDirectory; + private XmlSchemaCollection m_Schemas; + + private readonly Dictionary m_Targets = new Dictionary(); + private readonly Dictionary m_Nodes = new Dictionary(); + + readonly List m_Solutions = new List(); + string m_Target; + string m_Clean; + string[] m_RemoveDirectories; + XmlDocument m_CurrentDoc; + bool m_PauseAfterFinish; + string[] m_ProjectGroups; + + #endregion + + #region Constructors + + private Kernel() + { + } + + #endregion + + #region Properties + + /// + /// Gets a value indicating whether [pause after finish]. + /// + /// true if [pause after finish]; otherwise, false. + public bool PauseAfterFinish + { + get + { + return m_PauseAfterFinish; + } + } + + /// + /// Gets the instance. + /// + /// The instance. + public static Kernel Instance + { + get + { + return m_Instance; + } + } + + /// + /// Gets the version. + /// + /// The version. + public string Version + { + get + { + return String.Format("{0}.{1}.{2}{3}", m_Version.Major, m_Version.Minor, m_Version.Build, m_Revision); + } + } + + /// + /// Gets the command line. + /// + /// The command line. + public CommandLineCollection CommandLine + { + get + { + return m_CommandLine; + } + } + + /// + /// Gets the targets. + /// + /// The targets. + public Dictionary Targets + { + get + { + return m_Targets; + } + } + + /// + /// Gets the log. + /// + /// The log. + public Log Log + { + get + { + return m_Log; + } + } + + /// + /// Gets the current working directory. + /// + /// The current working directory. + public CurrentDirectory CurrentWorkingDirectory + { + get + { + return m_CurrentWorkingDirectory; + } + } + + /// + /// Gets the solutions. + /// + /// The solutions. + public List Solutions + { + get + { + return m_Solutions; + } + } + + /// + /// Gets the XmlDocument object representing the prebuild.xml + /// being processed + /// + /// The XmlDocument object + public XmlDocument CurrentDoc + { + get + { + return m_CurrentDoc; + } + } + + #endregion + + #region Private Methods + + private static void RemoveDirectories(string rootDir, string[] dirNames) + { + foreach(string dir in Directory.GetDirectories(rootDir)) + { + string simpleName = Path.GetFileName(dir); + + if(Array.IndexOf(dirNames, simpleName) != -1) + { + //delete if the name matches one of the directory names to delete + string fullDirPath = Path.GetFullPath(dir); + Directory.Delete(fullDirPath,true); + } + else//not a match, so check children + { + RemoveDirectories(dir,dirNames); + //recurse, checking children for them + } + } + } + +// private void RemoveDirectoryMatches(string rootDir, string dirPattern) +// { +// foreach(string dir in Directory.GetDirectories(rootDir)) +// { +// foreach(string match in Directory.GetDirectories(dir)) +// {//delete all child directories that match +// Directory.Delete(Path.GetFullPath(match),true); +// } +// //recure through the rest checking for nested matches to delete +// RemoveDirectoryMatches(dir,dirPattern); +// } +// } + + private void LoadSchema() + { + Assembly assembly = GetType().Assembly; + Stream stream = assembly.GetManifestResourceStream("Prebuild.data." + m_Schema); + if(stream == null) + { + //try without the default namespace prepending to it in case was compiled with SharpDevelop or MonoDevelop instead of Visual Studio .NET + stream = assembly.GetManifestResourceStream(m_Schema); + if(stream == null) + { + throw new System.Reflection.TargetException(string.Format("Could not find the scheme embedded resource file '{0}'.", m_Schema)); + } + } + XmlReader schema = new XmlTextReader(stream); + + m_Schemas = new XmlSchemaCollection(); + m_Schemas.Add(m_SchemaURI, schema); + } + + private void CacheVersion() + { + m_Version = Assembly.GetEntryAssembly().GetName().Version; + } + + private void CacheTargets(Assembly assm) + { + foreach(Type t in assm.GetTypes()) + { + TargetAttribute ta = (TargetAttribute)Helper.CheckType(t, typeof(TargetAttribute), typeof(ITarget)); + + if(ta == null) + continue; + + if (t.IsAbstract) + continue; + + ITarget target = (ITarget)assm.CreateInstance(t.FullName); + if (target == null) + { + throw new MissingMethodException("Could not create ITarget instance"); + } + + m_Targets[ta.Name] = target; + } + } + + private void CacheNodeTypes(Assembly assm) + { + foreach(Type t in assm.GetTypes()) + { + foreach (DataNodeAttribute dna in t.GetCustomAttributes(typeof(DataNodeAttribute), true)) + { + NodeEntry ne = new NodeEntry(); + ne.Type = t; + ne.Attribute = dna; + m_Nodes[dna.Name] = ne; + } + } + } + + private void LogBanner() + { + m_Log.Write("Prebuild v" + Version); + m_Log.Write("Copyright (c) 2004-2010"); + m_Log.Write("Matthew Holmes (matthew@wildfiregames.com),"); + m_Log.Write("Dan Moorehead (dan05a@gmail.com),"); + m_Log.Write("David Hudson (jendave@yahoo.com),"); + m_Log.Write("Rob Loach (http://www.robloach.net),"); + m_Log.Write("C.J. Adams-Collier (cjac@colliertech.org),"); + m_Log.Write("John Hurliman (john.hurliman@intel.com),"); + + m_Log.Write("See 'prebuild /usage' for help"); + m_Log.Write(); + } + + + + private void ProcessFile(string file) + { + ProcessFile(file, m_Solutions); + } + + public void ProcessFile(ProcessNode node, SolutionNode parent) + { + if (node.IsValid) + { + List list = new List(); + ProcessFile(node.Path, list); + + foreach (SolutionNode solution in list) + parent.SolutionsTable[solution.Name] = solution; + } + } + + /// + /// + /// + /// + /// + /// + public void ProcessFile(string file, IList solutions) + { + m_CurrentWorkingDirectory.Push(); + + string path = file; + try + { + try + { + path = Helper.ResolvePath(path); + } + catch(ArgumentException) + { + m_Log.Write("Could not open Prebuild file: " + path); + m_CurrentWorkingDirectory.Pop(); + return; + } + + Helper.SetCurrentDir(Path.GetDirectoryName(path)); + + XmlTextReader reader = new XmlTextReader(path); + + Core.Parse.Preprocessor pre = new Core.Parse.Preprocessor(); + + //register command line arguments as XML variables + IEnumerator> dict = m_CommandLine.GetEnumerator(); + while (dict.MoveNext()) + { + string name = dict.Current.Key.Trim(); + if (name.Length > 0) + pre.RegisterVariable(name, dict.Current.Value); + } + + string xml = pre.Process(reader);//remove script and evaulate pre-proccessing to get schema-conforming XML + + // See if the user put into a pseudo target of "prebuild:preprocessed-input" to indicate they want to see the + // output before the system processes it. + if (m_CommandLine.WasPassed("ppi")) + { + // Get the filename if there is one, otherwise use a default. + string ppiFile = m_CommandLine["ppi"]; + if (ppiFile == null || ppiFile.Trim().Length == 0) + { + ppiFile = "preprocessed-input.xml"; + } + + // Write out the string to the given stream. + try + { + using (StreamWriter ppiWriter = new StreamWriter(ppiFile)) + { + ppiWriter.WriteLine(xml); + } + } + catch(IOException ex) + { + Console.WriteLine("Could not write PPI file '{0}': {1}", ppiFile, ex.Message); + } + + // Finish processing this special tag. + return; + } + + m_CurrentDoc = new XmlDocument(); + try + { +#if NO_VALIDATE + XmlReader validator = XmlReader.Create(new StringReader(xml)); + m_CurrentDoc.Load(validator); +#else + XmlValidatingReader validator = new XmlValidatingReader(new XmlTextReader(new StringReader(xml))); + + //validate while reading from string into XmlDocument DOM structure in memory + foreach(XmlSchema schema in m_Schemas) + { + validator.Schemas.Add(schema); + } + m_CurrentDoc.Load(validator); +#endif + } + catch(XmlException e) + { + throw new XmlException(e.ToString()); + } + + //is there a purpose to writing it? An syntax/schema problem would have been found during pre.Process() and reported with details + if(m_CommandLine.WasPassed("ppo")) + { + string ppoFile = m_CommandLine["ppo"]; + if(ppoFile == null || ppoFile.Trim().Length < 1) + { + ppoFile = "preprocessed.xml"; + } + + StreamWriter writer = null; + try + { + writer = new StreamWriter(ppoFile); + writer.Write(xml); + } + catch(IOException ex) + { + Console.WriteLine("Could not write PPO file '{0}': {1}", ppoFile, ex.Message); + } + finally + { + if(writer != null) + { + writer.Close(); + } + } + return; + } + //start reading the xml config file + XmlElement rootNode = m_CurrentDoc.DocumentElement; + //string suggestedVersion = Helper.AttributeValue(rootNode,"version","1.0"); + Helper.CheckForOSVariables = Helper.ParseBoolean(rootNode,"checkOsVars",false); + + foreach(XmlNode node in rootNode.ChildNodes)//solutions or if pre-proc instructions + { + IDataNode dataNode = ParseNode(node, null); + if(dataNode is ProcessNode) + { + ProcessNode proc = (ProcessNode)dataNode; + if(proc.IsValid) + { + ProcessFile(proc.Path); + } + } + else if(dataNode is SolutionNode) + { + solutions.Add((SolutionNode)dataNode); + } + } + } + catch(XmlSchemaException xse) + { + m_Log.Write("XML validation error at line {0} in {1}:\n\n{2}", + xse.LineNumber, path, xse.Message); + } + finally + { + m_CurrentWorkingDirectory.Pop(); + } + } + + #endregion + + #region Public Methods + + /// + /// Allows the project. + /// + /// The project groups flags. + /// + public bool AllowProject(string projectGroupsFlags) + { + if(m_ProjectGroups != null && m_ProjectGroups.Length > 0) + { + if(projectGroupsFlags != null && projectGroupsFlags.Length == 0) + { + foreach(string group in projectGroupsFlags.Split('|')) + { + if(Array.IndexOf(m_ProjectGroups, group) != -1) //if included in the filter list + { + return true; + } + } + } + return false;//not included in the list or no groups specified for the project + } + return true;//no filter specified in the command line args + } + + /// + /// Gets the type of the node. + /// + /// The node. + /// + public Type GetNodeType(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + if(!m_Nodes.ContainsKey(node.Name)) + { + return null; + } + + NodeEntry ne = m_Nodes[node.Name]; + return ne.Type; + } + + /// + /// + /// + /// + /// + /// + public IDataNode ParseNode(XmlNode node, IDataNode parent) + { + return ParseNode(node, parent, null); + } + + //Create an instance of the data node type that is mapped to the name of the xml DOM node + /// + /// Parses the node. + /// + /// The node. + /// The parent. + /// The pre node. + /// + public IDataNode ParseNode(XmlNode node, IDataNode parent, IDataNode preNode) + { + IDataNode dataNode; + + try + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + if(preNode == null) + { + if(!m_Nodes.ContainsKey(node.Name)) + { + Console.WriteLine("WARNING: Unknown XML node: " + node.Name); + return null; + } + + NodeEntry ne = m_Nodes[node.Name]; + Type type = ne.Type; + //DataNodeAttribute dna = ne.Attribute; + + dataNode = (IDataNode)type.Assembly.CreateInstance(type.FullName); + if(dataNode == null) + { + throw new System.Reflection.TargetException("Could not create new parser instance: " + type.FullName); + } + } + else + dataNode = preNode; + + dataNode.Parent = parent; + dataNode.Parse(node); + } + catch(WarningException wex) + { + m_Log.Write(LogType.Warning, wex.Message); + return null; + } + catch(FatalException fex) + { + m_Log.WriteException(LogType.Error, fex); + throw; + } + catch(Exception ex) + { + m_Log.WriteException(LogType.Error, ex); + throw; + } + + return dataNode; + } + + /// + /// Initializes the specified target. + /// + /// The target. + /// The args. + public void Initialize(LogTargets target, string[] args) + { + CacheTargets(GetType().Assembly); + CacheNodeTypes(GetType().Assembly); + CacheVersion(); + + m_CommandLine = new CommandLineCollection(args); + + string logFile = null; + if(m_CommandLine.WasPassed("log")) + { + logFile = m_CommandLine["log"]; + + if(logFile != null && logFile.Length == 0) + { + logFile = "Prebuild.log"; + } + } + else + { + target = target & ~LogTargets.File; //dont output to a file + } + + m_Log = new Log(target, logFile); + LogBanner(); + + m_CurrentWorkingDirectory = new CurrentDirectory(); + + m_Target = m_CommandLine["target"]; + m_Clean = m_CommandLine["clean"]; + string removeDirs = m_CommandLine["removedir"]; + if(removeDirs != null && removeDirs.Length == 0) + { + m_RemoveDirectories = removeDirs.Split('|'); + } + + string flags = m_CommandLine["allowedgroups"];//allows filtering by specifying a pipe-delimited list of groups to include + if(flags != null && flags.Length == 0) + { + m_ProjectGroups = flags.Split('|'); + } + m_PauseAfterFinish = m_CommandLine.WasPassed("pause"); + + LoadSchema(); + } + + /// + /// Processes this instance. + /// + public void Process() + { + bool perfomedOtherTask = false; + if(m_RemoveDirectories != null && m_RemoveDirectories.Length > 0) + { + try + { + RemoveDirectories(".",m_RemoveDirectories); + } + catch(IOException e) + { + m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories); + m_Log.WriteException(LogType.Error,e); + } + catch(UnauthorizedAccessException e) + { + m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories); + m_Log.WriteException(LogType.Error,e); + } + perfomedOtherTask = true; + } + + if(m_Target != null && m_Clean != null) + { + m_Log.Write(LogType.Error, "The options /target and /clean cannot be passed together"); + return; + } + + if(m_Target == null && m_Clean == null) + { + if(perfomedOtherTask) //finished + { + return; + } + m_Log.Write(LogType.Error, "Must pass either /target or /clean to process a Prebuild file"); + return; + } + + string file = "./prebuild.xml"; + if(m_CommandLine.WasPassed("file")) + { + file = m_CommandLine["file"]; + } + + ProcessFile(file); + + string target = (m_Target != null ? m_Target.ToLower() : m_Clean.ToLower()); + bool clean = (m_Target == null); + if(clean && target != null && target.Length == 0) + { + target = "all"; + } + if(clean && target == "all")//default to all if no target was specified for clean + { + //check if they passed yes + if (!m_CommandLine.WasPassed("yes")) + { + Console.WriteLine("WARNING: This operation will clean ALL project files for all targets, are you sure? (y/n):"); + string ret = Console.ReadLine(); + if(ret == null) + { + return; + } + ret = ret.Trim().ToLower(); + if((ret.ToLower() != "y" && ret.ToLower() != "yes")) + { + return; + } + } + //clean all targets (just cleaning vs2002 target didn't clean nant) + foreach(ITarget targ in m_Targets.Values) + { + targ.Clean(this); + } + } + else + { + if (!m_Targets.ContainsKey(target)) { + m_Log.Write(LogType.Error, "Unknown Target \"{0}\"", target); + return; + } + ITarget targ = m_Targets[target]; + + if(clean) + { + targ.Clean(this); + } + else + { + targ.Write(this); + } + } + + m_Log.Flush(); + } + + #endregion + + #region IDisposable Members + + /// + /// + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Dispose objects + /// + /// + /// If true, it will dispose close the handle + /// + /// + /// Will dispose managed and unmanaged resources. + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + GC.SuppressFinalize(this); + if (m_Log != null) + { + m_Log.Close(); + m_Log = null; + } + } + } + disposed = true; + } + + /// + /// + /// + ~Kernel() + { + Dispose(false); + } + + /// + /// Closes and destroys this object + /// + /// + /// Same as Dispose(true) + /// + public void Close() + { + Dispose(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/all-wcprops b/Prebuild/src/Core/Nodes/.svn/all-wcprops new file mode 100644 index 0000000..6565f05 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/all-wcprops @@ -0,0 +1,119 @@ +K 25 +svn:wc:ra_dav:version-url +V 56 +/svnroot/dnpb/!svn/ver/321/trunk/Prebuild/src/Core/Nodes +END +CleanFilesNode.cs +K 25 +svn:wc:ra_dav:version-url +V 74 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Nodes/CleanFilesNode.cs +END +ProjectNode.cs +K 25 +svn:wc:ra_dav:version-url +V 71 +/svnroot/dnpb/!svn/ver/319/trunk/Prebuild/src/Core/Nodes/ProjectNode.cs +END +ConfigurationNode.cs +K 25 +svn:wc:ra_dav:version-url +V 77 +/svnroot/dnpb/!svn/ver/316/trunk/Prebuild/src/Core/Nodes/ConfigurationNode.cs +END +DataNode.cs +K 25 +svn:wc:ra_dav:version-url +V 68 +/svnroot/dnpb/!svn/ver/321/trunk/Prebuild/src/Core/Nodes/DataNode.cs +END +ReferencePathNode.cs +K 25 +svn:wc:ra_dav:version-url +V 77 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Nodes/ReferencePathNode.cs +END +SolutionNode.cs +K 25 +svn:wc:ra_dav:version-url +V 72 +/svnroot/dnpb/!svn/ver/315/trunk/Prebuild/src/Core/Nodes/SolutionNode.cs +END +ProcessNode.cs +K 25 +svn:wc:ra_dav:version-url +V 71 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Nodes/ProcessNode.cs +END +FileNode.cs +K 25 +svn:wc:ra_dav:version-url +V 68 +/svnroot/dnpb/!svn/ver/316/trunk/Prebuild/src/Core/Nodes/FileNode.cs +END +DescriptionNode.cs +K 25 +svn:wc:ra_dav:version-url +V 75 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Nodes/DescriptionNode.cs +END +DatabaseReferenceNode.cs +K 25 +svn:wc:ra_dav:version-url +V 81 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs +END +ConfigurationNodeCollection.cs +K 25 +svn:wc:ra_dav:version-url +V 87 +/svnroot/dnpb/!svn/ver/315/trunk/Prebuild/src/Core/Nodes/ConfigurationNodeCollection.cs +END +CleanupNode.cs +K 25 +svn:wc:ra_dav:version-url +V 71 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Nodes/CleanupNode.cs +END +ExcludeNode.cs +K 25 +svn:wc:ra_dav:version-url +V 71 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/Nodes/ExcludeNode.cs +END +OptionsNode.cs +K 25 +svn:wc:ra_dav:version-url +V 71 +/svnroot/dnpb/!svn/ver/315/trunk/Prebuild/src/Core/Nodes/OptionsNode.cs +END +DatabaseProjectNode.cs +K 25 +svn:wc:ra_dav:version-url +V 79 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs +END +MatchNode.cs +K 25 +svn:wc:ra_dav:version-url +V 69 +/svnroot/dnpb/!svn/ver/318/trunk/Prebuild/src/Core/Nodes/MatchNode.cs +END +ReferenceNode.cs +K 25 +svn:wc:ra_dav:version-url +V 73 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/Nodes/ReferenceNode.cs +END +FilesNode.cs +K 25 +svn:wc:ra_dav:version-url +V 69 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Nodes/FilesNode.cs +END +AuthorNode.cs +K 25 +svn:wc:ra_dav:version-url +V 70 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Nodes/AuthorNode.cs +END diff --git a/Prebuild/src/Core/Nodes/.svn/dir-prop-base b/Prebuild/src/Core/Nodes/.svn/dir-prop-base new file mode 100644 index 0000000..a1989a0 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/dir-prop-base @@ -0,0 +1,5 @@ +K 10 +svn:ignore +V 5 +*.swp +END diff --git a/Prebuild/src/Core/Nodes/.svn/entries b/Prebuild/src/Core/Nodes/.svn/entries new file mode 100644 index 0000000..b60f190 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/entries @@ -0,0 +1,674 @@ +10 + +dir +323 +https://dnpb.svn.sourceforge.net/svnroot/dnpb/trunk/Prebuild/src/Core/Nodes +https://dnpb.svn.sourceforge.net/svnroot/dnpb + + + +2010-08-12T16:58:08.825470Z +321 +jhurliman +has-props + + + + + + + + + + + + + +3355ff64-970d-0410-bbe8-d0fbd18be4fb + +CleanFilesNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +c798b3c4167ec1a3815ddae93a552427 +2009-04-15T01:28:16.827957Z +307 +kunnis + + + + + + + + + + + + + + + + + + + + + +2666 + +ProjectNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +be9ade7048917117783a06508fa4d378 +2010-05-09T23:19:49.063286Z +319 +jhurliman +has-props + + + + + + + + + + + + + + + + + + + + +13444 + +ConfigurationNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +e42a548bfaba22cf94dbb203b2b28352 +2010-05-08T05:43:01.449559Z +316 +jhurliman +has-props + + + + + + + + + + + + + + + + + + + + +5222 + +DataNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +39b1d83bff018fce9f616ae2e6f1be82 +2010-08-12T16:58:08.825470Z +321 +jhurliman +has-props + + + + + + + + + + + + + + + + + + + + +3294 + +ReferencePathNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +409c91bafff2572218a6cdefcc6ec48c +2009-04-15T01:28:16.827957Z +307 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +2677 + +SolutionNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +79bdf34c92682dc5ba8b5db15aaa95d6 +2009-06-06T19:47:31.451428Z +315 +dmoonfire +has-props + + + + + + + + + + + + + + + + + + + + +9720 + +ProcessNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +1816314797ef66235c58938b33ea2b3b +2009-04-15T01:28:16.827957Z +307 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +2900 + +FileNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +43f98599da19618be6c6ed74f36fceae +2010-05-08T05:43:01.449559Z +316 +jhurliman +has-props + + + + + + + + + + + + + + + + + + + + +6043 + +DescriptionNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +3f8a8b8cc4b3a94b94109276ad2222d3 +2009-04-15T01:28:16.827957Z +307 +kunnis + + + + + + + + + + + + + + + + + + + + + +2493 + +DatabaseReferenceNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +4104ed953ae9105ac6498ce7882ed8ee +2009-02-19T06:47:52.218324Z +295 +kunnis + + + + + + + + + + + + + + + + + + + + + +2390 + +ConfigurationNodeCollection.cs +file + + + + +2010-09-10T22:51:44.000000Z +8620885fc85bdc06288acf6b8f58b3ff +2009-06-06T19:47:31.451428Z +315 +dmoonfire + + + + + + + + + + + + + + + + + + + + + +2406 + +CleanupNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +198fb1e15cd545655978686277e39d96 +2009-04-15T01:28:16.827957Z +307 +kunnis + + + + + + + + + + + + + + + + + + + + + +2689 + +ExcludeNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +810fc73f537028052471239c72f41c11 +2009-02-19T06:47:52.218324Z +295 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +2608 + +OptionsNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +691dd5f7e7ce2a06814cdcae611fc40e +2009-06-06T19:47:31.451428Z +315 +dmoonfire +has-props + + + + + + + + + + + + + + + + + + + + +10949 + +DatabaseProjectNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +18995e6577e6bb3622fe41f5bfe01b48 +2009-04-15T01:28:16.827957Z +307 +kunnis + + + + + + + + + + + + + + + + + + + + + +2476 + +MatchNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +3344ef3bdb7db2006eb987a80128cd06 +2010-05-09T08:21:52.307305Z +318 +jhurliman +has-props + + + + + + + + + + + + + + + + + + + + +10846 + +ReferenceNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +18d76c27d53a4d54f16f57a855a21916 +2009-02-19T06:47:52.218324Z +295 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +3705 + +FilesNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +e6ddefd5fff49958f77b5ef96f06c09e +2009-04-15T01:28:16.827957Z +307 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +6036 + +AuthorNode.cs +file + + + + +2010-09-10T22:51:44.000000Z +07607d8988fc1236ab8bef5fc12f8cd5 +2009-04-15T01:28:16.827957Z +307 +kunnis + + + + + + + + + + + + + + + + + + + + + +2425 + diff --git a/Prebuild/src/Core/Nodes/.svn/prop-base/ConfigurationNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/prop-base/ConfigurationNode.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/prop-base/ConfigurationNode.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Nodes/.svn/prop-base/DataNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/prop-base/DataNode.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/prop-base/DataNode.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Nodes/.svn/prop-base/ExcludeNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/prop-base/ExcludeNode.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/prop-base/ExcludeNode.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Nodes/.svn/prop-base/FileNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/prop-base/FileNode.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/prop-base/FileNode.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Nodes/.svn/prop-base/FilesNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/prop-base/FilesNode.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/prop-base/FilesNode.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Nodes/.svn/prop-base/MatchNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/prop-base/MatchNode.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/prop-base/MatchNode.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Nodes/.svn/prop-base/OptionsNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/prop-base/OptionsNode.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/prop-base/OptionsNode.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Nodes/.svn/prop-base/ProcessNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/prop-base/ProcessNode.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/prop-base/ProcessNode.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Nodes/.svn/prop-base/ProjectNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/prop-base/ProjectNode.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/prop-base/ProjectNode.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Nodes/.svn/prop-base/ReferenceNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/prop-base/ReferenceNode.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/prop-base/ReferenceNode.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Nodes/.svn/prop-base/ReferencePathNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/prop-base/ReferencePathNode.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/prop-base/ReferencePathNode.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Nodes/.svn/prop-base/SolutionNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/prop-base/SolutionNode.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/prop-base/SolutionNode.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/AuthorNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/AuthorNode.cs.svn-base new file mode 100644 index 0000000..4c415bb --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/AuthorNode.cs.svn-base @@ -0,0 +1,87 @@ +#region BSD License +/* +Copyright (c) 2007 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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Author")] + public class AuthorNode : DataNode + { + #region Fields + + private string m_Signature; + + #endregion + + #region Properties + + /// + /// Gets the signature. + /// + /// The signature. + public string Signature + { + get + { + return m_Signature; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Signature = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Signature == null) + { + m_Signature = ""; + } + + m_Signature = m_Signature.Trim(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/CleanFilesNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/CleanFilesNode.cs.svn-base new file mode 100644 index 0000000..dc2da9a --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/CleanFilesNode.cs.svn-base @@ -0,0 +1,80 @@ +#region BSD License +/* +Copyright (c) 2007 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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + [DataNode("CleanFiles")] + public class CleanFilesNode : DataNode + { + #region Fields + + private string m_Pattern; + + #endregion + + #region Properties + + /// + /// Gets the signature. + /// + /// The signature. + public string Pattern + { + get + { + return m_Pattern; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if (node == null) + { + throw new ArgumentNullException("node"); + } + + m_Pattern = Helper.AttributeValue(node, "pattern", String.Empty); ; + m_Pattern = m_Pattern.Trim(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/CleanupNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/CleanupNode.cs.svn-base new file mode 100644 index 0000000..a9b77eb --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/CleanupNode.cs.svn-base @@ -0,0 +1,85 @@ +#region BSD License +/* +Copyright (c) 2007 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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; + +namespace Prebuild.Core.Nodes +{ + [DataNode("Cleanup")] + public class CleanupNode : DataNode + { + #region Fields + + private List m_CleanFiles = new List(); + + #endregion + + #region Properties + + /// + /// Gets the signature. + /// + /// The signature. + public List CleanFiles + { + get + { + return m_CleanFiles; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach (XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if (dataNode is CleanFilesNode) + { + m_CleanFiles.Add((CleanFilesNode)dataNode); + } + } + } + + #endregion + } +} \ No newline at end of file diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/ConfigurationNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/ConfigurationNode.cs.svn-base new file mode 100644 index 0000000..cd2f740 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/ConfigurationNode.cs.svn-base @@ -0,0 +1,225 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Configuration")] + public class ConfigurationNode : DataNode, ICloneable, IComparable + { + #region Fields + + private string m_Name = "unknown"; + private string m_Platform = "AnyCPU"; + private OptionsNode m_Options; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public ConfigurationNode() + { + m_Options = new OptionsNode(); + } + + #endregion + + #region Properties + + /// + /// Gets or sets the parent. + /// + /// The parent. + public override IDataNode Parent + { + get + { + return base.Parent; + } + set + { + base.Parent = value; + if(base.Parent is SolutionNode) + { + SolutionNode node = (SolutionNode)base.Parent; + if(node != null && node.Options != null) + { + node.Options.CopyTo(m_Options); + } + } + } + } + + /// + /// Identifies the platform for this specific configuration. + /// + public string Platform + { + get + { + return m_Platform; + } + set + { + switch ((value + "").ToLower()) + { + case "x86": + case "x64": + m_Platform = value; + break; + case "itanium": + m_Platform = "Itanium"; + break; + default: + m_Platform = "AnyCPU"; + break; + } + } + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets the name and platform for the configuration. + /// + /// The name and platform. + public string NameAndPlatform + { + get + { + string platform = m_Platform; + if (platform == "AnyCPU") + platform = "Any CPU"; + + return String.Format("{0}|{1}", m_Name, platform); + } + } + + /// + /// Gets or sets the options. + /// + /// The options. + public OptionsNode Options + { + get + { + return m_Options; + } + set + { + m_Options = value; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + Platform = Helper.AttributeValue(node, "platform", m_Platform); + + if (node == null) + { + throw new ArgumentNullException("node"); + } + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is OptionsNode) + { + ((OptionsNode)dataNode).CopyTo(m_Options); + } + } + } + + /// + /// Copies to. + /// + /// The conf. + public void CopyTo(ConfigurationNode conf) + { + m_Options.CopyTo(conf.m_Options); + } + + #endregion + + #region ICloneable Members + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// + /// A new object that is a copy of this instance. + /// + public object Clone() + { + ConfigurationNode ret = new ConfigurationNode(); + ret.m_Name = m_Name; + ret.m_Platform = m_Platform; + m_Options.CopyTo(ret.m_Options); + return ret; + } + + #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + ConfigurationNode that = (ConfigurationNode) obj; + return this.m_Name.CompareTo(that.m_Name); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/ConfigurationNodeCollection.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/ConfigurationNodeCollection.cs.svn-base new file mode 100644 index 0000000..7c59ac5 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/ConfigurationNodeCollection.cs.svn-base @@ -0,0 +1,71 @@ +#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.Collections.Generic; + +namespace Prebuild.Core.Nodes +{ + /// + /// Implements a specialized list of configuration nodes which allows for lookup via + /// configuration name and platform. + /// + public class ConfigurationNodeCollection : List + { + #region Properties + + public ConfigurationNode this[string nameAndPlatform] + { + get + { + foreach (ConfigurationNode configurationNode in this) + { + if (configurationNode.NameAndPlatform == nameAndPlatform) + { + return configurationNode; + } + } + + return null; + } + + set + { + // See if the node + ConfigurationNode configurationNode = this[nameAndPlatform]; + + if (configurationNode != null) + { + this[IndexOf(configurationNode)] = value; + } + else + { + Add(value); + } + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/DataNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/DataNode.cs.svn-base new file mode 100644 index 0000000..318b13c --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/DataNode.cs.svn-base @@ -0,0 +1,117 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using System.IO; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + public abstract class DataNode : IDataNode + { + #region Fields + + private IDataNode parent; + string[] m_WebTypes = new string[] { "aspx", "ascx", "master", "ashx", "asmx" }; + + #endregion + + #region IDataNode Members + + /// + /// Gets or sets the parent. + /// + /// The parent. + public virtual IDataNode Parent + { + get + { + return parent; + } + set + { + parent = value; + } + } + public string[] WebTypes + { + get { return m_WebTypes; } + } + /// + /// Parses the specified node. + /// + /// The node. + public virtual void Parse(XmlNode node) + { + } + public BuildAction GetBuildActionByFileName(string fileName) + { + string extension = Path.GetExtension(fileName).ToLower(); + foreach (string type in WebTypes) + { + if (extension == type) + return BuildAction.Content; + } + return BuildAction.Compile; + } + /// + /// Parses the file type to figure out what type it is + /// + /// + public SubType GetSubTypeByFileName(string fileName) + { + string extension = System.IO.Path.GetExtension(fileName).ToLower(); + string designer = String.Format(".designer{0}", extension); + string path = fileName.ToLower(); + if (extension == ".resx") + { + return SubType.Designer; + } + else if (path.EndsWith(".settings")) + { + return SubType.Settings; + } + else + { + + foreach (string type in WebTypes) + { + if (path.EndsWith(type)) + { + return SubType.CodeBehind; + } + } + } + return SubType.Code; + } + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseProjectNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseProjectNode.cs.svn-base new file mode 100644 index 0000000..20095c3 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseProjectNode.cs.svn-base @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + [DataNode("DatabaseProject")] + public class DatabaseProjectNode : DataNode + { + string name; + string path; + string fullpath; + Guid guid = Guid.NewGuid(); + readonly List authors = new List(); + readonly List references = new List(); + + public Guid Guid + { + get { return guid; } + } + + public string Name + { + get { return name; } + } + + public string Path + { + get { return path; } + } + + public string FullPath + { + get { return fullpath; } + } + + public IEnumerable References + { + get { return references; } + } + + public override void Parse(XmlNode node) + { + name = Helper.AttributeValue(node, "name", name); + path = Helper.AttributeValue(node, "path", name); + + try + { + fullpath = Helper.ResolvePath(path); + } + catch + { + throw new WarningException("Could not resolve Solution path: {0}", path); + } + + Kernel.Instance.CurrentWorkingDirectory.Push(); + + try + { + Helper.SetCurrentDir(fullpath); + + if (node == null) + { + throw new ArgumentNullException("node"); + } + + foreach (XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + + if (dataNode == null) + continue; + + if (dataNode is AuthorNode) + authors.Add((AuthorNode)dataNode); + else if (dataNode is DatabaseReferenceNode) + references.Add((DatabaseReferenceNode)dataNode); + } + } + finally + { + Kernel.Instance.CurrentWorkingDirectory.Pop(); + } + + base.Parse(node); + } + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseReferenceNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseReferenceNode.cs.svn-base new file mode 100644 index 0000000..97c3964 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseReferenceNode.cs.svn-base @@ -0,0 +1,63 @@ +using System; +using Prebuild.Core.Attributes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + [DataNode("DatabaseReference")] + public class DatabaseReferenceNode : DataNode + { + string name; + Guid providerId; + string connectionString; + + public string Name + { + get { return name; } + } + + public Guid ProviderId + { + get { return providerId; } + } + + public string ConnectionString + { + get { return connectionString; } + } + + public override void Parse(System.Xml.XmlNode node) + { + name = Helper.AttributeValue(node, "name", name); + + string providerName = Helper.AttributeValue(node, "providerName", string.Empty); + if (providerName != null) + { + switch (providerName) + { + // digitaljeebus: pulled from HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\DataProviders\* + // Not sure if these will help other operating systems, or if there's a better way. + case "Microsoft.SqlServerCe.Client.3.5": + providerId = new Guid("7C602B5B-ACCB-4acd-9DC0-CA66388C1533"); break; + case "System.Data.OleDb": + providerId = new Guid("7F041D59-D76A-44ed-9AA2-FBF6B0548B80"); break; + case "System.Data.OracleClient": + providerId = new Guid("8F5C5018-AE09-42cf-B2CC-2CCCC7CFC2BB"); break; + case "System.Data.SqlClient": + providerId = new Guid("91510608-8809-4020-8897-FBA057E22D54"); break; + case "System.Data.Odbc": + providerId = new Guid("C3D4F4CE-2C48-4381-B4D6-34FA50C51C86"); break; + + default: + throw new ArgumentOutOfRangeException("providerName", providerName, "Could not provider name to an id."); + } + } + else + providerId = new Guid(Helper.AttributeValue(node, "providerId", Guid.Empty.ToString("B"))); + + connectionString = Helper.AttributeValue(node, "connectionString", connectionString); + + base.Parse(node); + } + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/DescriptionNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/DescriptionNode.cs.svn-base new file mode 100644 index 0000000..d1293a0 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/DescriptionNode.cs.svn-base @@ -0,0 +1,87 @@ +#region BSD License +/* +Copyright (c) 2007 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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// The object representing the /Prebuild/Solution/Project/Description element + /// + [DataNode("Description")] + public class DescriptionNode : DataNode + { + #region Fields + + private string m_Value; + + #endregion + + #region Properties + + /// + /// Gets the description Value. + /// + /// The description Value. + public string Value + { + get + { + return m_Value; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Value = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Value == null) + { + m_Value = ""; + } + + m_Value = m_Value.Trim(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/ExcludeNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/ExcludeNode.cs.svn-base new file mode 100644 index 0000000..7f04cba --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/ExcludeNode.cs.svn-base @@ -0,0 +1,89 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Exclude")] + public class ExcludeNode : DataNode + { + #region Fields + + private string m_Pattern = ""; + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Pattern; + } + } + + /// + /// Gets the pattern. + /// + /// The pattern. + public string Pattern + { + get + { + return m_Pattern; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Pattern = Helper.AttributeValue( node, "name", m_Pattern ); + m_Pattern = Helper.AttributeValue(node, "pattern", m_Pattern ); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/FileNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/FileNode.cs.svn-base new file mode 100644 index 0000000..01cea1e --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/FileNode.cs.svn-base @@ -0,0 +1,285 @@ +#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.IO; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; +using Prebuild.Core.Targets; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + public enum BuildAction + { + /// + /// + /// + None, + /// + /// + /// + Compile, + /// + /// + /// + Content, + /// + /// + /// + EmbeddedResource, + /// + /// + /// + ApplicationDefinition, + /// + /// + /// + Page + } + + /// + /// + /// + public enum SubType + { + /// + /// + /// + Code, + /// + /// + /// + Component, + /// + /// + /// + Designer, + /// + /// + /// + Form, + /// + /// + /// + Settings, + /// + /// + /// + UserControl, + /// + /// + /// + CodeBehind, + } + + public enum CopyToOutput + { + Never, + Always, + PreserveNewest + } + + /// + /// + /// + [DataNode("File")] + public class FileNode : DataNode + { + #region Fields + + private string m_Path; + private string m_ResourceName = ""; + private BuildAction? m_BuildAction; + private bool m_Valid; + private SubType? m_SubType; + private CopyToOutput m_CopyToOutput = CopyToOutput.Never; + private bool m_Link = false; + private string m_LinkPath = string.Empty; + private bool m_PreservePath = false; + + + #endregion + + #region Properties + + /// + /// + /// + public string Path + { + get + { + return m_Path; + } + } + + /// + /// + /// + public string ResourceName + { + get + { + return m_ResourceName; + } + } + + /// + /// + /// + public BuildAction BuildAction + { + get + { + if (m_BuildAction != null) + return m_BuildAction.Value; + else + return GetBuildActionByFileName(this.Path); + + } + } + + public CopyToOutput CopyToOutput + { + get + { + return this.m_CopyToOutput; + } + } + + public bool IsLink + { + get + { + return this.m_Link; + } + } + + public string LinkPath + { + get + { + return this.m_LinkPath; + } + } + /// + /// + /// + public SubType SubType + { + get + { + if (m_SubType != null) + return m_SubType.Value; + else + return GetSubTypeByFileName(this.Path); + } + } + + /// + /// + /// + public bool IsValid + { + get + { + return m_Valid; + } + } + + /// + /// + /// + /// + /// + public bool PreservePath + { + get + { + return m_PreservePath; + } + } + + #endregion + + #region Public Methods + + /// + /// + /// + /// + public override void Parse(XmlNode node) + { + string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty); + if (buildAction != string.Empty) + m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction); + string subType = Helper.AttributeValue(node, "subType", string.Empty); + if (subType != String.Empty) + m_SubType = (SubType)Enum.Parse(typeof(SubType), subType); + + m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); + this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); + if ( this.m_Link == true ) + { + this.m_LinkPath = Helper.AttributeValue( node, "linkPath", string.Empty ); + } + this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); + this.m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) ); + + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Path == null) + { + m_Path = ""; + } + + m_Path = m_Path.Trim(); + m_Valid = true; + if(!File.Exists(m_Path)) + { + m_Valid = false; + Kernel.Instance.Log.Write(LogType.Warning, "File does not exist: {0}", m_Path); + } + + if (System.IO.Path.GetExtension(m_Path) == ".settings") + { + m_SubType = SubType.Settings; + m_BuildAction = BuildAction.None; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/FilesNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/FilesNode.cs.svn-base new file mode 100644 index 0000000..23a716c --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/FilesNode.cs.svn-base @@ -0,0 +1,204 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using System.IO; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Files")] + public class FilesNode : DataNode + { + #region Fields + + private readonly List m_Files = new List(); + private readonly Dictionary m_BuildActions = new Dictionary(); + private readonly Dictionary m_SubTypes = new Dictionary(); + private readonly Dictionary m_ResourceNames = new Dictionary(); + private readonly Dictionary m_CopyToOutputs = new Dictionary(); + private readonly Dictionary m_Links = new Dictionary(); + private readonly Dictionary m_LinkPaths = new Dictionary(); + private readonly Dictionary m_PreservePaths = new Dictionary(); + + #endregion + + #region Properties + + public int Count + { + get + { + return m_Files.Count; + } + } + + #endregion + + #region Public Methods + + public BuildAction GetBuildAction(string file) + { + if(!m_BuildActions.ContainsKey(file)) + { + return BuildAction.Compile; + } + + return m_BuildActions[file]; + } + + public CopyToOutput GetCopyToOutput(string file) + { + if (!m_CopyToOutputs.ContainsKey(file)) + { + return CopyToOutput.Never; + } + return m_CopyToOutputs[file]; + } + + public bool GetIsLink(string file) + { + if (!m_Links.ContainsKey(file)) + { + return false; + } + return m_Links[file]; + } + + public bool Contains(string file) + { + return m_Files.Contains(file); + } + + public string GetLinkPath( string file ) + { + if ( !m_LinkPaths.ContainsKey( file ) ) + { + return string.Empty; + } + return m_LinkPaths[ file ]; + } + + public SubType GetSubType(string file) + { + if(!m_SubTypes.ContainsKey(file)) + { + return SubType.Code; + } + + return m_SubTypes[file]; + } + + public string GetResourceName(string file) + { + if(!m_ResourceNames.ContainsKey(file)) + { + return string.Empty; + } + + return m_ResourceNames[file]; + } + + public bool GetPreservePath( string file ) + { + if ( !m_PreservePaths.ContainsKey( file ) ) + { + return false; + } + + return m_PreservePaths[ file ]; + } + + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is FileNode) + { + FileNode fileNode = (FileNode)dataNode; + if(fileNode.IsValid) + { + if (!m_Files.Contains(fileNode.Path)) + { + m_Files.Add(fileNode.Path); + m_BuildActions[fileNode.Path] = fileNode.BuildAction; + m_SubTypes[fileNode.Path] = fileNode.SubType; + m_ResourceNames[fileNode.Path] = fileNode.ResourceName; + m_PreservePaths[ fileNode.Path ] = fileNode.PreservePath; + m_Links[ fileNode.Path ] = fileNode.IsLink; + m_LinkPaths[ fileNode.Path ] = fileNode.LinkPath; + m_CopyToOutputs[ fileNode.Path ] = fileNode.CopyToOutput; + + } + } + } + else if(dataNode is MatchNode) + { + foreach(string file in ((MatchNode)dataNode).Files) + { + MatchNode matchNode = (MatchNode)dataNode; + if (!m_Files.Contains(file)) + { + m_Files.Add(file); + if (matchNode.BuildAction == null) + m_BuildActions[file] = GetBuildActionByFileName(file); + else + m_BuildActions[file] = matchNode.BuildAction.Value; + m_SubTypes[file] = matchNode.SubType == null ? GetSubTypeByFileName(file) : matchNode.SubType.Value; + m_ResourceNames[ file ] = matchNode.ResourceName; + m_PreservePaths[ file ] = matchNode.PreservePath; + m_Links[ file ] = matchNode.IsLink; + m_LinkPaths[ file ] = matchNode.LinkPath; + m_CopyToOutputs[ file ] = matchNode.CopyToOutput; + + } + } + } + } + } + + // TODO: Check in to why StringCollection's enumerator doesn't implement + // IEnumerator? + public IEnumerator GetEnumerator() + { + return m_Files.GetEnumerator(); + } + + #endregion + + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/MatchNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/MatchNode.cs.svn-base new file mode 100644 index 0000000..9735265 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/MatchNode.cs.svn-base @@ -0,0 +1,367 @@ +#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 System.Text.RegularExpressions; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Match")] + public class MatchNode : DataNode + { + #region Fields + + private readonly List m_Files = new List(); + private Regex m_Regex; + private BuildAction? m_BuildAction; + private SubType? m_SubType; + string m_ResourceName = ""; + private CopyToOutput m_CopyToOutput; + private bool m_Link; + private string m_LinkPath; + private bool m_PreservePath; + private readonly List m_Exclusions = new List(); + + #endregion + + #region Properties + + /// + /// + /// + public IEnumerable Files + { + get + { + return m_Files; + } + } + + /// + /// + /// + public BuildAction? BuildAction + { + get + { + return m_BuildAction; + } + } + + /// + /// + /// + public SubType? SubType + { + get + { + return m_SubType; + } + } + + public CopyToOutput CopyToOutput + { + get + { + return m_CopyToOutput; + } + } + + public bool IsLink + { + get + { + return m_Link; + } + } + + public string LinkPath + { + get + { + return m_LinkPath; + } + } + /// + /// + /// + public string ResourceName + { + get + { + return m_ResourceName; + } + } + + public bool PreservePath + { + get + { + return m_PreservePath; + } + } + + #endregion + + #region Private Methods + + /// + /// Recurses the directories. + /// + /// The path. + /// The pattern. + /// if set to true [recurse]. + /// if set to true [use regex]. + private void RecurseDirectories(string path, string pattern, bool recurse, bool useRegex, List exclusions) + { + Match match; + try + { + string[] files; + + Boolean excludeFile; + if(!useRegex) + { + try + { + files = Directory.GetFiles(path, pattern); + } + catch (IOException) + { + // swallow weird IOException error when running in a virtual box + // guest OS on a network share when the host OS is not Windows. + // This seems to happen on network shares + // when no files match, and may be related to this report: + // http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=254546 + + files = null; + } + + if(files != null) + { + foreach (string file in files) + { + excludeFile = false; + string fileTemp; + if (file.Substring(0,2) == "./" || file.Substring(0,2) == ".\\") + { + fileTemp = file.Substring(2); + } + else + { + fileTemp = file; + } + + // Check all excludions and set flag if there are any hits. + foreach ( ExcludeNode exclude in exclusions ) + { + Regex exRegEx = new Regex( exclude.Pattern ); + match = exRegEx.Match( file ); + excludeFile |= match.Success; + } + + if ( !excludeFile ) + { + m_Files.Add( fileTemp ); + } + + } + } + + // don't call return here, because we may need to recursively search directories below + // this one, even if no matches were found in this directory. + } + else + { + try + { + files = Directory.GetFiles(path); + } + catch (IOException) + { + // swallow weird IOException error when running in a virtual box + // guest OS on a network share. + files = null; + } + + if (files != null) + { + foreach (string file in files) + { + excludeFile = false; + + match = m_Regex.Match(file); + if (match.Success) + { + // Check all excludions and set flag if there are any hits. + foreach (ExcludeNode exclude in exclusions) + { + Regex exRegEx = new Regex(exclude.Pattern); + match = exRegEx.Match(file); + excludeFile |= !match.Success; + } + + if (!excludeFile) + { + m_Files.Add(file); + } + } + } + } + } + + if(recurse) + { + string[] dirs = Directory.GetDirectories(path); + if(dirs != null && dirs.Length > 0) + { + foreach (string str in dirs) + { + // hack to skip subversion folders. Not having this can cause + // a significant performance hit when running on a network drive. + if (str.EndsWith(".svn")) + continue; + + RecurseDirectories(Helper.NormalizePath(str), pattern, recurse, useRegex, exclusions); + } + } + } + } + catch(DirectoryNotFoundException) + { + return; + } + catch(ArgumentException) + { + return; + } + } + + #endregion + + #region Public Methods + + /// + /// + /// + /// + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + string path = Helper.AttributeValue(node, "path", "."); + string pattern = Helper.AttributeValue(node, "pattern", "*"); + bool recurse = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "recurse", "false")); + bool useRegex = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "useRegex", "false")); + string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty); + if (buildAction != string.Empty) + m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction); + + //TODO: Figure out where the subtype node is being assigned + //string subType = Helper.AttributeValue(node, "subType", string.Empty); + //if (subType != String.Empty) + // m_SubType = (SubType)Enum.Parse(typeof(SubType), subType); + m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName); + m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", m_CopyToOutput.ToString())); + m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); + if ( m_Link ) + { + m_LinkPath = Helper.AttributeValue( node, "linkPath", string.Empty ); + } + m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) ); + + + if(path != null && path.Length == 0) + { + path = ".";//use current directory + } + //throw new WarningException("Match must have a 'path' attribute"); + + if(pattern == null) + { + throw new WarningException("Match must have a 'pattern' attribute"); + } + + path = Helper.NormalizePath(path); + if(!Directory.Exists(path)) + { + throw new WarningException("Match path does not exist: {0}", path); + } + + try + { + if(useRegex) + { + m_Regex = new Regex(pattern); + } + } + catch(ArgumentException ex) + { + throw new WarningException("Could not compile regex pattern: {0}", ex.Message); + } + + + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is ExcludeNode) + { + ExcludeNode excludeNode = (ExcludeNode)dataNode; + m_Exclusions.Add( excludeNode ); + } + } + + RecurseDirectories( path, pattern, recurse, useRegex, m_Exclusions ); + + if (m_Files.Count < 1) + { + // Include the project name when the match node returns no matches to provide extra + // debug info. + ProjectNode project = Parent.Parent as ProjectNode; + string projectName = ""; + + if (project != null) + projectName = " in project " + project.AssemblyName; + + throw new WarningException("Match" + projectName + " returned no files: {0}{1}", Helper.EndPath(path), pattern); + } + m_Regex = null; + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/OptionsNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/OptionsNode.cs.svn-base new file mode 100644 index 0000000..577de71 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/OptionsNode.cs.svn-base @@ -0,0 +1,634 @@ +#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.Reflection; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Options")] + public class OptionsNode : DataNode + { + #region Fields + + private static readonly Dictionary m_OptionFields = new Dictionary(); + + [OptionNode("CompilerDefines")] + private string m_CompilerDefines = ""; + + /// + /// + /// + public string CompilerDefines + { + get + { + return m_CompilerDefines; + } + set + { + m_CompilerDefines = value; + } + } + + [OptionNode("OptimizeCode")] + private bool m_OptimizeCode; + + /// + /// + /// + public bool OptimizeCode + { + get + { + return m_OptimizeCode; + } + set + { + m_OptimizeCode = value; + } + } + + [OptionNode("CheckUnderflowOverflow")] + private bool m_CheckUnderflowOverflow; + + /// + /// + /// + public bool CheckUnderflowOverflow + { + get + { + return m_CheckUnderflowOverflow; + } + set + { + m_CheckUnderflowOverflow = value; + } + } + + [OptionNode("AllowUnsafe")] + private bool m_AllowUnsafe; + + /// + /// + /// + public bool AllowUnsafe + { + get + { + return m_AllowUnsafe; + } + set + { + m_AllowUnsafe = value; + } + } + + [OptionNode("PreBuildEvent")] + private string m_PreBuildEvent; + + /// + /// + /// + public string PreBuildEvent + { + get + { + return m_PreBuildEvent; + } + set + { + m_PreBuildEvent = value; + } + } + + [OptionNode("PostBuildEvent")] + private string m_PostBuildEvent; + + /// + /// + /// + public string PostBuildEvent + { + get + { + return m_PostBuildEvent; + } + set + { + m_PostBuildEvent = value; + } + } + + [OptionNode("PreBuildEventArgs")] + private string m_PreBuildEventArgs; + + /// + /// + /// + public string PreBuildEventArgs + { + get + { + return m_PreBuildEventArgs; + } + set + { + m_PreBuildEventArgs = value; + } + } + + [OptionNode("PostBuildEventArgs")] + private string m_PostBuildEventArgs; + + /// + /// + /// + public string PostBuildEventArgs + { + get + { + return m_PostBuildEventArgs; + } + set + { + m_PostBuildEventArgs = value; + } + } + + [OptionNode("RunPostBuildEvent")] + private string m_RunPostBuildEvent; + + /// + /// + /// + public string RunPostBuildEvent + { + get + { + return m_RunPostBuildEvent; + } + set + { + m_RunPostBuildEvent = value; + } + } + + [OptionNode("RunScript")] + private string m_RunScript; + + /// + /// + /// + public string RunScript + { + get + { + return m_RunScript; + } + set + { + m_RunScript = value; + } + } + + [OptionNode("WarningLevel")] + private int m_WarningLevel = 4; + + /// + /// + /// + public int WarningLevel + { + get + { + return m_WarningLevel; + } + set + { + m_WarningLevel = value; + } + } + + [OptionNode("WarningsAsErrors")] + private bool m_WarningsAsErrors; + + /// + /// + /// + public bool WarningsAsErrors + { + get + { + return m_WarningsAsErrors; + } + set + { + m_WarningsAsErrors = value; + } + } + + [OptionNode("SuppressWarnings")] + private string m_SuppressWarnings = ""; + + /// + /// + /// + public string SuppressWarnings + { + get + { + return m_SuppressWarnings; + } + set + { + m_SuppressWarnings = value; + } + } + + [OptionNode("OutputPath")] + private string m_OutputPath = "bin/"; + + /// + /// + /// + public string OutputPath + { + get + { + return m_OutputPath; + } + set + { + m_OutputPath = value; + } + } + + [OptionNode("GenerateDocumentation")] + private bool m_GenerateDocumentation; + + /// + /// + /// + public bool GenerateDocumentation + { + get + { + return m_GenerateDocumentation; + } + set + { + m_GenerateDocumentation = value; + } + } + + [OptionNode("GenerateXmlDocFile")] + private bool m_GenerateXmlDocFile; + + /// + /// + /// + public bool GenerateXmlDocFile + { + get + { + return m_GenerateXmlDocFile; + } + set + { + m_GenerateXmlDocFile = value; + } + } + + [OptionNode("XmlDocFile")] + private string m_XmlDocFile = ""; + + /// + /// + /// + public string XmlDocFile + { + get + { + return m_XmlDocFile; + } + set + { + m_XmlDocFile = value; + } + } + + [OptionNode("KeyFile")] + private string m_KeyFile = ""; + + /// + /// + /// + public string KeyFile + { + get + { + return m_KeyFile; + } + set + { + m_KeyFile = value; + } + } + + [OptionNode("DebugInformation")] + private bool m_DebugInformation; + + /// + /// + /// + public bool DebugInformation + { + get + { + return m_DebugInformation; + } + set + { + m_DebugInformation = value; + } + } + + [OptionNode("RegisterComInterop")] + private bool m_RegisterComInterop; + + /// + /// + /// + public bool RegisterComInterop + { + get + { + return m_RegisterComInterop; + } + set + { + m_RegisterComInterop = value; + } + } + + [OptionNode("RemoveIntegerChecks")] + private bool m_RemoveIntegerChecks; + + /// + /// + /// + public bool RemoveIntegerChecks + { + get + { + return m_RemoveIntegerChecks; + } + set + { + m_RemoveIntegerChecks = value; + } + } + + [OptionNode("IncrementalBuild")] + private bool m_IncrementalBuild; + + /// + /// + /// + public bool IncrementalBuild + { + get + { + return m_IncrementalBuild; + } + set + { + m_IncrementalBuild = value; + } + } + + [OptionNode("BaseAddress")] + private string m_BaseAddress = "285212672"; + + /// + /// + /// + public string BaseAddress + { + get + { + return m_BaseAddress; + } + set + { + m_BaseAddress = value; + } + } + + [OptionNode("FileAlignment")] + private int m_FileAlignment = 4096; + + /// + /// + /// + public int FileAlignment + { + get + { + return m_FileAlignment; + } + set + { + m_FileAlignment = value; + } + } + + [OptionNode("NoStdLib")] + private bool m_NoStdLib; + + /// + /// + /// + public bool NoStdLib + { + get + { + return m_NoStdLib; + } + set + { + m_NoStdLib = value; + } + } + + private readonly List m_FieldsDefined = new List(); + + #endregion + + #region Constructors + + /// + /// Initializes the class. + /// + static OptionsNode() + { + Type t = typeof(OptionsNode); + + foreach(FieldInfo f in t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) + { + object[] attrs = f.GetCustomAttributes(typeof(OptionNodeAttribute), false); + if(attrs == null || attrs.Length < 1) + { + continue; + } + + OptionNodeAttribute ona = (OptionNodeAttribute)attrs[0]; + m_OptionFields[ona.NodeName] = f; + } + } + + #endregion + + #region Properties + + /// + /// Gets the at the specified index. + /// + /// + public object this[string index] + { + get + { + if(!m_OptionFields.ContainsKey(index)) + { + return null; + } + + FieldInfo f = m_OptionFields[index]; + return f.GetValue(this); + } + } + + /// + /// Gets the at the specified index. + /// + /// + public object this[string index, object defaultValue] + { + get + { + object valueObject = this[index]; + if(valueObject != null && valueObject is string && ((string)valueObject).Length == 0) + { + return defaultValue; + } + return valueObject; + } + } + + + #endregion + + #region Private Methods + + private void FlagDefined(string name) + { + if(!m_FieldsDefined.Contains(name)) + { + m_FieldsDefined.Add(name); + } + } + + private void SetOption(string nodeName, string val) + { + lock(m_OptionFields) + { + if(!m_OptionFields.ContainsKey(nodeName)) + { + return; + } + + FieldInfo f = m_OptionFields[nodeName]; + f.SetValue(this, Helper.TranslateValue(f.FieldType, val)); + FlagDefined(f.Name); + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach(XmlNode child in node.ChildNodes) + { + SetOption(child.Name, Helper.InterpolateForEnvironmentVariables(child.InnerText)); + } + } + + /// + /// Copies to. + /// + /// The opt. + public void CopyTo(OptionsNode opt) + { + if(opt == null) + { + return; + } + + foreach(FieldInfo f in m_OptionFields.Values) + { + if(m_FieldsDefined.Contains(f.Name)) + { + f.SetValue(opt, f.GetValue(this)); + opt.m_FieldsDefined.Add(f.Name); + } + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/ProcessNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/ProcessNode.cs.svn-base new file mode 100644 index 0000000..8ca8e49 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/ProcessNode.cs.svn-base @@ -0,0 +1,108 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Process")] + public class ProcessNode : DataNode + { + #region Fields + + private string m_Path; + private bool m_IsValid = true; + + #endregion + + #region Properties + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets a value indicating whether this instance is valid. + /// + /// true if this instance is valid; otherwise, false. + public bool IsValid + { + get + { + return m_IsValid; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Path == null) + { + m_Path = ""; + } + + try + { + m_Path = Helper.ResolvePath(m_Path); + } + catch(ArgumentException) + { + Kernel.Instance.Log.Write(LogType.Warning, "Could not find prebuild file for processing: {0}", m_Path); + m_IsValid = false; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/ProjectNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/ProjectNode.cs.svn-base new file mode 100644 index 0000000..fb92b32 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/ProjectNode.cs.svn-base @@ -0,0 +1,579 @@ +#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 System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// A set of values that the Project's type can be + /// + public enum ProjectType + { + /// + /// The project is a console executable + /// + Exe, + /// + /// The project is a windows executable + /// + WinExe, + /// + /// The project is a library + /// + Library, + /// + /// The project is a website + /// + Web, + } + + /// + /// + /// + public enum ClrRuntime + { + /// + /// + /// + Microsoft, + /// + /// + /// + Mono + } + /// + /// The version of the .NET framework to use (Required for VS2008) + /// We don't need .NET 1.1 in here, it'll default when using vs2003. + /// + public enum FrameworkVersion + { + /// + /// .NET 2.0 + /// + v2_0, + /// + /// .NET 3.0 + /// + v3_0, + /// + /// .NET 3.5 + /// + v3_5, + /// + /// .NET 4.0 + /// + v4_0, + } + /// + /// The Node object representing /Prebuild/Solution/Project elements + /// + [DataNode("Project")] + public class ProjectNode : DataNode, IComparable + { + #region Fields + + private string m_Name = "unknown"; + private string m_Path = ""; + private string m_FullPath = ""; + private string m_AssemblyName; + private string m_AppIcon = ""; + private string m_ConfigFile = ""; + private string m_DesignerFolder = ""; + private string m_Language = "C#"; + private ProjectType m_Type = ProjectType.Exe; + private ClrRuntime m_Runtime = ClrRuntime.Microsoft; + private FrameworkVersion m_Framework = FrameworkVersion.v2_0; + private string m_StartupObject = ""; + private string m_RootNamespace; + private string m_FilterGroups = ""; + private string m_Version = ""; + private Guid m_Guid; + private string m_DebugStartParameters; + + private readonly Dictionary m_Configurations = new Dictionary(); + private readonly List m_ReferencePaths = new List(); + private readonly List m_References = new List(); + private readonly List m_Authors = new List(); + private FilesNode m_Files; + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + /// + /// The version of the .NET Framework to compile under + /// + public FrameworkVersion FrameworkVersion + { + get + { + return m_Framework; + } + } + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets the filter groups. + /// + /// The filter groups. + public string FilterGroups + { + get + { + return m_FilterGroups; + } + } + + /// + /// Gets the project's version + /// + /// The project's version. + public string Version + { + get + { + return m_Version; + } + } + + /// + /// Gets the full path. + /// + /// The full path. + public string FullPath + { + get + { + return m_FullPath; + } + } + + /// + /// Gets the name of the assembly. + /// + /// The name of the assembly. + public string AssemblyName + { + get + { + return m_AssemblyName; + } + } + + /// + /// Gets the app icon. + /// + /// The app icon. + public string AppIcon + { + get + { + return m_AppIcon; + } + } + + /// + /// Gets the app icon. + /// + /// The app icon. + public string ConfigFile + { + get + { + return m_ConfigFile; + } + } + + /// + /// + /// + public string DesignerFolder + { + get + { + return m_DesignerFolder; + } + } + + /// + /// Gets the language. + /// + /// The language. + public string Language + { + get + { + return m_Language; + } + } + + /// + /// Gets the type. + /// + /// The type. + public ProjectType Type + { + get + { + return m_Type; + } + } + + /// + /// Gets the runtime. + /// + /// The runtime. + public ClrRuntime Runtime + { + get + { + return m_Runtime; + } + } + + private bool m_GenerateAssemblyInfoFile; + + /// + /// + /// + public bool GenerateAssemblyInfoFile + { + get + { + return m_GenerateAssemblyInfoFile; + } + set + { + m_GenerateAssemblyInfoFile = value; + } + } + + /// + /// Gets the startup object. + /// + /// The startup object. + public string StartupObject + { + get + { + return m_StartupObject; + } + } + + /// + /// Gets the root namespace. + /// + /// The root namespace. + public string RootNamespace + { + get + { + return m_RootNamespace; + } + } + + /// + /// Gets the configurations. + /// + /// The configurations. + public List Configurations + { + get + { + List tmp = new List(ConfigurationsTable.Values); + tmp.Sort(); + return tmp; + } + } + + /// + /// Gets the configurations table. + /// + /// The configurations table. + public Dictionary ConfigurationsTable + { + get + { + return m_Configurations; + } + } + + /// + /// Gets the reference paths. + /// + /// The reference paths. + public List ReferencePaths + { + get + { + List tmp = new List(m_ReferencePaths); + tmp.Sort(); + return tmp; + } + } + + /// + /// Gets the references. + /// + /// The references. + public List References + { + get + { + List tmp = new List(m_References); + tmp.Sort(); + return tmp; + } + } + + /// + /// Gets the Authors list. + /// + /// The list of the project's authors. + public List Authors + { + get + { + return m_Authors; + } + } + + /// + /// Gets the files. + /// + /// The files. + public FilesNode Files + { + get + { + return m_Files; + } + } + + /// + /// Gets or sets the parent. + /// + /// The parent. + public override IDataNode Parent + { + get + { + return base.Parent; + } + set + { + base.Parent = value; + if(base.Parent is SolutionNode && m_Configurations.Count < 1) + { + SolutionNode parent = (SolutionNode)base.Parent; + foreach(ConfigurationNode conf in parent.Configurations) + { + m_Configurations[conf.NameAndPlatform] = (ConfigurationNode) conf.Clone(); + } + } + } + } + + /// + /// Gets the GUID. + /// + /// The GUID. + public Guid Guid + { + get + { + return m_Guid; + } + } + + public string DebugStartParameters + { + get + { + return m_DebugStartParameters; + } + } + + #endregion + + #region Private Methods + + private void HandleConfiguration(ConfigurationNode conf) + { + if(String.Compare(conf.Name, "all", true) == 0) //apply changes to all, this may not always be applied first, + //so it *may* override changes to the same properties for configurations defines at the project level + { + foreach(ConfigurationNode confNode in m_Configurations.Values) + { + conf.CopyTo(confNode);//update the config templates defines at the project level with the overrides + } + } + if(m_Configurations.ContainsKey(conf.NameAndPlatform)) + { + ConfigurationNode parentConf = m_Configurations[conf.NameAndPlatform]; + conf.CopyTo(parentConf);//update the config templates defines at the project level with the overrides + } + else + { + m_Configurations[conf.NameAndPlatform] = conf; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + m_Path = Helper.AttributeValue(node, "path", m_Path); + m_FilterGroups = Helper.AttributeValue(node, "filterGroups", m_FilterGroups); + m_Version = Helper.AttributeValue(node, "version", m_Version); + m_AppIcon = Helper.AttributeValue(node, "icon", m_AppIcon); + m_ConfigFile = Helper.AttributeValue(node, "configFile", m_ConfigFile); + m_DesignerFolder = Helper.AttributeValue(node, "designerFolder", m_DesignerFolder); + m_AssemblyName = Helper.AttributeValue(node, "assemblyName", m_AssemblyName); + m_Language = Helper.AttributeValue(node, "language", m_Language); + m_Type = (ProjectType)Helper.EnumAttributeValue(node, "type", typeof(ProjectType), m_Type); + m_Runtime = (ClrRuntime)Helper.EnumAttributeValue(node, "runtime", typeof(ClrRuntime), m_Runtime); + m_Framework = (FrameworkVersion)Helper.EnumAttributeValue(node, "frameworkVersion", typeof(FrameworkVersion), m_Framework); + m_StartupObject = Helper.AttributeValue(node, "startupObject", m_StartupObject); + m_RootNamespace = Helper.AttributeValue(node, "rootNamespace", m_RootNamespace); + + int hash = m_Name.GetHashCode(); + Guid guidByHash = new Guid(hash, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + string guid = Helper.AttributeValue(node, "guid", guidByHash.ToString()); + m_Guid = new Guid(guid); + + m_GenerateAssemblyInfoFile = Helper.ParseBoolean(node, "generateAssemblyInfoFile", false); + m_DebugStartParameters = Helper.AttributeValue(node, "debugStartParameters", string.Empty); + + if(string.IsNullOrEmpty(m_AssemblyName)) + { + m_AssemblyName = m_Name; + } + + if(string.IsNullOrEmpty(m_RootNamespace)) + { + m_RootNamespace = m_Name; + } + + m_FullPath = m_Path; + try + { + m_FullPath = Helper.ResolvePath(m_FullPath); + } + catch + { + throw new WarningException("Could not resolve Solution path: {0}", m_Path); + } + + Kernel.Instance.CurrentWorkingDirectory.Push(); + try + { + Helper.SetCurrentDir(m_FullPath); + + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is ConfigurationNode) + { + HandleConfiguration((ConfigurationNode)dataNode); + } + else if(dataNode is ReferencePathNode) + { + m_ReferencePaths.Add((ReferencePathNode)dataNode); + } + else if(dataNode is ReferenceNode) + { + m_References.Add((ReferenceNode)dataNode); + } + else if(dataNode is AuthorNode) + { + m_Authors.Add((AuthorNode)dataNode); + } + else if(dataNode is FilesNode) + { + m_Files = (FilesNode)dataNode; + } + } + } + finally + { + Kernel.Instance.CurrentWorkingDirectory.Pop(); + } + } + + #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + ProjectNode that = (ProjectNode)obj; + return m_Name.CompareTo(that.m_Name); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/ReferenceNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/ReferenceNode.cs.svn-base new file mode 100644 index 0000000..9c5d1a3 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/ReferenceNode.cs.svn-base @@ -0,0 +1,144 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Reference")] + public class ReferenceNode : DataNode, IComparable + { + #region Fields + + private string m_Name = "unknown"; + private string m_Path; + private string m_LocalCopy; + private string m_Version; + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets a value indicating whether [local copy specified]. + /// + /// true if [local copy specified]; otherwise, false. + public bool LocalCopySpecified + { + get + { + return ( m_LocalCopy != null && m_LocalCopy.Length == 0); + } + } + + /// + /// Gets a value indicating whether [local copy]. + /// + /// true if [local copy]; otherwise, false. + public bool LocalCopy + { + get + { + if( m_LocalCopy == null) + { + return false; + } + return bool.Parse(m_LocalCopy); + } + } + + /// + /// Gets the version. + /// + /// The version. + public string Version + { + get + { + return m_Version; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + m_Path = Helper.AttributeValue(node, "path", m_Path); + m_LocalCopy = Helper.AttributeValue(node, "localCopy", m_LocalCopy); + m_Version = Helper.AttributeValue(node, "version", m_Version); + } + + #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + ReferenceNode that = (ReferenceNode)obj; + return this.m_Name.CompareTo(that.m_Name); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/ReferencePathNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/ReferencePathNode.cs.svn-base new file mode 100644 index 0000000..7331cd7 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/ReferencePathNode.cs.svn-base @@ -0,0 +1,97 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("ReferencePath")] + public class ReferencePathNode : DataNode, IComparable + { + #region Fields + + private string m_Path; + + #endregion + + #region Properties + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Path == null) + { + m_Path = ""; + } + + m_Path = m_Path.Trim(); + } + + #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + ReferencePathNode that = (ReferencePathNode)obj; + return this.m_Path.CompareTo(that.m_Path); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/SolutionNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/SolutionNode.cs.svn-base new file mode 100644 index 0000000..10c0223 --- /dev/null +++ b/Prebuild/src/Core/Nodes/.svn/text-base/SolutionNode.cs.svn-base @@ -0,0 +1,382 @@ +#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.Diagnostics; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Solution")] + [DataNode("EmbeddedSolution")] + [DebuggerDisplay("{Name}")] + public class SolutionNode : DataNode + { + #region Fields + + private Guid m_Guid = Guid.NewGuid(); + private string m_Name = "unknown"; + private string m_Path = ""; + private string m_FullPath = ""; + private string m_ActiveConfig; + private string m_Version = "1.0.0"; + + private OptionsNode m_Options; + private FilesNode m_Files; + private readonly ConfigurationNodeCollection m_Configurations = new ConfigurationNodeCollection(); + private readonly Dictionary m_Projects = new Dictionary(); + private readonly Dictionary m_DatabaseProjects = new Dictionary(); + private readonly List m_ProjectsOrder = new List(); + private readonly Dictionary m_Solutions = new Dictionary(); + private CleanupNode m_Cleanup; + + #endregion + + #region Properties + public override IDataNode Parent + { + get + { + return base.Parent; + } + set + { + if (value is SolutionNode) + { + SolutionNode solution = (SolutionNode)value; + foreach (ConfigurationNode conf in solution.Configurations) + { + m_Configurations[conf.Name] = (ConfigurationNode) conf.Clone(); + } + } + + base.Parent = value; + } + } + + public CleanupNode Cleanup + { + get + { + return m_Cleanup; + } + set + { + m_Cleanup = value; + } + } + + public Guid Guid + { + get + { + return m_Guid; + } + set + { + m_Guid = value; + } + } + /// + /// Gets or sets the active config. + /// + /// The active config. + public string ActiveConfig + { + get + { + return m_ActiveConfig; + } + set + { + m_ActiveConfig = value; + } + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets the full path. + /// + /// The full path. + public string FullPath + { + get + { + return m_FullPath; + } + } + + /// + /// Gets the version. + /// + /// The version. + public string Version + { + get + { + return m_Version; + } + } + + /// + /// Gets the options. + /// + /// The options. + public OptionsNode Options + { + get + { + return m_Options; + } + } + + /// + /// Gets the files. + /// + /// The files. + public FilesNode Files + { + get + { + return m_Files; + } + } + + /// + /// Gets the configurations. + /// + /// The configurations. + public ConfigurationNodeCollection Configurations + { + get + { + ConfigurationNodeCollection tmp = new ConfigurationNodeCollection(); + tmp.AddRange(ConfigurationsTable); + return tmp; + } + } + + /// + /// Gets the configurations table. + /// + /// The configurations table. + public ConfigurationNodeCollection ConfigurationsTable + { + get + { + return m_Configurations; + } + } + /// + /// Gets the database projects. + /// + public ICollection DatabaseProjects + { + get + { + return m_DatabaseProjects.Values; + } + } + /// + /// Gets the nested solutions. + /// + public ICollection Solutions + { + get + { + return m_Solutions.Values; + } + } + /// + /// Gets the nested solutions hash table. + /// + public Dictionary SolutionsTable + { + get + { + return m_Solutions; + } + } + /// + /// Gets the projects. + /// + /// The projects. + public ICollection Projects + { + get + { + List tmp = new List(m_Projects.Values); + tmp.Sort(); + return tmp; + } + } + + /// + /// Gets the projects table. + /// + /// The projects table. + public Dictionary ProjectsTable + { + get + { + return m_Projects; + } + } + + /// + /// Gets the projects table. + /// + /// The projects table. + public List ProjectsTableOrder + { + get + { + return m_ProjectsOrder; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + m_ActiveConfig = Helper.AttributeValue(node, "activeConfig", m_ActiveConfig); + m_Path = Helper.AttributeValue(node, "path", m_Path); + m_Version = Helper.AttributeValue(node, "version", m_Version); + + m_FullPath = m_Path; + try + { + m_FullPath = Helper.ResolvePath(m_FullPath); + } + catch + { + throw new WarningException("Could not resolve solution path: {0}", m_Path); + } + + Kernel.Instance.CurrentWorkingDirectory.Push(); + try + { + Helper.SetCurrentDir(m_FullPath); + + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is OptionsNode) + { + m_Options = (OptionsNode)dataNode; + } + else if(dataNode is FilesNode) + { + m_Files = (FilesNode)dataNode; + } + else if(dataNode is ConfigurationNode) + { + ConfigurationNode configurationNode = (ConfigurationNode) dataNode; + m_Configurations[configurationNode.NameAndPlatform] = configurationNode; + + // If the active configuration is null, then we populate it. + if (ActiveConfig == null) + { + ActiveConfig = configurationNode.Name; + } + } + else if(dataNode is ProjectNode) + { + m_Projects[((ProjectNode)dataNode).Name] = (ProjectNode) dataNode; + m_ProjectsOrder.Add((ProjectNode)dataNode); + } + else if(dataNode is SolutionNode) + { + m_Solutions[((SolutionNode)dataNode).Name] = (SolutionNode) dataNode; + } + else if (dataNode is ProcessNode) + { + ProcessNode p = (ProcessNode)dataNode; + Kernel.Instance.ProcessFile(p, this); + } + else if (dataNode is DatabaseProjectNode) + { + m_DatabaseProjects[((DatabaseProjectNode)dataNode).Name] = (DatabaseProjectNode) dataNode; + } + else if(dataNode is CleanupNode) + { + if(m_Cleanup != null) + throw new WarningException("There can only be one Cleanup node."); + m_Cleanup = (CleanupNode)dataNode; + } + } + } + finally + { + Kernel.Instance.CurrentWorkingDirectory.Pop(); + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/AuthorNode.cs b/Prebuild/src/Core/Nodes/AuthorNode.cs new file mode 100644 index 0000000..4c415bb --- /dev/null +++ b/Prebuild/src/Core/Nodes/AuthorNode.cs @@ -0,0 +1,87 @@ +#region BSD License +/* +Copyright (c) 2007 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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Author")] + public class AuthorNode : DataNode + { + #region Fields + + private string m_Signature; + + #endregion + + #region Properties + + /// + /// Gets the signature. + /// + /// The signature. + public string Signature + { + get + { + return m_Signature; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Signature = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Signature == null) + { + m_Signature = ""; + } + + m_Signature = m_Signature.Trim(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/CleanFilesNode.cs b/Prebuild/src/Core/Nodes/CleanFilesNode.cs new file mode 100644 index 0000000..dc2da9a --- /dev/null +++ b/Prebuild/src/Core/Nodes/CleanFilesNode.cs @@ -0,0 +1,80 @@ +#region BSD License +/* +Copyright (c) 2007 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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + [DataNode("CleanFiles")] + public class CleanFilesNode : DataNode + { + #region Fields + + private string m_Pattern; + + #endregion + + #region Properties + + /// + /// Gets the signature. + /// + /// The signature. + public string Pattern + { + get + { + return m_Pattern; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if (node == null) + { + throw new ArgumentNullException("node"); + } + + m_Pattern = Helper.AttributeValue(node, "pattern", String.Empty); ; + m_Pattern = m_Pattern.Trim(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Prebuild/src/Core/Nodes/CleanupNode.cs b/Prebuild/src/Core/Nodes/CleanupNode.cs new file mode 100644 index 0000000..a9b77eb --- /dev/null +++ b/Prebuild/src/Core/Nodes/CleanupNode.cs @@ -0,0 +1,85 @@ +#region BSD License +/* +Copyright (c) 2007 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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; + +namespace Prebuild.Core.Nodes +{ + [DataNode("Cleanup")] + public class CleanupNode : DataNode + { + #region Fields + + private List m_CleanFiles = new List(); + + #endregion + + #region Properties + + /// + /// Gets the signature. + /// + /// The signature. + public List CleanFiles + { + get + { + return m_CleanFiles; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach (XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if (dataNode is CleanFilesNode) + { + m_CleanFiles.Add((CleanFilesNode)dataNode); + } + } + } + + #endregion + } +} \ No newline at end of file diff --git a/Prebuild/src/Core/Nodes/ConfigurationNode.cs b/Prebuild/src/Core/Nodes/ConfigurationNode.cs new file mode 100644 index 0000000..cd2f740 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ConfigurationNode.cs @@ -0,0 +1,225 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Configuration")] + public class ConfigurationNode : DataNode, ICloneable, IComparable + { + #region Fields + + private string m_Name = "unknown"; + private string m_Platform = "AnyCPU"; + private OptionsNode m_Options; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public ConfigurationNode() + { + m_Options = new OptionsNode(); + } + + #endregion + + #region Properties + + /// + /// Gets or sets the parent. + /// + /// The parent. + public override IDataNode Parent + { + get + { + return base.Parent; + } + set + { + base.Parent = value; + if(base.Parent is SolutionNode) + { + SolutionNode node = (SolutionNode)base.Parent; + if(node != null && node.Options != null) + { + node.Options.CopyTo(m_Options); + } + } + } + } + + /// + /// Identifies the platform for this specific configuration. + /// + public string Platform + { + get + { + return m_Platform; + } + set + { + switch ((value + "").ToLower()) + { + case "x86": + case "x64": + m_Platform = value; + break; + case "itanium": + m_Platform = "Itanium"; + break; + default: + m_Platform = "AnyCPU"; + break; + } + } + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets the name and platform for the configuration. + /// + /// The name and platform. + public string NameAndPlatform + { + get + { + string platform = m_Platform; + if (platform == "AnyCPU") + platform = "Any CPU"; + + return String.Format("{0}|{1}", m_Name, platform); + } + } + + /// + /// Gets or sets the options. + /// + /// The options. + public OptionsNode Options + { + get + { + return m_Options; + } + set + { + m_Options = value; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + Platform = Helper.AttributeValue(node, "platform", m_Platform); + + if (node == null) + { + throw new ArgumentNullException("node"); + } + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is OptionsNode) + { + ((OptionsNode)dataNode).CopyTo(m_Options); + } + } + } + + /// + /// Copies to. + /// + /// The conf. + public void CopyTo(ConfigurationNode conf) + { + m_Options.CopyTo(conf.m_Options); + } + + #endregion + + #region ICloneable Members + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// + /// A new object that is a copy of this instance. + /// + public object Clone() + { + ConfigurationNode ret = new ConfigurationNode(); + ret.m_Name = m_Name; + ret.m_Platform = m_Platform; + m_Options.CopyTo(ret.m_Options); + return ret; + } + + #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + ConfigurationNode that = (ConfigurationNode) obj; + return this.m_Name.CompareTo(that.m_Name); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ConfigurationNodeCollection.cs b/Prebuild/src/Core/Nodes/ConfigurationNodeCollection.cs new file mode 100644 index 0000000..7c59ac5 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ConfigurationNodeCollection.cs @@ -0,0 +1,71 @@ +#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.Collections.Generic; + +namespace Prebuild.Core.Nodes +{ + /// + /// Implements a specialized list of configuration nodes which allows for lookup via + /// configuration name and platform. + /// + public class ConfigurationNodeCollection : List + { + #region Properties + + public ConfigurationNode this[string nameAndPlatform] + { + get + { + foreach (ConfigurationNode configurationNode in this) + { + if (configurationNode.NameAndPlatform == nameAndPlatform) + { + return configurationNode; + } + } + + return null; + } + + set + { + // See if the node + ConfigurationNode configurationNode = this[nameAndPlatform]; + + if (configurationNode != null) + { + this[IndexOf(configurationNode)] = value; + } + else + { + Add(value); + } + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/DataNode.cs b/Prebuild/src/Core/Nodes/DataNode.cs new file mode 100644 index 0000000..318b13c --- /dev/null +++ b/Prebuild/src/Core/Nodes/DataNode.cs @@ -0,0 +1,117 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using System.IO; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + public abstract class DataNode : IDataNode + { + #region Fields + + private IDataNode parent; + string[] m_WebTypes = new string[] { "aspx", "ascx", "master", "ashx", "asmx" }; + + #endregion + + #region IDataNode Members + + /// + /// Gets or sets the parent. + /// + /// The parent. + public virtual IDataNode Parent + { + get + { + return parent; + } + set + { + parent = value; + } + } + public string[] WebTypes + { + get { return m_WebTypes; } + } + /// + /// Parses the specified node. + /// + /// The node. + public virtual void Parse(XmlNode node) + { + } + public BuildAction GetBuildActionByFileName(string fileName) + { + string extension = Path.GetExtension(fileName).ToLower(); + foreach (string type in WebTypes) + { + if (extension == type) + return BuildAction.Content; + } + return BuildAction.Compile; + } + /// + /// Parses the file type to figure out what type it is + /// + /// + public SubType GetSubTypeByFileName(string fileName) + { + string extension = System.IO.Path.GetExtension(fileName).ToLower(); + string designer = String.Format(".designer{0}", extension); + string path = fileName.ToLower(); + if (extension == ".resx") + { + return SubType.Designer; + } + else if (path.EndsWith(".settings")) + { + return SubType.Settings; + } + else + { + + foreach (string type in WebTypes) + { + if (path.EndsWith(type)) + { + return SubType.CodeBehind; + } + } + } + return SubType.Code; + } + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs b/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs new file mode 100644 index 0000000..20095c3 --- /dev/null +++ b/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + [DataNode("DatabaseProject")] + public class DatabaseProjectNode : DataNode + { + string name; + string path; + string fullpath; + Guid guid = Guid.NewGuid(); + readonly List authors = new List(); + readonly List references = new List(); + + public Guid Guid + { + get { return guid; } + } + + public string Name + { + get { return name; } + } + + public string Path + { + get { return path; } + } + + public string FullPath + { + get { return fullpath; } + } + + public IEnumerable References + { + get { return references; } + } + + public override void Parse(XmlNode node) + { + name = Helper.AttributeValue(node, "name", name); + path = Helper.AttributeValue(node, "path", name); + + try + { + fullpath = Helper.ResolvePath(path); + } + catch + { + throw new WarningException("Could not resolve Solution path: {0}", path); + } + + Kernel.Instance.CurrentWorkingDirectory.Push(); + + try + { + Helper.SetCurrentDir(fullpath); + + if (node == null) + { + throw new ArgumentNullException("node"); + } + + foreach (XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + + if (dataNode == null) + continue; + + if (dataNode is AuthorNode) + authors.Add((AuthorNode)dataNode); + else if (dataNode is DatabaseReferenceNode) + references.Add((DatabaseReferenceNode)dataNode); + } + } + finally + { + Kernel.Instance.CurrentWorkingDirectory.Pop(); + } + + base.Parse(node); + } + } +} diff --git a/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs b/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs new file mode 100644 index 0000000..97c3964 --- /dev/null +++ b/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs @@ -0,0 +1,63 @@ +using System; +using Prebuild.Core.Attributes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + [DataNode("DatabaseReference")] + public class DatabaseReferenceNode : DataNode + { + string name; + Guid providerId; + string connectionString; + + public string Name + { + get { return name; } + } + + public Guid ProviderId + { + get { return providerId; } + } + + public string ConnectionString + { + get { return connectionString; } + } + + public override void Parse(System.Xml.XmlNode node) + { + name = Helper.AttributeValue(node, "name", name); + + string providerName = Helper.AttributeValue(node, "providerName", string.Empty); + if (providerName != null) + { + switch (providerName) + { + // digitaljeebus: pulled from HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\DataProviders\* + // Not sure if these will help other operating systems, or if there's a better way. + case "Microsoft.SqlServerCe.Client.3.5": + providerId = new Guid("7C602B5B-ACCB-4acd-9DC0-CA66388C1533"); break; + case "System.Data.OleDb": + providerId = new Guid("7F041D59-D76A-44ed-9AA2-FBF6B0548B80"); break; + case "System.Data.OracleClient": + providerId = new Guid("8F5C5018-AE09-42cf-B2CC-2CCCC7CFC2BB"); break; + case "System.Data.SqlClient": + providerId = new Guid("91510608-8809-4020-8897-FBA057E22D54"); break; + case "System.Data.Odbc": + providerId = new Guid("C3D4F4CE-2C48-4381-B4D6-34FA50C51C86"); break; + + default: + throw new ArgumentOutOfRangeException("providerName", providerName, "Could not provider name to an id."); + } + } + else + providerId = new Guid(Helper.AttributeValue(node, "providerId", Guid.Empty.ToString("B"))); + + connectionString = Helper.AttributeValue(node, "connectionString", connectionString); + + base.Parse(node); + } + } +} diff --git a/Prebuild/src/Core/Nodes/DescriptionNode.cs b/Prebuild/src/Core/Nodes/DescriptionNode.cs new file mode 100644 index 0000000..d1293a0 --- /dev/null +++ b/Prebuild/src/Core/Nodes/DescriptionNode.cs @@ -0,0 +1,87 @@ +#region BSD License +/* +Copyright (c) 2007 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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// The object representing the /Prebuild/Solution/Project/Description element + /// + [DataNode("Description")] + public class DescriptionNode : DataNode + { + #region Fields + + private string m_Value; + + #endregion + + #region Properties + + /// + /// Gets the description Value. + /// + /// The description Value. + public string Value + { + get + { + return m_Value; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Value = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Value == null) + { + m_Value = ""; + } + + m_Value = m_Value.Trim(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ExcludeNode.cs b/Prebuild/src/Core/Nodes/ExcludeNode.cs new file mode 100644 index 0000000..7f04cba --- /dev/null +++ b/Prebuild/src/Core/Nodes/ExcludeNode.cs @@ -0,0 +1,89 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Exclude")] + public class ExcludeNode : DataNode + { + #region Fields + + private string m_Pattern = ""; + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Pattern; + } + } + + /// + /// Gets the pattern. + /// + /// The pattern. + public string Pattern + { + get + { + return m_Pattern; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Pattern = Helper.AttributeValue( node, "name", m_Pattern ); + m_Pattern = Helper.AttributeValue(node, "pattern", m_Pattern ); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/FileNode.cs b/Prebuild/src/Core/Nodes/FileNode.cs new file mode 100644 index 0000000..01cea1e --- /dev/null +++ b/Prebuild/src/Core/Nodes/FileNode.cs @@ -0,0 +1,285 @@ +#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.IO; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; +using Prebuild.Core.Targets; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + public enum BuildAction + { + /// + /// + /// + None, + /// + /// + /// + Compile, + /// + /// + /// + Content, + /// + /// + /// + EmbeddedResource, + /// + /// + /// + ApplicationDefinition, + /// + /// + /// + Page + } + + /// + /// + /// + public enum SubType + { + /// + /// + /// + Code, + /// + /// + /// + Component, + /// + /// + /// + Designer, + /// + /// + /// + Form, + /// + /// + /// + Settings, + /// + /// + /// + UserControl, + /// + /// + /// + CodeBehind, + } + + public enum CopyToOutput + { + Never, + Always, + PreserveNewest + } + + /// + /// + /// + [DataNode("File")] + public class FileNode : DataNode + { + #region Fields + + private string m_Path; + private string m_ResourceName = ""; + private BuildAction? m_BuildAction; + private bool m_Valid; + private SubType? m_SubType; + private CopyToOutput m_CopyToOutput = CopyToOutput.Never; + private bool m_Link = false; + private string m_LinkPath = string.Empty; + private bool m_PreservePath = false; + + + #endregion + + #region Properties + + /// + /// + /// + public string Path + { + get + { + return m_Path; + } + } + + /// + /// + /// + public string ResourceName + { + get + { + return m_ResourceName; + } + } + + /// + /// + /// + public BuildAction BuildAction + { + get + { + if (m_BuildAction != null) + return m_BuildAction.Value; + else + return GetBuildActionByFileName(this.Path); + + } + } + + public CopyToOutput CopyToOutput + { + get + { + return this.m_CopyToOutput; + } + } + + public bool IsLink + { + get + { + return this.m_Link; + } + } + + public string LinkPath + { + get + { + return this.m_LinkPath; + } + } + /// + /// + /// + public SubType SubType + { + get + { + if (m_SubType != null) + return m_SubType.Value; + else + return GetSubTypeByFileName(this.Path); + } + } + + /// + /// + /// + public bool IsValid + { + get + { + return m_Valid; + } + } + + /// + /// + /// + /// + /// + public bool PreservePath + { + get + { + return m_PreservePath; + } + } + + #endregion + + #region Public Methods + + /// + /// + /// + /// + public override void Parse(XmlNode node) + { + string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty); + if (buildAction != string.Empty) + m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction); + string subType = Helper.AttributeValue(node, "subType", string.Empty); + if (subType != String.Empty) + m_SubType = (SubType)Enum.Parse(typeof(SubType), subType); + + m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); + this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); + if ( this.m_Link == true ) + { + this.m_LinkPath = Helper.AttributeValue( node, "linkPath", string.Empty ); + } + this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); + this.m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) ); + + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Path == null) + { + m_Path = ""; + } + + m_Path = m_Path.Trim(); + m_Valid = true; + if(!File.Exists(m_Path)) + { + m_Valid = false; + Kernel.Instance.Log.Write(LogType.Warning, "File does not exist: {0}", m_Path); + } + + if (System.IO.Path.GetExtension(m_Path) == ".settings") + { + m_SubType = SubType.Settings; + m_BuildAction = BuildAction.None; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/FilesNode.cs b/Prebuild/src/Core/Nodes/FilesNode.cs new file mode 100644 index 0000000..23a716c --- /dev/null +++ b/Prebuild/src/Core/Nodes/FilesNode.cs @@ -0,0 +1,204 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using System.IO; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Files")] + public class FilesNode : DataNode + { + #region Fields + + private readonly List m_Files = new List(); + private readonly Dictionary m_BuildActions = new Dictionary(); + private readonly Dictionary m_SubTypes = new Dictionary(); + private readonly Dictionary m_ResourceNames = new Dictionary(); + private readonly Dictionary m_CopyToOutputs = new Dictionary(); + private readonly Dictionary m_Links = new Dictionary(); + private readonly Dictionary m_LinkPaths = new Dictionary(); + private readonly Dictionary m_PreservePaths = new Dictionary(); + + #endregion + + #region Properties + + public int Count + { + get + { + return m_Files.Count; + } + } + + #endregion + + #region Public Methods + + public BuildAction GetBuildAction(string file) + { + if(!m_BuildActions.ContainsKey(file)) + { + return BuildAction.Compile; + } + + return m_BuildActions[file]; + } + + public CopyToOutput GetCopyToOutput(string file) + { + if (!m_CopyToOutputs.ContainsKey(file)) + { + return CopyToOutput.Never; + } + return m_CopyToOutputs[file]; + } + + public bool GetIsLink(string file) + { + if (!m_Links.ContainsKey(file)) + { + return false; + } + return m_Links[file]; + } + + public bool Contains(string file) + { + return m_Files.Contains(file); + } + + public string GetLinkPath( string file ) + { + if ( !m_LinkPaths.ContainsKey( file ) ) + { + return string.Empty; + } + return m_LinkPaths[ file ]; + } + + public SubType GetSubType(string file) + { + if(!m_SubTypes.ContainsKey(file)) + { + return SubType.Code; + } + + return m_SubTypes[file]; + } + + public string GetResourceName(string file) + { + if(!m_ResourceNames.ContainsKey(file)) + { + return string.Empty; + } + + return m_ResourceNames[file]; + } + + public bool GetPreservePath( string file ) + { + if ( !m_PreservePaths.ContainsKey( file ) ) + { + return false; + } + + return m_PreservePaths[ file ]; + } + + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is FileNode) + { + FileNode fileNode = (FileNode)dataNode; + if(fileNode.IsValid) + { + if (!m_Files.Contains(fileNode.Path)) + { + m_Files.Add(fileNode.Path); + m_BuildActions[fileNode.Path] = fileNode.BuildAction; + m_SubTypes[fileNode.Path] = fileNode.SubType; + m_ResourceNames[fileNode.Path] = fileNode.ResourceName; + m_PreservePaths[ fileNode.Path ] = fileNode.PreservePath; + m_Links[ fileNode.Path ] = fileNode.IsLink; + m_LinkPaths[ fileNode.Path ] = fileNode.LinkPath; + m_CopyToOutputs[ fileNode.Path ] = fileNode.CopyToOutput; + + } + } + } + else if(dataNode is MatchNode) + { + foreach(string file in ((MatchNode)dataNode).Files) + { + MatchNode matchNode = (MatchNode)dataNode; + if (!m_Files.Contains(file)) + { + m_Files.Add(file); + if (matchNode.BuildAction == null) + m_BuildActions[file] = GetBuildActionByFileName(file); + else + m_BuildActions[file] = matchNode.BuildAction.Value; + m_SubTypes[file] = matchNode.SubType == null ? GetSubTypeByFileName(file) : matchNode.SubType.Value; + m_ResourceNames[ file ] = matchNode.ResourceName; + m_PreservePaths[ file ] = matchNode.PreservePath; + m_Links[ file ] = matchNode.IsLink; + m_LinkPaths[ file ] = matchNode.LinkPath; + m_CopyToOutputs[ file ] = matchNode.CopyToOutput; + + } + } + } + } + } + + // TODO: Check in to why StringCollection's enumerator doesn't implement + // IEnumerator? + public IEnumerator GetEnumerator() + { + return m_Files.GetEnumerator(); + } + + #endregion + + } +} diff --git a/Prebuild/src/Core/Nodes/MatchNode.cs b/Prebuild/src/Core/Nodes/MatchNode.cs new file mode 100644 index 0000000..9735265 --- /dev/null +++ b/Prebuild/src/Core/Nodes/MatchNode.cs @@ -0,0 +1,367 @@ +#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 System.Text.RegularExpressions; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Match")] + public class MatchNode : DataNode + { + #region Fields + + private readonly List m_Files = new List(); + private Regex m_Regex; + private BuildAction? m_BuildAction; + private SubType? m_SubType; + string m_ResourceName = ""; + private CopyToOutput m_CopyToOutput; + private bool m_Link; + private string m_LinkPath; + private bool m_PreservePath; + private readonly List m_Exclusions = new List(); + + #endregion + + #region Properties + + /// + /// + /// + public IEnumerable Files + { + get + { + return m_Files; + } + } + + /// + /// + /// + public BuildAction? BuildAction + { + get + { + return m_BuildAction; + } + } + + /// + /// + /// + public SubType? SubType + { + get + { + return m_SubType; + } + } + + public CopyToOutput CopyToOutput + { + get + { + return m_CopyToOutput; + } + } + + public bool IsLink + { + get + { + return m_Link; + } + } + + public string LinkPath + { + get + { + return m_LinkPath; + } + } + /// + /// + /// + public string ResourceName + { + get + { + return m_ResourceName; + } + } + + public bool PreservePath + { + get + { + return m_PreservePath; + } + } + + #endregion + + #region Private Methods + + /// + /// Recurses the directories. + /// + /// The path. + /// The pattern. + /// if set to true [recurse]. + /// if set to true [use regex]. + private void RecurseDirectories(string path, string pattern, bool recurse, bool useRegex, List exclusions) + { + Match match; + try + { + string[] files; + + Boolean excludeFile; + if(!useRegex) + { + try + { + files = Directory.GetFiles(path, pattern); + } + catch (IOException) + { + // swallow weird IOException error when running in a virtual box + // guest OS on a network share when the host OS is not Windows. + // This seems to happen on network shares + // when no files match, and may be related to this report: + // http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=254546 + + files = null; + } + + if(files != null) + { + foreach (string file in files) + { + excludeFile = false; + string fileTemp; + if (file.Substring(0,2) == "./" || file.Substring(0,2) == ".\\") + { + fileTemp = file.Substring(2); + } + else + { + fileTemp = file; + } + + // Check all excludions and set flag if there are any hits. + foreach ( ExcludeNode exclude in exclusions ) + { + Regex exRegEx = new Regex( exclude.Pattern ); + match = exRegEx.Match( file ); + excludeFile |= match.Success; + } + + if ( !excludeFile ) + { + m_Files.Add( fileTemp ); + } + + } + } + + // don't call return here, because we may need to recursively search directories below + // this one, even if no matches were found in this directory. + } + else + { + try + { + files = Directory.GetFiles(path); + } + catch (IOException) + { + // swallow weird IOException error when running in a virtual box + // guest OS on a network share. + files = null; + } + + if (files != null) + { + foreach (string file in files) + { + excludeFile = false; + + match = m_Regex.Match(file); + if (match.Success) + { + // Check all excludions and set flag if there are any hits. + foreach (ExcludeNode exclude in exclusions) + { + Regex exRegEx = new Regex(exclude.Pattern); + match = exRegEx.Match(file); + excludeFile |= !match.Success; + } + + if (!excludeFile) + { + m_Files.Add(file); + } + } + } + } + } + + if(recurse) + { + string[] dirs = Directory.GetDirectories(path); + if(dirs != null && dirs.Length > 0) + { + foreach (string str in dirs) + { + // hack to skip subversion folders. Not having this can cause + // a significant performance hit when running on a network drive. + if (str.EndsWith(".svn")) + continue; + + RecurseDirectories(Helper.NormalizePath(str), pattern, recurse, useRegex, exclusions); + } + } + } + } + catch(DirectoryNotFoundException) + { + return; + } + catch(ArgumentException) + { + return; + } + } + + #endregion + + #region Public Methods + + /// + /// + /// + /// + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + string path = Helper.AttributeValue(node, "path", "."); + string pattern = Helper.AttributeValue(node, "pattern", "*"); + bool recurse = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "recurse", "false")); + bool useRegex = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "useRegex", "false")); + string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty); + if (buildAction != string.Empty) + m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction); + + //TODO: Figure out where the subtype node is being assigned + //string subType = Helper.AttributeValue(node, "subType", string.Empty); + //if (subType != String.Empty) + // m_SubType = (SubType)Enum.Parse(typeof(SubType), subType); + m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName); + m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", m_CopyToOutput.ToString())); + m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); + if ( m_Link ) + { + m_LinkPath = Helper.AttributeValue( node, "linkPath", string.Empty ); + } + m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) ); + + + if(path != null && path.Length == 0) + { + path = ".";//use current directory + } + //throw new WarningException("Match must have a 'path' attribute"); + + if(pattern == null) + { + throw new WarningException("Match must have a 'pattern' attribute"); + } + + path = Helper.NormalizePath(path); + if(!Directory.Exists(path)) + { + throw new WarningException("Match path does not exist: {0}", path); + } + + try + { + if(useRegex) + { + m_Regex = new Regex(pattern); + } + } + catch(ArgumentException ex) + { + throw new WarningException("Could not compile regex pattern: {0}", ex.Message); + } + + + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is ExcludeNode) + { + ExcludeNode excludeNode = (ExcludeNode)dataNode; + m_Exclusions.Add( excludeNode ); + } + } + + RecurseDirectories( path, pattern, recurse, useRegex, m_Exclusions ); + + if (m_Files.Count < 1) + { + // Include the project name when the match node returns no matches to provide extra + // debug info. + ProjectNode project = Parent.Parent as ProjectNode; + string projectName = ""; + + if (project != null) + projectName = " in project " + project.AssemblyName; + + throw new WarningException("Match" + projectName + " returned no files: {0}{1}", Helper.EndPath(path), pattern); + } + m_Regex = null; + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/OptionsNode.cs b/Prebuild/src/Core/Nodes/OptionsNode.cs new file mode 100644 index 0000000..577de71 --- /dev/null +++ b/Prebuild/src/Core/Nodes/OptionsNode.cs @@ -0,0 +1,634 @@ +#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.Reflection; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Options")] + public class OptionsNode : DataNode + { + #region Fields + + private static readonly Dictionary m_OptionFields = new Dictionary(); + + [OptionNode("CompilerDefines")] + private string m_CompilerDefines = ""; + + /// + /// + /// + public string CompilerDefines + { + get + { + return m_CompilerDefines; + } + set + { + m_CompilerDefines = value; + } + } + + [OptionNode("OptimizeCode")] + private bool m_OptimizeCode; + + /// + /// + /// + public bool OptimizeCode + { + get + { + return m_OptimizeCode; + } + set + { + m_OptimizeCode = value; + } + } + + [OptionNode("CheckUnderflowOverflow")] + private bool m_CheckUnderflowOverflow; + + /// + /// + /// + public bool CheckUnderflowOverflow + { + get + { + return m_CheckUnderflowOverflow; + } + set + { + m_CheckUnderflowOverflow = value; + } + } + + [OptionNode("AllowUnsafe")] + private bool m_AllowUnsafe; + + /// + /// + /// + public bool AllowUnsafe + { + get + { + return m_AllowUnsafe; + } + set + { + m_AllowUnsafe = value; + } + } + + [OptionNode("PreBuildEvent")] + private string m_PreBuildEvent; + + /// + /// + /// + public string PreBuildEvent + { + get + { + return m_PreBuildEvent; + } + set + { + m_PreBuildEvent = value; + } + } + + [OptionNode("PostBuildEvent")] + private string m_PostBuildEvent; + + /// + /// + /// + public string PostBuildEvent + { + get + { + return m_PostBuildEvent; + } + set + { + m_PostBuildEvent = value; + } + } + + [OptionNode("PreBuildEventArgs")] + private string m_PreBuildEventArgs; + + /// + /// + /// + public string PreBuildEventArgs + { + get + { + return m_PreBuildEventArgs; + } + set + { + m_PreBuildEventArgs = value; + } + } + + [OptionNode("PostBuildEventArgs")] + private string m_PostBuildEventArgs; + + /// + /// + /// + public string PostBuildEventArgs + { + get + { + return m_PostBuildEventArgs; + } + set + { + m_PostBuildEventArgs = value; + } + } + + [OptionNode("RunPostBuildEvent")] + private string m_RunPostBuildEvent; + + /// + /// + /// + public string RunPostBuildEvent + { + get + { + return m_RunPostBuildEvent; + } + set + { + m_RunPostBuildEvent = value; + } + } + + [OptionNode("RunScript")] + private string m_RunScript; + + /// + /// + /// + public string RunScript + { + get + { + return m_RunScript; + } + set + { + m_RunScript = value; + } + } + + [OptionNode("WarningLevel")] + private int m_WarningLevel = 4; + + /// + /// + /// + public int WarningLevel + { + get + { + return m_WarningLevel; + } + set + { + m_WarningLevel = value; + } + } + + [OptionNode("WarningsAsErrors")] + private bool m_WarningsAsErrors; + + /// + /// + /// + public bool WarningsAsErrors + { + get + { + return m_WarningsAsErrors; + } + set + { + m_WarningsAsErrors = value; + } + } + + [OptionNode("SuppressWarnings")] + private string m_SuppressWarnings = ""; + + /// + /// + /// + public string SuppressWarnings + { + get + { + return m_SuppressWarnings; + } + set + { + m_SuppressWarnings = value; + } + } + + [OptionNode("OutputPath")] + private string m_OutputPath = "bin/"; + + /// + /// + /// + public string OutputPath + { + get + { + return m_OutputPath; + } + set + { + m_OutputPath = value; + } + } + + [OptionNode("GenerateDocumentation")] + private bool m_GenerateDocumentation; + + /// + /// + /// + public bool GenerateDocumentation + { + get + { + return m_GenerateDocumentation; + } + set + { + m_GenerateDocumentation = value; + } + } + + [OptionNode("GenerateXmlDocFile")] + private bool m_GenerateXmlDocFile; + + /// + /// + /// + public bool GenerateXmlDocFile + { + get + { + return m_GenerateXmlDocFile; + } + set + { + m_GenerateXmlDocFile = value; + } + } + + [OptionNode("XmlDocFile")] + private string m_XmlDocFile = ""; + + /// + /// + /// + public string XmlDocFile + { + get + { + return m_XmlDocFile; + } + set + { + m_XmlDocFile = value; + } + } + + [OptionNode("KeyFile")] + private string m_KeyFile = ""; + + /// + /// + /// + public string KeyFile + { + get + { + return m_KeyFile; + } + set + { + m_KeyFile = value; + } + } + + [OptionNode("DebugInformation")] + private bool m_DebugInformation; + + /// + /// + /// + public bool DebugInformation + { + get + { + return m_DebugInformation; + } + set + { + m_DebugInformation = value; + } + } + + [OptionNode("RegisterComInterop")] + private bool m_RegisterComInterop; + + /// + /// + /// + public bool RegisterComInterop + { + get + { + return m_RegisterComInterop; + } + set + { + m_RegisterComInterop = value; + } + } + + [OptionNode("RemoveIntegerChecks")] + private bool m_RemoveIntegerChecks; + + /// + /// + /// + public bool RemoveIntegerChecks + { + get + { + return m_RemoveIntegerChecks; + } + set + { + m_RemoveIntegerChecks = value; + } + } + + [OptionNode("IncrementalBuild")] + private bool m_IncrementalBuild; + + /// + /// + /// + public bool IncrementalBuild + { + get + { + return m_IncrementalBuild; + } + set + { + m_IncrementalBuild = value; + } + } + + [OptionNode("BaseAddress")] + private string m_BaseAddress = "285212672"; + + /// + /// + /// + public string BaseAddress + { + get + { + return m_BaseAddress; + } + set + { + m_BaseAddress = value; + } + } + + [OptionNode("FileAlignment")] + private int m_FileAlignment = 4096; + + /// + /// + /// + public int FileAlignment + { + get + { + return m_FileAlignment; + } + set + { + m_FileAlignment = value; + } + } + + [OptionNode("NoStdLib")] + private bool m_NoStdLib; + + /// + /// + /// + public bool NoStdLib + { + get + { + return m_NoStdLib; + } + set + { + m_NoStdLib = value; + } + } + + private readonly List m_FieldsDefined = new List(); + + #endregion + + #region Constructors + + /// + /// Initializes the class. + /// + static OptionsNode() + { + Type t = typeof(OptionsNode); + + foreach(FieldInfo f in t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) + { + object[] attrs = f.GetCustomAttributes(typeof(OptionNodeAttribute), false); + if(attrs == null || attrs.Length < 1) + { + continue; + } + + OptionNodeAttribute ona = (OptionNodeAttribute)attrs[0]; + m_OptionFields[ona.NodeName] = f; + } + } + + #endregion + + #region Properties + + /// + /// Gets the at the specified index. + /// + /// + public object this[string index] + { + get + { + if(!m_OptionFields.ContainsKey(index)) + { + return null; + } + + FieldInfo f = m_OptionFields[index]; + return f.GetValue(this); + } + } + + /// + /// Gets the at the specified index. + /// + /// + public object this[string index, object defaultValue] + { + get + { + object valueObject = this[index]; + if(valueObject != null && valueObject is string && ((string)valueObject).Length == 0) + { + return defaultValue; + } + return valueObject; + } + } + + + #endregion + + #region Private Methods + + private void FlagDefined(string name) + { + if(!m_FieldsDefined.Contains(name)) + { + m_FieldsDefined.Add(name); + } + } + + private void SetOption(string nodeName, string val) + { + lock(m_OptionFields) + { + if(!m_OptionFields.ContainsKey(nodeName)) + { + return; + } + + FieldInfo f = m_OptionFields[nodeName]; + f.SetValue(this, Helper.TranslateValue(f.FieldType, val)); + FlagDefined(f.Name); + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach(XmlNode child in node.ChildNodes) + { + SetOption(child.Name, Helper.InterpolateForEnvironmentVariables(child.InnerText)); + } + } + + /// + /// Copies to. + /// + /// The opt. + public void CopyTo(OptionsNode opt) + { + if(opt == null) + { + return; + } + + foreach(FieldInfo f in m_OptionFields.Values) + { + if(m_FieldsDefined.Contains(f.Name)) + { + f.SetValue(opt, f.GetValue(this)); + opt.m_FieldsDefined.Add(f.Name); + } + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ProcessNode.cs b/Prebuild/src/Core/Nodes/ProcessNode.cs new file mode 100644 index 0000000..8ca8e49 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ProcessNode.cs @@ -0,0 +1,108 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Process")] + public class ProcessNode : DataNode + { + #region Fields + + private string m_Path; + private bool m_IsValid = true; + + #endregion + + #region Properties + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets a value indicating whether this instance is valid. + /// + /// true if this instance is valid; otherwise, false. + public bool IsValid + { + get + { + return m_IsValid; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Path == null) + { + m_Path = ""; + } + + try + { + m_Path = Helper.ResolvePath(m_Path); + } + catch(ArgumentException) + { + Kernel.Instance.Log.Write(LogType.Warning, "Could not find prebuild file for processing: {0}", m_Path); + m_IsValid = false; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ProjectNode.cs b/Prebuild/src/Core/Nodes/ProjectNode.cs new file mode 100644 index 0000000..fb92b32 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ProjectNode.cs @@ -0,0 +1,579 @@ +#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 System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// A set of values that the Project's type can be + /// + public enum ProjectType + { + /// + /// The project is a console executable + /// + Exe, + /// + /// The project is a windows executable + /// + WinExe, + /// + /// The project is a library + /// + Library, + /// + /// The project is a website + /// + Web, + } + + /// + /// + /// + public enum ClrRuntime + { + /// + /// + /// + Microsoft, + /// + /// + /// + Mono + } + /// + /// The version of the .NET framework to use (Required for VS2008) + /// We don't need .NET 1.1 in here, it'll default when using vs2003. + /// + public enum FrameworkVersion + { + /// + /// .NET 2.0 + /// + v2_0, + /// + /// .NET 3.0 + /// + v3_0, + /// + /// .NET 3.5 + /// + v3_5, + /// + /// .NET 4.0 + /// + v4_0, + } + /// + /// The Node object representing /Prebuild/Solution/Project elements + /// + [DataNode("Project")] + public class ProjectNode : DataNode, IComparable + { + #region Fields + + private string m_Name = "unknown"; + private string m_Path = ""; + private string m_FullPath = ""; + private string m_AssemblyName; + private string m_AppIcon = ""; + private string m_ConfigFile = ""; + private string m_DesignerFolder = ""; + private string m_Language = "C#"; + private ProjectType m_Type = ProjectType.Exe; + private ClrRuntime m_Runtime = ClrRuntime.Microsoft; + private FrameworkVersion m_Framework = FrameworkVersion.v2_0; + private string m_StartupObject = ""; + private string m_RootNamespace; + private string m_FilterGroups = ""; + private string m_Version = ""; + private Guid m_Guid; + private string m_DebugStartParameters; + + private readonly Dictionary m_Configurations = new Dictionary(); + private readonly List m_ReferencePaths = new List(); + private readonly List m_References = new List(); + private readonly List m_Authors = new List(); + private FilesNode m_Files; + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + /// + /// The version of the .NET Framework to compile under + /// + public FrameworkVersion FrameworkVersion + { + get + { + return m_Framework; + } + } + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets the filter groups. + /// + /// The filter groups. + public string FilterGroups + { + get + { + return m_FilterGroups; + } + } + + /// + /// Gets the project's version + /// + /// The project's version. + public string Version + { + get + { + return m_Version; + } + } + + /// + /// Gets the full path. + /// + /// The full path. + public string FullPath + { + get + { + return m_FullPath; + } + } + + /// + /// Gets the name of the assembly. + /// + /// The name of the assembly. + public string AssemblyName + { + get + { + return m_AssemblyName; + } + } + + /// + /// Gets the app icon. + /// + /// The app icon. + public string AppIcon + { + get + { + return m_AppIcon; + } + } + + /// + /// Gets the app icon. + /// + /// The app icon. + public string ConfigFile + { + get + { + return m_ConfigFile; + } + } + + /// + /// + /// + public string DesignerFolder + { + get + { + return m_DesignerFolder; + } + } + + /// + /// Gets the language. + /// + /// The language. + public string Language + { + get + { + return m_Language; + } + } + + /// + /// Gets the type. + /// + /// The type. + public ProjectType Type + { + get + { + return m_Type; + } + } + + /// + /// Gets the runtime. + /// + /// The runtime. + public ClrRuntime Runtime + { + get + { + return m_Runtime; + } + } + + private bool m_GenerateAssemblyInfoFile; + + /// + /// + /// + public bool GenerateAssemblyInfoFile + { + get + { + return m_GenerateAssemblyInfoFile; + } + set + { + m_GenerateAssemblyInfoFile = value; + } + } + + /// + /// Gets the startup object. + /// + /// The startup object. + public string StartupObject + { + get + { + return m_StartupObject; + } + } + + /// + /// Gets the root namespace. + /// + /// The root namespace. + public string RootNamespace + { + get + { + return m_RootNamespace; + } + } + + /// + /// Gets the configurations. + /// + /// The configurations. + public List Configurations + { + get + { + List tmp = new List(ConfigurationsTable.Values); + tmp.Sort(); + return tmp; + } + } + + /// + /// Gets the configurations table. + /// + /// The configurations table. + public Dictionary ConfigurationsTable + { + get + { + return m_Configurations; + } + } + + /// + /// Gets the reference paths. + /// + /// The reference paths. + public List ReferencePaths + { + get + { + List tmp = new List(m_ReferencePaths); + tmp.Sort(); + return tmp; + } + } + + /// + /// Gets the references. + /// + /// The references. + public List References + { + get + { + List tmp = new List(m_References); + tmp.Sort(); + return tmp; + } + } + + /// + /// Gets the Authors list. + /// + /// The list of the project's authors. + public List Authors + { + get + { + return m_Authors; + } + } + + /// + /// Gets the files. + /// + /// The files. + public FilesNode Files + { + get + { + return m_Files; + } + } + + /// + /// Gets or sets the parent. + /// + /// The parent. + public override IDataNode Parent + { + get + { + return base.Parent; + } + set + { + base.Parent = value; + if(base.Parent is SolutionNode && m_Configurations.Count < 1) + { + SolutionNode parent = (SolutionNode)base.Parent; + foreach(ConfigurationNode conf in parent.Configurations) + { + m_Configurations[conf.NameAndPlatform] = (ConfigurationNode) conf.Clone(); + } + } + } + } + + /// + /// Gets the GUID. + /// + /// The GUID. + public Guid Guid + { + get + { + return m_Guid; + } + } + + public string DebugStartParameters + { + get + { + return m_DebugStartParameters; + } + } + + #endregion + + #region Private Methods + + private void HandleConfiguration(ConfigurationNode conf) + { + if(String.Compare(conf.Name, "all", true) == 0) //apply changes to all, this may not always be applied first, + //so it *may* override changes to the same properties for configurations defines at the project level + { + foreach(ConfigurationNode confNode in m_Configurations.Values) + { + conf.CopyTo(confNode);//update the config templates defines at the project level with the overrides + } + } + if(m_Configurations.ContainsKey(conf.NameAndPlatform)) + { + ConfigurationNode parentConf = m_Configurations[conf.NameAndPlatform]; + conf.CopyTo(parentConf);//update the config templates defines at the project level with the overrides + } + else + { + m_Configurations[conf.NameAndPlatform] = conf; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + m_Path = Helper.AttributeValue(node, "path", m_Path); + m_FilterGroups = Helper.AttributeValue(node, "filterGroups", m_FilterGroups); + m_Version = Helper.AttributeValue(node, "version", m_Version); + m_AppIcon = Helper.AttributeValue(node, "icon", m_AppIcon); + m_ConfigFile = Helper.AttributeValue(node, "configFile", m_ConfigFile); + m_DesignerFolder = Helper.AttributeValue(node, "designerFolder", m_DesignerFolder); + m_AssemblyName = Helper.AttributeValue(node, "assemblyName", m_AssemblyName); + m_Language = Helper.AttributeValue(node, "language", m_Language); + m_Type = (ProjectType)Helper.EnumAttributeValue(node, "type", typeof(ProjectType), m_Type); + m_Runtime = (ClrRuntime)Helper.EnumAttributeValue(node, "runtime", typeof(ClrRuntime), m_Runtime); + m_Framework = (FrameworkVersion)Helper.EnumAttributeValue(node, "frameworkVersion", typeof(FrameworkVersion), m_Framework); + m_StartupObject = Helper.AttributeValue(node, "startupObject", m_StartupObject); + m_RootNamespace = Helper.AttributeValue(node, "rootNamespace", m_RootNamespace); + + int hash = m_Name.GetHashCode(); + Guid guidByHash = new Guid(hash, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + string guid = Helper.AttributeValue(node, "guid", guidByHash.ToString()); + m_Guid = new Guid(guid); + + m_GenerateAssemblyInfoFile = Helper.ParseBoolean(node, "generateAssemblyInfoFile", false); + m_DebugStartParameters = Helper.AttributeValue(node, "debugStartParameters", string.Empty); + + if(string.IsNullOrEmpty(m_AssemblyName)) + { + m_AssemblyName = m_Name; + } + + if(string.IsNullOrEmpty(m_RootNamespace)) + { + m_RootNamespace = m_Name; + } + + m_FullPath = m_Path; + try + { + m_FullPath = Helper.ResolvePath(m_FullPath); + } + catch + { + throw new WarningException("Could not resolve Solution path: {0}", m_Path); + } + + Kernel.Instance.CurrentWorkingDirectory.Push(); + try + { + Helper.SetCurrentDir(m_FullPath); + + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is ConfigurationNode) + { + HandleConfiguration((ConfigurationNode)dataNode); + } + else if(dataNode is ReferencePathNode) + { + m_ReferencePaths.Add((ReferencePathNode)dataNode); + } + else if(dataNode is ReferenceNode) + { + m_References.Add((ReferenceNode)dataNode); + } + else if(dataNode is AuthorNode) + { + m_Authors.Add((AuthorNode)dataNode); + } + else if(dataNode is FilesNode) + { + m_Files = (FilesNode)dataNode; + } + } + } + finally + { + Kernel.Instance.CurrentWorkingDirectory.Pop(); + } + } + + #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + ProjectNode that = (ProjectNode)obj; + return m_Name.CompareTo(that.m_Name); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ReferenceNode.cs b/Prebuild/src/Core/Nodes/ReferenceNode.cs new file mode 100644 index 0000000..9c5d1a3 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ReferenceNode.cs @@ -0,0 +1,144 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Reference")] + public class ReferenceNode : DataNode, IComparable + { + #region Fields + + private string m_Name = "unknown"; + private string m_Path; + private string m_LocalCopy; + private string m_Version; + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets a value indicating whether [local copy specified]. + /// + /// true if [local copy specified]; otherwise, false. + public bool LocalCopySpecified + { + get + { + return ( m_LocalCopy != null && m_LocalCopy.Length == 0); + } + } + + /// + /// Gets a value indicating whether [local copy]. + /// + /// true if [local copy]; otherwise, false. + public bool LocalCopy + { + get + { + if( m_LocalCopy == null) + { + return false; + } + return bool.Parse(m_LocalCopy); + } + } + + /// + /// Gets the version. + /// + /// The version. + public string Version + { + get + { + return m_Version; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + m_Path = Helper.AttributeValue(node, "path", m_Path); + m_LocalCopy = Helper.AttributeValue(node, "localCopy", m_LocalCopy); + m_Version = Helper.AttributeValue(node, "version", m_Version); + } + + #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + ReferenceNode that = (ReferenceNode)obj; + return this.m_Name.CompareTo(that.m_Name); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ReferencePathNode.cs b/Prebuild/src/Core/Nodes/ReferencePathNode.cs new file mode 100644 index 0000000..7331cd7 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ReferencePathNode.cs @@ -0,0 +1,97 @@ +#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.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("ReferencePath")] + public class ReferencePathNode : DataNode, IComparable + { + #region Fields + + private string m_Path; + + #endregion + + #region Properties + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Path == null) + { + m_Path = ""; + } + + m_Path = m_Path.Trim(); + } + + #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + ReferencePathNode that = (ReferencePathNode)obj; + return this.m_Path.CompareTo(that.m_Path); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/SolutionNode.cs b/Prebuild/src/Core/Nodes/SolutionNode.cs new file mode 100644 index 0000000..10c0223 --- /dev/null +++ b/Prebuild/src/Core/Nodes/SolutionNode.cs @@ -0,0 +1,382 @@ +#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.Diagnostics; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Solution")] + [DataNode("EmbeddedSolution")] + [DebuggerDisplay("{Name}")] + public class SolutionNode : DataNode + { + #region Fields + + private Guid m_Guid = Guid.NewGuid(); + private string m_Name = "unknown"; + private string m_Path = ""; + private string m_FullPath = ""; + private string m_ActiveConfig; + private string m_Version = "1.0.0"; + + private OptionsNode m_Options; + private FilesNode m_Files; + private readonly ConfigurationNodeCollection m_Configurations = new ConfigurationNodeCollection(); + private readonly Dictionary m_Projects = new Dictionary(); + private readonly Dictionary m_DatabaseProjects = new Dictionary(); + private readonly List m_ProjectsOrder = new List(); + private readonly Dictionary m_Solutions = new Dictionary(); + private CleanupNode m_Cleanup; + + #endregion + + #region Properties + public override IDataNode Parent + { + get + { + return base.Parent; + } + set + { + if (value is SolutionNode) + { + SolutionNode solution = (SolutionNode)value; + foreach (ConfigurationNode conf in solution.Configurations) + { + m_Configurations[conf.Name] = (ConfigurationNode) conf.Clone(); + } + } + + base.Parent = value; + } + } + + public CleanupNode Cleanup + { + get + { + return m_Cleanup; + } + set + { + m_Cleanup = value; + } + } + + public Guid Guid + { + get + { + return m_Guid; + } + set + { + m_Guid = value; + } + } + /// + /// Gets or sets the active config. + /// + /// The active config. + public string ActiveConfig + { + get + { + return m_ActiveConfig; + } + set + { + m_ActiveConfig = value; + } + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets the full path. + /// + /// The full path. + public string FullPath + { + get + { + return m_FullPath; + } + } + + /// + /// Gets the version. + /// + /// The version. + public string Version + { + get + { + return m_Version; + } + } + + /// + /// Gets the options. + /// + /// The options. + public OptionsNode Options + { + get + { + return m_Options; + } + } + + /// + /// Gets the files. + /// + /// The files. + public FilesNode Files + { + get + { + return m_Files; + } + } + + /// + /// Gets the configurations. + /// + /// The configurations. + public ConfigurationNodeCollection Configurations + { + get + { + ConfigurationNodeCollection tmp = new ConfigurationNodeCollection(); + tmp.AddRange(ConfigurationsTable); + return tmp; + } + } + + /// + /// Gets the configurations table. + /// + /// The configurations table. + public ConfigurationNodeCollection ConfigurationsTable + { + get + { + return m_Configurations; + } + } + /// + /// Gets the database projects. + /// + public ICollection DatabaseProjects + { + get + { + return m_DatabaseProjects.Values; + } + } + /// + /// Gets the nested solutions. + /// + public ICollection Solutions + { + get + { + return m_Solutions.Values; + } + } + /// + /// Gets the nested solutions hash table. + /// + public Dictionary SolutionsTable + { + get + { + return m_Solutions; + } + } + /// + /// Gets the projects. + /// + /// The projects. + public ICollection Projects + { + get + { + List tmp = new List(m_Projects.Values); + tmp.Sort(); + return tmp; + } + } + + /// + /// Gets the projects table. + /// + /// The projects table. + public Dictionary ProjectsTable + { + get + { + return m_Projects; + } + } + + /// + /// Gets the projects table. + /// + /// The projects table. + public List ProjectsTableOrder + { + get + { + return m_ProjectsOrder; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + m_ActiveConfig = Helper.AttributeValue(node, "activeConfig", m_ActiveConfig); + m_Path = Helper.AttributeValue(node, "path", m_Path); + m_Version = Helper.AttributeValue(node, "version", m_Version); + + m_FullPath = m_Path; + try + { + m_FullPath = Helper.ResolvePath(m_FullPath); + } + catch + { + throw new WarningException("Could not resolve solution path: {0}", m_Path); + } + + Kernel.Instance.CurrentWorkingDirectory.Push(); + try + { + Helper.SetCurrentDir(m_FullPath); + + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is OptionsNode) + { + m_Options = (OptionsNode)dataNode; + } + else if(dataNode is FilesNode) + { + m_Files = (FilesNode)dataNode; + } + else if(dataNode is ConfigurationNode) + { + ConfigurationNode configurationNode = (ConfigurationNode) dataNode; + m_Configurations[configurationNode.NameAndPlatform] = configurationNode; + + // If the active configuration is null, then we populate it. + if (ActiveConfig == null) + { + ActiveConfig = configurationNode.Name; + } + } + else if(dataNode is ProjectNode) + { + m_Projects[((ProjectNode)dataNode).Name] = (ProjectNode) dataNode; + m_ProjectsOrder.Add((ProjectNode)dataNode); + } + else if(dataNode is SolutionNode) + { + m_Solutions[((SolutionNode)dataNode).Name] = (SolutionNode) dataNode; + } + else if (dataNode is ProcessNode) + { + ProcessNode p = (ProcessNode)dataNode; + Kernel.Instance.ProcessFile(p, this); + } + else if (dataNode is DatabaseProjectNode) + { + m_DatabaseProjects[((DatabaseProjectNode)dataNode).Name] = (DatabaseProjectNode) dataNode; + } + else if(dataNode is CleanupNode) + { + if(m_Cleanup != null) + throw new WarningException("There can only be one Cleanup node."); + m_Cleanup = (CleanupNode)dataNode; + } + } + } + finally + { + Kernel.Instance.CurrentWorkingDirectory.Pop(); + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Parse/.svn/all-wcprops b/Prebuild/src/Core/Parse/.svn/all-wcprops new file mode 100644 index 0000000..c77d416 --- /dev/null +++ b/Prebuild/src/Core/Parse/.svn/all-wcprops @@ -0,0 +1,17 @@ +K 25 +svn:wc:ra_dav:version-url +V 56 +/svnroot/dnpb/!svn/ver/323/trunk/Prebuild/src/Core/Parse +END +IfContext.cs +K 25 +svn:wc:ra_dav:version-url +V 69 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/Parse/IfContext.cs +END +Preprocessor.cs +K 25 +svn:wc:ra_dav:version-url +V 72 +/svnroot/dnpb/!svn/ver/323/trunk/Prebuild/src/Core/Parse/Preprocessor.cs +END diff --git a/Prebuild/src/Core/Parse/.svn/dir-prop-base b/Prebuild/src/Core/Parse/.svn/dir-prop-base new file mode 100644 index 0000000..a1989a0 --- /dev/null +++ b/Prebuild/src/Core/Parse/.svn/dir-prop-base @@ -0,0 +1,5 @@ +K 10 +svn:ignore +V 5 +*.swp +END diff --git a/Prebuild/src/Core/Parse/.svn/entries b/Prebuild/src/Core/Parse/.svn/entries new file mode 100644 index 0000000..2aae711 --- /dev/null +++ b/Prebuild/src/Core/Parse/.svn/entries @@ -0,0 +1,96 @@ +10 + +dir +323 +https://dnpb.svn.sourceforge.net/svnroot/dnpb/trunk/Prebuild/src/Core/Parse +https://dnpb.svn.sourceforge.net/svnroot/dnpb + + + +2010-09-10T17:51:36.189738Z +323 +jhurliman +has-props + + + + + + + + + + + + + +3355ff64-970d-0410-bbe8-d0fbd18be4fb + +IfContext.cs +file + + + + +2010-09-10T22:51:44.000000Z +859fca08c6a39a48f179d5ffe3d19bd0 +2009-02-19T06:47:52.218324Z +295 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +3653 + +Preprocessor.cs +file + + + + +2010-09-10T22:51:44.000000Z +6ef27f33f41caca9d4ab6c82ead76902 +2010-09-10T17:51:36.189738Z +323 +jhurliman +has-props + + + + + + + + + + + + + + + + + + + + +18590 + diff --git a/Prebuild/src/Core/Parse/.svn/prop-base/IfContext.cs.svn-base b/Prebuild/src/Core/Parse/.svn/prop-base/IfContext.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Parse/.svn/prop-base/IfContext.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Parse/.svn/prop-base/Preprocessor.cs.svn-base b/Prebuild/src/Core/Parse/.svn/prop-base/Preprocessor.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Parse/.svn/prop-base/Preprocessor.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Parse/.svn/text-base/IfContext.cs.svn-base b/Prebuild/src/Core/Parse/.svn/text-base/IfContext.cs.svn-base new file mode 100644 index 0000000..3c79d38 --- /dev/null +++ b/Prebuild/src/Core/Parse/.svn/text-base/IfContext.cs.svn-base @@ -0,0 +1,154 @@ +#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; + +namespace Prebuild.Core.Parse +{ + /// + /// + /// + public enum IfState + { + /// + /// + /// + None, + /// + /// + /// + If, + /// + /// + /// + ElseIf, + /// + /// + /// + Else + } + + /// + /// Summary description for IfContext. + /// + // Inspired by the equivalent WiX class (see www.sourceforge.net/projects/wix/) + public class IfContext + { + #region Properties + + bool m_Active; + bool m_Keep; + bool m_EverKept; + IfState m_State = IfState.None; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// if set to true [active]. + /// if set to true [keep]. + /// The state. + public IfContext(bool active, bool keep, IfState state) + { + m_Active = active; + m_Keep = keep; + m_EverKept = keep; + m_State = state; + } + + #endregion + + #region Properties + + /// + /// Gets or sets a value indicating whether this is active. + /// + /// true if active; otherwise, false. + public bool Active + { + get + { + return m_Active; + } + set + { + m_Active = value; + } + } + + /// + /// Gets or sets a value indicating whether this is keep. + /// + /// true if keep; otherwise, false. + public bool Keep + { + get + { + return m_Keep; + } + set + { + m_Keep = value; + if(m_Keep) + { + m_EverKept = true; + } + } + } + + /// + /// Gets a value indicating whether [ever kept]. + /// + /// true if [ever kept]; otherwise, false. + public bool EverKept + { + get + { + return m_EverKept; + } + } + + /// + /// Gets or sets the state. + /// + /// The state. + public IfState State + { + get + { + return m_State; + } + set + { + m_State = value; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Parse/.svn/text-base/Preprocessor.cs.svn-base b/Prebuild/src/Core/Parse/.svn/text-base/Preprocessor.cs.svn-base new file mode 100644 index 0000000..0648fad --- /dev/null +++ b/Prebuild/src/Core/Parse/.svn/text-base/Preprocessor.cs.svn-base @@ -0,0 +1,652 @@ +#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 System.Text.RegularExpressions; +using System.Xml; + +namespace Prebuild.Core.Parse +{ + /// + /// + /// + public enum OperatorSymbol + { + /// + /// + /// + None, + /// + /// + /// + Equal, + /// + /// + /// + NotEqual, + /// + /// + /// + LessThan, + /// + /// + /// + GreaterThan, + /// + /// + /// + LessThanEqual, + /// + /// + /// + GreaterThanEqual + } + + /// + /// + /// + public class Preprocessor + { + #region Constants + + /// + /// Includes the regex to look for file tags in the processing instruction. + /// + private static readonly Regex includeFileRegex = new Regex("file=\"(.+?)\""); + + #endregion + + #region Fields + + readonly XmlDocument m_OutDoc = new XmlDocument(); + readonly Stack m_IfStack = new Stack(); + readonly Dictionary m_Variables = new Dictionary(); + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public Preprocessor() + { + RegisterVariable("OS", GetOS()); + RegisterVariable("RuntimeVersion", Environment.Version.Major); + RegisterVariable("RuntimeMajor", Environment.Version.Major); + RegisterVariable("RuntimeMinor", Environment.Version.Minor); + RegisterVariable("RuntimeRevision", Environment.Version.Revision); + } + + #endregion + + #region Properties + + /// + /// Gets the processed doc. + /// + /// The processed doc. + public XmlDocument ProcessedDoc + { + get + { + return m_OutDoc; + } + } + + #endregion + + #region Private Methods + + /// + /// Parts of this code were taken from NAnt and is subject to the GPL + /// as per NAnt's license. Thanks to the NAnt guys for this little gem. + /// + /// + public static string GetOS() + { + PlatformID platId = Environment.OSVersion.Platform; + if(platId == PlatformID.Win32NT || platId == PlatformID.Win32Windows) + { + return "Win32"; + } + + if (File.Exists("/System/Library/Frameworks/Cocoa.framework/Cocoa")) + { + return "MACOSX"; + } + + /* + * .NET 1.x, under Mono, the UNIX code is 128. Under + * .NET 2.x, Mono or MS, the UNIX code is 4 + */ + if(Environment.Version.Major == 1) + { + if((int)platId == 128) + { + return "UNIX"; + } + } + else if((int)platId == 4) + { + return "UNIX"; + } + + return "Unknown"; + } + + private static bool CompareNum(OperatorSymbol oper, int val1, int val2) + { + switch(oper) + { + case OperatorSymbol.Equal: + return (val1 == val2); + case OperatorSymbol.NotEqual: + return (val1 != val2); + case OperatorSymbol.LessThan: + return (val1 < val2); + case OperatorSymbol.LessThanEqual: + return (val1 <= val2); + case OperatorSymbol.GreaterThan: + return (val1 > val2); + case OperatorSymbol.GreaterThanEqual: + return (val1 >= val2); + } + + throw new WarningException("Unknown operator type"); + } + + private static bool CompareStr(OperatorSymbol oper, string val1, string val2) + { + switch(oper) + { + case OperatorSymbol.Equal: + return (val1 == val2); + case OperatorSymbol.NotEqual: + return (val1 != val2); + case OperatorSymbol.LessThan: + return (val1.CompareTo(val2) < 0); + case OperatorSymbol.LessThanEqual: + return (val1.CompareTo(val2) <= 0); + case OperatorSymbol.GreaterThan: + return (val1.CompareTo(val2) > 0); + case OperatorSymbol.GreaterThanEqual: + return (val1.CompareTo(val2) >= 0); + } + + throw new WarningException("Unknown operator type"); + } + + private static char NextChar(int idx, string str) + { + if((idx + 1) >= str.Length) + { + return Char.MaxValue; + } + + return str[idx + 1]; + } + // Very very simple expression parser. Can only match expressions of the form + // : + // OS = Windows + // OS != Linux + // RuntimeMinor > 0 + private bool ParseExpression(string exp) + { + if(exp == null) + { + throw new ArgumentException("Invalid expression, cannot be null"); + } + + exp = exp.Trim(); + if(exp.Length < 1) + { + throw new ArgumentException("Invalid expression, cannot be 0 length"); + } + + string id = ""; + string str = ""; + OperatorSymbol oper = OperatorSymbol.None; + bool inStr = false; + + for(int i = 0; i < exp.Length; i++) + { + char c = exp[i]; + if(Char.IsWhiteSpace(c)) + { + continue; + } + + if(Char.IsLetterOrDigit(c) || c == '_') + { + if(inStr) + { + str += c; + } + else + { + id += c; + } + } + else if(c == '\"') + { + inStr = !inStr; + if(inStr) + { + str = ""; + } + } + else + { + if(inStr) + { + str += c; + } + else + { + switch(c) + { + case '=': + oper = OperatorSymbol.Equal; + break; + + case '!': + if(NextChar(i, exp) == '=') + { + oper = OperatorSymbol.NotEqual; + } + + break; + + case '<': + if(NextChar(i, exp) == '=') + { + oper = OperatorSymbol.LessThanEqual; + } + else + { + oper = OperatorSymbol.LessThan; + } + + break; + + case '>': + if(NextChar(i, exp) == '=') + { + oper = OperatorSymbol.GreaterThanEqual; + } + else + { + oper = OperatorSymbol.GreaterThan; + } + + break; + } + } + } + } + + + if(inStr) + { + throw new WarningException("Expected end of string in expression"); + } + + if(oper == OperatorSymbol.None) + { + throw new WarningException("Expected operator in expression"); + } + if(id.Length < 1) + { + throw new WarningException("Expected identifier in expression"); + } + if(str.Length < 1) + { + throw new WarningException("Expected value in expression"); + } + + bool ret; + try + { + object val = m_Variables[id.ToLower()]; + if(val == null) + { + throw new WarningException("Unknown identifier '{0}'", id); + } + + Type t = val.GetType(); + if(t.IsAssignableFrom(typeof(int))) + { + int numVal = (int)val; + int numVal2 = Int32.Parse(str); + ret = CompareNum(oper, numVal, numVal2); + } + else + { + string strVal = val.ToString(); + string strVal2 = str; + ret = CompareStr(oper, strVal, strVal2); + } + } + catch(ArgumentException ex) + { + ex.ToString(); + throw new WarningException("Invalid value type for system variable '{0}', expected int", id); + } + + return ret; + } + + /// + /// Taken from current Prebuild included in OpenSim 0.7.x + /// + /// + /// A + /// + /// + /// A + /// + private static void WildCardInclude (Stack readerStack, string include) + { + if (!include.Contains ("*")) { + return; + } + + // Console.WriteLine("Processing {0}", include); + + // Break up the include into pre and post wildcard sections + string preWildcard = include.Substring (0, include.IndexOf ("*")); + string postWildcard = include.Substring (include.IndexOf ("*") + 2); + + // If preWildcard is a directory, recurse + if (Directory.Exists (preWildcard)) { + string[] directories = Directory.GetDirectories (preWildcard); + Array.Sort (directories); + Array.Reverse (directories); + foreach (string dirPath in directories) { + //Console.WriteLine ("Scanning : {0}", dirPath); + + string includeFile = Path.Combine (dirPath, postWildcard); + if (includeFile.Contains ("*")) { + // postWildcard included another wildcard, recurse. + WildCardInclude (readerStack, includeFile); + } else { + FileInfo file = new FileInfo (includeFile); + if (file.Exists) { + //Console.WriteLine ("Including File: {0}", includeFile); + XmlReader newReader = new XmlTextReader (file.Open (FileMode.Open, FileAccess.Read, FileShare.Read)); + readerStack.Push (newReader); + } + } + } + } else { + // preWildcard is not a path to a directory, so the wildcard is in the filename + string searchFilename = Path.GetFileName (preWildcard.Substring (preWildcard.IndexOf ("/") + 1) + "*" + postWildcard); + Console.WriteLine ("searchFilename: {0}", searchFilename); + + string searchDirectory = Path.GetDirectoryName (preWildcard); + Console.WriteLine ("searchDirectory: {0}", searchDirectory); + + string[] files = Directory.GetFiles (searchDirectory, searchFilename); + Array.Sort (files); + Array.Reverse (files); + foreach (string includeFile in files) { + FileInfo file = new FileInfo (includeFile); + if (file.Exists) { + // Console.WriteLine ("Including File: {0}", includeFile); + XmlReader newReader = new XmlTextReader (file.Open (FileMode.Open, FileAccess.Read, FileShare.Read)); + readerStack.Push (newReader); + } + } + } + } + + #endregion + + #region Public Methods + + /// + /// + /// + /// + /// + public void RegisterVariable(string name, object variableValue) + { + if(name == null || variableValue == null) + { + return; + } + + m_Variables[name.ToLower()] = variableValue; + } + + /// + /// Performs validation on the xml source as well as evaluates conditional and flow expresions + /// + /// For invalid use of conditional expressions or for invalid XML syntax. If a XmlValidatingReader is passed, then will also throw exceptions for non-schema-conforming xml + /// + /// the output xml + public string Process(XmlReader initialReader) + { + if(initialReader == null) + { + throw new ArgumentException("Invalid XML reader to pre-process"); + } + + IfContext context = new IfContext(true, true, IfState.None); + StringWriter xmlText = new StringWriter(); + XmlTextWriter writer = new XmlTextWriter(xmlText); + writer.Formatting = Formatting.Indented; + + // Create a queue of XML readers and add the initial + // reader to it. Then we process until we run out of + // readers which lets the operation add more + // readers to generate a multi-file parser and not require + // XML fragments that a recursive version would use. + Stack readerStack = new Stack(); + readerStack.Push(initialReader); + + while(readerStack.Count > 0) + { + // Pop off the next reader. + XmlReader reader = readerStack.Pop(); + + // Process through this XML reader until it is + // completed (or it is replaced by the include + // operation). + while(reader.Read()) + { + // The prebuild file has a series of processing + // instructions which allow for specific + // inclusions based on operating system or to + // include additional files. + if(reader.NodeType == XmlNodeType.ProcessingInstruction) + { + bool ignore = false; + + switch(reader.LocalName) + { + case "include": + // use regular expressions to parse out the attributes. + MatchCollection matches = includeFileRegex.Matches(reader.Value); + + // make sure there is only one file attribute. + if(matches.Count > 1) + { + throw new WarningException("An node was found, but it specified more than one file."); + } + + if(matches.Count == 0) + { + throw new WarningException("An node was found, but it did not specify the file attribute."); + } + + // ***** Adding for wildcard handling + // Push current reader back onto the stack. + readerStack.Push (reader); + + // Pull the file out from the regex and make sure it is a valid file before using it. + string filename = matches[0].Groups[1].Value; + + filename = String.Join (Path.DirectorySeparatorChar.ToString (), filename.Split (new char[] { '/', '\\' })); + + if (!filename.Contains ("*")) { + + FileInfo includeFile = new FileInfo (filename); + if (!includeFile.Exists) { + throw new WarningException ("Cannot include file: " + includeFile.FullName); + } + + // Create a new reader object for this file. Then put the old reader back on the stack and start + // processing using this new XML reader. + + XmlReader newReader = new XmlTextReader (includeFile.Open (FileMode.Open, FileAccess.Read, FileShare.Read)); + reader = newReader; + readerStack.Push (reader); + + } else { + WildCardInclude (readerStack, filename); + } + + reader = (XmlReader)readerStack.Pop (); + ignore = true; + break; + + case "if": + m_IfStack.Push(context); + context = new IfContext(context.Keep & context.Active, ParseExpression(reader.Value), IfState.If); + ignore = true; + break; + + case "elseif": + if(m_IfStack.Count == 0) + { + throw new WarningException("Unexpected 'elseif' outside of 'if'"); + } + if(context.State != IfState.If && context.State != IfState.ElseIf) + { + throw new WarningException("Unexpected 'elseif' outside of 'if'"); + } + + context.State = IfState.ElseIf; + if(!context.EverKept) + { + context.Keep = ParseExpression(reader.Value); + } + else + { + context.Keep = false; + } + + ignore = true; + break; + + case "else": + if(m_IfStack.Count == 0) + { + throw new WarningException("Unexpected 'else' outside of 'if'"); + } + if(context.State != IfState.If && context.State != IfState.ElseIf) + { + throw new WarningException("Unexpected 'else' outside of 'if'"); + } + + context.State = IfState.Else; + context.Keep = !context.EverKept; + ignore = true; + break; + + case "endif": + if(m_IfStack.Count == 0) + { + throw new WarningException("Unexpected 'endif' outside of 'if'"); + } + + context = m_IfStack.Pop(); + ignore = true; + break; + } + + if(ignore) + { + continue; + } + }//end pre-proc instruction + + if(!context.Active || !context.Keep) + { + continue; + } + + switch(reader.NodeType) + { + case XmlNodeType.Element: + bool empty = reader.IsEmptyElement; + writer.WriteStartElement(reader.Name); + + while (reader.MoveToNextAttribute()) + { + writer.WriteAttributeString(reader.Name, reader.Value); + } + + if(empty) + { + writer.WriteEndElement(); + } + + break; + + case XmlNodeType.EndElement: + writer.WriteEndElement(); + break; + + case XmlNodeType.Text: + writer.WriteString(reader.Value); + break; + + case XmlNodeType.CDATA: + writer.WriteCData(reader.Value); + break; + + default: + break; + } + } + + if(m_IfStack.Count != 0) + { + throw new WarningException("Mismatched 'if', 'endif' pair"); + } + } + + return xmlText.ToString(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Parse/IfContext.cs b/Prebuild/src/Core/Parse/IfContext.cs new file mode 100644 index 0000000..3c79d38 --- /dev/null +++ b/Prebuild/src/Core/Parse/IfContext.cs @@ -0,0 +1,154 @@ +#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; + +namespace Prebuild.Core.Parse +{ + /// + /// + /// + public enum IfState + { + /// + /// + /// + None, + /// + /// + /// + If, + /// + /// + /// + ElseIf, + /// + /// + /// + Else + } + + /// + /// Summary description for IfContext. + /// + // Inspired by the equivalent WiX class (see www.sourceforge.net/projects/wix/) + public class IfContext + { + #region Properties + + bool m_Active; + bool m_Keep; + bool m_EverKept; + IfState m_State = IfState.None; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// if set to true [active]. + /// if set to true [keep]. + /// The state. + public IfContext(bool active, bool keep, IfState state) + { + m_Active = active; + m_Keep = keep; + m_EverKept = keep; + m_State = state; + } + + #endregion + + #region Properties + + /// + /// Gets or sets a value indicating whether this is active. + /// + /// true if active; otherwise, false. + public bool Active + { + get + { + return m_Active; + } + set + { + m_Active = value; + } + } + + /// + /// Gets or sets a value indicating whether this is keep. + /// + /// true if keep; otherwise, false. + public bool Keep + { + get + { + return m_Keep; + } + set + { + m_Keep = value; + if(m_Keep) + { + m_EverKept = true; + } + } + } + + /// + /// Gets a value indicating whether [ever kept]. + /// + /// true if [ever kept]; otherwise, false. + public bool EverKept + { + get + { + return m_EverKept; + } + } + + /// + /// Gets or sets the state. + /// + /// The state. + public IfState State + { + get + { + return m_State; + } + set + { + m_State = value; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Parse/Preprocessor.cs b/Prebuild/src/Core/Parse/Preprocessor.cs new file mode 100644 index 0000000..0648fad --- /dev/null +++ b/Prebuild/src/Core/Parse/Preprocessor.cs @@ -0,0 +1,652 @@ +#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 System.Text.RegularExpressions; +using System.Xml; + +namespace Prebuild.Core.Parse +{ + /// + /// + /// + public enum OperatorSymbol + { + /// + /// + /// + None, + /// + /// + /// + Equal, + /// + /// + /// + NotEqual, + /// + /// + /// + LessThan, + /// + /// + /// + GreaterThan, + /// + /// + /// + LessThanEqual, + /// + /// + /// + GreaterThanEqual + } + + /// + /// + /// + public class Preprocessor + { + #region Constants + + /// + /// Includes the regex to look for file tags in the processing instruction. + /// + private static readonly Regex includeFileRegex = new Regex("file=\"(.+?)\""); + + #endregion + + #region Fields + + readonly XmlDocument m_OutDoc = new XmlDocument(); + readonly Stack m_IfStack = new Stack(); + readonly Dictionary m_Variables = new Dictionary(); + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public Preprocessor() + { + RegisterVariable("OS", GetOS()); + RegisterVariable("RuntimeVersion", Environment.Version.Major); + RegisterVariable("RuntimeMajor", Environment.Version.Major); + RegisterVariable("RuntimeMinor", Environment.Version.Minor); + RegisterVariable("RuntimeRevision", Environment.Version.Revision); + } + + #endregion + + #region Properties + + /// + /// Gets the processed doc. + /// + /// The processed doc. + public XmlDocument ProcessedDoc + { + get + { + return m_OutDoc; + } + } + + #endregion + + #region Private Methods + + /// + /// Parts of this code were taken from NAnt and is subject to the GPL + /// as per NAnt's license. Thanks to the NAnt guys for this little gem. + /// + /// + public static string GetOS() + { + PlatformID platId = Environment.OSVersion.Platform; + if(platId == PlatformID.Win32NT || platId == PlatformID.Win32Windows) + { + return "Win32"; + } + + if (File.Exists("/System/Library/Frameworks/Cocoa.framework/Cocoa")) + { + return "MACOSX"; + } + + /* + * .NET 1.x, under Mono, the UNIX code is 128. Under + * .NET 2.x, Mono or MS, the UNIX code is 4 + */ + if(Environment.Version.Major == 1) + { + if((int)platId == 128) + { + return "UNIX"; + } + } + else if((int)platId == 4) + { + return "UNIX"; + } + + return "Unknown"; + } + + private static bool CompareNum(OperatorSymbol oper, int val1, int val2) + { + switch(oper) + { + case OperatorSymbol.Equal: + return (val1 == val2); + case OperatorSymbol.NotEqual: + return (val1 != val2); + case OperatorSymbol.LessThan: + return (val1 < val2); + case OperatorSymbol.LessThanEqual: + return (val1 <= val2); + case OperatorSymbol.GreaterThan: + return (val1 > val2); + case OperatorSymbol.GreaterThanEqual: + return (val1 >= val2); + } + + throw new WarningException("Unknown operator type"); + } + + private static bool CompareStr(OperatorSymbol oper, string val1, string val2) + { + switch(oper) + { + case OperatorSymbol.Equal: + return (val1 == val2); + case OperatorSymbol.NotEqual: + return (val1 != val2); + case OperatorSymbol.LessThan: + return (val1.CompareTo(val2) < 0); + case OperatorSymbol.LessThanEqual: + return (val1.CompareTo(val2) <= 0); + case OperatorSymbol.GreaterThan: + return (val1.CompareTo(val2) > 0); + case OperatorSymbol.GreaterThanEqual: + return (val1.CompareTo(val2) >= 0); + } + + throw new WarningException("Unknown operator type"); + } + + private static char NextChar(int idx, string str) + { + if((idx + 1) >= str.Length) + { + return Char.MaxValue; + } + + return str[idx + 1]; + } + // Very very simple expression parser. Can only match expressions of the form + // : + // OS = Windows + // OS != Linux + // RuntimeMinor > 0 + private bool ParseExpression(string exp) + { + if(exp == null) + { + throw new ArgumentException("Invalid expression, cannot be null"); + } + + exp = exp.Trim(); + if(exp.Length < 1) + { + throw new ArgumentException("Invalid expression, cannot be 0 length"); + } + + string id = ""; + string str = ""; + OperatorSymbol oper = OperatorSymbol.None; + bool inStr = false; + + for(int i = 0; i < exp.Length; i++) + { + char c = exp[i]; + if(Char.IsWhiteSpace(c)) + { + continue; + } + + if(Char.IsLetterOrDigit(c) || c == '_') + { + if(inStr) + { + str += c; + } + else + { + id += c; + } + } + else if(c == '\"') + { + inStr = !inStr; + if(inStr) + { + str = ""; + } + } + else + { + if(inStr) + { + str += c; + } + else + { + switch(c) + { + case '=': + oper = OperatorSymbol.Equal; + break; + + case '!': + if(NextChar(i, exp) == '=') + { + oper = OperatorSymbol.NotEqual; + } + + break; + + case '<': + if(NextChar(i, exp) == '=') + { + oper = OperatorSymbol.LessThanEqual; + } + else + { + oper = OperatorSymbol.LessThan; + } + + break; + + case '>': + if(NextChar(i, exp) == '=') + { + oper = OperatorSymbol.GreaterThanEqual; + } + else + { + oper = OperatorSymbol.GreaterThan; + } + + break; + } + } + } + } + + + if(inStr) + { + throw new WarningException("Expected end of string in expression"); + } + + if(oper == OperatorSymbol.None) + { + throw new WarningException("Expected operator in expression"); + } + if(id.Length < 1) + { + throw new WarningException("Expected identifier in expression"); + } + if(str.Length < 1) + { + throw new WarningException("Expected value in expression"); + } + + bool ret; + try + { + object val = m_Variables[id.ToLower()]; + if(val == null) + { + throw new WarningException("Unknown identifier '{0}'", id); + } + + Type t = val.GetType(); + if(t.IsAssignableFrom(typeof(int))) + { + int numVal = (int)val; + int numVal2 = Int32.Parse(str); + ret = CompareNum(oper, numVal, numVal2); + } + else + { + string strVal = val.ToString(); + string strVal2 = str; + ret = CompareStr(oper, strVal, strVal2); + } + } + catch(ArgumentException ex) + { + ex.ToString(); + throw new WarningException("Invalid value type for system variable '{0}', expected int", id); + } + + return ret; + } + + /// + /// Taken from current Prebuild included in OpenSim 0.7.x + /// + /// + /// A + /// + /// + /// A + /// + private static void WildCardInclude (Stack readerStack, string include) + { + if (!include.Contains ("*")) { + return; + } + + // Console.WriteLine("Processing {0}", include); + + // Break up the include into pre and post wildcard sections + string preWildcard = include.Substring (0, include.IndexOf ("*")); + string postWildcard = include.Substring (include.IndexOf ("*") + 2); + + // If preWildcard is a directory, recurse + if (Directory.Exists (preWildcard)) { + string[] directories = Directory.GetDirectories (preWildcard); + Array.Sort (directories); + Array.Reverse (directories); + foreach (string dirPath in directories) { + //Console.WriteLine ("Scanning : {0}", dirPath); + + string includeFile = Path.Combine (dirPath, postWildcard); + if (includeFile.Contains ("*")) { + // postWildcard included another wildcard, recurse. + WildCardInclude (readerStack, includeFile); + } else { + FileInfo file = new FileInfo (includeFile); + if (file.Exists) { + //Console.WriteLine ("Including File: {0}", includeFile); + XmlReader newReader = new XmlTextReader (file.Open (FileMode.Open, FileAccess.Read, FileShare.Read)); + readerStack.Push (newReader); + } + } + } + } else { + // preWildcard is not a path to a directory, so the wildcard is in the filename + string searchFilename = Path.GetFileName (preWildcard.Substring (preWildcard.IndexOf ("/") + 1) + "*" + postWildcard); + Console.WriteLine ("searchFilename: {0}", searchFilename); + + string searchDirectory = Path.GetDirectoryName (preWildcard); + Console.WriteLine ("searchDirectory: {0}", searchDirectory); + + string[] files = Directory.GetFiles (searchDirectory, searchFilename); + Array.Sort (files); + Array.Reverse (files); + foreach (string includeFile in files) { + FileInfo file = new FileInfo (includeFile); + if (file.Exists) { + // Console.WriteLine ("Including File: {0}", includeFile); + XmlReader newReader = new XmlTextReader (file.Open (FileMode.Open, FileAccess.Read, FileShare.Read)); + readerStack.Push (newReader); + } + } + } + } + + #endregion + + #region Public Methods + + /// + /// + /// + /// + /// + public void RegisterVariable(string name, object variableValue) + { + if(name == null || variableValue == null) + { + return; + } + + m_Variables[name.ToLower()] = variableValue; + } + + /// + /// Performs validation on the xml source as well as evaluates conditional and flow expresions + /// + /// For invalid use of conditional expressions or for invalid XML syntax. If a XmlValidatingReader is passed, then will also throw exceptions for non-schema-conforming xml + /// + /// the output xml + public string Process(XmlReader initialReader) + { + if(initialReader == null) + { + throw new ArgumentException("Invalid XML reader to pre-process"); + } + + IfContext context = new IfContext(true, true, IfState.None); + StringWriter xmlText = new StringWriter(); + XmlTextWriter writer = new XmlTextWriter(xmlText); + writer.Formatting = Formatting.Indented; + + // Create a queue of XML readers and add the initial + // reader to it. Then we process until we run out of + // readers which lets the operation add more + // readers to generate a multi-file parser and not require + // XML fragments that a recursive version would use. + Stack readerStack = new Stack(); + readerStack.Push(initialReader); + + while(readerStack.Count > 0) + { + // Pop off the next reader. + XmlReader reader = readerStack.Pop(); + + // Process through this XML reader until it is + // completed (or it is replaced by the include + // operation). + while(reader.Read()) + { + // The prebuild file has a series of processing + // instructions which allow for specific + // inclusions based on operating system or to + // include additional files. + if(reader.NodeType == XmlNodeType.ProcessingInstruction) + { + bool ignore = false; + + switch(reader.LocalName) + { + case "include": + // use regular expressions to parse out the attributes. + MatchCollection matches = includeFileRegex.Matches(reader.Value); + + // make sure there is only one file attribute. + if(matches.Count > 1) + { + throw new WarningException("An node was found, but it specified more than one file."); + } + + if(matches.Count == 0) + { + throw new WarningException("An node was found, but it did not specify the file attribute."); + } + + // ***** Adding for wildcard handling + // Push current reader back onto the stack. + readerStack.Push (reader); + + // Pull the file out from the regex and make sure it is a valid file before using it. + string filename = matches[0].Groups[1].Value; + + filename = String.Join (Path.DirectorySeparatorChar.ToString (), filename.Split (new char[] { '/', '\\' })); + + if (!filename.Contains ("*")) { + + FileInfo includeFile = new FileInfo (filename); + if (!includeFile.Exists) { + throw new WarningException ("Cannot include file: " + includeFile.FullName); + } + + // Create a new reader object for this file. Then put the old reader back on the stack and start + // processing using this new XML reader. + + XmlReader newReader = new XmlTextReader (includeFile.Open (FileMode.Open, FileAccess.Read, FileShare.Read)); + reader = newReader; + readerStack.Push (reader); + + } else { + WildCardInclude (readerStack, filename); + } + + reader = (XmlReader)readerStack.Pop (); + ignore = true; + break; + + case "if": + m_IfStack.Push(context); + context = new IfContext(context.Keep & context.Active, ParseExpression(reader.Value), IfState.If); + ignore = true; + break; + + case "elseif": + if(m_IfStack.Count == 0) + { + throw new WarningException("Unexpected 'elseif' outside of 'if'"); + } + if(context.State != IfState.If && context.State != IfState.ElseIf) + { + throw new WarningException("Unexpected 'elseif' outside of 'if'"); + } + + context.State = IfState.ElseIf; + if(!context.EverKept) + { + context.Keep = ParseExpression(reader.Value); + } + else + { + context.Keep = false; + } + + ignore = true; + break; + + case "else": + if(m_IfStack.Count == 0) + { + throw new WarningException("Unexpected 'else' outside of 'if'"); + } + if(context.State != IfState.If && context.State != IfState.ElseIf) + { + throw new WarningException("Unexpected 'else' outside of 'if'"); + } + + context.State = IfState.Else; + context.Keep = !context.EverKept; + ignore = true; + break; + + case "endif": + if(m_IfStack.Count == 0) + { + throw new WarningException("Unexpected 'endif' outside of 'if'"); + } + + context = m_IfStack.Pop(); + ignore = true; + break; + } + + if(ignore) + { + continue; + } + }//end pre-proc instruction + + if(!context.Active || !context.Keep) + { + continue; + } + + switch(reader.NodeType) + { + case XmlNodeType.Element: + bool empty = reader.IsEmptyElement; + writer.WriteStartElement(reader.Name); + + while (reader.MoveToNextAttribute()) + { + writer.WriteAttributeString(reader.Name, reader.Value); + } + + if(empty) + { + writer.WriteEndElement(); + } + + break; + + case XmlNodeType.EndElement: + writer.WriteEndElement(); + break; + + case XmlNodeType.Text: + writer.WriteString(reader.Value); + break; + + case XmlNodeType.CDATA: + writer.WriteCData(reader.Value); + break; + + default: + break; + } + } + + if(m_IfStack.Count != 0) + { + throw new WarningException("Mismatched 'if', 'endif' pair"); + } + } + + return xmlText.ToString(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/.NAntTarget.cs.swp b/Prebuild/src/Core/Targets/.NAntTarget.cs.swp new file mode 100644 index 0000000..afec61c Binary files /dev/null and b/Prebuild/src/Core/Targets/.NAntTarget.cs.swp differ diff --git a/Prebuild/src/Core/Targets/.svn/all-wcprops b/Prebuild/src/Core/Targets/.svn/all-wcprops new file mode 100644 index 0000000..91d6694 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/all-wcprops @@ -0,0 +1,101 @@ +K 25 +svn:wc:ra_dav:version-url +V 58 +/svnroot/dnpb/!svn/ver/323/trunk/Prebuild/src/Core/Targets +END +MakefileTarget.cs +K 25 +svn:wc:ra_dav:version-url +V 76 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Targets/MakefileTarget.cs +END +SharpDevelop2Target.cs +K 25 +svn:wc:ra_dav:version-url +V 81 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/Targets/SharpDevelop2Target.cs +END +ToolInfo.cs +K 25 +svn:wc:ra_dav:version-url +V 70 +/svnroot/dnpb/!svn/ver/290/trunk/Prebuild/src/Core/Targets/ToolInfo.cs +END +VSGenericTarget.cs +K 25 +svn:wc:ra_dav:version-url +V 77 +/svnroot/dnpb/!svn/ver/316/trunk/Prebuild/src/Core/Targets/VSGenericTarget.cs +END +DebugTarget.cs +K 25 +svn:wc:ra_dav:version-url +V 73 +/svnroot/dnpb/!svn/ver/164/trunk/Prebuild/src/Core/Targets/DebugTarget.cs +END +VSVersion.cs +K 25 +svn:wc:ra_dav:version-url +V 71 +/svnroot/dnpb/!svn/ver/316/trunk/Prebuild/src/Core/Targets/VSVersion.cs +END +MonoDevelopTarget.cs +K 25 +svn:wc:ra_dav:version-url +V 79 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Targets/MonoDevelopTarget.cs +END +AutotoolsTarget.cs +K 25 +svn:wc:ra_dav:version-url +V 77 +/svnroot/dnpb/!svn/ver/298/trunk/Prebuild/src/Core/Targets/AutotoolsTarget.cs +END +VS2010Target.cs +K 25 +svn:wc:ra_dav:version-url +V 74 +/svnroot/dnpb/!svn/ver/317/trunk/Prebuild/src/Core/Targets/VS2010Target.cs +END +VS2002Target.cs +K 25 +svn:wc:ra_dav:version-url +V 74 +/svnroot/dnpb/!svn/ver/295/trunk/Prebuild/src/Core/Targets/VS2002Target.cs +END +SharpDevelopTarget.cs +K 25 +svn:wc:ra_dav:version-url +V 80 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Targets/SharpDevelopTarget.cs +END +VS2003Target.cs +K 25 +svn:wc:ra_dav:version-url +V 74 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Targets/VS2003Target.cs +END +VS2005Target.cs +K 25 +svn:wc:ra_dav:version-url +V 74 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Targets/VS2005Target.cs +END +NAntTarget.cs +K 25 +svn:wc:ra_dav:version-url +V 72 +/svnroot/dnpb/!svn/ver/323/trunk/Prebuild/src/Core/Targets/NAntTarget.cs +END +XcodeTarget.cs +K 25 +svn:wc:ra_dav:version-url +V 73 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Targets/XcodeTarget.cs +END +VS2008Target.cs +K 25 +svn:wc:ra_dav:version-url +V 74 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Targets/VS2008Target.cs +END diff --git a/Prebuild/src/Core/Targets/.svn/dir-prop-base b/Prebuild/src/Core/Targets/.svn/dir-prop-base new file mode 100644 index 0000000..a1989a0 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/dir-prop-base @@ -0,0 +1,5 @@ +K 10 +svn:ignore +V 5 +*.swp +END diff --git a/Prebuild/src/Core/Targets/.svn/entries b/Prebuild/src/Core/Targets/.svn/entries new file mode 100644 index 0000000..c6daa49 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/entries @@ -0,0 +1,572 @@ +10 + +dir +323 +https://dnpb.svn.sourceforge.net/svnroot/dnpb/trunk/Prebuild/src/Core/Targets +https://dnpb.svn.sourceforge.net/svnroot/dnpb + + + +2010-09-10T17:51:36.189738Z +323 +jhurliman +has-props + + + + + + + + + + + + + +3355ff64-970d-0410-bbe8-d0fbd18be4fb + +MakefileTarget.cs +file + + + + +2010-09-10T22:51:44.000000Z +9f1538adc7e579b57d104dc7f313946b +2009-04-15T01:28:16.827957Z +307 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +19043 + +SharpDevelop2Target.cs +file + + + + +2010-09-10T22:51:44.000000Z +f6e8e9d8f335a5a264babb4a8f05a2a5 +2009-02-19T06:47:52.218324Z +295 +kunnis + + + + + + + + + + + + + + + + + + + + + +2442 + +ToolInfo.cs +file + + + + +2010-09-10T22:51:44.000000Z +20e6cf8e0ad0b0744b6189534bfd049a +2009-02-18T05:47:43.979044Z +290 +kunnis + + + + + + + + + + + + + + + + + + + + + +4315 + +VSGenericTarget.cs +file + + + + +2010-09-10T22:51:44.000000Z +6956b93fe770e1f5786cc44872c31d06 +2010-05-08T05:43:01.449559Z +316 +jhurliman + + + + + + + + + + + + + + + + + + + + + +34542 + +DebugTarget.cs +file + + + + +2010-09-10T22:51:44.000000Z +7346beba16e30e642f272e7bcf3924bb +2006-09-20T07:42:51.680045Z +164 +jendave +has-props + + + + + + + + + + + + + + + + + + + + +2703 + +VSVersion.cs +file + + + + +2010-09-10T22:51:44.000000Z +78ab7ae5edbe12dfb34c9fbd3dba9c23 +2010-05-08T05:43:01.449559Z +316 +jhurliman + + + + + + + + + + + + + + + + + + + + + +1950 + +MonoDevelopTarget.cs +file + + + + +2010-09-10T22:51:44.000000Z +d8b264553d4c2d66a19f9610be56f4b4 +2009-04-15T01:28:16.827957Z +307 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +15976 + +AutotoolsTarget.cs +file + + + + +2010-09-10T22:51:44.000000Z +bc5383cb56dd751ac946386a51852a77 +2009-02-20T02:15:45.530129Z +298 +kunnis + + + + + + + + + + + + + + + + + + + + + +41145 + +VS2010Target.cs +file + + + + +2010-09-10T22:51:44.000000Z +7d9c7f130f06ead33e747f0920b989c4 +2010-05-09T07:39:45.137959Z +317 +jhurliman + + + + + + + + + + + + + + + + + + + + + +2745 + +VS2002Target.cs +file + + + + +2010-09-10T22:51:44.000000Z +912769a89b935429b3801db96c467de7 +2009-02-19T06:47:52.218324Z +295 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +2507 + +SharpDevelopTarget.cs +file + + + + +2010-09-10T22:51:44.000000Z +f9017c8dd94137dee4b673bee40c8e6e +2009-04-15T01:28:16.827957Z +307 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +12773 + +VS2003Target.cs +file + + + + +2010-09-10T22:51:44.000000Z +c8e60070e9d7343d50c297d3dff12ac4 +2009-04-15T01:28:16.827957Z +307 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +18912 + +VS2005Target.cs +file + + + + +2010-09-10T22:51:44.000000Z +812092c2b5b068e087806088d80fe635 +2009-04-15T01:28:16.827957Z +307 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +4291 + +NAntTarget.cs +file + + + + +2010-09-10T22:51:44.000000Z +b635fc47efdd3eed660017693b9073c4 +2010-09-10T17:51:36.189738Z +323 +jhurliman +has-props + + + + + + + + + + + + + + + + + + + + +32065 + +VS2008Target.cs +file + + + + +2010-09-10T22:51:44.000000Z +154f10d6947ee7bf4d5caf10fad8c43d +2009-04-15T01:28:16.827957Z +307 +kunnis + + + + + + + + + + + + + + + + + + + + + +2514 + +XcodeTarget.cs +file + + + + +2010-09-10T22:51:44.000000Z +7ec0bbdd62020f03a725d8f99258769d +2009-04-15T01:28:16.827957Z +307 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +28408 + diff --git a/Prebuild/src/Core/Targets/.svn/prop-base/DebugTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/prop-base/DebugTarget.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/prop-base/DebugTarget.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Targets/.svn/prop-base/MakefileTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/prop-base/MakefileTarget.cs.svn-base new file mode 100644 index 0000000..05f6c06 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/prop-base/MakefileTarget.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 13 +svn:mime-type +V 13 +text/x-csharp +END diff --git a/Prebuild/src/Core/Targets/.svn/prop-base/MonoDevelopTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/prop-base/MonoDevelopTarget.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/prop-base/MonoDevelopTarget.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Targets/.svn/prop-base/NAntTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/prop-base/NAntTarget.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/prop-base/NAntTarget.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Targets/.svn/prop-base/SharpDevelopTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/prop-base/SharpDevelopTarget.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/prop-base/SharpDevelopTarget.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Targets/.svn/prop-base/VS2002Target.cs.svn-base b/Prebuild/src/Core/Targets/.svn/prop-base/VS2002Target.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/prop-base/VS2002Target.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Targets/.svn/prop-base/VS2003Target.cs.svn-base b/Prebuild/src/Core/Targets/.svn/prop-base/VS2003Target.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/prop-base/VS2003Target.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Targets/.svn/prop-base/VS2005Target.cs.svn-base b/Prebuild/src/Core/Targets/.svn/prop-base/VS2005Target.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/prop-base/VS2005Target.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Targets/.svn/prop-base/XcodeTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/prop-base/XcodeTarget.cs.svn-base new file mode 100644 index 0000000..05f6c06 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/prop-base/XcodeTarget.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 13 +svn:mime-type +V 13 +text/x-csharp +END diff --git a/Prebuild/src/Core/Targets/.svn/text-base/AutotoolsTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/AutotoolsTarget.cs.svn-base new file mode 100644 index 0000000..e46b5a5 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/AutotoolsTarget.cs.svn-base @@ -0,0 +1,1070 @@ +#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.IO; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using System.Xml.Xsl; +using System.Net; +using System.Diagnostics; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Targets +{ + public enum ClrVersion + { + Default, + Net_1_1, + Net_2_0 + } + + public class SystemPackage + { + string name; + string version; + string description; + string[] assemblies; + bool isInternal; + ClrVersion targetVersion; + + public void Initialize(string name, + string version, + string description, + string[] assemblies, + ClrVersion targetVersion, + bool isInternal) + { + this.isInternal = isInternal; + this.name = name; + this.version = version; + this.assemblies = assemblies; + this.description = description; + this.targetVersion = targetVersion; + } + + public string Name + { + get { return name; } + } + + public string Version + { + get { return version; } + } + + public string Description + { + get { return description; } + } + + public ClrVersion TargetVersion + { + get { return targetVersion; } + } + + // The package is part of the mono SDK + public bool IsCorePackage + { + get { return name == "mono"; } + } + + // The package has been registered by an add-in, and is not installed + // in the system. + public bool IsInternalPackage + { + get { return isInternal; } + } + + public string[] Assemblies + { + get { return assemblies; } + } + + } + + + /// + /// + /// + [Target("autotools")] + public class AutotoolsTarget : ITarget + { + #region Fields + + Kernel m_Kernel; + XmlDocument autotoolsDoc; + XmlUrlResolver xr; + System.Security.Policy.Evidence e; + readonly Dictionary assemblyPathToPackage = new Dictionary(); + readonly Dictionary assemblyFullNameToPath = new Dictionary(); + readonly Dictionary packagesHash = new Dictionary(); + readonly List packages = new List(); + + #endregion + + #region Private Methods + + private static void mkdirDashP(string dirName) + { + DirectoryInfo di = new DirectoryInfo(dirName); + if (di.Exists) + return; + + string parentDirName = System.IO.Path.GetDirectoryName(dirName); + DirectoryInfo parentDi = new DirectoryInfo(parentDirName); + if (!parentDi.Exists) + mkdirDashP(parentDirName); + + di.Create(); + } + + private static void chkMkDir(string dirName) + { + System.IO.DirectoryInfo di = + new System.IO.DirectoryInfo(dirName); + + if (!di.Exists) + di.Create(); + } + + private void transformToFile(string filename, XsltArgumentList argList, string nodeName) + { + // Create an XslTransform for this file + XslTransform templateTransformer = + new XslTransform(); + + // Load up the template + XmlNode templateNode = + autotoolsDoc.SelectSingleNode(nodeName + "/*"); + templateTransformer.Load(templateNode.CreateNavigator(), xr, e); + + // Create a writer for the transformed template + XmlTextWriter templateWriter = + new XmlTextWriter(filename, null); + + // Perform transformation, writing the file + templateTransformer.Transform + (m_Kernel.CurrentDoc, argList, templateWriter, xr); + } + + static string NormalizeAsmName(string name) + { + int 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 + { + System.Reflection.AssemblyName an = System.Reflection.AssemblyName.GetAssemblyName(assemblyfile); + assemblyFullNameToPath[NormalizeAsmName(an.FullName)] = assemblyfile; + assemblyPathToPackage[assemblyfile] = package; + } + catch + { + } + } + + private static List GetAssembliesWithLibInfo(string line, string file) + { + List references = new List(); + List libdirs = new List(); + List retval = new List(); + foreach (string 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 (string refrnc in references) + { + foreach (string libdir in libdirs) + { + if (File.Exists(libdir + Path.DirectorySeparatorChar + refrnc)) + { + retval.Add(libdir + Path.DirectorySeparatorChar + refrnc); + } + } + } + + return retval; + } + + private static List GetAssembliesWithoutLibInfo(string line, string file) + { + List references = new List(); + foreach (string reference in line.Split(' ')) + { + if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:")) + { + string final_ref = reference.Substring(3).Trim(); + references.Add(ProcessPiece(final_ref, file)); + } + } + return references; + } + + private static string ProcessPiece(string piece, string pcfile) + { + int start = piece.IndexOf("${"); + if (start == -1) + return piece; + + int end = piece.IndexOf("}"); + if (end == -1) + return piece; + + string variable = piece.Substring(start + 2, end - start - 2); + string interp = GetVariableFromPkgConfig(variable, Path.GetFileNameWithoutExtension(pcfile)); + return ProcessPiece(piece.Replace("${" + variable + "}", interp), pcfile); + } + + private static string GetVariableFromPkgConfig(string var, string pcfile) + { + ProcessStartInfo psi = new ProcessStartInfo("pkg-config"); + psi.RedirectStandardOutput = true; + psi.UseShellExecute = false; + psi.Arguments = String.Format("--variable={0} {1}", var, pcfile); + Process p = new Process(); + p.StartInfo = psi; + p.Start(); + string 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 + string pname = Path.GetFileNameWithoutExtension(pcfile); + if (packagesHash.ContainsKey(pname)) + return; + + List fullassemblies = null; + string version = ""; + string desc = ""; + + SystemPackage package = new SystemPackage(); + + using (StreamReader reader = new StreamReader(pcfile)) + { + string line; + while ((line = reader.ReadLine()) != null) + { + string lowerLine = line.ToLower(); + if (lowerLine.StartsWith("libs:") && lowerLine.IndexOf(".dll") != -1) + { + string 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 (string assembly in fullassemblies) + { + AddAssembly(assembly, package); + } + + package.Initialize(pname, + version, + desc, + fullassemblies.ToArray(), + ClrVersion.Default, + false); + packages.Add(package); + packagesHash[pname] = package; + } + + void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver) + { + SystemPackage package = new SystemPackage(); + List list = new List(); + + string dir = Path.Combine(prefix, version); + if (!Directory.Exists(dir)) + { + return; + } + + foreach (string 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); + } + + void RunInitialization() + { + string versionDir; + + if (Environment.Version.Major == 1) + { + versionDir = "1.0"; + } + else + { + versionDir = "2.0"; + } + + //Pull up assemblies from the installed mono system. + string 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); + + string search_dirs = Environment.GetEnvironmentVariable("PKG_CONFIG_PATH"); + string libpath = Environment.GetEnvironmentVariable("PKG_CONFIG_LIBPATH"); + + if (String.IsNullOrEmpty(libpath)) + { + string path_dirs = Environment.GetEnvironmentVariable("PATH"); + foreach (string 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)) + { + List scanDirs = new List(); + foreach (string potentialDir in search_dirs.Split(Path.PathSeparator)) + { + if (!scanDirs.Contains(potentialDir)) + scanDirs.Add(potentialDir); + } + foreach (string pcdir in scanDirs) + { + if (pcdir == null) + continue; + + if (Directory.Exists(pcdir)) + { + foreach (string pcfile in Directory.GetFiles(pcdir, "*.pc")) + { + ParsePCFile(pcfile); + } + } + } + } + } + + private void WriteCombine(SolutionNode solution) + { + #region "Create Solution directory if it doesn't exist" + string solutionDir = Path.Combine(solution.FullPath, + Path.Combine("autotools", + solution.Name)); + chkMkDir(solutionDir); + #endregion + + #region "Write Solution-level files" + XsltArgumentList 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 (ProjectNode 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 (ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = + Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if (File.Exists(fullPath)) { + return fullPath; + } + } + + return null; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if (conf == null) + { + throw new ArgumentNullException("conf"); + } + if (project == null) + { + throw new ArgumentNullException("project"); + } + string 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; + } + + /// + /// Normalizes the path. + /// + /// The path. + /// + public static string NormalizePath(string path) + { + if (path == null) + { + return ""; + } + + StringBuilder tmpPath; + + if (Core.Parse.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) + { + string solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name)); + string projectDir = Path.Combine(solutionDir, project.Name); + string projectVersion = project.Version; + bool hasAssemblyConfig = false; + chkMkDir(projectDir); + + List + compiledFiles = new List(), + contentFiles = new List(), + embeddedFiles = new List(), + + binaryLibs = new List(), + pkgLibs = new List(), + systemLibs = new List(), + runtimeLibs = new List(), + + extraDistFiles = new List(), + localCopyTargets = new List(); + + // 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 + string projectAssemblyName = project.Name; + if (project.AssemblyName != null) + projectAssemblyName = project.AssemblyName; + + if (File.Exists(Path.Combine(project.FullPath, projectAssemblyName) + ".dll.config")) + { + hasAssemblyConfig = true; + System.IO.File.Copy(Path.Combine(project.FullPath, projectAssemblyName + ".dll.config"), Path.Combine(projectDir, projectAssemblyName + ".dll.config"), true); + extraDistFiles.Add(project.AssemblyName + ".dll.config"); + } + + foreach (ConfigurationNode 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 + string source = Path.Combine(project.FullPath, conf.Options.KeyFile); + string keyFile = conf.Options.KeyFile; + Regex re = new Regex(".*/"); + keyFile = re.Replace(keyFile, ""); + + string dest = Path.Combine(projectDir, keyFile); + // Tell the user if there's a problem copying the file + try + { + mkdirDashP(System.IO.Path.GetDirectoryName(dest)); + System.IO.File.Copy(source, dest, true); + } + catch (System.IO.IOException e) + { + Console.WriteLine(e.Message); + } + } + } + + // Copy compiled, embedded and content files into the project's directory + foreach (string filename in project.Files) + { + string source = Path.Combine(project.FullPath, filename); + string 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(System.IO.Path.GetDirectoryName(dest)); + System.IO.File.Copy(source, dest, true); + } + catch (System.IO.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 (int refNum = 0; refNum < project.References.Count; refNum++) + { + ReferenceNode refr = project.References[refNum]; + Assembly refAssembly = Assembly.LoadWithPartialName(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 + { + string assemblyFullName = string.Empty; + if (refAssembly != null) + assemblyFullName = refAssembly.FullName; + + string 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); + + string 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 */ + + string filename = refr.Name + ".dll"; + string source = filename; + if (refr.Path != null) + source = Path.Combine(refr.Path, source); + source = Path.Combine(project.FullPath, source); + string 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")) + { + System.IO.File.Copy(source + ".config", Path.GetDirectoryName(dest), true); + extraDistFiles.Add(refr.Name + ".dll.config"); + } + + try + { + System.IO.File.Copy(source, dest, true); + } + catch (System.IO.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 + */ + + ProjectNode sourcePrj = + ((solution.ProjectsTable[refr.Name])); + + string 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 + string assemName = string.Empty; + int 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"; + string compiledFilesString = string.Empty; + if (compiledFiles.Count > 0) + compiledFilesString = + lineSep + string.Join(lineSep, compiledFiles.ToArray()); + + string embeddedFilesString = ""; + if (embeddedFiles.Count > 0) + embeddedFilesString = + lineSep + string.Join(lineSep, embeddedFiles.ToArray()); + + string contentFilesString = ""; + if (contentFiles.Count > 0) + contentFilesString = + lineSep + string.Join(lineSep, contentFiles.ToArray()); + + string extraDistFilesString = ""; + if (extraDistFiles.Count > 0) + extraDistFilesString = + lineSep + string.Join(lineSep, extraDistFiles.ToArray()); + + string pkgLibsString = ""; + if (pkgLibs.Count > 0) + pkgLibsString = + lineSep + string.Join(lineSep, pkgLibs.ToArray()); + + string binaryLibsString = ""; + if (binaryLibs.Count > 0) + binaryLibsString = + lineSep + string.Join(lineSep, binaryLibs.ToArray()); + + string systemLibsString = ""; + if (systemLibs.Count > 0) + systemLibsString = + lineSep + string.Join(lineSep, systemLibs.ToArray()); + + string localCopyTargetsString = ""; + if (localCopyTargets.Count > 0) + localCopyTargetsString = + string.Join("\n", localCopyTargets.ToArray()); + + string monoPath = ""; + foreach (string runtimeLib in runtimeLibs) + { + monoPath += ":`pkg-config --variable=libdir " + runtimeLib + "`"; + } + + // Add the project name to the list of transformation + // parameters + XsltArgumentList 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 == Core.Nodes.ProjectType.Library) + transformToFile(Path.Combine(projectDir, project.Name + ".pc.in"), argList, "/Autotools/ProjectPcIn"); + if (project.Type == Core.Nodes.ProjectType.Exe || project.Type == Core.Nodes.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); + string 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); + + string 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 (ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + 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"; + string fqStreamName = String.Format("Prebuild.data.{0}", + streamName + ); + + // Retrieve stream for the autotools template XML + Stream 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){ + string errStr = + String.Format("Could not find embedded resource file:\n" + + "'{0}' or '{1}'", + streamName, fqStreamName + ); + + m_Kernel.Log.Write(errStr); + + throw new System.Reflection.TargetException(errStr); + } + } + + // Create an XML URL Resolver with default credentials + xr = new System.Xml.XmlUrlResolver(); + xr.Credentials = CredentialCache.DefaultCredentials; + + // Create a default evidence - no need to limit access + e = new System.Security.Policy.Evidence(); + + // 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 + */ + + string pwd = Directory.GetCurrentDirectory(); + //string pwd = System.Environment.GetEnvironmentVariable("PWD"); + //if (pwd.Length != 0) + //{ + string rootDir = Path.Combine(pwd, "autotools"); + //} + //else + //{ + // pwd = Assembly.GetExecutingAssembly() + //} + chkMkDir(rootDir); + + foreach (SolutionNode solution in kern.Solutions) + { + m_Kernel.Log.Write(String.Format("Writing solution: {0}", + solution.Name)); + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach (SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "autotools"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/DebugTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/DebugTarget.cs.svn-base new file mode 100644 index 0000000..3494c30 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/DebugTarget.cs.svn-base @@ -0,0 +1,102 @@ +#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$ + * $Date$ + * $Revision$ + */ +#endregion + +using System; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; + +#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 diff --git a/Prebuild/src/Core/Targets/.svn/text-base/MakefileTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/MakefileTarget.cs.svn-base new file mode 100644 index 0000000..54046dd --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/MakefileTarget.cs.svn-base @@ -0,0 +1,469 @@ +#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; +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 +{ + [Target("makefile")] + public class MakefileTarget : ITarget + { + #region Fields + + private Kernel m_Kernel = null; + + #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; + SolutionNode 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) + { + int a = res.IndexOf("/../"); + int 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 (string 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 (string file in project.Files) + if (project.Files.GetBuildAction(file) == BuildAction.EmbeddedResource) + { + string 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 (ReferencePathNode refPath in project.ReferencePaths) + { + string 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 (ReferenceNode 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 (string 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"; + } + else if (t == ProjectType.Library) + { + return "dll"; + } + else + { + throw new FatalException("Bad ProjectType: {0}", t); + } + } + + private string ProjectTypeToTarget(ProjectType t) + { + if (t == ProjectType.Exe) + { + return "exe"; + } + else if (t == ProjectType.WinExe) + { + return "winexe"; + } + else if (t == ProjectType.Library) + { + return "library"; + } + else + { + 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 (ConfigurationNode conf1 in project.Configurations) + foreach (ConfigurationNode 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); + + bool clash = ProjectClashes(project); + + foreach (ConfigurationNode conf in project.Configurations) + { + string outpath = ProjectOutput(project, conf); + string 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 (ReferenceNode refr in project.References) + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode refProj = (ProjectNode)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 (ReferenceNode refr in project.References) + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode refProj; + refProj = (ProjectNode)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 (ReferenceNode 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 = (ProjectNode)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 (ConfigurationNode 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 (ConfigurationNode conf in solution.Configurations) + f.Write(" {0}", conf.Name); + f.WriteLine(); + + f.WriteLine("# Projects:"); + foreach (ProjectNode 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) + { + string defconf = ""; + foreach (ConfigurationNode conf in solution.Configurations) + { + defconf = conf.Name; + break; + } + + f.Write(".PHONY: all"); + foreach (ProjectNode proj in solution.Projects) + f.Write(" {0} {0}-clean", proj.Name); + foreach (ConfigurationNode conf in solution.Configurations) + f.Write(" {0} {0}-clean", conf.Name); + foreach (ProjectNode proj in solution.Projects) + foreach (ConfigurationNode 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 (ConfigurationNode conf in solution.Configurations) + f.Write(" {0}-clean", conf.Name); + f.WriteLine(); + f.WriteLine(); + + foreach (ConfigurationNode conf in solution.Configurations) + { + f.Write("{0}: ", conf.Name); + foreach (ProjectNode proj in solution.Projects) + f.Write(" {0}-{1}", proj.Name, conf.Name); + f.WriteLine(); + f.WriteLine(); + + f.Write("{0}-clean: ", conf.Name); + foreach (ProjectNode proj in solution.Projects) + f.Write(" {0}-{1}-clean", proj.Name, conf.Name); + f.WriteLine(); + f.WriteLine(); + } + + foreach (ProjectNode proj in solution.Projects) + { + f.WriteLine("{0}: {0}-{1}", proj.Name, defconf); + f.WriteLine(); + + f.Write("{0}-clean:", proj.Name); + foreach (ConfigurationNode 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(); + + string file = "Makefile";// Helper.MakeFilePath(solution.FullPath, solution.Name, "make"); + StreamWriter f = new StreamWriter(file); + + Helper.SetCurrentDir(Path.GetDirectoryName(file)); + + using (f) + { + WriteIntro(f, solution); + WritePhony(f, solution); + + foreach (ProjectNode 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); + + string 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 (SolutionNode solution in kern.Solutions) + WriteSolution(solution); + m_Kernel = null; + } + + public virtual void Clean(Kernel kern) + { + m_Kernel = kern; + foreach (SolutionNode sol in kern.Solutions) + CleanSolution(sol); + m_Kernel = null; + } + + public string Name + { + get + { + return "makefile"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/MonoDevelopTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/MonoDevelopTarget.cs.svn-base new file mode 100644 index 0000000..ea6d2c2 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/MonoDevelopTarget.cs.svn-base @@ -0,0 +1,515 @@ +#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 +{ + /// + /// + /// + [Target("monodev")] + public class MonoDevelopTarget : ITarget + { + #region Fields + + private Kernel m_Kernel; + + #endregion + + #region Private Methods + + private static string PrependPath(string path) + { + string tmpPath = Helper.NormalizePath(path, '/'); + Regex regex = new Regex(@"(\w):/(\w+)"); + Match 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) + { + string ret = ""; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if(refr.Path != null || fileRef != null) + { + ret += "Assembly\" refto=\""; + + string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; + + ret += finalPath; + ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; + return ret; + } + + ret += "Gac\""; + ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\""; + 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 + */ + Assembly assem = Assembly.LoadWithPartialName(refr.Name); + ret += assem.FullName; + //ret += refr.Name; + } + catch (System.NullReferenceException e) + { + e.ToString(); + ret += refr.Name; + } + ret += "\" />"; + } + + return ret; + } + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach(ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if(File.Exists(fullPath)) + { + return fullPath; + } + } + + return null; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if( conf == null ) + { + throw new ArgumentNullException("conf"); + } + if( project == null ) + { + throw new ArgumentNullException("project"); + } + string 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) + { + string csComp = "Mcs"; + string netRuntime = "Mono"; + if(project.Runtime == ClrRuntime.Microsoft) + { + csComp = "Csc"; + netRuntime = "MsNet"; + } + + string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); + StreamWriter ss = new StreamWriter(projFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + + using(ss) + { + ss.WriteLine( + "", + project.Name, + project.RootNamespace + ); + + int count = 0; + + ss.WriteLine(" ", solution.ActiveConfig); + + foreach(ConfigurationNode conf in project.Configurations) + { + ss.WriteLine(" ", conf.Name); + ss.Write(" "); + + ss.Write(" "); + + ss.Write(" "); + + ss.Write(" "); + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + + ss.Write(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(string file in project.Files) + { + string buildAction; + string dependson = ""; + string resource_id = ""; + string 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. + string extension = Path.GetExtension(file); + string designer_format = string.Format(".Designer{0}", extension); + + if (file.EndsWith(designer_format)) + { + string basename = file.Substring(0, file.LastIndexOf(designer_format)); + string[] extensions = new string[] { ".cs", ".resx", ".settings" }; + + foreach(string ext in extensions) + { + if (project.Files.Contains(basename + ext)) + { + dependson = string.Format(" dependson=\"{0}{1}\"", basename, ext); + break; + } + } + } + if (extension == ".resx") + { + buildAction = "EmbedAsResource"; + string 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 = string.Format(" copyToOutputDirectory=\"Always\""); + break; + case CopyToOutput.PreserveNewest: + copyToOutput = string.Format(" copyToOutputDirectory=\"PreserveNewest\""); + break; + } + + // Sort of a hack, we try and resolve the path and make it relative, if we can. + string filePath = PrependPath(file); + ss.WriteLine(" ", + filePath, buildAction, dependson, resource_id, copyToOutput); + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ReferenceNode refr in project.References) + { + ss.WriteLine(" {0}", BuildReference(solution, refr)); + } + ss.WriteLine(" "); + + + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteCombine(SolutionNode solution) + { + m_Kernel.Log.Write("Creating MonoDevelop combine and project files"); + foreach(ProjectNode 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(""); + string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); + StreamWriter ss = new StreamWriter(combFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + int count = 0; + + using(ss) + { + ss.WriteLine("", solution.Name); + + count = 0; + foreach(ConfigurationNode conf in solution.Configurations) + { + if(count == 0) + { + ss.WriteLine(" ", conf.Name); + } + + ss.WriteLine(" ", conf.Name); + foreach(ProjectNode project in solution.Projects) + { + ss.WriteLine(" ", project.Name, conf.Name); + } + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + + count = 0; + + foreach(ProjectNode project in solution.Projects) + { + if(count == 0) + ss.WriteLine(" ", project.Name); + + ss.WriteLine(" ", project.Name); + count++; + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.WriteLine(" ", + Helper.MakeFilePath(path, project.Name, "mdp")); + } + ss.WriteLine(" "); + + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string 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); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); + Helper.DeleteIfExists(slnFile); + + foreach(ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode solution in kern.Solutions) + { + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "sharpdev"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/NAntTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/NAntTarget.cs.svn-base new file mode 100644 index 0000000..1efc16d --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/NAntTarget.cs.svn-base @@ -0,0 +1,776 @@ +#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 +{ + /// + /// + /// + [Target("nant")] + public class NAntTarget : ITarget + { + #region Fields + + private Kernel m_Kernel; + + #endregion + + #region Private Methods + + private static string PrependPath(string path) + { + string tmpPath = Helper.NormalizePath(path, '/'); + Regex regex = new Regex(@"(\w):/(\w+)"); + Match 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)) + { + ProjectNode projectRef = (ProjectNode) solution.ProjectsTable[refr.Name]; + string finalPath = + Helper.NormalizePath(refr.Name + GetProjectExtension(projectRef), '/'); + return finalPath; + } + + ProjectNode project = (ProjectNode) refr.Parent; + + // Do we have an explicit file reference? + string 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; + } + else + { + return refName + ".dll"; + } + } + + private static bool ExtensionSpecified(string refName) + { + return refName.EndsWith(".dll") || refName.EndsWith(".exe"); + } + + private static string GetProjectExtension(ProjectNode project) + { + string extension = ".dll"; + if (project.Type == ProjectType.Exe || project.Type == ProjectType.WinExe) + { + extension = ".exe"; + } + return extension; + } + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach (ReferencePathNode refPath in project.ReferencePaths) + { + string 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; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if (conf == null) + { + throw new ArgumentNullException("conf"); + } + if (project == null) + { + throw new ArgumentNullException("project"); + } + string 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) + { + string projFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build"); + StreamWriter ss = new StreamWriter(projFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + bool hasDoc = false; + + using (ss) + { + ss.WriteLine(""); + ss.WriteLine("", project.Name); + ss.WriteLine(" ", "build"); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + if (refr.LocalCopy) + { + ss.WriteLine(" ", '/')); + } + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + if (project.ConfigFile != null && project.ConfigFile.Length!=0) + { + ss.Write(" "); + } + + // Add the content files to just be copied + ss.WriteLine(" {0}", ""); + ss.WriteLine(" {0}", ""); + + foreach (string 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}", ""); + } + + ss.WriteLine(" {0}", ""); + ss.WriteLine(" {0}", ""); + + ss.Write(" "); + ss.WriteLine(" ", project.RootNamespace); + foreach (string file in project.Files) + { + switch (project.Files.GetBuildAction(file)) + { + case BuildAction.EmbeddedResource: + ss.WriteLine(" {0}", ""); + break; + default: + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ss.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + } + break; + } + } + //if (project.Files.GetSubType(file).ToString() != "Code") + //{ + // ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (string file in project.Files) + { + switch (project.Files.GetBuildAction(file)) + { + case BuildAction.Compile: + ss.WriteLine(" "); + break; + default: + break; + } + } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach(ReferencePathNode refPath in project.ReferencePaths) + { + ss.WriteLine(" "); + } + ss.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/'); + if (refr.Path != null) { + if (ExtensionSpecified(refr.Name)) + { + ss.WriteLine (" "); + } + else + { + ss.WriteLine (" "); + } + } + else + { + ss.WriteLine (" "); + } + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + + foreach (ConfigurationNode conf in project.Configurations) + { + if (!String.IsNullOrEmpty(conf.Options.OutputPath)) + { + string targetDir = Helper.NormalizePath(conf.Options.OutputPath, '/'); + + ss.WriteLine(" "); + + ss.WriteLine(" "); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + break; + } + } + + ss.WriteLine(" "); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + ss.WriteLine(" "); + if (hasDoc) + { + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.Write(" "); + } + else + { + ss.WriteLine(".exe\" />"); + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + // foreach(ReferenceNode refr in project.References) + // { + // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); + // if (path != "") + // { + // ss.WriteLine(" ", path); + // } + // } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + } + ss.WriteLine(" "); + ss.WriteLine(""); + } + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteCombine(SolutionNode solution) + { + m_Kernel.Log.Write("Creating NAnt build files"); + foreach (ProjectNode 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(""); + string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); + StreamWriter ss = new StreamWriter(combFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + using (ss) + { + ss.WriteLine(""); + ss.WriteLine("", solution.Name); + ss.WriteLine(" "); + ss.WriteLine(); + + //ss.WriteLine(" "); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + // Use the active configuration, which is the first configuration name in the prebuild file. + Dictionary emittedConfigurations = new Dictionary(); + + ss.WriteLine(" ", solution.ActiveConfig); + ss.WriteLine(); + + foreach (ConfigurationNode 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(" ", conf.Name, conf.Platform); + ss.WriteLine(" "); + ss.WriteLine(); + } + + // Write out the target for the configuration. + ss.WriteLine(" ", conf.Name, conf.Platform); + ss.WriteLine(" ", conf.Name); + ss.WriteLine(" ", conf.Options["DebugInformation"].ToString().ToLower()); + ss.WriteLine("\t\t ", conf.Platform); + ss.WriteLine(" "); + ss.WriteLine(); + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + 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 + { + Regex re = new Regex(".include$"); + DirectoryInfo nantdir = new DirectoryInfo(".nant"); + foreach (FileSystemInfo item in nantdir.GetFileSystemInfos()) + { + if (item is DirectoryInfo) { } + else if (item is FileInfo) + { + if (re.Match(item.FullName) != + System.Text.RegularExpressions.Match.Empty) + { + Console.WriteLine("Including file: " + item.FullName); + + using (FileStream fs = new FileStream(item.FullName, + FileMode.Open, + FileAccess.Read, + FileShare.None)) + { + using (StreamReader sr = new StreamReader(fs)) + { + ss.WriteLine("", (item).FullName); + while (sr.Peek() != -1) + { + ss.WriteLine(sr.ReadLine()); + } + ss.WriteLine(); + } + } + } + } + } + } + catch { } + // ss.WriteLine(" "); + // ss.WriteLine(" "); + // ss.WriteLine(" ", solution.Name, solution.Version); + // ss.WriteLine(" "); + + // ss.WriteLine(" "); + // // ss.WriteLine(" "); + // ss.WriteLine(" "); + // ss.WriteLine(" "); + // ss.WriteLine(" "); + // ss.WriteLine(" "); + ss.WriteLine(); + + + ss.WriteLine(" "); + ss.WriteLine(" "); + //ss.WriteLine(" "); + if (solution.Cleanup != null && solution.Cleanup.CleanFiles.Count > 0) + { + foreach (CleanFilesNode cleanFile in solution.Cleanup.CleanFiles) + { + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" ", cleanFile.Pattern); + ss.WriteLine(" ", cleanFile.Pattern); + ss.WriteLine(" "); + ss.WriteLine(" "); + } + } + ss.WriteLine(" "); + foreach (ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + + foreach (ProjectNode project in solution.ProjectsTableOrder) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(); + ss.WriteLine(" "); + ss.WriteLine(); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string 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); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); + Helper.DeleteIfExists(slnFile); + + foreach (ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach (SolutionNode solution in kern.Solutions) + { + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach (SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "nant"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/SharpDevelop2Target.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/SharpDevelop2Target.cs.svn-base new file mode 100644 index 0000000..66dd1bc --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/SharpDevelop2Target.cs.svn-base @@ -0,0 +1,82 @@ +#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 Prebuild.Core.Attributes; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + [Target("sharpdev2")] + public class SharpDevelop2Target : VS2005Target + { + #region Properties + public override string VersionName + { + get + { + return "SharpDevelop2"; + } + } + #endregion + + #region Public Methods + + /// + /// Writes the specified kern. + /// + /// The kern. + public override void Write(Kernel kern) + { + base.Write(kern); + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public override void Clean(Kernel kern) + { + base.Clean(kern); + } + + /// + /// Gets the name. + /// + /// The name. + public override string Name + { + get + { + return "sharpdev2"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/SharpDevelopTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/SharpDevelopTarget.cs.svn-base new file mode 100644 index 0000000..8e32050 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/SharpDevelopTarget.cs.svn-base @@ -0,0 +1,425 @@ +#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 +{ + /// + /// + /// + [Target("sharpdev")] + public class SharpDevelopTarget : ITarget + { + #region Fields + + private Kernel m_Kernel; + + #endregion + + #region Private Methods + + private static string PrependPath(string path) + { + string tmpPath = Helper.NormalizePath(path, '/'); + Regex regex = new Regex(@"(\w):/(\w+)"); + Match 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) + { + string ret = ""; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if(refr.Path != null || fileRef != null) + { + ret += "Assembly\" refto=\""; + + string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; + + ret += finalPath; + ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; + return ret; + } + + ret += "Gac\" refto=\""; + try + { + //Assembly assem = Assembly.Load(refr.Name); + ret += refr.Name;// assem.FullName; + } + catch (System.NullReferenceException e) + { + e.ToString(); + ret += refr.Name; + } + ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; + } + + return ret; + } + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach(ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if(File.Exists(fullPath)) + { + return fullPath; + } + } + + return null; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if( conf == null ) + { + throw new ArgumentNullException("conf"); + } + if( project == null ) + { + throw new ArgumentNullException("project"); + } + string 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) + { + string csComp = "Csc"; + string netRuntime = "MsNet"; + if(project.Runtime == ClrRuntime.Mono) + { + csComp = "Mcs"; + netRuntime = "Mono"; + } + + string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx"); + StreamWriter ss = new StreamWriter(projFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + + using(ss) + { + ss.WriteLine( + "", + project.Name, + project.RootNamespace + ); + + ss.WriteLine(" "); + foreach(string file in project.Files) + { + string 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. + string filePath = PrependPath(file); + ss.WriteLine(" ", filePath, buildAction); + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ReferenceNode refr in project.References) + { + ss.WriteLine(" {0}", BuildReference(solution, refr)); + } + ss.WriteLine(" "); + + ss.Write(" "); + + int count = 0; + + ss.WriteLine(" ", solution.ActiveConfig); + + foreach(ConfigurationNode conf in project.Configurations) + { + ss.Write(" "); + ss.Write(" "); + + ss.Write(" "); + + ss.Write(" "); + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteCombine(SolutionNode solution) + { + m_Kernel.Log.Write("Creating SharpDevelop combine and project files"); + foreach(ProjectNode 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(""); + string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx"); + StreamWriter ss = new StreamWriter(combFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + using(ss) + { + ss.WriteLine("", solution.Name); + + int count = 0; + foreach(ProjectNode project in solution.Projects) + { + if(count == 0) + ss.WriteLine(" ", project.Name); + + ss.WriteLine(" ", project.Name); + count++; + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.WriteLine(" ", + Helper.MakeFilePath(path, project.Name, "prjx")); + } + ss.WriteLine(" "); + + count = 0; + foreach(ConfigurationNode conf in solution.Configurations) + { + if(count == 0) + { + ss.WriteLine(" ", conf.Name); + } + + ss.WriteLine(" ", conf.Name); + foreach(ProjectNode project in solution.Projects) + { + ss.WriteLine(" ", project.Name, conf.Name); + } + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string 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); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx"); + Helper.DeleteIfExists(slnFile); + + foreach(ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode solution in kern.Solutions) + { + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "sharpdev"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/ToolInfo.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/ToolInfo.cs.svn-base new file mode 100644 index 0000000..935c674 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/ToolInfo.cs.svn-base @@ -0,0 +1,197 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + public struct ToolInfo + { + string name; + string guid; + string fileExtension; + string xmlTag; + string importProject; + + /// + /// Gets or sets the name. + /// + /// The name. + public string Name + { + get + { + return name; + } + set + { + name = value; + } + } + + /// + /// Gets or sets the GUID. + /// + /// The GUID. + public string Guid + { + get + { + return guid; + } + set + { + guid = value; + } + } + + /// + /// Gets or sets the file extension. + /// + /// The file extension. + public string FileExtension + { + get + { + return fileExtension; + } + set + { + fileExtension = value; + } + } + public string LanguageExtension + { + get + { + switch (this.Name) + { + case "C#": + return ".cs"; + case "VisualBasic": + return ".vb"; + case "Boo": + return ".boo"; + default: + return ".cs"; + } + } + } + /// + /// Gets or sets the XML tag. + /// + /// The XML tag. + public string XmlTag + { + get + { + return xmlTag; + } + set + { + xmlTag = value; + } + } + + /// + /// Gets or sets the import project property. + /// + /// The ImportProject tag. + public string ImportProject + { + get + { + return importProject; + } + set + { + importProject = value; + } + } + + /// + /// Initializes a new instance of the class. + /// + /// The name. + /// The GUID. + /// The file extension. + /// The XML. + /// The import project. + public ToolInfo(string name, string guid, string fileExtension, string xml, string importProject) + { + this.name = name; + this.guid = guid; + this.fileExtension = fileExtension; + this.xmlTag = xml; + this.importProject = importProject; + } + + /// + /// Initializes a new instance of the class. + /// + /// The name. + /// The GUID. + /// The file extension. + /// The XML. + public ToolInfo(string name, string guid, string fileExtension, string xml) + { + this.name = name; + this.guid = guid; + this.fileExtension = fileExtension; + this.xmlTag = xml; + this.importProject = "$(MSBuildBinPath)\\Microsoft." + xml + ".Targets"; + } + + /// + /// Equals operator + /// + /// ToolInfo to compare + /// true if toolInfos are equal + public override bool Equals(object obj) + { + if (obj == null) + { + throw new ArgumentNullException("obj"); + } + if (obj.GetType() != typeof(ToolInfo)) + return false; + + ToolInfo c = (ToolInfo)obj; + return ((this.name == c.name) && (this.guid == c.guid) && (this.fileExtension == c.fileExtension) && (this.importProject == c.importProject)); + } + + /// + /// Equals operator + /// + /// ToolInfo to compare + /// ToolInfo to compare + /// True if toolInfos are equal + 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)); + } + + /// + /// Not equals operator + /// + /// ToolInfo to compare + /// ToolInfo to compare + /// True if toolInfos are not equal + public static bool operator !=(ToolInfo c1, ToolInfo c2) + { + return !(c1 == c2); + } + + /// + /// Hash Code + /// + /// Hash code + public override int GetHashCode() + { + return name.GetHashCode() ^ guid.GetHashCode() ^ this.fileExtension.GetHashCode() ^ this.importProject.GetHashCode() ^ this.xmlTag.GetHashCode(); + + } + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/VS2002Target.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/VS2002Target.cs.svn-base new file mode 100644 index 0000000..2292624 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/VS2002Target.cs.svn-base @@ -0,0 +1,87 @@ +#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 Prebuild.Core.Attributes; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + [Target("vs2002")] + public class VS2002Target : VS2003Target + { + #region Private Methods + + private void SetVS2002() + { + this.SolutionVersion = "7.00"; + this.ProductVersion = "7.0.9254"; + this.SchemaVersion = "1.0"; + this.VersionName = "2002"; + this.Version = VSVersion.VS70; + } + + #endregion + + #region Public Methods + + /// + /// Writes the specified kern. + /// + /// The kern. + public override void Write(Kernel kern) + { + SetVS2002(); + base.Write(kern); + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public override void Clean(Kernel kern) + { + SetVS2002(); + base.Clean(kern); + } + + /// + /// Gets the name. + /// + /// The name. + public override string Name + { + get + { + return "vs2002"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/VS2003Target.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/VS2003Target.cs.svn-base new file mode 100644 index 0000000..10e2dc4 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/VS2003Target.cs.svn-base @@ -0,0 +1,593 @@ +#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 Fields + + string solutionVersion = "8.00"; + string productVersion = "7.10.3077"; + string schemaVersion = "2.0"; + string versionName = "2003"; + VSVersion version = VSVersion.VS71; + + readonly Dictionary m_Tools = new Dictionary(); + Kernel m_Kernel; + + /// + /// Gets or sets the solution version. + /// + /// The solution version. + protected string SolutionVersion + { + get + { + return solutionVersion; + } + set + { + solutionVersion = value; + } + } + /// + /// Gets or sets the product version. + /// + /// The product version. + protected string ProductVersion + { + get + { + return productVersion; + } + set + { + productVersion = value; + } + } + /// + /// Gets or sets the schema version. + /// + /// The schema version. + protected string SchemaVersion + { + get + { + return schemaVersion; + } + set + { + schemaVersion = value; + } + } + /// + /// Gets or sets the name of the version. + /// + /// The name of the version. + protected string VersionName + { + get + { + return versionName; + } + set + { + versionName = value; + } + } + /// + /// Gets or sets the version. + /// + /// The version. + protected VSVersion Version + { + get + { + return version; + } + set + { + version = value; + } + } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + 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 Private Methods + + private string MakeRefPath(ProjectNode project) + { + string ret = ""; + foreach(ReferencePathNode node in project.ReferencePaths) + { + try + { + string 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); + } + + ToolInfo toolInfo = m_Tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + StreamWriter ps = new StreamWriter(projectFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); + + using(ps) + { + ps.WriteLine(""); + 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"); + ps.WriteLine(" "); + + foreach(ConfigurationNode conf in project.Configurations) + { + ps.WriteLine("\t\t\t\t "); + } + + ps.WriteLine(" "); + + ps.WriteLine(" "); + foreach(ReferenceNode refr in project.References) + { + ps.WriteLine(" "); + } + ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" "); + + ps.WriteLine(" "); + + foreach(string file in project.Files) + { + string fileName = file.Replace(".\\", ""); + ps.WriteLine(" "); + + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ps.WriteLine(" "); + + } + } + ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" ", toolInfo.XmlTag); + ps.WriteLine(""); + } + + ps = new StreamWriter(projectFile + ".user"); + using(ps) + { + ps.WriteLine(""); + ps.WriteLine(" <{0}>", toolInfo.XmlTag); + ps.WriteLine(" "); + + ps.WriteLine(" ", MakeRefPath(project)); + foreach(ConfigurationNode conf in project.Configurations) + { + ps.WriteLine(" "); + } + ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" ", toolInfo.XmlTag); + ps.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + 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(ProjectNode 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(""); + string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + StreamWriter 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(ProjectNode project in solution.Projects) + { + if(!m_Tools.ContainsKey(project.Language)) + { + throw new UnknownLanguageException("Unknown .NET language: " + project.Language); + } + + ToolInfo toolInfo = m_Tools[project.Language]; + + string 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(ConfigurationNode conf in solution.Configurations) + { + ss.WriteLine("\t\t{0} = {0}", conf.Name); + } + ss.WriteLine("\tEndGlobalSection"); + + ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution"); + foreach(ProjectNode project in solution.Projects) + { + for(int i = 0; i < project.References.Count; i++) + { + ReferenceNode refr = project.References[i]; + if(solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode 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(ProjectNode project in solution.Projects) + { + foreach(ConfigurationNode 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(string 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); + + ToolInfo toolInfo = m_Tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + string 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); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); + + Helper.DeleteIfExists(slnFile); + Helper.DeleteIfExists(suoFile); + + foreach(ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public virtual void Write(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in m_Kernel.Solutions) + { + WriteSolution(sol); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in m_Kernel.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public virtual string Name + { + get + { + return "vs2003"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/VS2005Target.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/VS2005Target.cs.svn-base new file mode 100644 index 0000000..9c70e26 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/VS2005Target.cs.svn-base @@ -0,0 +1,147 @@ +#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 System; +using System.IO; +using System.Text; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + [Target("vs2005")] + public class VS2005Target : VSGenericTarget + { + #region Inner Classes + + #endregion + + #region Fields + + string solutionVersion = "9.00"; + string productVersion = "8.0.50727"; + string schemaVersion = "2.0"; + string versionName = "Visual C# 2005"; + string name = "vs2005"; + + VSVersion version = VSVersion.VS80; + + public override string SolutionTag + { + get { return "# Visual Studio 2005"; } + } + + protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion) + { + return string.Empty; + } + /// + /// Gets or sets the solution version. + /// + /// The solution version. + public override string SolutionVersion + { + get + { + return solutionVersion; + } + } + /// + /// Gets or sets the product version. + /// + /// The product version. + public override string ProductVersion + { + get + { + return productVersion; + } + } + /// + /// Gets or sets the schema version. + /// + /// The schema version. + public override string SchemaVersion + { + get + { + return schemaVersion; + } + } + /// + /// Gets or sets the name of the version. + /// + /// The name of the version. + public override string VersionName + { + get + { + return versionName; + } + } + /// + /// Gets or sets the version. + /// + /// The version. + public override VSVersion Version + { + get + { + return version; + } + } + /// + /// Gets the name. + /// + /// The name. + public override string Name + { + get + { + return name; + } + } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public VS2005Target() + : base() + { + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/VS2008Target.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/VS2008Target.cs.svn-base new file mode 100644 index 0000000..fee4f7f --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/VS2008Target.cs.svn-base @@ -0,0 +1,127 @@ +using System; +using System.IO; +using System.Text; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; +using System.CodeDom.Compiler; + +namespace Prebuild.Core.Targets +{ + + /// + /// + /// + [Target("vs2008")] + public class VS2008Target : VSGenericTarget + { + #region Fields + string solutionVersion = "10.00"; + string productVersion = "9.0.21022"; + string schemaVersion = "2.0"; + string versionName = "Visual Studio 2008"; + string name = "vs2008"; + VSVersion version = VSVersion.VS90; + + /// + /// Gets or sets the solution version. + /// + /// The solution version. + public override string SolutionVersion + { + get + { + return solutionVersion; + } + } + /// + /// Gets or sets the product version. + /// + /// The product version. + public override string ProductVersion + { + get + { + return productVersion; + } + } + /// + /// Gets or sets the schema version. + /// + /// The schema version. + public override string SchemaVersion + { + get + { + return schemaVersion; + } + } + /// + /// Gets or sets the name of the version. + /// + /// The name of the version. + public override string VersionName + { + get + { + return versionName; + } + } + /// + /// Gets or sets the version. + /// + /// The version. + public override VSVersion Version + { + get + { + return version; + } + } + /// + /// Gets the name. + /// + /// The name. + public override string Name + { + get + { + return name; + } + } + + 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 + { + get { return "# Visual Studio 2008"; } + } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public VS2008Target() + : base() + { + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/VS2010Target.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/VS2010Target.cs.svn-base new file mode 100644 index 0000000..ea9f736 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/VS2010Target.cs.svn-base @@ -0,0 +1,138 @@ +using System; +using System.IO; +using System.Text; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; +using System.CodeDom.Compiler; + +namespace Prebuild.Core.Targets +{ + + /// + /// + /// + [Target("vs2010")] + public class VS2010Target : VSGenericTarget + { + #region Fields + + string solutionVersion = "11.00"; + string productVersion = "9.0.30729"; + string schemaVersion = "2.0"; + string versionName = "Visual Studio 2010"; + string name = "vs2010"; + VSVersion version = VSVersion.VS10; + + #endregion + + #region Properties + + /// + /// Gets or sets the solution version. + /// + /// The solution version. + public override string SolutionVersion + { + get + { + return solutionVersion; + } + } + + /// + /// Gets or sets the product version. + /// + /// The product version. + public override string ProductVersion + { + get + { + return productVersion; + } + } + + /// + /// Gets or sets the schema version. + /// + /// The schema version. + public override string SchemaVersion + { + get + { + return schemaVersion; + } + } + + /// + /// Gets or sets the name of the version. + /// + /// The name of the version. + public override string VersionName + { + get + { + return versionName; + } + } + + /// + /// Gets or sets the version. + /// + /// The version. + public override VSVersion Version + { + get + { + return version; + } + } + + /// + /// Gets the name. + /// + /// The name. + public override string Name + { + get + { + return name; + } + } + + protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion) + { + switch (frameworkVersion) + { + 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 + { + get { return "# Visual Studio 2010"; } + } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public VS2010Target() + : base() + { + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/VSGenericTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/VSGenericTarget.cs.svn-base new file mode 100644 index 0000000..6969dd7 --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/VSGenericTarget.cs.svn-base @@ -0,0 +1,922 @@ +#region BSD License +/* +Copyright (c) 2008 Matthew Holmes (matthew@wildfiregames.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 + +using System; +using System.Collections.Generic; +using System.IO; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; +using System.CodeDom.Compiler; + +namespace Prebuild.Core.Targets +{ + + /// + /// + /// + public abstract class VSGenericTarget : ITarget + { + #region Fields + + readonly Dictionary tools = new Dictionary(); + Kernel kernel; + #endregion + + #region Properties + /// + /// Gets or sets the solution version. + /// + /// The solution version. + public abstract string SolutionVersion { get; } + /// + /// Gets or sets the product version. + /// + /// The product version. + public abstract string ProductVersion { get; } + /// + /// Gets or sets the schema version. + /// + /// The schema version. + public abstract string SchemaVersion { get; } + /// + /// Gets or sets the name of the version. + /// + /// The name of the version. + public abstract string VersionName { get; } + /// + /// Gets or sets the version. + /// + /// The version. + public abstract VSVersion Version { get; } + /// + /// Gets the name. + /// + /// The name. + public abstract string Name { get; } + + protected abstract string GetToolsVersionXml(FrameworkVersion version); + public abstract string SolutionTag { get; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + protected VSGenericTarget() + { + tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets"); + tools["Database"] = new ToolInfo("Database", "{4F174C21-8C12-11D0-8340-0000F80270F8}", "dbp", "UNKNOWN"); + tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets"); + tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets"); + tools["Folder"] = new ToolInfo("Folder", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", null, null); + } + + #endregion + + #region Private Methods + + private string MakeRefPath(ProjectNode project) + { + string ret = ""; + foreach (ReferencePathNode node in project.ReferencePaths) + { + try + { + string fullPath = Helper.ResolvePath(node.Path); + if (ret.Length < 1) + { + ret = fullPath; + } + else + { + ret += ";" + fullPath; + } + } + catch (ArgumentException) + { + kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); + } + } + + return ret; + } + + private static ProjectNode FindProjectInSolution(string name, SolutionNode solution) + { + SolutionNode node = solution; + + while (node.Parent is SolutionNode) + node = node.Parent as SolutionNode; + + return FindProjectInSolutionRecursively(name, node); + } + + private static ProjectNode FindProjectInSolutionRecursively(string name, SolutionNode solution) + { + if (solution.ProjectsTable.ContainsKey(name)) + return solution.ProjectsTable[name]; + + foreach (SolutionNode child in solution.Solutions) + { + ProjectNode node = FindProjectInSolutionRecursively(name, child); + if (node != null) + return node; + } + + return null; + } + + private void WriteProject(SolutionNode solution, ProjectNode project) + { + if (!tools.ContainsKey(project.Language)) + { + throw new UnknownLanguageException("Unknown .NET language: " + project.Language); + } + + ToolInfo toolInfo = tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + StreamWriter ps = new StreamWriter(projectFile); + + kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); + + #region Project File + using (ps) + { + ps.WriteLine("", GetToolsVersionXml(project.FrameworkVersion)); + ps.WriteLine(" "); + ps.WriteLine(" Local"); + ps.WriteLine(" {0}", ProductVersion); + ps.WriteLine(" {0}", SchemaVersion); + ps.WriteLine(" {{{0}}}", project.Guid.ToString().ToUpper()); + + // Visual Studio has a hard coded guid for the project type + if (project.Type == ProjectType.Web) + ps.WriteLine(" {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}"); + ps.WriteLine(" Debug"); + ps.WriteLine(" {0}", project.AppIcon); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" {0}", project.AssemblyName); + foreach (ConfigurationNode conf in project.Configurations) + { + if (conf.Options.KeyFile != "") + { + ps.WriteLine(" {0}", conf.Options.KeyFile); + ps.WriteLine(" true"); + break; + } + } + ps.WriteLine(" JScript"); + ps.WriteLine(" Grid"); + ps.WriteLine(" IE50"); + ps.WriteLine(" false"); + ps.WriteLine(" {0}", project.FrameworkVersion.ToString().Replace("_", ".")); + + ps.WriteLine(" {0}", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString()); + ps.WriteLine(" {0}", project.DesignerFolder); + ps.WriteLine(" {0}", project.RootNamespace); + ps.WriteLine(" {0}", project.StartupObject); + if (string.IsNullOrEmpty(project.DebugStartParameters)) + { + ps.WriteLine(" {0}", project.DebugStartParameters); + } + ps.WriteLine(" "); + ps.WriteLine(" "); + + ps.WriteLine(" "); + + foreach (ConfigurationNode conf in project.Configurations) + { + ps.Write(" ", conf.Name, conf.Platform); + ps.WriteLine(" {0}", conf.Options["AllowUnsafe"]); + ps.WriteLine(" {0}", conf.Options["BaseAddress"]); + ps.WriteLine(" {0}", conf.Options["CheckUnderflowOverflow"]); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" {0}", conf.Options["CompilerDefines"]); + ps.WriteLine(" {0}", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString())); + ps.WriteLine(" {0}", conf.Options["DebugInformation"]); + ps.WriteLine(" {0}", conf.Options["FileAlignment"]); + ps.WriteLine(" {0}", conf.Options["OptimizeCode"]); + if (project.Type != ProjectType.Web) + ps.WriteLine(" {0}", + Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); + else + ps.WriteLine(" {0}", + Helper.EndPath(Helper.NormalizePath("bin\\"))); + + ps.WriteLine(" {0}", conf.Options["RegisterComInterop"]); + ps.WriteLine(" {0}", conf.Options["RemoveIntegerChecks"]); + ps.WriteLine(" {0}", conf.Options["WarningsAsErrors"]); + ps.WriteLine(" {0}", conf.Options["WarningLevel"]); + ps.WriteLine(" {0}", conf.Options["NoStdLib"]); + ps.WriteLine(" {0}", conf.Options["SuppressWarnings"]); + ps.WriteLine(" {0}", conf.Platform); + ps.WriteLine(" "); + } + + //ps.WriteLine(" "); + + Dictionary projectReferences = new Dictionary(); + List otherReferences = new List(); + + foreach (ReferenceNode refr in project.References) + { + ProjectNode projectNode = FindProjectInSolution(refr.Name, solution); + + if (projectNode == null) + otherReferences.Add(refr); + else + projectReferences.Add(refr, projectNode); + } + // Assembly References + ps.WriteLine(" "); + + foreach (ReferenceNode refr in otherReferences) + { + ps.Write(" "); + ps.Write(" "); + ps.Write(refr.Name); + ps.WriteLine(""); + + if(!String.IsNullOrEmpty(refr.Path)) + { + // Use absolute path to assembly (for determining assembly type) + string absolutePath = Path.Combine(project.FullPath, refr.Path); + if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "exe"))) { + // Assembly is an executable (exe) + ps.WriteLine(" {0}", Helper.MakeFilePath(refr.Path, refr.Name, "exe")); + } else if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "dll"))) { + // Assembly is an library (dll) + ps.WriteLine(" {0}", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); + } else { + string referencePath = Helper.MakeFilePath(refr.Path, refr.Name, "dll"); + kernel.Log.Write(LogType.Warning, "Reference \"{0}\": The specified file doesn't exist.", referencePath); + ps.WriteLine(" {0}", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); + } + } + + ps.WriteLine(" {0}", refr.LocalCopy); + ps.WriteLine(" "); + } + ps.WriteLine(" "); + + //Project References + ps.WriteLine(" "); + foreach (KeyValuePair pair in projectReferences) + { + ToolInfo tool = tools[pair.Value.Language]; + if (tools == null) + throw new UnknownLanguageException(); + + string path = + Helper.MakePathRelativeTo(project.FullPath, + Helper.MakeFilePath(pair.Value.FullPath, pair.Value.Name, tool.FileExtension)); + ps.WriteLine(" ", path); + + // TODO: Allow reference to visual basic projects + ps.WriteLine(" {0}", pair.Value.Name); + ps.WriteLine(" {0}", pair.Value.Guid.ToString("B").ToUpper()); + ps.WriteLine(" {0}", tool.Guid.ToUpper()); + + //This is the Copy Local flag in VS + ps.WriteLine(" {0}", pair.Key.LocalCopy); + + ps.WriteLine(" "); + } + ps.WriteLine(" "); + + // ps.WriteLine(" "); + ps.WriteLine(" "); + + // ps.WriteLine(" "); + List list = new List(); + + foreach (string path in project.Files) + { + string lower = path.ToLower(); + if (lower.EndsWith(".resx")) + { + string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension); + if (!list.Contains(codebehind)) + list.Add(codebehind); + } + + } + + foreach (string filePath in project.Files) + { + // if (file == "Properties\\Bind.Designer.cs") + // { + // Console.WriteLine("Wait a minute!"); + // Console.WriteLine(project.Files.GetSubType(file).ToString()); + // } + SubType subType = project.Files.GetSubType(filePath); + + // Visual Studio chokes on file names if forward slash is used as a path separator + // instead of backslash. So we must make sure that all file paths written to the + // project file use \ as a path separator. + string file = filePath.Replace(@"/", @"\"); + + if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer + && subType != SubType.CodeBehind) + { + ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + ps.WriteLine(" {0}", Path.GetFileName(file)); + ps.WriteLine(" Designer"); + ps.WriteLine(" "); + // + } + + if (subType == SubType.Designer) + { + ps.WriteLine(" ", file); + + string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"; + string dependent_name = filePath.Substring(0, file.LastIndexOf('.')) + ".cs"; + + // Check for a parent .cs file with the same name as this designer file + if (File.Exists(Helper.NormalizePath(dependent_name))) + { + ps.WriteLine(" {0}", Path.GetFileName(dependent_name)); + } + else + { + ps.WriteLine(" ResXFileCodeGenerator"); + ps.WriteLine(" {0}", Path.GetFileName(autogen_name)); + ps.WriteLine(" " + subType + ""); + } + + ps.WriteLine(" "); + if (File.Exists(Helper.NormalizePath(autogen_name))) + { + ps.WriteLine(" ", autogen_name); + //ps.WriteLine(" True"); + + // If a parent .cs file exists, link this autogen file to it. Otherwise link + // to the designer file + if (File.Exists(dependent_name)) + { + ps.WriteLine(" {0}", Path.GetFileName(dependent_name)); + } + else + { + ps.WriteLine(" True"); + ps.WriteLine(" {0}", Path.GetFileName(filePath)); + } + + ps.WriteLine(" "); + } + list.Add(autogen_name); + } + if (subType == SubType.Settings) + { + ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); + ps.WriteLine("Include=\"{0}\">", file); + string fileName = Path.GetFileName(filePath); + if (project.Files.GetBuildAction(filePath) == BuildAction.None) + { + ps.WriteLine(" SettingsSingleFileGenerator"); + ps.WriteLine(" {0}", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); + } + else + { + ps.WriteLine(" Code"); + ps.WriteLine(" True"); + ps.WriteLine(" True"); + string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); + string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); + ps.WriteLine(" {0}", Path.GetFileName(fileNameShorter + ".settings")); + } + ps.WriteLine(" ", project.Files.GetBuildAction(filePath)); + } + else if (subType != SubType.Designer) + { + string path = Helper.NormalizePath(file); + string path_lower = path.ToLower(); + + if (!list.Contains(filePath)) + { + ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); + + int startPos = 0; + if (project.Files.GetPreservePath(filePath)) + { + while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1) + startPos++; + + } + else + { + startPos = file.LastIndexOf(Path.GetFileName(path)); + } + + // be sure to write out the path with backslashes so VS recognizes + // the file properly. + ps.WriteLine("Include=\"{0}\">", file); + + int last_period_index = file.LastIndexOf('.'); + string short_file_name = file.Substring(0, last_period_index); + string extension = Path.GetExtension(path); + // make this upper case, so that when File.Exists tests for the + // existence of a designer file on a case-sensitive platform, + // it is correctly identified. + string designer_format = string.Format(".Designer{0}", extension); + + if (path_lower.EndsWith(designer_format.ToLowerInvariant())) + { + int designer_index = path.IndexOf(designer_format); + string file_name = path.Substring(0, designer_index); + + // There are two corrections to the next lines: + // 1. Fix the connection between a designer file and a form + // or usercontrol that don't have an associated resx file. + // 2. Connect settings files to associated designer files. + if (File.Exists(file_name + extension)) + ps.WriteLine(" {0}", Path.GetFileName(file_name + extension)); + else if (File.Exists(file_name + ".resx")) + ps.WriteLine(" {0}", Path.GetFileName(file_name + ".resx")); + else if (File.Exists(file_name + ".settings")) + { + ps.WriteLine(" {0}", Path.GetFileName(file_name + ".settings")); + ps.WriteLine(" True"); + ps.WriteLine(" True"); + } + } + else if (subType == SubType.CodeBehind) + { + ps.WriteLine(" {0}", Path.GetFileName(short_file_name)); + } + if (project.Files.GetIsLink(filePath)) + { + string alias = project.Files.GetLinkPath(filePath); + alias += file.Substring(startPos); + alias = Helper.NormalizePath(alias); + ps.WriteLine(" {0}", alias); + } + else if (project.Files.GetBuildAction(filePath) != BuildAction.None) + { + if (project.Files.GetBuildAction(filePath) != BuildAction.EmbeddedResource) + { + ps.WriteLine(" {0}", subType); + } + } + + if (project.Files.GetCopyToOutput(filePath) != CopyToOutput.Never) + { + ps.WriteLine(" {0}", project.Files.GetCopyToOutput(filePath)); + } + + ps.WriteLine(" ", project.Files.GetBuildAction(filePath)); + } + } + } + + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(""); + } + #endregion + + #region User File + + ps = new StreamWriter(projectFile + ".user"); + using (ps) + { + // Get the first configuration from the project. + ConfigurationNode firstConfiguration = null; + + if (project.Configurations.Count > 0) + { + firstConfiguration = project.Configurations[0]; + } + + ps.WriteLine(""); + //ps.WriteLine( "" ); + //ps.WriteLine(" <{0}>", toolInfo.XMLTag); + //ps.WriteLine(" "); + ps.WriteLine(" "); + //ps.WriteLine(" ", MakeRefPath(project)); + + if (firstConfiguration != null) + { + ps.WriteLine(" {0}", firstConfiguration.Name); + ps.WriteLine(" {0}", firstConfiguration.Platform); + } + + ps.WriteLine(" {0}", MakeRefPath(project)); + ps.WriteLine(" {0}", ProductVersion); + ps.WriteLine(" ProjectFiles"); + ps.WriteLine(" 0"); + ps.WriteLine(" "); + foreach (ConfigurationNode conf in project.Configurations) + { + ps.Write(" "); + } + ps.WriteLine(""); + } + #endregion + + kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteSolution(SolutionNode solution, bool writeSolutionToDisk) + { + kernel.Log.Write("Creating {0} solution and project files", VersionName); + + foreach (SolutionNode child in solution.Solutions) + { + kernel.Log.Write("...Creating folder: {0}", child.Name); + WriteSolution(child, false); + } + + foreach (ProjectNode project in solution.Projects) + { + kernel.Log.Write("...Creating project: {0}", project.Name); + WriteProject(solution, project); + } + + foreach (DatabaseProjectNode project in solution.DatabaseProjects) + { + kernel.Log.Write("...Creating database project: {0}", project.Name); + WriteDatabaseProject(solution, project); + } + + if (writeSolutionToDisk) // only write main solution + { + kernel.Log.Write(""); + string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + + using (StreamWriter ss = new StreamWriter(solutionFile)) + { + kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); + + ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", SolutionVersion); + ss.WriteLine(SolutionTag); + + WriteProjectDeclarations(ss, solution, solution); + + ss.WriteLine("Global"); + + ss.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution"); + foreach (ConfigurationNode conf in solution.Configurations) + { + ss.WriteLine("\t\t{0} = {0}", conf.NameAndPlatform); + } + ss.WriteLine("\tEndGlobalSection"); + + ss.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution"); + WriteConfigurationLines(solution.Configurations, solution, ss); + ss.WriteLine("\tEndGlobalSection"); + + if (solution.Solutions.Count > 0) + { + ss.WriteLine("\tGlobalSection(NestedProjects) = preSolution"); + foreach (SolutionNode embeddedSolution in solution.Solutions) + { + WriteNestedProjectMap(ss, embeddedSolution); + } + ss.WriteLine("\tEndGlobalSection"); + } + + ss.WriteLine("EndGlobal"); + } + + kernel.CurrentWorkingDirectory.Pop(); + } + } + + private void WriteProjectDeclarations(TextWriter writer, SolutionNode actualSolution, SolutionNode embeddedSolution) + { + foreach (SolutionNode childSolution in embeddedSolution.Solutions) + { + WriteEmbeddedSolution(writer, childSolution); + WriteProjectDeclarations(writer, actualSolution, childSolution); + } + + foreach (ProjectNode project in embeddedSolution.Projects) + { + WriteProject(actualSolution, writer, project); + } + + foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) + { + WriteProject(actualSolution, writer, dbProject); + } + + if (actualSolution.Guid == embeddedSolution.Guid) + { + WriteSolutionFiles(actualSolution, writer); + } + } + + private static void WriteNestedProjectMap(TextWriter writer, SolutionNode embeddedSolution) + { + foreach (ProjectNode project in embeddedSolution.Projects) + { + WriteNestedProject(writer, embeddedSolution, project.Guid); + } + + foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) + { + WriteNestedProject(writer, embeddedSolution, dbProject.Guid); + } + + foreach (SolutionNode child in embeddedSolution.Solutions) + { + WriteNestedProject(writer, embeddedSolution, child.Guid); + WriteNestedProjectMap(writer, child); + } + } + + private static void WriteNestedProject(TextWriter writer, SolutionNode solution, Guid projectGuid) + { + WriteNestedFolder(writer, solution.Guid, projectGuid); + } + + private static void WriteNestedFolder(TextWriter writer, Guid parentGuid, Guid childGuid) + { + writer.WriteLine("\t\t{0} = {1}", + childGuid.ToString("B").ToUpper(), + parentGuid.ToString("B").ToUpper()); + } + + private static void WriteConfigurationLines(IEnumerable configurations, SolutionNode solution, TextWriter ss) + { + foreach (ProjectNode project in solution.Projects) + { + foreach (ConfigurationNode conf in configurations) + { + ss.WriteLine("\t\t{0}.{1}.ActiveCfg = {1}", + project.Guid.ToString("B").ToUpper(), + conf.NameAndPlatform); + + ss.WriteLine("\t\t{0}.{1}.Build.0 = {1}", + project.Guid.ToString("B").ToUpper(), + conf.NameAndPlatform); + } + } + + foreach (SolutionNode child in solution.Solutions) + { + WriteConfigurationLines(configurations, child, ss); + } + } + + private void WriteSolutionFiles(SolutionNode solution, TextWriter ss) + { + if(solution.Files != null && solution.Files.Count > 0) + WriteProject(ss, "Folder", solution.Guid, "Solution Files", "Solution Files", solution.Files); + } + + private void WriteEmbeddedSolution(TextWriter writer, SolutionNode embeddedSolution) + { + WriteProject(writer, "Folder", embeddedSolution.Guid, embeddedSolution.Name, embeddedSolution.Name, embeddedSolution.Files); + } + + private void WriteProject(SolutionNode solution, TextWriter ss, ProjectNode project) + { + WriteProject(ss, solution, project.Language, project.Guid, project.Name, project.FullPath); + } + + private void WriteProject(SolutionNode solution, TextWriter ss, DatabaseProjectNode dbProject) + { + if (solution.Files != null && solution.Files.Count > 0) + WriteProject(ss, solution, "Database", dbProject.Guid, dbProject.Name, dbProject.FullPath); + } + + const string ProjectDeclarationBeginFormat = "Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\""; + const string ProjectDeclarationEndFormat = "EndProject"; + + private void WriteProject(TextWriter ss, SolutionNode solution, string language, Guid guid, string name, string projectFullPath) + { + if (!tools.ContainsKey(language)) + throw new UnknownLanguageException("Unknown .NET language: " + language); + + ToolInfo toolInfo = tools[language]; + + string path = Helper.MakePathRelativeTo(solution.FullPath, projectFullPath); + + path = Helper.MakeFilePath(path, name, toolInfo.FileExtension); + + WriteProject(ss, language, guid, name, path); + } + + private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location) + { + WriteProject(writer, language, projectGuid, name, location, null); + } + + private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location, FilesNode files) + { + if (!tools.ContainsKey(language)) + throw new UnknownLanguageException("Unknown .NET language: " + language); + + ToolInfo toolInfo = tools[language]; + + writer.WriteLine(ProjectDeclarationBeginFormat, + toolInfo.Guid, + name, + location, + projectGuid.ToString("B").ToUpper()); + + if (files != null) + { + writer.WriteLine("\tProjectSection(SolutionItems) = preProject"); + + foreach (string file in files) + writer.WriteLine("\t\t{0} = {0}", file); + + writer.WriteLine("\tEndProjectSection"); + } + + writer.WriteLine(ProjectDeclarationEndFormat); + } + + private void WriteDatabaseProject(SolutionNode solution, DatabaseProjectNode project) + { + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "dbp"); + IndentedTextWriter ps = new IndentedTextWriter(new StreamWriter(projectFile), " "); + + kernel.CurrentWorkingDirectory.Push(); + + Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); + + using (ps) + { + ps.WriteLine("# Microsoft Developer Studio Project File - Database Project"); + ps.WriteLine("Begin DataProject = \"{0}\"", project.Name); + ps.Indent++; + ps.WriteLine("MSDTVersion = \"80\""); + // TODO: Use the project.Files property + if (ContainsSqlFiles(Path.GetDirectoryName(projectFile))) + WriteDatabaseFoldersAndFiles(ps, Path.GetDirectoryName(projectFile)); + + ps.WriteLine("Begin DBRefFolder = \"Database References\""); + ps.Indent++; + foreach (DatabaseReferenceNode reference in project.References) + { + ps.WriteLine("Begin DBRefNode = \"{0}\"", reference.Name); + ps.Indent++; + ps.WriteLine("ConnectStr = \"{0}\"", reference.ConnectionString); + ps.WriteLine("Provider = \"{0}\"", reference.ProviderId.ToString("B").ToUpper()); + //ps.WriteLine("Colorizer = 5"); + ps.Indent--; + ps.WriteLine("End"); + } + ps.Indent--; + ps.WriteLine("End"); + ps.Indent--; + ps.WriteLine("End"); + + ps.Flush(); + } + + kernel.CurrentWorkingDirectory.Pop(); + } + + private static bool ContainsSqlFiles(string folder) + { + if(Directory.GetFiles(folder, "*.sql").Length > 0) + return true; // if the folder contains 1 .sql file, that's good enough + + foreach (string child in Directory.GetDirectories(folder)) + { + if (ContainsSqlFiles(child)) + return true; // if 1 child folder contains a .sql file, still good enough + } + + return false; + } + + private static void WriteDatabaseFoldersAndFiles(IndentedTextWriter writer, string folder) + { + foreach (string child in Directory.GetDirectories(folder)) + { + if (ContainsSqlFiles(child)) + { + writer.WriteLine("Begin Folder = \"{0}\"", Path.GetFileName(child)); + writer.Indent++; + WriteDatabaseFoldersAndFiles(writer, child); + writer.Indent--; + writer.WriteLine("End"); + } + } + foreach (string file in Directory.GetFiles(folder, "*.sql")) + { + writer.WriteLine("Script = \"{0}\"", Path.GetFileName(file)); + } + } + + private void CleanProject(ProjectNode project) + { + kernel.Log.Write("...Cleaning project: {0}", project.Name); + + ToolInfo toolInfo = tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + string userFile = projectFile + ".user"; + + Helper.DeleteIfExists(projectFile); + Helper.DeleteIfExists(userFile); + } + + private void CleanSolution(SolutionNode solution) + { + kernel.Log.Write("Cleaning {0} solution and project files", VersionName, solution.Name); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); + + Helper.DeleteIfExists(slnFile); + Helper.DeleteIfExists(suoFile); + + foreach (ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public virtual void Write(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + kernel = kern; + foreach (SolutionNode sol in kernel.Solutions) + { + WriteSolution(sol, true); + } + kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + kernel = kern; + foreach (SolutionNode sol in kernel.Solutions) + { + CleanSolution(sol); + } + kernel = null; + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/VSVersion.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/VSVersion.cs.svn-base new file mode 100644 index 0000000..699b5ca --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/VSVersion.cs.svn-base @@ -0,0 +1,54 @@ +#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 +{ + /// + /// + /// + public enum VSVersion + { + /// + /// Visual Studio 2002 + /// + VS70, + /// + /// Visual Studio 2003 + /// + VS71, + /// + /// Visual Studio 2005 + /// + VS80, + /// + /// Visual Studio 2008 + /// + VS90, + /// + /// Visual Studio 2010 + /// + VS10 + } +} diff --git a/Prebuild/src/Core/Targets/.svn/text-base/XcodeTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/XcodeTarget.cs.svn-base new file mode 100644 index 0000000..5393cec --- /dev/null +++ b/Prebuild/src/Core/Targets/.svn/text-base/XcodeTarget.cs.svn-base @@ -0,0 +1,594 @@ +#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 +{ + /// + /// + /// + [Target("xcode")] + public class XcodeTarget : ITarget + { + #region Fields + + private Kernel m_Kernel; + + #endregion + + #region Private Methods + + private static string PrependPath(string path) + { + string tmpPath = Helper.NormalizePath(path, '/'); + Regex regex = new Regex(@"(\w):/(\w+)"); + Match 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) + { + string ret = ""; + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; + string fileRef = FindFileReference(refr.Name, project); + string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/${build.dir}/", refr.Name, "dll"), '/'); + ret += finalPath; + return ret; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if (refr.Path != null || fileRef != null) + { + string 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 (System.NullReferenceException e) + { + e.ToString(); + ret += refr.Name + ".dll"; + } + } + return ret; + } + + private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) + { + string ret = ""; + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; + string fileRef = FindFileReference(refr.Name, project); + string finalPath = Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/'); + ret += finalPath; + return ret; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if (refr.Path != null || fileRef != null) + { + string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; + ret += finalPath; + return ret; + } + + try + { + Assembly assem = Assembly.Load(refr.Name); + if (assem != null) + { + ret += ""; + } + else + { + ret += ""; + } + } + catch (System.NullReferenceException e) + { + e.ToString(); + ret += ""; + } + } + return ret; + } + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach (ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if (File.Exists(fullPath)) + { + return fullPath; + } + } + + return null; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if (conf == null) + { + throw new ArgumentNullException("conf"); + } + if (project == null) + { + throw new ArgumentNullException("project"); + } + string 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) + { + string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); + StreamWriter ss = new StreamWriter(projFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + bool hasDoc = false; + + using (ss) + { + ss.WriteLine(""); + ss.WriteLine("", project.Name); + ss.WriteLine(" ", "build"); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + if (refr.LocalCopy) + { + ss.WriteLine(" ", '/')); + } + } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.Write(" "); + ss.WriteLine(" ", project.RootNamespace); + foreach (string file in project.Files) + { + switch (project.Files.GetBuildAction(file)) + { + case BuildAction.EmbeddedResource: + ss.WriteLine(" {0}", ""); + break; + default: + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ss.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + } + break; + } + } + //if (project.Files.GetSubType(file).ToString() != "Code") + //{ + // ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (string file in project.Files) + { + switch (project.Files.GetBuildAction(file)) + { + case BuildAction.Compile: + ss.WriteLine(" "); + break; + default: + break; + } + } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + ss.WriteLine(" ", '/')); + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + ss.WriteLine(" "); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + ss.WriteLine(" "); + if (hasDoc) + { + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.Write(" "); + } + else + { + ss.WriteLine(".exe\" />"); + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + // foreach(ReferenceNode refr in project.References) + // { + // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); + // if (path != "") + // { + // ss.WriteLine(" ", path); + // } + // } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + } + ss.WriteLine(" "); + ss.WriteLine(""); + } + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteCombine(SolutionNode solution) + { + m_Kernel.Log.Write("Creating Xcode build files"); + foreach (ProjectNode 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(""); + DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj")); + if (!directoryInfo.Exists) + { + directoryInfo.Create(); + } + string combFile = Helper.MakeFilePath(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj"), "project", "pbxproj"); + StreamWriter ss = new StreamWriter(combFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + using (ss) + { + ss.WriteLine(""); + ss.WriteLine("", solution.Name); + ss.WriteLine(" "); + ss.WriteLine(); + + //ss.WriteLine(" "); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + foreach (ConfigurationNode conf in solution.Configurations) + { + // Set the project.config to a non-debug configuration + if (conf.Options["DebugInformation"].ToString().ToLower() != "true") + { + ss.WriteLine(" ", conf.Name); + } + ss.WriteLine(); + ss.WriteLine(" ", conf.Name); + ss.WriteLine(" ", conf.Name); + ss.WriteLine(" ", conf.Options["DebugInformation"].ToString().ToLower()); + ss.WriteLine(" "); + ss.WriteLine(); + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + //foreach(ProjectNode project in solution.Projects) + //{ + // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + // ss.Write(" "); + //} + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + + foreach (ProjectNode project in solution.ProjectsTableOrder) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(); + ss.WriteLine(" "); + ss.WriteLine(); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string 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); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); + Helper.DeleteIfExists(slnFile); + + foreach (ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach (SolutionNode solution in kern.Solutions) + { + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach (SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "xcode"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/AutotoolsTarget.cs b/Prebuild/src/Core/Targets/AutotoolsTarget.cs new file mode 100644 index 0000000..e46b5a5 --- /dev/null +++ b/Prebuild/src/Core/Targets/AutotoolsTarget.cs @@ -0,0 +1,1070 @@ +#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.IO; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using System.Xml.Xsl; +using System.Net; +using System.Diagnostics; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Targets +{ + public enum ClrVersion + { + Default, + Net_1_1, + Net_2_0 + } + + public class SystemPackage + { + string name; + string version; + string description; + string[] assemblies; + bool isInternal; + ClrVersion targetVersion; + + public void Initialize(string name, + string version, + string description, + string[] assemblies, + ClrVersion targetVersion, + bool isInternal) + { + this.isInternal = isInternal; + this.name = name; + this.version = version; + this.assemblies = assemblies; + this.description = description; + this.targetVersion = targetVersion; + } + + public string Name + { + get { return name; } + } + + public string Version + { + get { return version; } + } + + public string Description + { + get { return description; } + } + + public ClrVersion TargetVersion + { + get { return targetVersion; } + } + + // The package is part of the mono SDK + public bool IsCorePackage + { + get { return name == "mono"; } + } + + // The package has been registered by an add-in, and is not installed + // in the system. + public bool IsInternalPackage + { + get { return isInternal; } + } + + public string[] Assemblies + { + get { return assemblies; } + } + + } + + + /// + /// + /// + [Target("autotools")] + public class AutotoolsTarget : ITarget + { + #region Fields + + Kernel m_Kernel; + XmlDocument autotoolsDoc; + XmlUrlResolver xr; + System.Security.Policy.Evidence e; + readonly Dictionary assemblyPathToPackage = new Dictionary(); + readonly Dictionary assemblyFullNameToPath = new Dictionary(); + readonly Dictionary packagesHash = new Dictionary(); + readonly List packages = new List(); + + #endregion + + #region Private Methods + + private static void mkdirDashP(string dirName) + { + DirectoryInfo di = new DirectoryInfo(dirName); + if (di.Exists) + return; + + string parentDirName = System.IO.Path.GetDirectoryName(dirName); + DirectoryInfo parentDi = new DirectoryInfo(parentDirName); + if (!parentDi.Exists) + mkdirDashP(parentDirName); + + di.Create(); + } + + private static void chkMkDir(string dirName) + { + System.IO.DirectoryInfo di = + new System.IO.DirectoryInfo(dirName); + + if (!di.Exists) + di.Create(); + } + + private void transformToFile(string filename, XsltArgumentList argList, string nodeName) + { + // Create an XslTransform for this file + XslTransform templateTransformer = + new XslTransform(); + + // Load up the template + XmlNode templateNode = + autotoolsDoc.SelectSingleNode(nodeName + "/*"); + templateTransformer.Load(templateNode.CreateNavigator(), xr, e); + + // Create a writer for the transformed template + XmlTextWriter templateWriter = + new XmlTextWriter(filename, null); + + // Perform transformation, writing the file + templateTransformer.Transform + (m_Kernel.CurrentDoc, argList, templateWriter, xr); + } + + static string NormalizeAsmName(string name) + { + int 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 + { + System.Reflection.AssemblyName an = System.Reflection.AssemblyName.GetAssemblyName(assemblyfile); + assemblyFullNameToPath[NormalizeAsmName(an.FullName)] = assemblyfile; + assemblyPathToPackage[assemblyfile] = package; + } + catch + { + } + } + + private static List GetAssembliesWithLibInfo(string line, string file) + { + List references = new List(); + List libdirs = new List(); + List retval = new List(); + foreach (string 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 (string refrnc in references) + { + foreach (string libdir in libdirs) + { + if (File.Exists(libdir + Path.DirectorySeparatorChar + refrnc)) + { + retval.Add(libdir + Path.DirectorySeparatorChar + refrnc); + } + } + } + + return retval; + } + + private static List GetAssembliesWithoutLibInfo(string line, string file) + { + List references = new List(); + foreach (string reference in line.Split(' ')) + { + if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:")) + { + string final_ref = reference.Substring(3).Trim(); + references.Add(ProcessPiece(final_ref, file)); + } + } + return references; + } + + private static string ProcessPiece(string piece, string pcfile) + { + int start = piece.IndexOf("${"); + if (start == -1) + return piece; + + int end = piece.IndexOf("}"); + if (end == -1) + return piece; + + string variable = piece.Substring(start + 2, end - start - 2); + string interp = GetVariableFromPkgConfig(variable, Path.GetFileNameWithoutExtension(pcfile)); + return ProcessPiece(piece.Replace("${" + variable + "}", interp), pcfile); + } + + private static string GetVariableFromPkgConfig(string var, string pcfile) + { + ProcessStartInfo psi = new ProcessStartInfo("pkg-config"); + psi.RedirectStandardOutput = true; + psi.UseShellExecute = false; + psi.Arguments = String.Format("--variable={0} {1}", var, pcfile); + Process p = new Process(); + p.StartInfo = psi; + p.Start(); + string 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 + string pname = Path.GetFileNameWithoutExtension(pcfile); + if (packagesHash.ContainsKey(pname)) + return; + + List fullassemblies = null; + string version = ""; + string desc = ""; + + SystemPackage package = new SystemPackage(); + + using (StreamReader reader = new StreamReader(pcfile)) + { + string line; + while ((line = reader.ReadLine()) != null) + { + string lowerLine = line.ToLower(); + if (lowerLine.StartsWith("libs:") && lowerLine.IndexOf(".dll") != -1) + { + string 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 (string assembly in fullassemblies) + { + AddAssembly(assembly, package); + } + + package.Initialize(pname, + version, + desc, + fullassemblies.ToArray(), + ClrVersion.Default, + false); + packages.Add(package); + packagesHash[pname] = package; + } + + void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver) + { + SystemPackage package = new SystemPackage(); + List list = new List(); + + string dir = Path.Combine(prefix, version); + if (!Directory.Exists(dir)) + { + return; + } + + foreach (string 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); + } + + void RunInitialization() + { + string versionDir; + + if (Environment.Version.Major == 1) + { + versionDir = "1.0"; + } + else + { + versionDir = "2.0"; + } + + //Pull up assemblies from the installed mono system. + string 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); + + string search_dirs = Environment.GetEnvironmentVariable("PKG_CONFIG_PATH"); + string libpath = Environment.GetEnvironmentVariable("PKG_CONFIG_LIBPATH"); + + if (String.IsNullOrEmpty(libpath)) + { + string path_dirs = Environment.GetEnvironmentVariable("PATH"); + foreach (string 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)) + { + List scanDirs = new List(); + foreach (string potentialDir in search_dirs.Split(Path.PathSeparator)) + { + if (!scanDirs.Contains(potentialDir)) + scanDirs.Add(potentialDir); + } + foreach (string pcdir in scanDirs) + { + if (pcdir == null) + continue; + + if (Directory.Exists(pcdir)) + { + foreach (string pcfile in Directory.GetFiles(pcdir, "*.pc")) + { + ParsePCFile(pcfile); + } + } + } + } + } + + private void WriteCombine(SolutionNode solution) + { + #region "Create Solution directory if it doesn't exist" + string solutionDir = Path.Combine(solution.FullPath, + Path.Combine("autotools", + solution.Name)); + chkMkDir(solutionDir); + #endregion + + #region "Write Solution-level files" + XsltArgumentList 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 (ProjectNode 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 (ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = + Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if (File.Exists(fullPath)) { + return fullPath; + } + } + + return null; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if (conf == null) + { + throw new ArgumentNullException("conf"); + } + if (project == null) + { + throw new ArgumentNullException("project"); + } + string 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; + } + + /// + /// Normalizes the path. + /// + /// The path. + /// + public static string NormalizePath(string path) + { + if (path == null) + { + return ""; + } + + StringBuilder tmpPath; + + if (Core.Parse.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) + { + string solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name)); + string projectDir = Path.Combine(solutionDir, project.Name); + string projectVersion = project.Version; + bool hasAssemblyConfig = false; + chkMkDir(projectDir); + + List + compiledFiles = new List(), + contentFiles = new List(), + embeddedFiles = new List(), + + binaryLibs = new List(), + pkgLibs = new List(), + systemLibs = new List(), + runtimeLibs = new List(), + + extraDistFiles = new List(), + localCopyTargets = new List(); + + // 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 + string projectAssemblyName = project.Name; + if (project.AssemblyName != null) + projectAssemblyName = project.AssemblyName; + + if (File.Exists(Path.Combine(project.FullPath, projectAssemblyName) + ".dll.config")) + { + hasAssemblyConfig = true; + System.IO.File.Copy(Path.Combine(project.FullPath, projectAssemblyName + ".dll.config"), Path.Combine(projectDir, projectAssemblyName + ".dll.config"), true); + extraDistFiles.Add(project.AssemblyName + ".dll.config"); + } + + foreach (ConfigurationNode 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 + string source = Path.Combine(project.FullPath, conf.Options.KeyFile); + string keyFile = conf.Options.KeyFile; + Regex re = new Regex(".*/"); + keyFile = re.Replace(keyFile, ""); + + string dest = Path.Combine(projectDir, keyFile); + // Tell the user if there's a problem copying the file + try + { + mkdirDashP(System.IO.Path.GetDirectoryName(dest)); + System.IO.File.Copy(source, dest, true); + } + catch (System.IO.IOException e) + { + Console.WriteLine(e.Message); + } + } + } + + // Copy compiled, embedded and content files into the project's directory + foreach (string filename in project.Files) + { + string source = Path.Combine(project.FullPath, filename); + string 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(System.IO.Path.GetDirectoryName(dest)); + System.IO.File.Copy(source, dest, true); + } + catch (System.IO.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 (int refNum = 0; refNum < project.References.Count; refNum++) + { + ReferenceNode refr = project.References[refNum]; + Assembly refAssembly = Assembly.LoadWithPartialName(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 + { + string assemblyFullName = string.Empty; + if (refAssembly != null) + assemblyFullName = refAssembly.FullName; + + string 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); + + string 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 */ + + string filename = refr.Name + ".dll"; + string source = filename; + if (refr.Path != null) + source = Path.Combine(refr.Path, source); + source = Path.Combine(project.FullPath, source); + string 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")) + { + System.IO.File.Copy(source + ".config", Path.GetDirectoryName(dest), true); + extraDistFiles.Add(refr.Name + ".dll.config"); + } + + try + { + System.IO.File.Copy(source, dest, true); + } + catch (System.IO.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 + */ + + ProjectNode sourcePrj = + ((solution.ProjectsTable[refr.Name])); + + string 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 + string assemName = string.Empty; + int 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"; + string compiledFilesString = string.Empty; + if (compiledFiles.Count > 0) + compiledFilesString = + lineSep + string.Join(lineSep, compiledFiles.ToArray()); + + string embeddedFilesString = ""; + if (embeddedFiles.Count > 0) + embeddedFilesString = + lineSep + string.Join(lineSep, embeddedFiles.ToArray()); + + string contentFilesString = ""; + if (contentFiles.Count > 0) + contentFilesString = + lineSep + string.Join(lineSep, contentFiles.ToArray()); + + string extraDistFilesString = ""; + if (extraDistFiles.Count > 0) + extraDistFilesString = + lineSep + string.Join(lineSep, extraDistFiles.ToArray()); + + string pkgLibsString = ""; + if (pkgLibs.Count > 0) + pkgLibsString = + lineSep + string.Join(lineSep, pkgLibs.ToArray()); + + string binaryLibsString = ""; + if (binaryLibs.Count > 0) + binaryLibsString = + lineSep + string.Join(lineSep, binaryLibs.ToArray()); + + string systemLibsString = ""; + if (systemLibs.Count > 0) + systemLibsString = + lineSep + string.Join(lineSep, systemLibs.ToArray()); + + string localCopyTargetsString = ""; + if (localCopyTargets.Count > 0) + localCopyTargetsString = + string.Join("\n", localCopyTargets.ToArray()); + + string monoPath = ""; + foreach (string runtimeLib in runtimeLibs) + { + monoPath += ":`pkg-config --variable=libdir " + runtimeLib + "`"; + } + + // Add the project name to the list of transformation + // parameters + XsltArgumentList 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 == Core.Nodes.ProjectType.Library) + transformToFile(Path.Combine(projectDir, project.Name + ".pc.in"), argList, "/Autotools/ProjectPcIn"); + if (project.Type == Core.Nodes.ProjectType.Exe || project.Type == Core.Nodes.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); + string 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); + + string 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 (ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + 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"; + string fqStreamName = String.Format("Prebuild.data.{0}", + streamName + ); + + // Retrieve stream for the autotools template XML + Stream 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){ + string errStr = + String.Format("Could not find embedded resource file:\n" + + "'{0}' or '{1}'", + streamName, fqStreamName + ); + + m_Kernel.Log.Write(errStr); + + throw new System.Reflection.TargetException(errStr); + } + } + + // Create an XML URL Resolver with default credentials + xr = new System.Xml.XmlUrlResolver(); + xr.Credentials = CredentialCache.DefaultCredentials; + + // Create a default evidence - no need to limit access + e = new System.Security.Policy.Evidence(); + + // 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 + */ + + string pwd = Directory.GetCurrentDirectory(); + //string pwd = System.Environment.GetEnvironmentVariable("PWD"); + //if (pwd.Length != 0) + //{ + string rootDir = Path.Combine(pwd, "autotools"); + //} + //else + //{ + // pwd = Assembly.GetExecutingAssembly() + //} + chkMkDir(rootDir); + + foreach (SolutionNode solution in kern.Solutions) + { + m_Kernel.Log.Write(String.Format("Writing solution: {0}", + solution.Name)); + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach (SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "autotools"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/DebugTarget.cs b/Prebuild/src/Core/Targets/DebugTarget.cs new file mode 100644 index 0000000..650007e --- /dev/null +++ b/Prebuild/src/Core/Targets/DebugTarget.cs @@ -0,0 +1,102 @@ +#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 08:42:51 +0100 (Wed, 20 Sep 2006) $ + * $Revision: 164 $ + */ +#endregion + +using System; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; + +#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 diff --git a/Prebuild/src/Core/Targets/MakefileTarget.cs b/Prebuild/src/Core/Targets/MakefileTarget.cs new file mode 100644 index 0000000..54046dd --- /dev/null +++ b/Prebuild/src/Core/Targets/MakefileTarget.cs @@ -0,0 +1,469 @@ +#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; +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 +{ + [Target("makefile")] + public class MakefileTarget : ITarget + { + #region Fields + + private Kernel m_Kernel = null; + + #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; + SolutionNode 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) + { + int a = res.IndexOf("/../"); + int 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 (string 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 (string file in project.Files) + if (project.Files.GetBuildAction(file) == BuildAction.EmbeddedResource) + { + string 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 (ReferencePathNode refPath in project.ReferencePaths) + { + string 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 (ReferenceNode 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 (string 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"; + } + else if (t == ProjectType.Library) + { + return "dll"; + } + else + { + throw new FatalException("Bad ProjectType: {0}", t); + } + } + + private string ProjectTypeToTarget(ProjectType t) + { + if (t == ProjectType.Exe) + { + return "exe"; + } + else if (t == ProjectType.WinExe) + { + return "winexe"; + } + else if (t == ProjectType.Library) + { + return "library"; + } + else + { + 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 (ConfigurationNode conf1 in project.Configurations) + foreach (ConfigurationNode 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); + + bool clash = ProjectClashes(project); + + foreach (ConfigurationNode conf in project.Configurations) + { + string outpath = ProjectOutput(project, conf); + string 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 (ReferenceNode refr in project.References) + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode refProj = (ProjectNode)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 (ReferenceNode refr in project.References) + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode refProj; + refProj = (ProjectNode)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 (ReferenceNode 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 = (ProjectNode)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 (ConfigurationNode 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 (ConfigurationNode conf in solution.Configurations) + f.Write(" {0}", conf.Name); + f.WriteLine(); + + f.WriteLine("# Projects:"); + foreach (ProjectNode 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) + { + string defconf = ""; + foreach (ConfigurationNode conf in solution.Configurations) + { + defconf = conf.Name; + break; + } + + f.Write(".PHONY: all"); + foreach (ProjectNode proj in solution.Projects) + f.Write(" {0} {0}-clean", proj.Name); + foreach (ConfigurationNode conf in solution.Configurations) + f.Write(" {0} {0}-clean", conf.Name); + foreach (ProjectNode proj in solution.Projects) + foreach (ConfigurationNode 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 (ConfigurationNode conf in solution.Configurations) + f.Write(" {0}-clean", conf.Name); + f.WriteLine(); + f.WriteLine(); + + foreach (ConfigurationNode conf in solution.Configurations) + { + f.Write("{0}: ", conf.Name); + foreach (ProjectNode proj in solution.Projects) + f.Write(" {0}-{1}", proj.Name, conf.Name); + f.WriteLine(); + f.WriteLine(); + + f.Write("{0}-clean: ", conf.Name); + foreach (ProjectNode proj in solution.Projects) + f.Write(" {0}-{1}-clean", proj.Name, conf.Name); + f.WriteLine(); + f.WriteLine(); + } + + foreach (ProjectNode proj in solution.Projects) + { + f.WriteLine("{0}: {0}-{1}", proj.Name, defconf); + f.WriteLine(); + + f.Write("{0}-clean:", proj.Name); + foreach (ConfigurationNode 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(); + + string file = "Makefile";// Helper.MakeFilePath(solution.FullPath, solution.Name, "make"); + StreamWriter f = new StreamWriter(file); + + Helper.SetCurrentDir(Path.GetDirectoryName(file)); + + using (f) + { + WriteIntro(f, solution); + WritePhony(f, solution); + + foreach (ProjectNode 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); + + string 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 (SolutionNode solution in kern.Solutions) + WriteSolution(solution); + m_Kernel = null; + } + + public virtual void Clean(Kernel kern) + { + m_Kernel = kern; + foreach (SolutionNode sol in kern.Solutions) + CleanSolution(sol); + m_Kernel = null; + } + + public string Name + { + get + { + return "makefile"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs new file mode 100644 index 0000000..ea6d2c2 --- /dev/null +++ b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs @@ -0,0 +1,515 @@ +#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 +{ + /// + /// + /// + [Target("monodev")] + public class MonoDevelopTarget : ITarget + { + #region Fields + + private Kernel m_Kernel; + + #endregion + + #region Private Methods + + private static string PrependPath(string path) + { + string tmpPath = Helper.NormalizePath(path, '/'); + Regex regex = new Regex(@"(\w):/(\w+)"); + Match 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) + { + string ret = ""; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if(refr.Path != null || fileRef != null) + { + ret += "Assembly\" refto=\""; + + string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; + + ret += finalPath; + ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; + return ret; + } + + ret += "Gac\""; + ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\""; + 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 + */ + Assembly assem = Assembly.LoadWithPartialName(refr.Name); + ret += assem.FullName; + //ret += refr.Name; + } + catch (System.NullReferenceException e) + { + e.ToString(); + ret += refr.Name; + } + ret += "\" />"; + } + + return ret; + } + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach(ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if(File.Exists(fullPath)) + { + return fullPath; + } + } + + return null; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if( conf == null ) + { + throw new ArgumentNullException("conf"); + } + if( project == null ) + { + throw new ArgumentNullException("project"); + } + string 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) + { + string csComp = "Mcs"; + string netRuntime = "Mono"; + if(project.Runtime == ClrRuntime.Microsoft) + { + csComp = "Csc"; + netRuntime = "MsNet"; + } + + string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); + StreamWriter ss = new StreamWriter(projFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + + using(ss) + { + ss.WriteLine( + "", + project.Name, + project.RootNamespace + ); + + int count = 0; + + ss.WriteLine(" ", solution.ActiveConfig); + + foreach(ConfigurationNode conf in project.Configurations) + { + ss.WriteLine(" ", conf.Name); + ss.Write(" "); + + ss.Write(" "); + + ss.Write(" "); + + ss.Write(" "); + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + + ss.Write(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(string file in project.Files) + { + string buildAction; + string dependson = ""; + string resource_id = ""; + string 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. + string extension = Path.GetExtension(file); + string designer_format = string.Format(".Designer{0}", extension); + + if (file.EndsWith(designer_format)) + { + string basename = file.Substring(0, file.LastIndexOf(designer_format)); + string[] extensions = new string[] { ".cs", ".resx", ".settings" }; + + foreach(string ext in extensions) + { + if (project.Files.Contains(basename + ext)) + { + dependson = string.Format(" dependson=\"{0}{1}\"", basename, ext); + break; + } + } + } + if (extension == ".resx") + { + buildAction = "EmbedAsResource"; + string 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 = string.Format(" copyToOutputDirectory=\"Always\""); + break; + case CopyToOutput.PreserveNewest: + copyToOutput = string.Format(" copyToOutputDirectory=\"PreserveNewest\""); + break; + } + + // Sort of a hack, we try and resolve the path and make it relative, if we can. + string filePath = PrependPath(file); + ss.WriteLine(" ", + filePath, buildAction, dependson, resource_id, copyToOutput); + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ReferenceNode refr in project.References) + { + ss.WriteLine(" {0}", BuildReference(solution, refr)); + } + ss.WriteLine(" "); + + + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteCombine(SolutionNode solution) + { + m_Kernel.Log.Write("Creating MonoDevelop combine and project files"); + foreach(ProjectNode 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(""); + string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); + StreamWriter ss = new StreamWriter(combFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + int count = 0; + + using(ss) + { + ss.WriteLine("", solution.Name); + + count = 0; + foreach(ConfigurationNode conf in solution.Configurations) + { + if(count == 0) + { + ss.WriteLine(" ", conf.Name); + } + + ss.WriteLine(" ", conf.Name); + foreach(ProjectNode project in solution.Projects) + { + ss.WriteLine(" ", project.Name, conf.Name); + } + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + + count = 0; + + foreach(ProjectNode project in solution.Projects) + { + if(count == 0) + ss.WriteLine(" ", project.Name); + + ss.WriteLine(" ", project.Name); + count++; + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.WriteLine(" ", + Helper.MakeFilePath(path, project.Name, "mdp")); + } + ss.WriteLine(" "); + + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string 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); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); + Helper.DeleteIfExists(slnFile); + + foreach(ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode solution in kern.Solutions) + { + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "sharpdev"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs new file mode 100644 index 0000000..d4a33f8 --- /dev/null +++ b/Prebuild/src/Core/Targets/NAntTarget.cs @@ -0,0 +1,792 @@ +#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 +{ + /// + /// + /// + [Target("nant")] + public class NAntTarget : ITarget + { + #region Fields + + private Kernel m_Kernel; + + #endregion + + #region Private Methods + + private static string PrependPath(string path) + { + string tmpPath = Helper.NormalizePath(path, '/'); + Regex regex = new Regex(@"(\w):/(\w+)"); + Match 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)) + { + ProjectNode projectRef = (ProjectNode) solution.ProjectsTable[refr.Name]; + string finalPath = + Helper.NormalizePath(refr.Name + GetProjectExtension(projectRef), '/'); + return finalPath; + } + + ProjectNode project = (ProjectNode) refr.Parent; + + // Do we have an explicit file reference? + string 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; + } + else + { + return refName + ".dll"; + } + } + + private static bool ExtensionSpecified(string refName) + { + return refName.EndsWith(".dll") || refName.EndsWith(".exe"); + } + + private static string GetProjectExtension(ProjectNode project) + { + string extension = ".dll"; + if (project.Type == ProjectType.Exe || project.Type == ProjectType.WinExe) + { + extension = ".exe"; + } + return extension; + } + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach (ReferencePathNode refPath in project.ReferencePaths) + { + string 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; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if (conf == null) + { + throw new ArgumentNullException("conf"); + } + if (project == null) + { + throw new ArgumentNullException("project"); + } + string 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) + { + string projFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build"); + StreamWriter ss = new StreamWriter(projFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + bool hasDoc = false; + + using (ss) + { + ss.WriteLine(""); + ss.WriteLine("", project.Name); + ss.WriteLine(" ", "build"); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + if (refr.LocalCopy) + { + ss.WriteLine(" ", '/')); + } + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + if (project.ConfigFile != null && project.ConfigFile.Length!=0) + { + ss.Write(" "); + } + + // Add the content files to just be copied + ss.WriteLine(" {0}", ""); + ss.WriteLine(" {0}", ""); + + foreach (string 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}", ""); + } + + ss.WriteLine(" {0}", ""); + ss.WriteLine(" {0}", ""); + + ss.Write(" "); + ss.WriteLine(" ", project.RootNamespace); + foreach (string file in project.Files) + { + switch (project.Files.GetBuildAction(file)) + { + case BuildAction.EmbeddedResource: + ss.WriteLine(" {0}", ""); + break; + default: + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ss.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + } + break; + } + } + //if (project.Files.GetSubType(file).ToString() != "Code") + //{ + // ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (string file in project.Files) + { + switch (project.Files.GetBuildAction(file)) + { + case BuildAction.Compile: + ss.WriteLine(" "); + break; + default: + break; + } + } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach(ReferencePathNode refPath in project.ReferencePaths) + { + ss.WriteLine(" "); + } + ss.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/'); + if (refr.Path != null) { + if (ExtensionSpecified(refr.Name)) + { + ss.WriteLine (" "); + } + else + { + ss.WriteLine (" "); + } + } + else + { + ss.WriteLine (" "); + } + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + + foreach (ConfigurationNode conf in project.Configurations) + { + if (!String.IsNullOrEmpty(conf.Options.OutputPath)) + { + string targetDir = Helper.NormalizePath(conf.Options.OutputPath, '/'); + + ss.WriteLine(" "); + + ss.WriteLine(" "); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + break; + } + } + + ss.WriteLine(" "); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + ss.WriteLine(" "); + if (hasDoc) + { + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.Write(" "); + } + else + { + ss.WriteLine(".exe\" />"); + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + // foreach(ReferenceNode refr in project.References) + // { + // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); + // if (path != "") + // { + // ss.WriteLine(" ", path); + // } + // } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + } + ss.WriteLine(" "); + ss.WriteLine(""); + } + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteCombine(SolutionNode solution) + { + m_Kernel.Log.Write("Creating NAnt build files"); + foreach (ProjectNode 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(""); + string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); + StreamWriter ss = new StreamWriter(combFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + using (ss) + { + ss.WriteLine(""); + ss.WriteLine("", solution.Name); + ss.WriteLine(" "); + ss.WriteLine(); + + //ss.WriteLine(" "); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + // Use the active configuration, which is the first configuration name in the prebuild file. + Dictionary emittedConfigurations = new Dictionary(); + + ss.WriteLine(" ", solution.ActiveConfig); + ss.WriteLine(); + + foreach (ConfigurationNode 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(" ", conf.Name, conf.Platform); + ss.WriteLine(" "); + ss.WriteLine(); + } + + // Write out the target for the configuration. + ss.WriteLine(" ", conf.Name, conf.Platform); + ss.WriteLine(" ", conf.Name); + ss.WriteLine(" ", conf.Options["DebugInformation"].ToString().ToLower()); + ss.WriteLine("\t\t ", conf.Platform); + ss.WriteLine(" "); + ss.WriteLine(); + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + 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 + { + Regex re = new Regex(".include$"); + DirectoryInfo nantdir = new DirectoryInfo(".nant"); + foreach (FileSystemInfo item in nantdir.GetFileSystemInfos()) + { + if (item is DirectoryInfo) { } + else if (item is FileInfo) + { + if (re.Match(item.FullName) != + System.Text.RegularExpressions.Match.Empty) + { + Console.WriteLine("Including file: " + item.FullName); + + using (FileStream fs = new FileStream(item.FullName, + FileMode.Open, + FileAccess.Read, + FileShare.None)) + { + using (StreamReader sr = new StreamReader(fs)) + { + ss.WriteLine("", (item).FullName); + while (sr.Peek() != -1) + { + ss.WriteLine(sr.ReadLine()); + } + ss.WriteLine(); + } + } + } + } + } + } + catch { } + // ss.WriteLine(" "); + // ss.WriteLine(" "); + // ss.WriteLine(" ", solution.Name, solution.Version); + // ss.WriteLine(" "); + + // ss.WriteLine(" "); + // // ss.WriteLine(" "); + // ss.WriteLine(" "); + // ss.WriteLine(" "); + // ss.WriteLine(" "); + // ss.WriteLine(" "); + ss.WriteLine(); + + + ss.WriteLine(" "); + ss.WriteLine(" "); + //ss.WriteLine(" "); + + // justincc: FIXME FIXME FIXME - A temporary OpenSim hack to clean up files when "nant clean" is executed. + // Should be replaced with extreme prejudice once anybody finds out if the CleanFiles stuff works or there is + // another working mechanism for specifying this stuff + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + if (solution.Cleanup != null && solution.Cleanup.CleanFiles.Count > 0) + { + foreach (CleanFilesNode cleanFile in solution.Cleanup.CleanFiles) + { + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" ", cleanFile.Pattern); + ss.WriteLine(" ", cleanFile.Pattern); + ss.WriteLine(" "); + ss.WriteLine(" "); + } + } + + ss.WriteLine(" "); + foreach (ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + + foreach (ProjectNode project in solution.ProjectsTableOrder) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(); + ss.WriteLine(" "); + ss.WriteLine(); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string 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); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); + Helper.DeleteIfExists(slnFile); + + foreach (ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach (SolutionNode solution in kern.Solutions) + { + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach (SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "nant"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs new file mode 100644 index 0000000..66dd1bc --- /dev/null +++ b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs @@ -0,0 +1,82 @@ +#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 Prebuild.Core.Attributes; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + [Target("sharpdev2")] + public class SharpDevelop2Target : VS2005Target + { + #region Properties + public override string VersionName + { + get + { + return "SharpDevelop2"; + } + } + #endregion + + #region Public Methods + + /// + /// Writes the specified kern. + /// + /// The kern. + public override void Write(Kernel kern) + { + base.Write(kern); + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public override void Clean(Kernel kern) + { + base.Clean(kern); + } + + /// + /// Gets the name. + /// + /// The name. + public override string Name + { + get + { + return "sharpdev2"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs new file mode 100644 index 0000000..8e32050 --- /dev/null +++ b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs @@ -0,0 +1,425 @@ +#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 +{ + /// + /// + /// + [Target("sharpdev")] + public class SharpDevelopTarget : ITarget + { + #region Fields + + private Kernel m_Kernel; + + #endregion + + #region Private Methods + + private static string PrependPath(string path) + { + string tmpPath = Helper.NormalizePath(path, '/'); + Regex regex = new Regex(@"(\w):/(\w+)"); + Match 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) + { + string ret = ""; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if(refr.Path != null || fileRef != null) + { + ret += "Assembly\" refto=\""; + + string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; + + ret += finalPath; + ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; + return ret; + } + + ret += "Gac\" refto=\""; + try + { + //Assembly assem = Assembly.Load(refr.Name); + ret += refr.Name;// assem.FullName; + } + catch (System.NullReferenceException e) + { + e.ToString(); + ret += refr.Name; + } + ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; + } + + return ret; + } + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach(ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if(File.Exists(fullPath)) + { + return fullPath; + } + } + + return null; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if( conf == null ) + { + throw new ArgumentNullException("conf"); + } + if( project == null ) + { + throw new ArgumentNullException("project"); + } + string 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) + { + string csComp = "Csc"; + string netRuntime = "MsNet"; + if(project.Runtime == ClrRuntime.Mono) + { + csComp = "Mcs"; + netRuntime = "Mono"; + } + + string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx"); + StreamWriter ss = new StreamWriter(projFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + + using(ss) + { + ss.WriteLine( + "", + project.Name, + project.RootNamespace + ); + + ss.WriteLine(" "); + foreach(string file in project.Files) + { + string 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. + string filePath = PrependPath(file); + ss.WriteLine(" ", filePath, buildAction); + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ReferenceNode refr in project.References) + { + ss.WriteLine(" {0}", BuildReference(solution, refr)); + } + ss.WriteLine(" "); + + ss.Write(" "); + + int count = 0; + + ss.WriteLine(" ", solution.ActiveConfig); + + foreach(ConfigurationNode conf in project.Configurations) + { + ss.Write(" "); + ss.Write(" "); + + ss.Write(" "); + + ss.Write(" "); + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteCombine(SolutionNode solution) + { + m_Kernel.Log.Write("Creating SharpDevelop combine and project files"); + foreach(ProjectNode 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(""); + string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx"); + StreamWriter ss = new StreamWriter(combFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + using(ss) + { + ss.WriteLine("", solution.Name); + + int count = 0; + foreach(ProjectNode project in solution.Projects) + { + if(count == 0) + ss.WriteLine(" ", project.Name); + + ss.WriteLine(" ", project.Name); + count++; + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.WriteLine(" ", + Helper.MakeFilePath(path, project.Name, "prjx")); + } + ss.WriteLine(" "); + + count = 0; + foreach(ConfigurationNode conf in solution.Configurations) + { + if(count == 0) + { + ss.WriteLine(" ", conf.Name); + } + + ss.WriteLine(" ", conf.Name); + foreach(ProjectNode project in solution.Projects) + { + ss.WriteLine(" ", project.Name, conf.Name); + } + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string 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); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx"); + Helper.DeleteIfExists(slnFile); + + foreach(ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode solution in kern.Solutions) + { + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "sharpdev"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/ToolInfo.cs b/Prebuild/src/Core/Targets/ToolInfo.cs new file mode 100644 index 0000000..935c674 --- /dev/null +++ b/Prebuild/src/Core/Targets/ToolInfo.cs @@ -0,0 +1,197 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + public struct ToolInfo + { + string name; + string guid; + string fileExtension; + string xmlTag; + string importProject; + + /// + /// Gets or sets the name. + /// + /// The name. + public string Name + { + get + { + return name; + } + set + { + name = value; + } + } + + /// + /// Gets or sets the GUID. + /// + /// The GUID. + public string Guid + { + get + { + return guid; + } + set + { + guid = value; + } + } + + /// + /// Gets or sets the file extension. + /// + /// The file extension. + public string FileExtension + { + get + { + return fileExtension; + } + set + { + fileExtension = value; + } + } + public string LanguageExtension + { + get + { + switch (this.Name) + { + case "C#": + return ".cs"; + case "VisualBasic": + return ".vb"; + case "Boo": + return ".boo"; + default: + return ".cs"; + } + } + } + /// + /// Gets or sets the XML tag. + /// + /// The XML tag. + public string XmlTag + { + get + { + return xmlTag; + } + set + { + xmlTag = value; + } + } + + /// + /// Gets or sets the import project property. + /// + /// The ImportProject tag. + public string ImportProject + { + get + { + return importProject; + } + set + { + importProject = value; + } + } + + /// + /// Initializes a new instance of the class. + /// + /// The name. + /// The GUID. + /// The file extension. + /// The XML. + /// The import project. + public ToolInfo(string name, string guid, string fileExtension, string xml, string importProject) + { + this.name = name; + this.guid = guid; + this.fileExtension = fileExtension; + this.xmlTag = xml; + this.importProject = importProject; + } + + /// + /// Initializes a new instance of the class. + /// + /// The name. + /// The GUID. + /// The file extension. + /// The XML. + public ToolInfo(string name, string guid, string fileExtension, string xml) + { + this.name = name; + this.guid = guid; + this.fileExtension = fileExtension; + this.xmlTag = xml; + this.importProject = "$(MSBuildBinPath)\\Microsoft." + xml + ".Targets"; + } + + /// + /// Equals operator + /// + /// ToolInfo to compare + /// true if toolInfos are equal + public override bool Equals(object obj) + { + if (obj == null) + { + throw new ArgumentNullException("obj"); + } + if (obj.GetType() != typeof(ToolInfo)) + return false; + + ToolInfo c = (ToolInfo)obj; + return ((this.name == c.name) && (this.guid == c.guid) && (this.fileExtension == c.fileExtension) && (this.importProject == c.importProject)); + } + + /// + /// Equals operator + /// + /// ToolInfo to compare + /// ToolInfo to compare + /// True if toolInfos are equal + 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)); + } + + /// + /// Not equals operator + /// + /// ToolInfo to compare + /// ToolInfo to compare + /// True if toolInfos are not equal + public static bool operator !=(ToolInfo c1, ToolInfo c2) + { + return !(c1 == c2); + } + + /// + /// Hash Code + /// + /// Hash code + public override int GetHashCode() + { + return name.GetHashCode() ^ guid.GetHashCode() ^ this.fileExtension.GetHashCode() ^ this.importProject.GetHashCode() ^ this.xmlTag.GetHashCode(); + + } + } +} diff --git a/Prebuild/src/Core/Targets/VS2002Target.cs b/Prebuild/src/Core/Targets/VS2002Target.cs new file mode 100644 index 0000000..2292624 --- /dev/null +++ b/Prebuild/src/Core/Targets/VS2002Target.cs @@ -0,0 +1,87 @@ +#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 Prebuild.Core.Attributes; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + [Target("vs2002")] + public class VS2002Target : VS2003Target + { + #region Private Methods + + private void SetVS2002() + { + this.SolutionVersion = "7.00"; + this.ProductVersion = "7.0.9254"; + this.SchemaVersion = "1.0"; + this.VersionName = "2002"; + this.Version = VSVersion.VS70; + } + + #endregion + + #region Public Methods + + /// + /// Writes the specified kern. + /// + /// The kern. + public override void Write(Kernel kern) + { + SetVS2002(); + base.Write(kern); + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public override void Clean(Kernel kern) + { + SetVS2002(); + base.Clean(kern); + } + + /// + /// Gets the name. + /// + /// The name. + public override string Name + { + get + { + return "vs2002"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/VS2003Target.cs b/Prebuild/src/Core/Targets/VS2003Target.cs new file mode 100644 index 0000000..10e2dc4 --- /dev/null +++ b/Prebuild/src/Core/Targets/VS2003Target.cs @@ -0,0 +1,593 @@ +#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 Fields + + string solutionVersion = "8.00"; + string productVersion = "7.10.3077"; + string schemaVersion = "2.0"; + string versionName = "2003"; + VSVersion version = VSVersion.VS71; + + readonly Dictionary m_Tools = new Dictionary(); + Kernel m_Kernel; + + /// + /// Gets or sets the solution version. + /// + /// The solution version. + protected string SolutionVersion + { + get + { + return solutionVersion; + } + set + { + solutionVersion = value; + } + } + /// + /// Gets or sets the product version. + /// + /// The product version. + protected string ProductVersion + { + get + { + return productVersion; + } + set + { + productVersion = value; + } + } + /// + /// Gets or sets the schema version. + /// + /// The schema version. + protected string SchemaVersion + { + get + { + return schemaVersion; + } + set + { + schemaVersion = value; + } + } + /// + /// Gets or sets the name of the version. + /// + /// The name of the version. + protected string VersionName + { + get + { + return versionName; + } + set + { + versionName = value; + } + } + /// + /// Gets or sets the version. + /// + /// The version. + protected VSVersion Version + { + get + { + return version; + } + set + { + version = value; + } + } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + 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 Private Methods + + private string MakeRefPath(ProjectNode project) + { + string ret = ""; + foreach(ReferencePathNode node in project.ReferencePaths) + { + try + { + string 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); + } + + ToolInfo toolInfo = m_Tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + StreamWriter ps = new StreamWriter(projectFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); + + using(ps) + { + ps.WriteLine(""); + 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"); + ps.WriteLine(" "); + + foreach(ConfigurationNode conf in project.Configurations) + { + ps.WriteLine("\t\t\t\t "); + } + + ps.WriteLine(" "); + + ps.WriteLine(" "); + foreach(ReferenceNode refr in project.References) + { + ps.WriteLine(" "); + } + ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" "); + + ps.WriteLine(" "); + + foreach(string file in project.Files) + { + string fileName = file.Replace(".\\", ""); + ps.WriteLine(" "); + + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ps.WriteLine(" "); + + } + } + ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" ", toolInfo.XmlTag); + ps.WriteLine(""); + } + + ps = new StreamWriter(projectFile + ".user"); + using(ps) + { + ps.WriteLine(""); + ps.WriteLine(" <{0}>", toolInfo.XmlTag); + ps.WriteLine(" "); + + ps.WriteLine(" ", MakeRefPath(project)); + foreach(ConfigurationNode conf in project.Configurations) + { + ps.WriteLine(" "); + } + ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" ", toolInfo.XmlTag); + ps.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + 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(ProjectNode 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(""); + string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + StreamWriter 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(ProjectNode project in solution.Projects) + { + if(!m_Tools.ContainsKey(project.Language)) + { + throw new UnknownLanguageException("Unknown .NET language: " + project.Language); + } + + ToolInfo toolInfo = m_Tools[project.Language]; + + string 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(ConfigurationNode conf in solution.Configurations) + { + ss.WriteLine("\t\t{0} = {0}", conf.Name); + } + ss.WriteLine("\tEndGlobalSection"); + + ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution"); + foreach(ProjectNode project in solution.Projects) + { + for(int i = 0; i < project.References.Count; i++) + { + ReferenceNode refr = project.References[i]; + if(solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode 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(ProjectNode project in solution.Projects) + { + foreach(ConfigurationNode 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(string 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); + + ToolInfo toolInfo = m_Tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + string 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); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); + + Helper.DeleteIfExists(slnFile); + Helper.DeleteIfExists(suoFile); + + foreach(ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public virtual void Write(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in m_Kernel.Solutions) + { + WriteSolution(sol); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in m_Kernel.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public virtual string Name + { + get + { + return "vs2003"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/VS2005Target.cs b/Prebuild/src/Core/Targets/VS2005Target.cs new file mode 100644 index 0000000..9c70e26 --- /dev/null +++ b/Prebuild/src/Core/Targets/VS2005Target.cs @@ -0,0 +1,147 @@ +#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 System; +using System.IO; +using System.Text; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + [Target("vs2005")] + public class VS2005Target : VSGenericTarget + { + #region Inner Classes + + #endregion + + #region Fields + + string solutionVersion = "9.00"; + string productVersion = "8.0.50727"; + string schemaVersion = "2.0"; + string versionName = "Visual C# 2005"; + string name = "vs2005"; + + VSVersion version = VSVersion.VS80; + + public override string SolutionTag + { + get { return "# Visual Studio 2005"; } + } + + protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion) + { + return string.Empty; + } + /// + /// Gets or sets the solution version. + /// + /// The solution version. + public override string SolutionVersion + { + get + { + return solutionVersion; + } + } + /// + /// Gets or sets the product version. + /// + /// The product version. + public override string ProductVersion + { + get + { + return productVersion; + } + } + /// + /// Gets or sets the schema version. + /// + /// The schema version. + public override string SchemaVersion + { + get + { + return schemaVersion; + } + } + /// + /// Gets or sets the name of the version. + /// + /// The name of the version. + public override string VersionName + { + get + { + return versionName; + } + } + /// + /// Gets or sets the version. + /// + /// The version. + public override VSVersion Version + { + get + { + return version; + } + } + /// + /// Gets the name. + /// + /// The name. + public override string Name + { + get + { + return name; + } + } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public VS2005Target() + : base() + { + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/VS2008Target.cs b/Prebuild/src/Core/Targets/VS2008Target.cs new file mode 100644 index 0000000..fee4f7f --- /dev/null +++ b/Prebuild/src/Core/Targets/VS2008Target.cs @@ -0,0 +1,127 @@ +using System; +using System.IO; +using System.Text; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; +using System.CodeDom.Compiler; + +namespace Prebuild.Core.Targets +{ + + /// + /// + /// + [Target("vs2008")] + public class VS2008Target : VSGenericTarget + { + #region Fields + string solutionVersion = "10.00"; + string productVersion = "9.0.21022"; + string schemaVersion = "2.0"; + string versionName = "Visual Studio 2008"; + string name = "vs2008"; + VSVersion version = VSVersion.VS90; + + /// + /// Gets or sets the solution version. + /// + /// The solution version. + public override string SolutionVersion + { + get + { + return solutionVersion; + } + } + /// + /// Gets or sets the product version. + /// + /// The product version. + public override string ProductVersion + { + get + { + return productVersion; + } + } + /// + /// Gets or sets the schema version. + /// + /// The schema version. + public override string SchemaVersion + { + get + { + return schemaVersion; + } + } + /// + /// Gets or sets the name of the version. + /// + /// The name of the version. + public override string VersionName + { + get + { + return versionName; + } + } + /// + /// Gets or sets the version. + /// + /// The version. + public override VSVersion Version + { + get + { + return version; + } + } + /// + /// Gets the name. + /// + /// The name. + public override string Name + { + get + { + return name; + } + } + + 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 + { + get { return "# Visual Studio 2008"; } + } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public VS2008Target() + : base() + { + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/VS2010Target.cs b/Prebuild/src/Core/Targets/VS2010Target.cs new file mode 100644 index 0000000..ea9f736 --- /dev/null +++ b/Prebuild/src/Core/Targets/VS2010Target.cs @@ -0,0 +1,138 @@ +using System; +using System.IO; +using System.Text; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; +using System.CodeDom.Compiler; + +namespace Prebuild.Core.Targets +{ + + /// + /// + /// + [Target("vs2010")] + public class VS2010Target : VSGenericTarget + { + #region Fields + + string solutionVersion = "11.00"; + string productVersion = "9.0.30729"; + string schemaVersion = "2.0"; + string versionName = "Visual Studio 2010"; + string name = "vs2010"; + VSVersion version = VSVersion.VS10; + + #endregion + + #region Properties + + /// + /// Gets or sets the solution version. + /// + /// The solution version. + public override string SolutionVersion + { + get + { + return solutionVersion; + } + } + + /// + /// Gets or sets the product version. + /// + /// The product version. + public override string ProductVersion + { + get + { + return productVersion; + } + } + + /// + /// Gets or sets the schema version. + /// + /// The schema version. + public override string SchemaVersion + { + get + { + return schemaVersion; + } + } + + /// + /// Gets or sets the name of the version. + /// + /// The name of the version. + public override string VersionName + { + get + { + return versionName; + } + } + + /// + /// Gets or sets the version. + /// + /// The version. + public override VSVersion Version + { + get + { + return version; + } + } + + /// + /// Gets the name. + /// + /// The name. + public override string Name + { + get + { + return name; + } + } + + protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion) + { + switch (frameworkVersion) + { + 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 + { + get { return "# Visual Studio 2010"; } + } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public VS2010Target() + : base() + { + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/VSGenericTarget.cs b/Prebuild/src/Core/Targets/VSGenericTarget.cs new file mode 100644 index 0000000..6969dd7 --- /dev/null +++ b/Prebuild/src/Core/Targets/VSGenericTarget.cs @@ -0,0 +1,922 @@ +#region BSD License +/* +Copyright (c) 2008 Matthew Holmes (matthew@wildfiregames.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 + +using System; +using System.Collections.Generic; +using System.IO; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; +using System.CodeDom.Compiler; + +namespace Prebuild.Core.Targets +{ + + /// + /// + /// + public abstract class VSGenericTarget : ITarget + { + #region Fields + + readonly Dictionary tools = new Dictionary(); + Kernel kernel; + #endregion + + #region Properties + /// + /// Gets or sets the solution version. + /// + /// The solution version. + public abstract string SolutionVersion { get; } + /// + /// Gets or sets the product version. + /// + /// The product version. + public abstract string ProductVersion { get; } + /// + /// Gets or sets the schema version. + /// + /// The schema version. + public abstract string SchemaVersion { get; } + /// + /// Gets or sets the name of the version. + /// + /// The name of the version. + public abstract string VersionName { get; } + /// + /// Gets or sets the version. + /// + /// The version. + public abstract VSVersion Version { get; } + /// + /// Gets the name. + /// + /// The name. + public abstract string Name { get; } + + protected abstract string GetToolsVersionXml(FrameworkVersion version); + public abstract string SolutionTag { get; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + protected VSGenericTarget() + { + tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets"); + tools["Database"] = new ToolInfo("Database", "{4F174C21-8C12-11D0-8340-0000F80270F8}", "dbp", "UNKNOWN"); + tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets"); + tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets"); + tools["Folder"] = new ToolInfo("Folder", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", null, null); + } + + #endregion + + #region Private Methods + + private string MakeRefPath(ProjectNode project) + { + string ret = ""; + foreach (ReferencePathNode node in project.ReferencePaths) + { + try + { + string fullPath = Helper.ResolvePath(node.Path); + if (ret.Length < 1) + { + ret = fullPath; + } + else + { + ret += ";" + fullPath; + } + } + catch (ArgumentException) + { + kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); + } + } + + return ret; + } + + private static ProjectNode FindProjectInSolution(string name, SolutionNode solution) + { + SolutionNode node = solution; + + while (node.Parent is SolutionNode) + node = node.Parent as SolutionNode; + + return FindProjectInSolutionRecursively(name, node); + } + + private static ProjectNode FindProjectInSolutionRecursively(string name, SolutionNode solution) + { + if (solution.ProjectsTable.ContainsKey(name)) + return solution.ProjectsTable[name]; + + foreach (SolutionNode child in solution.Solutions) + { + ProjectNode node = FindProjectInSolutionRecursively(name, child); + if (node != null) + return node; + } + + return null; + } + + private void WriteProject(SolutionNode solution, ProjectNode project) + { + if (!tools.ContainsKey(project.Language)) + { + throw new UnknownLanguageException("Unknown .NET language: " + project.Language); + } + + ToolInfo toolInfo = tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + StreamWriter ps = new StreamWriter(projectFile); + + kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); + + #region Project File + using (ps) + { + ps.WriteLine("", GetToolsVersionXml(project.FrameworkVersion)); + ps.WriteLine(" "); + ps.WriteLine(" Local"); + ps.WriteLine(" {0}", ProductVersion); + ps.WriteLine(" {0}", SchemaVersion); + ps.WriteLine(" {{{0}}}", project.Guid.ToString().ToUpper()); + + // Visual Studio has a hard coded guid for the project type + if (project.Type == ProjectType.Web) + ps.WriteLine(" {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}"); + ps.WriteLine(" Debug"); + ps.WriteLine(" {0}", project.AppIcon); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" {0}", project.AssemblyName); + foreach (ConfigurationNode conf in project.Configurations) + { + if (conf.Options.KeyFile != "") + { + ps.WriteLine(" {0}", conf.Options.KeyFile); + ps.WriteLine(" true"); + break; + } + } + ps.WriteLine(" JScript"); + ps.WriteLine(" Grid"); + ps.WriteLine(" IE50"); + ps.WriteLine(" false"); + ps.WriteLine(" {0}", project.FrameworkVersion.ToString().Replace("_", ".")); + + ps.WriteLine(" {0}", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString()); + ps.WriteLine(" {0}", project.DesignerFolder); + ps.WriteLine(" {0}", project.RootNamespace); + ps.WriteLine(" {0}", project.StartupObject); + if (string.IsNullOrEmpty(project.DebugStartParameters)) + { + ps.WriteLine(" {0}", project.DebugStartParameters); + } + ps.WriteLine(" "); + ps.WriteLine(" "); + + ps.WriteLine(" "); + + foreach (ConfigurationNode conf in project.Configurations) + { + ps.Write(" ", conf.Name, conf.Platform); + ps.WriteLine(" {0}", conf.Options["AllowUnsafe"]); + ps.WriteLine(" {0}", conf.Options["BaseAddress"]); + ps.WriteLine(" {0}", conf.Options["CheckUnderflowOverflow"]); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" {0}", conf.Options["CompilerDefines"]); + ps.WriteLine(" {0}", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString())); + ps.WriteLine(" {0}", conf.Options["DebugInformation"]); + ps.WriteLine(" {0}", conf.Options["FileAlignment"]); + ps.WriteLine(" {0}", conf.Options["OptimizeCode"]); + if (project.Type != ProjectType.Web) + ps.WriteLine(" {0}", + Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); + else + ps.WriteLine(" {0}", + Helper.EndPath(Helper.NormalizePath("bin\\"))); + + ps.WriteLine(" {0}", conf.Options["RegisterComInterop"]); + ps.WriteLine(" {0}", conf.Options["RemoveIntegerChecks"]); + ps.WriteLine(" {0}", conf.Options["WarningsAsErrors"]); + ps.WriteLine(" {0}", conf.Options["WarningLevel"]); + ps.WriteLine(" {0}", conf.Options["NoStdLib"]); + ps.WriteLine(" {0}", conf.Options["SuppressWarnings"]); + ps.WriteLine(" {0}", conf.Platform); + ps.WriteLine(" "); + } + + //ps.WriteLine(" "); + + Dictionary projectReferences = new Dictionary(); + List otherReferences = new List(); + + foreach (ReferenceNode refr in project.References) + { + ProjectNode projectNode = FindProjectInSolution(refr.Name, solution); + + if (projectNode == null) + otherReferences.Add(refr); + else + projectReferences.Add(refr, projectNode); + } + // Assembly References + ps.WriteLine(" "); + + foreach (ReferenceNode refr in otherReferences) + { + ps.Write(" "); + ps.Write(" "); + ps.Write(refr.Name); + ps.WriteLine(""); + + if(!String.IsNullOrEmpty(refr.Path)) + { + // Use absolute path to assembly (for determining assembly type) + string absolutePath = Path.Combine(project.FullPath, refr.Path); + if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "exe"))) { + // Assembly is an executable (exe) + ps.WriteLine(" {0}", Helper.MakeFilePath(refr.Path, refr.Name, "exe")); + } else if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "dll"))) { + // Assembly is an library (dll) + ps.WriteLine(" {0}", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); + } else { + string referencePath = Helper.MakeFilePath(refr.Path, refr.Name, "dll"); + kernel.Log.Write(LogType.Warning, "Reference \"{0}\": The specified file doesn't exist.", referencePath); + ps.WriteLine(" {0}", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); + } + } + + ps.WriteLine(" {0}", refr.LocalCopy); + ps.WriteLine(" "); + } + ps.WriteLine(" "); + + //Project References + ps.WriteLine(" "); + foreach (KeyValuePair pair in projectReferences) + { + ToolInfo tool = tools[pair.Value.Language]; + if (tools == null) + throw new UnknownLanguageException(); + + string path = + Helper.MakePathRelativeTo(project.FullPath, + Helper.MakeFilePath(pair.Value.FullPath, pair.Value.Name, tool.FileExtension)); + ps.WriteLine(" ", path); + + // TODO: Allow reference to visual basic projects + ps.WriteLine(" {0}", pair.Value.Name); + ps.WriteLine(" {0}", pair.Value.Guid.ToString("B").ToUpper()); + ps.WriteLine(" {0}", tool.Guid.ToUpper()); + + //This is the Copy Local flag in VS + ps.WriteLine(" {0}", pair.Key.LocalCopy); + + ps.WriteLine(" "); + } + ps.WriteLine(" "); + + // ps.WriteLine(" "); + ps.WriteLine(" "); + + // ps.WriteLine(" "); + List list = new List(); + + foreach (string path in project.Files) + { + string lower = path.ToLower(); + if (lower.EndsWith(".resx")) + { + string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension); + if (!list.Contains(codebehind)) + list.Add(codebehind); + } + + } + + foreach (string filePath in project.Files) + { + // if (file == "Properties\\Bind.Designer.cs") + // { + // Console.WriteLine("Wait a minute!"); + // Console.WriteLine(project.Files.GetSubType(file).ToString()); + // } + SubType subType = project.Files.GetSubType(filePath); + + // Visual Studio chokes on file names if forward slash is used as a path separator + // instead of backslash. So we must make sure that all file paths written to the + // project file use \ as a path separator. + string file = filePath.Replace(@"/", @"\"); + + if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer + && subType != SubType.CodeBehind) + { + ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + ps.WriteLine(" {0}", Path.GetFileName(file)); + ps.WriteLine(" Designer"); + ps.WriteLine(" "); + // + } + + if (subType == SubType.Designer) + { + ps.WriteLine(" ", file); + + string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"; + string dependent_name = filePath.Substring(0, file.LastIndexOf('.')) + ".cs"; + + // Check for a parent .cs file with the same name as this designer file + if (File.Exists(Helper.NormalizePath(dependent_name))) + { + ps.WriteLine(" {0}", Path.GetFileName(dependent_name)); + } + else + { + ps.WriteLine(" ResXFileCodeGenerator"); + ps.WriteLine(" {0}", Path.GetFileName(autogen_name)); + ps.WriteLine(" " + subType + ""); + } + + ps.WriteLine(" "); + if (File.Exists(Helper.NormalizePath(autogen_name))) + { + ps.WriteLine(" ", autogen_name); + //ps.WriteLine(" True"); + + // If a parent .cs file exists, link this autogen file to it. Otherwise link + // to the designer file + if (File.Exists(dependent_name)) + { + ps.WriteLine(" {0}", Path.GetFileName(dependent_name)); + } + else + { + ps.WriteLine(" True"); + ps.WriteLine(" {0}", Path.GetFileName(filePath)); + } + + ps.WriteLine(" "); + } + list.Add(autogen_name); + } + if (subType == SubType.Settings) + { + ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); + ps.WriteLine("Include=\"{0}\">", file); + string fileName = Path.GetFileName(filePath); + if (project.Files.GetBuildAction(filePath) == BuildAction.None) + { + ps.WriteLine(" SettingsSingleFileGenerator"); + ps.WriteLine(" {0}", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); + } + else + { + ps.WriteLine(" Code"); + ps.WriteLine(" True"); + ps.WriteLine(" True"); + string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); + string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); + ps.WriteLine(" {0}", Path.GetFileName(fileNameShorter + ".settings")); + } + ps.WriteLine(" ", project.Files.GetBuildAction(filePath)); + } + else if (subType != SubType.Designer) + { + string path = Helper.NormalizePath(file); + string path_lower = path.ToLower(); + + if (!list.Contains(filePath)) + { + ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); + + int startPos = 0; + if (project.Files.GetPreservePath(filePath)) + { + while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1) + startPos++; + + } + else + { + startPos = file.LastIndexOf(Path.GetFileName(path)); + } + + // be sure to write out the path with backslashes so VS recognizes + // the file properly. + ps.WriteLine("Include=\"{0}\">", file); + + int last_period_index = file.LastIndexOf('.'); + string short_file_name = file.Substring(0, last_period_index); + string extension = Path.GetExtension(path); + // make this upper case, so that when File.Exists tests for the + // existence of a designer file on a case-sensitive platform, + // it is correctly identified. + string designer_format = string.Format(".Designer{0}", extension); + + if (path_lower.EndsWith(designer_format.ToLowerInvariant())) + { + int designer_index = path.IndexOf(designer_format); + string file_name = path.Substring(0, designer_index); + + // There are two corrections to the next lines: + // 1. Fix the connection between a designer file and a form + // or usercontrol that don't have an associated resx file. + // 2. Connect settings files to associated designer files. + if (File.Exists(file_name + extension)) + ps.WriteLine(" {0}", Path.GetFileName(file_name + extension)); + else if (File.Exists(file_name + ".resx")) + ps.WriteLine(" {0}", Path.GetFileName(file_name + ".resx")); + else if (File.Exists(file_name + ".settings")) + { + ps.WriteLine(" {0}", Path.GetFileName(file_name + ".settings")); + ps.WriteLine(" True"); + ps.WriteLine(" True"); + } + } + else if (subType == SubType.CodeBehind) + { + ps.WriteLine(" {0}", Path.GetFileName(short_file_name)); + } + if (project.Files.GetIsLink(filePath)) + { + string alias = project.Files.GetLinkPath(filePath); + alias += file.Substring(startPos); + alias = Helper.NormalizePath(alias); + ps.WriteLine(" {0}", alias); + } + else if (project.Files.GetBuildAction(filePath) != BuildAction.None) + { + if (project.Files.GetBuildAction(filePath) != BuildAction.EmbeddedResource) + { + ps.WriteLine(" {0}", subType); + } + } + + if (project.Files.GetCopyToOutput(filePath) != CopyToOutput.Never) + { + ps.WriteLine(" {0}", project.Files.GetCopyToOutput(filePath)); + } + + ps.WriteLine(" ", project.Files.GetBuildAction(filePath)); + } + } + } + + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(""); + } + #endregion + + #region User File + + ps = new StreamWriter(projectFile + ".user"); + using (ps) + { + // Get the first configuration from the project. + ConfigurationNode firstConfiguration = null; + + if (project.Configurations.Count > 0) + { + firstConfiguration = project.Configurations[0]; + } + + ps.WriteLine(""); + //ps.WriteLine( "" ); + //ps.WriteLine(" <{0}>", toolInfo.XMLTag); + //ps.WriteLine(" "); + ps.WriteLine(" "); + //ps.WriteLine(" ", MakeRefPath(project)); + + if (firstConfiguration != null) + { + ps.WriteLine(" {0}", firstConfiguration.Name); + ps.WriteLine(" {0}", firstConfiguration.Platform); + } + + ps.WriteLine(" {0}", MakeRefPath(project)); + ps.WriteLine(" {0}", ProductVersion); + ps.WriteLine(" ProjectFiles"); + ps.WriteLine(" 0"); + ps.WriteLine(" "); + foreach (ConfigurationNode conf in project.Configurations) + { + ps.Write(" "); + } + ps.WriteLine(""); + } + #endregion + + kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteSolution(SolutionNode solution, bool writeSolutionToDisk) + { + kernel.Log.Write("Creating {0} solution and project files", VersionName); + + foreach (SolutionNode child in solution.Solutions) + { + kernel.Log.Write("...Creating folder: {0}", child.Name); + WriteSolution(child, false); + } + + foreach (ProjectNode project in solution.Projects) + { + kernel.Log.Write("...Creating project: {0}", project.Name); + WriteProject(solution, project); + } + + foreach (DatabaseProjectNode project in solution.DatabaseProjects) + { + kernel.Log.Write("...Creating database project: {0}", project.Name); + WriteDatabaseProject(solution, project); + } + + if (writeSolutionToDisk) // only write main solution + { + kernel.Log.Write(""); + string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + + using (StreamWriter ss = new StreamWriter(solutionFile)) + { + kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); + + ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", SolutionVersion); + ss.WriteLine(SolutionTag); + + WriteProjectDeclarations(ss, solution, solution); + + ss.WriteLine("Global"); + + ss.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution"); + foreach (ConfigurationNode conf in solution.Configurations) + { + ss.WriteLine("\t\t{0} = {0}", conf.NameAndPlatform); + } + ss.WriteLine("\tEndGlobalSection"); + + ss.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution"); + WriteConfigurationLines(solution.Configurations, solution, ss); + ss.WriteLine("\tEndGlobalSection"); + + if (solution.Solutions.Count > 0) + { + ss.WriteLine("\tGlobalSection(NestedProjects) = preSolution"); + foreach (SolutionNode embeddedSolution in solution.Solutions) + { + WriteNestedProjectMap(ss, embeddedSolution); + } + ss.WriteLine("\tEndGlobalSection"); + } + + ss.WriteLine("EndGlobal"); + } + + kernel.CurrentWorkingDirectory.Pop(); + } + } + + private void WriteProjectDeclarations(TextWriter writer, SolutionNode actualSolution, SolutionNode embeddedSolution) + { + foreach (SolutionNode childSolution in embeddedSolution.Solutions) + { + WriteEmbeddedSolution(writer, childSolution); + WriteProjectDeclarations(writer, actualSolution, childSolution); + } + + foreach (ProjectNode project in embeddedSolution.Projects) + { + WriteProject(actualSolution, writer, project); + } + + foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) + { + WriteProject(actualSolution, writer, dbProject); + } + + if (actualSolution.Guid == embeddedSolution.Guid) + { + WriteSolutionFiles(actualSolution, writer); + } + } + + private static void WriteNestedProjectMap(TextWriter writer, SolutionNode embeddedSolution) + { + foreach (ProjectNode project in embeddedSolution.Projects) + { + WriteNestedProject(writer, embeddedSolution, project.Guid); + } + + foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) + { + WriteNestedProject(writer, embeddedSolution, dbProject.Guid); + } + + foreach (SolutionNode child in embeddedSolution.Solutions) + { + WriteNestedProject(writer, embeddedSolution, child.Guid); + WriteNestedProjectMap(writer, child); + } + } + + private static void WriteNestedProject(TextWriter writer, SolutionNode solution, Guid projectGuid) + { + WriteNestedFolder(writer, solution.Guid, projectGuid); + } + + private static void WriteNestedFolder(TextWriter writer, Guid parentGuid, Guid childGuid) + { + writer.WriteLine("\t\t{0} = {1}", + childGuid.ToString("B").ToUpper(), + parentGuid.ToString("B").ToUpper()); + } + + private static void WriteConfigurationLines(IEnumerable configurations, SolutionNode solution, TextWriter ss) + { + foreach (ProjectNode project in solution.Projects) + { + foreach (ConfigurationNode conf in configurations) + { + ss.WriteLine("\t\t{0}.{1}.ActiveCfg = {1}", + project.Guid.ToString("B").ToUpper(), + conf.NameAndPlatform); + + ss.WriteLine("\t\t{0}.{1}.Build.0 = {1}", + project.Guid.ToString("B").ToUpper(), + conf.NameAndPlatform); + } + } + + foreach (SolutionNode child in solution.Solutions) + { + WriteConfigurationLines(configurations, child, ss); + } + } + + private void WriteSolutionFiles(SolutionNode solution, TextWriter ss) + { + if(solution.Files != null && solution.Files.Count > 0) + WriteProject(ss, "Folder", solution.Guid, "Solution Files", "Solution Files", solution.Files); + } + + private void WriteEmbeddedSolution(TextWriter writer, SolutionNode embeddedSolution) + { + WriteProject(writer, "Folder", embeddedSolution.Guid, embeddedSolution.Name, embeddedSolution.Name, embeddedSolution.Files); + } + + private void WriteProject(SolutionNode solution, TextWriter ss, ProjectNode project) + { + WriteProject(ss, solution, project.Language, project.Guid, project.Name, project.FullPath); + } + + private void WriteProject(SolutionNode solution, TextWriter ss, DatabaseProjectNode dbProject) + { + if (solution.Files != null && solution.Files.Count > 0) + WriteProject(ss, solution, "Database", dbProject.Guid, dbProject.Name, dbProject.FullPath); + } + + const string ProjectDeclarationBeginFormat = "Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\""; + const string ProjectDeclarationEndFormat = "EndProject"; + + private void WriteProject(TextWriter ss, SolutionNode solution, string language, Guid guid, string name, string projectFullPath) + { + if (!tools.ContainsKey(language)) + throw new UnknownLanguageException("Unknown .NET language: " + language); + + ToolInfo toolInfo = tools[language]; + + string path = Helper.MakePathRelativeTo(solution.FullPath, projectFullPath); + + path = Helper.MakeFilePath(path, name, toolInfo.FileExtension); + + WriteProject(ss, language, guid, name, path); + } + + private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location) + { + WriteProject(writer, language, projectGuid, name, location, null); + } + + private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location, FilesNode files) + { + if (!tools.ContainsKey(language)) + throw new UnknownLanguageException("Unknown .NET language: " + language); + + ToolInfo toolInfo = tools[language]; + + writer.WriteLine(ProjectDeclarationBeginFormat, + toolInfo.Guid, + name, + location, + projectGuid.ToString("B").ToUpper()); + + if (files != null) + { + writer.WriteLine("\tProjectSection(SolutionItems) = preProject"); + + foreach (string file in files) + writer.WriteLine("\t\t{0} = {0}", file); + + writer.WriteLine("\tEndProjectSection"); + } + + writer.WriteLine(ProjectDeclarationEndFormat); + } + + private void WriteDatabaseProject(SolutionNode solution, DatabaseProjectNode project) + { + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "dbp"); + IndentedTextWriter ps = new IndentedTextWriter(new StreamWriter(projectFile), " "); + + kernel.CurrentWorkingDirectory.Push(); + + Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); + + using (ps) + { + ps.WriteLine("# Microsoft Developer Studio Project File - Database Project"); + ps.WriteLine("Begin DataProject = \"{0}\"", project.Name); + ps.Indent++; + ps.WriteLine("MSDTVersion = \"80\""); + // TODO: Use the project.Files property + if (ContainsSqlFiles(Path.GetDirectoryName(projectFile))) + WriteDatabaseFoldersAndFiles(ps, Path.GetDirectoryName(projectFile)); + + ps.WriteLine("Begin DBRefFolder = \"Database References\""); + ps.Indent++; + foreach (DatabaseReferenceNode reference in project.References) + { + ps.WriteLine("Begin DBRefNode = \"{0}\"", reference.Name); + ps.Indent++; + ps.WriteLine("ConnectStr = \"{0}\"", reference.ConnectionString); + ps.WriteLine("Provider = \"{0}\"", reference.ProviderId.ToString("B").ToUpper()); + //ps.WriteLine("Colorizer = 5"); + ps.Indent--; + ps.WriteLine("End"); + } + ps.Indent--; + ps.WriteLine("End"); + ps.Indent--; + ps.WriteLine("End"); + + ps.Flush(); + } + + kernel.CurrentWorkingDirectory.Pop(); + } + + private static bool ContainsSqlFiles(string folder) + { + if(Directory.GetFiles(folder, "*.sql").Length > 0) + return true; // if the folder contains 1 .sql file, that's good enough + + foreach (string child in Directory.GetDirectories(folder)) + { + if (ContainsSqlFiles(child)) + return true; // if 1 child folder contains a .sql file, still good enough + } + + return false; + } + + private static void WriteDatabaseFoldersAndFiles(IndentedTextWriter writer, string folder) + { + foreach (string child in Directory.GetDirectories(folder)) + { + if (ContainsSqlFiles(child)) + { + writer.WriteLine("Begin Folder = \"{0}\"", Path.GetFileName(child)); + writer.Indent++; + WriteDatabaseFoldersAndFiles(writer, child); + writer.Indent--; + writer.WriteLine("End"); + } + } + foreach (string file in Directory.GetFiles(folder, "*.sql")) + { + writer.WriteLine("Script = \"{0}\"", Path.GetFileName(file)); + } + } + + private void CleanProject(ProjectNode project) + { + kernel.Log.Write("...Cleaning project: {0}", project.Name); + + ToolInfo toolInfo = tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + string userFile = projectFile + ".user"; + + Helper.DeleteIfExists(projectFile); + Helper.DeleteIfExists(userFile); + } + + private void CleanSolution(SolutionNode solution) + { + kernel.Log.Write("Cleaning {0} solution and project files", VersionName, solution.Name); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); + + Helper.DeleteIfExists(slnFile); + Helper.DeleteIfExists(suoFile); + + foreach (ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public virtual void Write(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + kernel = kern; + foreach (SolutionNode sol in kernel.Solutions) + { + WriteSolution(sol, true); + } + kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + kernel = kern; + foreach (SolutionNode sol in kernel.Solutions) + { + CleanSolution(sol); + } + kernel = null; + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/VSVersion.cs b/Prebuild/src/Core/Targets/VSVersion.cs new file mode 100644 index 0000000..699b5ca --- /dev/null +++ b/Prebuild/src/Core/Targets/VSVersion.cs @@ -0,0 +1,54 @@ +#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 +{ + /// + /// + /// + public enum VSVersion + { + /// + /// Visual Studio 2002 + /// + VS70, + /// + /// Visual Studio 2003 + /// + VS71, + /// + /// Visual Studio 2005 + /// + VS80, + /// + /// Visual Studio 2008 + /// + VS90, + /// + /// Visual Studio 2010 + /// + VS10 + } +} diff --git a/Prebuild/src/Core/Targets/XcodeTarget.cs b/Prebuild/src/Core/Targets/XcodeTarget.cs new file mode 100644 index 0000000..5393cec --- /dev/null +++ b/Prebuild/src/Core/Targets/XcodeTarget.cs @@ -0,0 +1,594 @@ +#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 +{ + /// + /// + /// + [Target("xcode")] + public class XcodeTarget : ITarget + { + #region Fields + + private Kernel m_Kernel; + + #endregion + + #region Private Methods + + private static string PrependPath(string path) + { + string tmpPath = Helper.NormalizePath(path, '/'); + Regex regex = new Regex(@"(\w):/(\w+)"); + Match 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) + { + string ret = ""; + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; + string fileRef = FindFileReference(refr.Name, project); + string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/${build.dir}/", refr.Name, "dll"), '/'); + ret += finalPath; + return ret; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if (refr.Path != null || fileRef != null) + { + string 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 (System.NullReferenceException e) + { + e.ToString(); + ret += refr.Name + ".dll"; + } + } + return ret; + } + + private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) + { + string ret = ""; + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; + string fileRef = FindFileReference(refr.Name, project); + string finalPath = Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/'); + ret += finalPath; + return ret; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if (refr.Path != null || fileRef != null) + { + string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; + ret += finalPath; + return ret; + } + + try + { + Assembly assem = Assembly.Load(refr.Name); + if (assem != null) + { + ret += ""; + } + else + { + ret += ""; + } + } + catch (System.NullReferenceException e) + { + e.ToString(); + ret += ""; + } + } + return ret; + } + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach (ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if (File.Exists(fullPath)) + { + return fullPath; + } + } + + return null; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if (conf == null) + { + throw new ArgumentNullException("conf"); + } + if (project == null) + { + throw new ArgumentNullException("project"); + } + string 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) + { + string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); + StreamWriter ss = new StreamWriter(projFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + bool hasDoc = false; + + using (ss) + { + ss.WriteLine(""); + ss.WriteLine("", project.Name); + ss.WriteLine(" ", "build"); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + if (refr.LocalCopy) + { + ss.WriteLine(" ", '/')); + } + } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.Write(" "); + ss.WriteLine(" ", project.RootNamespace); + foreach (string file in project.Files) + { + switch (project.Files.GetBuildAction(file)) + { + case BuildAction.EmbeddedResource: + ss.WriteLine(" {0}", ""); + break; + default: + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ss.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + } + break; + } + } + //if (project.Files.GetSubType(file).ToString() != "Code") + //{ + // ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (string file in project.Files) + { + switch (project.Files.GetBuildAction(file)) + { + case BuildAction.Compile: + ss.WriteLine(" "); + break; + default: + break; + } + } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + ss.WriteLine(" ", '/')); + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + ss.WriteLine(" "); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + ss.WriteLine(" "); + if (hasDoc) + { + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.Write(" "); + } + else + { + ss.WriteLine(".exe\" />"); + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + // foreach(ReferenceNode refr in project.References) + // { + // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); + // if (path != "") + // { + // ss.WriteLine(" ", path); + // } + // } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + } + ss.WriteLine(" "); + ss.WriteLine(""); + } + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteCombine(SolutionNode solution) + { + m_Kernel.Log.Write("Creating Xcode build files"); + foreach (ProjectNode 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(""); + DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj")); + if (!directoryInfo.Exists) + { + directoryInfo.Create(); + } + string combFile = Helper.MakeFilePath(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj"), "project", "pbxproj"); + StreamWriter ss = new StreamWriter(combFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + using (ss) + { + ss.WriteLine(""); + ss.WriteLine("", solution.Name); + ss.WriteLine(" "); + ss.WriteLine(); + + //ss.WriteLine(" "); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + foreach (ConfigurationNode conf in solution.Configurations) + { + // Set the project.config to a non-debug configuration + if (conf.Options["DebugInformation"].ToString().ToLower() != "true") + { + ss.WriteLine(" ", conf.Name); + } + ss.WriteLine(); + ss.WriteLine(" ", conf.Name); + ss.WriteLine(" ", conf.Name); + ss.WriteLine(" ", conf.Options["DebugInformation"].ToString().ToLower()); + ss.WriteLine(" "); + ss.WriteLine(); + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + //foreach(ProjectNode project in solution.Projects) + //{ + // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + // ss.Write(" "); + //} + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + + foreach (ProjectNode project in solution.ProjectsTableOrder) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(); + ss.WriteLine(" "); + ss.WriteLine(); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string 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); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); + Helper.DeleteIfExists(slnFile); + + foreach (ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach (SolutionNode solution in kern.Solutions) + { + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach (SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "xcode"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/UnknownLanguageException.cs b/Prebuild/src/Core/UnknownLanguageException.cs new file mode 100644 index 0000000..607b66c --- /dev/null +++ b/Prebuild/src/Core/UnknownLanguageException.cs @@ -0,0 +1,63 @@ +/* + * $RCSfile$ + * Copyright (C) 2004, 2005 David Hudson (jendave@yahoo.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +using System; +using System.Runtime.Serialization; + +namespace Prebuild.Core +{ + /// + /// + [Serializable()] + public class UnknownLanguageException : Exception + { + /// + /// Basic exception. + /// + public UnknownLanguageException() + { + } + + /// + /// Exception with specified string + /// + /// Exception message + public UnknownLanguageException(string message): base(message) + { + } + + /// + /// + /// + /// + /// + public UnknownLanguageException(string message, Exception exception) : base(message, exception) + { + } + + /// + /// + /// + /// + /// + protected UnknownLanguageException(SerializationInfo info, StreamingContext context) : base( info, context ) + { + } + } +} diff --git a/Prebuild/src/Core/Utilities/.svn/all-wcprops b/Prebuild/src/Core/Utilities/.svn/all-wcprops new file mode 100644 index 0000000..7418c29 --- /dev/null +++ b/Prebuild/src/Core/Utilities/.svn/all-wcprops @@ -0,0 +1,29 @@ +K 25 +svn:wc:ra_dav:version-url +V 60 +/svnroot/dnpb/!svn/ver/309/trunk/Prebuild/src/Core/Utilities +END +Helper.cs +K 25 +svn:wc:ra_dav:version-url +V 70 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Utilities/Helper.cs +END +Log.cs +K 25 +svn:wc:ra_dav:version-url +V 67 +/svnroot/dnpb/!svn/ver/309/trunk/Prebuild/src/Core/Utilities/Log.cs +END +CommandLineCollection.cs +K 25 +svn:wc:ra_dav:version-url +V 85 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Utilities/CommandLineCollection.cs +END +CurrentDirectory.cs +K 25 +svn:wc:ra_dav:version-url +V 80 +/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Utilities/CurrentDirectory.cs +END diff --git a/Prebuild/src/Core/Utilities/.svn/dir-prop-base b/Prebuild/src/Core/Utilities/.svn/dir-prop-base new file mode 100644 index 0000000..a1989a0 --- /dev/null +++ b/Prebuild/src/Core/Utilities/.svn/dir-prop-base @@ -0,0 +1,5 @@ +K 10 +svn:ignore +V 5 +*.swp +END diff --git a/Prebuild/src/Core/Utilities/.svn/entries b/Prebuild/src/Core/Utilities/.svn/entries new file mode 100644 index 0000000..cc148d7 --- /dev/null +++ b/Prebuild/src/Core/Utilities/.svn/entries @@ -0,0 +1,164 @@ +10 + +dir +323 +https://dnpb.svn.sourceforge.net/svnroot/dnpb/trunk/Prebuild/src/Core/Utilities +https://dnpb.svn.sourceforge.net/svnroot/dnpb + + + +2009-04-15T01:40:10.014568Z +309 +kunnis +has-props + + + + + + + + + + + + + +3355ff64-970d-0410-bbe8-d0fbd18be4fb + +Helper.cs +file + + + + +2010-09-10T22:51:44.000000Z +7a0749dec0ce5453fc73dd11f89ce613 +2009-04-15T01:28:16.827957Z +307 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +14966 + +Log.cs +file + + + + +2010-09-10T22:51:44.000000Z +d91804d20a90778d74744cd14bb2fa4c +2009-04-15T01:40:10.014568Z +309 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +6100 + +CommandLineCollection.cs +file + + + + +2010-09-10T22:51:44.000000Z +2a00bed45ea425e5e8a21a5ff6a68d69 +2009-04-15T01:28:16.827957Z +307 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +4032 + +CurrentDirectory.cs +file + + + + +2010-09-10T22:51:44.000000Z +e710723e685cc628a3761209001c8767 +2009-04-15T01:28:16.827957Z +307 +kunnis +has-props + + + + + + + + + + + + + + + + + + + + +2124 + diff --git a/Prebuild/src/Core/Utilities/.svn/prop-base/CommandLineCollection.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/prop-base/CommandLineCollection.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Utilities/.svn/prop-base/CommandLineCollection.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Utilities/.svn/prop-base/CurrentDirectory.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/prop-base/CurrentDirectory.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Utilities/.svn/prop-base/CurrentDirectory.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Utilities/.svn/prop-base/Helper.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/prop-base/Helper.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Utilities/.svn/prop-base/Helper.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Utilities/.svn/prop-base/Log.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/prop-base/Log.cs.svn-base new file mode 100644 index 0000000..7b57b30 --- /dev/null +++ b/Prebuild/src/Core/Utilities/.svn/prop-base/Log.cs.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +Author Date Id Revision +END diff --git a/Prebuild/src/Core/Utilities/.svn/text-base/CommandLineCollection.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/text-base/CommandLineCollection.cs.svn-base new file mode 100644 index 0000000..786fa1e --- /dev/null +++ b/Prebuild/src/Core/Utilities/.svn/text-base/CommandLineCollection.cs.svn-base @@ -0,0 +1,152 @@ +#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.Collections; +using System.Collections.Generic; + +namespace Prebuild.Core.Utilities +{ + /// + /// The CommandLine class parses and interprets the command-line arguments passed to + /// prebuild. + /// + public class CommandLineCollection : IEnumerable> + { + #region Fields + + // The raw OS arguments + private readonly string[] m_RawArgs; + + // Command-line argument storage + private readonly Dictionary m_Arguments = new Dictionary(); + + #endregion + + #region Constructors + + /// + /// Create a new CommandLine instance and set some internal variables. + /// + public CommandLineCollection(string[] args) + { + m_RawArgs = args; + + Parse(); + } + + #endregion + + #region Private Methods + + private void Parse() + { + if(m_RawArgs.Length < 1) + return; + + int idx = 0; + string lastArg = null; + + while(idx 2 && arg[0] == '/') + { + arg = arg.Substring(1); + lastArg = arg; + m_Arguments[arg] = ""; + } + else + { + if(lastArg != null) + { + m_Arguments[lastArg] = arg; + lastArg = null; + } + } + + idx++; + } + } + + #endregion + + #region Public Methods + + /// + /// Wases the passed. + /// + /// The arg. + /// + public bool WasPassed(string arg) + { + return (m_Arguments.ContainsKey(arg)); + } + + #endregion + + #region Properties + + /// + /// Gets the parameter associated with the command line option + /// + /// Returns null if option was not specified, + /// null string if no parameter was specified, and the value if a parameter was specified + public string this[string index] + { + get + { + if(m_Arguments.ContainsKey(index)) + { + return (m_Arguments[index]); + } + return null; + } + } + + #endregion + + #region IEnumerable Members + + /// + /// Returns an enumerator that can iterate through a collection. + /// + /// + /// An + /// that can be used to iterate through the collection. + /// + public IEnumerator> GetEnumerator() + { + return m_Arguments.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Utilities/.svn/text-base/CurrentDirectory.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/text-base/CurrentDirectory.cs.svn-base new file mode 100644 index 0000000..9624c35 --- /dev/null +++ b/Prebuild/src/Core/Utilities/.svn/text-base/CurrentDirectory.cs.svn-base @@ -0,0 +1,68 @@ +#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; + +namespace Prebuild.Core.Utilities +{ + /// + /// + /// + public class CurrentDirectory + { + #region Fields + + private readonly Stack m_Stack = new Stack(); + + #endregion + + #region Public Methods + + /// + /// Pushes this instance. + /// + public void Push() + { + m_Stack.Push(Environment.CurrentDirectory); + } + + /// + /// Pops this instance. + /// + public void Pop() + { + if(m_Stack.Count < 1) + { + return; + } + + string cwd = m_Stack.Pop(); + Helper.SetCurrentDir(cwd); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Utilities/.svn/text-base/Helper.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/text-base/Helper.cs.svn-base new file mode 100644 index 0000000..8c3e968 --- /dev/null +++ b/Prebuild/src/Core/Utilities/.svn/text-base/Helper.cs.svn-base @@ -0,0 +1,575 @@ +#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.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Text.RegularExpressions; +using System.Collections.Specialized; +using System.Xml; +using Prebuild.Core.Nodes; + +namespace Prebuild.Core.Utilities +{ + /// + /// + /// + public class Helper + { + #region Fields + + static bool checkForOSVariables; + + /// + /// + /// + public static bool CheckForOSVariables + { + get + { + return checkForOSVariables; + } + set + { + checkForOSVariables = value; + } + } + + #endregion + + #region Public Methods + + #region String Parsing + + public delegate string StringLookup(string key); + + /// + /// Gets a collection of StringLocationPair objects that represent the matches + /// + /// The target. + /// The before group. + /// The after group. + /// if set to true [include delimiters in substrings]. + /// + public static StringCollection FindGroups(string target, string beforeGroup, string afterGroup, bool includeDelimitersInSubstrings) + { + if( beforeGroup == null ) + { + throw new ArgumentNullException("beforeGroup"); + } + if( afterGroup == null ) + { + throw new ArgumentNullException("afterGroup"); + } + StringCollection results = new StringCollection(); + if(target == null || target.Length == 0) + { + return results; + } + + int beforeMod = 0; + int afterMod = 0; + if(includeDelimitersInSubstrings) + { + //be sure to not exlude the delims + beforeMod = beforeGroup.Length; + afterMod = afterGroup.Length; + } + int startIndex = 0; + while((startIndex = target.IndexOf(beforeGroup,startIndex)) != -1) { + int endIndex = target.IndexOf(afterGroup,startIndex);//the index of the char after it + if(endIndex == -1) + { + break; + } + int length = endIndex - startIndex - beforeGroup.Length;//move to the first char in the string + string substring = substring = target.Substring(startIndex + beforeGroup.Length - beforeMod, + length - afterMod); + + results.Add(substring); + //results.Add(new StringLocationPair(substring,startIndex)); + startIndex = endIndex + 1; + //the Interpolate*() methods will not work if expressions are expandded inside expression due to an optimization + //so start after endIndex + + } + return results; + } + + /// + /// Replaces the groups. + /// + /// The target. + /// The before group. + /// The after group. + /// The lookup. + /// + public static string ReplaceGroups(string target, string beforeGroup, string afterGroup, StringLookup lookup) { + if( target == null ) + { + throw new ArgumentNullException("target"); + } + //int targetLength = target.Length; + StringCollection strings = FindGroups(target,beforeGroup,afterGroup,false); + if( lookup == null ) + { + throw new ArgumentNullException("lookup"); + } + foreach(string substring in strings) + { + target = target.Replace(beforeGroup + substring + afterGroup, lookup(substring) ); + } + return target; + } + + /// + /// Replaces ${var} statements in a string with the corresonding values as detirmined by the lookup delegate + /// + /// The target. + /// The lookup. + /// + public static string InterpolateForVariables(string target, StringLookup lookup) + { + return ReplaceGroups(target, "${" , "}" , lookup); + } + + /// + /// Replaces ${var} statements in a string with the corresonding environment variable with name var + /// + /// + /// + public static string InterpolateForEnvironmentVariables(string target) + { + return InterpolateForVariables(target, new StringLookup(Environment.GetEnvironmentVariable)); + } + + #endregion + + /// + /// Translates the value. + /// + /// Type of the translate. + /// The translation item. + /// + public static object TranslateValue(Type translateType, string translationItem) + { + if(translationItem == null) + { + return null; + } + + try + { + string lowerVal = translationItem.ToLower(); + if(translateType == typeof(bool)) + { + return (lowerVal == "true" || lowerVal == "1" || lowerVal == "y" || lowerVal == "yes" || lowerVal == "on"); + } + else if(translateType == typeof(int)) + { + return (Int32.Parse(translationItem)); + } + else + { + return translationItem; + } + } + catch(FormatException) + { + return null; + } + } + + /// + /// Deletes if exists. + /// + /// The file. + /// + public static bool DeleteIfExists(string file) + { + string resFile = null; + try + { + resFile = ResolvePath(file); + } + catch(ArgumentException) + { + return false; + } + + if(!File.Exists(resFile)) + { + return false; + } + + File.Delete(resFile); + return true; + } + + static readonly char seperator = Path.DirectorySeparatorChar; + + // This little gem was taken from the NeL source, thanks guys! + /// + /// Makes a relative path + /// + /// Path to start from + /// Path to end at + /// Path that will get from startPath to endPath + public static string MakePathRelativeTo(string startPath, string endPath) + { + string tmp = NormalizePath(startPath, seperator); + string src = NormalizePath(endPath, seperator); + string prefix = ""; + + while(true) + { + if((String.Compare(tmp, 0, src, 0, tmp.Length) == 0)) + { + string ret; + int size = tmp.Length; + if(size == src.Length) + { + return "./"; + } + if((src.Length > tmp.Length) && src[tmp.Length - 1] != seperator) + { + } + else + { + ret = prefix + endPath.Substring(size, endPath.Length - size); + ret = ret.Trim(); + if(ret[0] == seperator) + { + ret = "." + ret; + } + + return NormalizePath(ret); + } + + } + + if(tmp.Length < 2) + { + break; + } + + int lastPos = tmp.LastIndexOf(seperator, tmp.Length - 2); + int prevPos = tmp.IndexOf(seperator); + + if((lastPos == prevPos) || (lastPos == -1)) + { + break; + } + + tmp = tmp.Substring(0, lastPos + 1); + prefix += ".." + seperator.ToString(); + } + + return endPath; + } + + /// + /// Resolves the path. + /// + /// The path. + /// + public static string ResolvePath(string path) + { + string tmpPath = NormalizePath(path); + if(tmpPath.Length < 1) + { + tmpPath = "."; + } + + tmpPath = Path.GetFullPath(tmpPath); + if(!File.Exists(tmpPath) && !Directory.Exists(tmpPath)) + { + throw new ArgumentException("Path could not be resolved: " + tmpPath); + } + + return tmpPath; + } + + /// + /// Normalizes the path. + /// + /// The path. + /// The separator character. + /// + public static string NormalizePath(string path, char separatorCharacter) + { + if(path == null || path == "" || path.Length < 1) + { + return ""; + } + + string tmpPath = path.Replace('\\', '/'); + tmpPath = tmpPath.Replace('/', separatorCharacter); + return tmpPath; + } + + /// + /// Normalizes the path. + /// + /// The path. + /// + public static string NormalizePath(string path) + { + return NormalizePath(path, Path.DirectorySeparatorChar); + } + + /// + /// Ends the path. + /// + /// The path. + /// The separator character. + /// + public static string EndPath(string path, char separatorCharacter) + { + if(path == null || path == "" || path.Length < 1) + { + return ""; + } + + if(!path.EndsWith(separatorCharacter.ToString())) + { + return (path + separatorCharacter); + } + + return path; + } + + /// + /// Ends the path. + /// + /// The path. + /// + public static string EndPath(string path) + { + return EndPath(path, Path.DirectorySeparatorChar); + } + + /// + /// Makes the file path. + /// + /// The path. + /// The name. + /// The ext. + /// + public static string MakeFilePath(string path, string name, string ext) + { + string ret = EndPath(NormalizePath(path)); + + if( name == null ) + { + throw new ArgumentNullException("name"); + } + + ret += name; + if(!name.EndsWith("." + ext)) + { + ret += "." + ext; + } + + //foreach(char c in Path.GetInvalidPathChars()) + //{ + // ret = ret.Replace(c, '_'); + //} + + return ret; + } + + /// + /// Makes the file path. + /// + /// The path. + /// The name. + /// + public static string MakeFilePath(string path, string name) + { + string ret = EndPath(NormalizePath(path)); + + if( name == null ) + { + throw new ArgumentNullException("name"); + } + + ret += name; + + //foreach (char c in Path.GetInvalidPathChars()) + //{ + // ret = ret.Replace(c, '_'); + //} + + return ret; + } + + /// + /// + /// + /// + /// + public static string MakeReferencePath(string path) + { + string ret = EndPath(NormalizePath(path)); + + //foreach (char c in Path.GetInvalidPathChars()) + //{ + // ret = ret.Replace(c, '_'); + //} + + return ret; + } + + /// + /// Sets the current dir. + /// + /// The path. + public static void SetCurrentDir(string path) + { + if( path == null ) + { + throw new ArgumentNullException("path"); + } + if(path.Length < 1) + { + return; + } + + Environment.CurrentDirectory = path; + } + + /// + /// Checks the type. + /// + /// The type to check. + /// The attr. + /// The inter. + /// + public static object CheckType(Type typeToCheck, Type attr, Type inter) + { + if(typeToCheck == null || attr == null) + { + return null; + } + + object[] attrs = typeToCheck.GetCustomAttributes(attr, false); + if(attrs == null || attrs.Length < 1) + { + return null; + } + if( inter == null ) + { + throw new ArgumentNullException("inter"); + } + + if(typeToCheck.GetInterface(inter.FullName) == null) + { + return null; + } + + return attrs[0]; + } + + /// + /// Attributes the value. + /// + /// The node. + /// The attr. + /// The def. + /// + public static string AttributeValue(XmlNode node, string attr, string def) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + if(node.Attributes[attr] == null) + { + return def; + } + string val = node.Attributes[attr].Value; + if(!CheckForOSVariables) + { + return val; + } + + return InterpolateForEnvironmentVariables(val); + } + + /// + /// Parses the boolean. + /// + /// The node. + /// The attr. + /// if set to true [default value]. + /// + public static bool ParseBoolean(XmlNode node, string attr, bool defaultValue) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + if(node.Attributes[attr] == null) + { + return defaultValue; + } + return bool.Parse(node.Attributes[attr].Value); + } + + /// + /// Enums the attribute value. + /// + /// The node. + /// The attr. + /// Type of the enum. + /// The def. + /// + public static object EnumAttributeValue(XmlNode node, string attr, Type enumType, object def) + { + if( def == null ) + { + throw new ArgumentNullException("def"); + } + string val = AttributeValue(node, attr, def.ToString()); + return Enum.Parse(enumType, val, true); + } + + /// + /// + /// + /// + /// + /// + public static string AssemblyFullName(string assemblyName, ProjectType projectType) + { + return assemblyName + (projectType == ProjectType.Library ? ".dll" : ".exe"); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Utilities/.svn/text-base/Log.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/text-base/Log.cs.svn-base new file mode 100644 index 0000000..4df3def --- /dev/null +++ b/Prebuild/src/Core/Utilities/.svn/text-base/Log.cs.svn-base @@ -0,0 +1,276 @@ +#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.IO; + +namespace Prebuild.Core.Utilities +{ + /// + /// + /// + public enum LogType + { + /// + /// + /// + None, + /// + /// + /// + Info, + /// + /// + /// + Warning, + /// + /// + /// + Error + } + + /// + /// + /// + [Flags] + public enum LogTargets + { + /// + /// + /// + None = 0, + /// + /// + /// + Null = 1, + /// + /// + /// + File = 2, + /// + /// + /// + Console = 4 + } + + /// + /// Summary description for Log. + /// + public class Log : IDisposable + { + #region Fields + + private TextWriter m_Writer; + private LogTargets m_Target = LogTargets.Null; + bool disposed; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The target. + /// Name of the file. + public Log(LogTargets target, string fileName) + { + m_Target = target; + + if ((m_Target & LogTargets.File) != 0) + { + m_Writer = new StreamWriter(fileName, false); + } + else if ((m_Target & LogTargets.Console) != 0) + { + // Prevents null reference exceptions when outputing to the log file. + // This seems to only happen when running on a network drive. + m_Writer = Console.Out; + } + } + + #endregion + + #region Public Methods + + /// + /// Writes this instance. + /// + public void Write() + { + Write(string.Empty); + } + + /// + /// Writes the specified MSG. + /// + /// The MSG. + public void Write(string msg) + { + if((m_Target & LogTargets.Null) != 0) + { + return; + } + + if((m_Target & LogTargets.Console) != 0) + { + Console.WriteLine(msg); + } + if((m_Target & LogTargets.File) != 0 && m_Writer != null) + { + m_Writer.WriteLine(msg); + } + } + + /// + /// Writes the specified format. + /// + /// The format. + /// The args. + public void Write(string format, params object[] args) + { + Write(string.Format(format,args)); + } + + /// + /// Writes the specified type. + /// + /// The type. + /// The format. + /// The args. + public void Write(LogType type, string format, params object[] args) + { + if((m_Target & LogTargets.Null) != 0) + { + return; + } + + string str = ""; + switch(type) + { + case LogType.Info: + str = "[I] "; + break; + case LogType.Warning: + str = "[!] "; + break; + case LogType.Error: + str = "[X] "; + break; + } + + Write(str + format,args); + } + + /// + /// Writes the exception. + /// + /// The type. + /// The ex. + public void WriteException(LogType type, Exception ex) + { + if(ex != null) + { + Write(type, ex.Message); + //#if DEBUG + m_Writer.WriteLine("Exception @{0} stack trace [[", ex.TargetSite.Name); + m_Writer.WriteLine(ex.StackTrace); + m_Writer.WriteLine("]]"); + //#endif + } + } + + /// + /// Flushes this instance. + /// + public void Flush() + { + if(m_Writer != null) + { + m_Writer.Flush(); + } + } + + #endregion + + #region IDisposable Members + + /// + /// Performs application-defined tasks associated with freeing, releasing, or + /// resetting unmanaged resources. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Dispose objects + /// + /// + /// If true, it will dispose close the handle + /// + /// + /// Will dispose managed and unmanaged resources. + /// + protected virtual void Dispose(bool disposing) + { + if (!this.disposed) + { + if (disposing) + { + if (m_Writer != null) + { + m_Writer.Close(); + m_Writer = null; + } + } + } + this.disposed = true; + } + + /// + /// + /// + ~Log() + { + this.Dispose(false); + } + + /// + /// Closes and destroys this object + /// + /// + /// Same as Dispose(true) + /// + public void Close() + { + Dispose(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Utilities/CommandLineCollection.cs b/Prebuild/src/Core/Utilities/CommandLineCollection.cs new file mode 100644 index 0000000..786fa1e --- /dev/null +++ b/Prebuild/src/Core/Utilities/CommandLineCollection.cs @@ -0,0 +1,152 @@ +#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.Collections; +using System.Collections.Generic; + +namespace Prebuild.Core.Utilities +{ + /// + /// The CommandLine class parses and interprets the command-line arguments passed to + /// prebuild. + /// + public class CommandLineCollection : IEnumerable> + { + #region Fields + + // The raw OS arguments + private readonly string[] m_RawArgs; + + // Command-line argument storage + private readonly Dictionary m_Arguments = new Dictionary(); + + #endregion + + #region Constructors + + /// + /// Create a new CommandLine instance and set some internal variables. + /// + public CommandLineCollection(string[] args) + { + m_RawArgs = args; + + Parse(); + } + + #endregion + + #region Private Methods + + private void Parse() + { + if(m_RawArgs.Length < 1) + return; + + int idx = 0; + string lastArg = null; + + while(idx 2 && arg[0] == '/') + { + arg = arg.Substring(1); + lastArg = arg; + m_Arguments[arg] = ""; + } + else + { + if(lastArg != null) + { + m_Arguments[lastArg] = arg; + lastArg = null; + } + } + + idx++; + } + } + + #endregion + + #region Public Methods + + /// + /// Wases the passed. + /// + /// The arg. + /// + public bool WasPassed(string arg) + { + return (m_Arguments.ContainsKey(arg)); + } + + #endregion + + #region Properties + + /// + /// Gets the parameter associated with the command line option + /// + /// Returns null if option was not specified, + /// null string if no parameter was specified, and the value if a parameter was specified + public string this[string index] + { + get + { + if(m_Arguments.ContainsKey(index)) + { + return (m_Arguments[index]); + } + return null; + } + } + + #endregion + + #region IEnumerable Members + + /// + /// Returns an enumerator that can iterate through a collection. + /// + /// + /// An + /// that can be used to iterate through the collection. + /// + public IEnumerator> GetEnumerator() + { + return m_Arguments.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Utilities/CurrentDirectory.cs b/Prebuild/src/Core/Utilities/CurrentDirectory.cs new file mode 100644 index 0000000..9624c35 --- /dev/null +++ b/Prebuild/src/Core/Utilities/CurrentDirectory.cs @@ -0,0 +1,68 @@ +#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; + +namespace Prebuild.Core.Utilities +{ + /// + /// + /// + public class CurrentDirectory + { + #region Fields + + private readonly Stack m_Stack = new Stack(); + + #endregion + + #region Public Methods + + /// + /// Pushes this instance. + /// + public void Push() + { + m_Stack.Push(Environment.CurrentDirectory); + } + + /// + /// Pops this instance. + /// + public void Pop() + { + if(m_Stack.Count < 1) + { + return; + } + + string cwd = m_Stack.Pop(); + Helper.SetCurrentDir(cwd); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Utilities/Helper.cs b/Prebuild/src/Core/Utilities/Helper.cs new file mode 100644 index 0000000..8c3e968 --- /dev/null +++ b/Prebuild/src/Core/Utilities/Helper.cs @@ -0,0 +1,575 @@ +#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.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Text.RegularExpressions; +using System.Collections.Specialized; +using System.Xml; +using Prebuild.Core.Nodes; + +namespace Prebuild.Core.Utilities +{ + /// + /// + /// + public class Helper + { + #region Fields + + static bool checkForOSVariables; + + /// + /// + /// + public static bool CheckForOSVariables + { + get + { + return checkForOSVariables; + } + set + { + checkForOSVariables = value; + } + } + + #endregion + + #region Public Methods + + #region String Parsing + + public delegate string StringLookup(string key); + + /// + /// Gets a collection of StringLocationPair objects that represent the matches + /// + /// The target. + /// The before group. + /// The after group. + /// if set to true [include delimiters in substrings]. + /// + public static StringCollection FindGroups(string target, string beforeGroup, string afterGroup, bool includeDelimitersInSubstrings) + { + if( beforeGroup == null ) + { + throw new ArgumentNullException("beforeGroup"); + } + if( afterGroup == null ) + { + throw new ArgumentNullException("afterGroup"); + } + StringCollection results = new StringCollection(); + if(target == null || target.Length == 0) + { + return results; + } + + int beforeMod = 0; + int afterMod = 0; + if(includeDelimitersInSubstrings) + { + //be sure to not exlude the delims + beforeMod = beforeGroup.Length; + afterMod = afterGroup.Length; + } + int startIndex = 0; + while((startIndex = target.IndexOf(beforeGroup,startIndex)) != -1) { + int endIndex = target.IndexOf(afterGroup,startIndex);//the index of the char after it + if(endIndex == -1) + { + break; + } + int length = endIndex - startIndex - beforeGroup.Length;//move to the first char in the string + string substring = substring = target.Substring(startIndex + beforeGroup.Length - beforeMod, + length - afterMod); + + results.Add(substring); + //results.Add(new StringLocationPair(substring,startIndex)); + startIndex = endIndex + 1; + //the Interpolate*() methods will not work if expressions are expandded inside expression due to an optimization + //so start after endIndex + + } + return results; + } + + /// + /// Replaces the groups. + /// + /// The target. + /// The before group. + /// The after group. + /// The lookup. + /// + public static string ReplaceGroups(string target, string beforeGroup, string afterGroup, StringLookup lookup) { + if( target == null ) + { + throw new ArgumentNullException("target"); + } + //int targetLength = target.Length; + StringCollection strings = FindGroups(target,beforeGroup,afterGroup,false); + if( lookup == null ) + { + throw new ArgumentNullException("lookup"); + } + foreach(string substring in strings) + { + target = target.Replace(beforeGroup + substring + afterGroup, lookup(substring) ); + } + return target; + } + + /// + /// Replaces ${var} statements in a string with the corresonding values as detirmined by the lookup delegate + /// + /// The target. + /// The lookup. + /// + public static string InterpolateForVariables(string target, StringLookup lookup) + { + return ReplaceGroups(target, "${" , "}" , lookup); + } + + /// + /// Replaces ${var} statements in a string with the corresonding environment variable with name var + /// + /// + /// + public static string InterpolateForEnvironmentVariables(string target) + { + return InterpolateForVariables(target, new StringLookup(Environment.GetEnvironmentVariable)); + } + + #endregion + + /// + /// Translates the value. + /// + /// Type of the translate. + /// The translation item. + /// + public static object TranslateValue(Type translateType, string translationItem) + { + if(translationItem == null) + { + return null; + } + + try + { + string lowerVal = translationItem.ToLower(); + if(translateType == typeof(bool)) + { + return (lowerVal == "true" || lowerVal == "1" || lowerVal == "y" || lowerVal == "yes" || lowerVal == "on"); + } + else if(translateType == typeof(int)) + { + return (Int32.Parse(translationItem)); + } + else + { + return translationItem; + } + } + catch(FormatException) + { + return null; + } + } + + /// + /// Deletes if exists. + /// + /// The file. + /// + public static bool DeleteIfExists(string file) + { + string resFile = null; + try + { + resFile = ResolvePath(file); + } + catch(ArgumentException) + { + return false; + } + + if(!File.Exists(resFile)) + { + return false; + } + + File.Delete(resFile); + return true; + } + + static readonly char seperator = Path.DirectorySeparatorChar; + + // This little gem was taken from the NeL source, thanks guys! + /// + /// Makes a relative path + /// + /// Path to start from + /// Path to end at + /// Path that will get from startPath to endPath + public static string MakePathRelativeTo(string startPath, string endPath) + { + string tmp = NormalizePath(startPath, seperator); + string src = NormalizePath(endPath, seperator); + string prefix = ""; + + while(true) + { + if((String.Compare(tmp, 0, src, 0, tmp.Length) == 0)) + { + string ret; + int size = tmp.Length; + if(size == src.Length) + { + return "./"; + } + if((src.Length > tmp.Length) && src[tmp.Length - 1] != seperator) + { + } + else + { + ret = prefix + endPath.Substring(size, endPath.Length - size); + ret = ret.Trim(); + if(ret[0] == seperator) + { + ret = "." + ret; + } + + return NormalizePath(ret); + } + + } + + if(tmp.Length < 2) + { + break; + } + + int lastPos = tmp.LastIndexOf(seperator, tmp.Length - 2); + int prevPos = tmp.IndexOf(seperator); + + if((lastPos == prevPos) || (lastPos == -1)) + { + break; + } + + tmp = tmp.Substring(0, lastPos + 1); + prefix += ".." + seperator.ToString(); + } + + return endPath; + } + + /// + /// Resolves the path. + /// + /// The path. + /// + public static string ResolvePath(string path) + { + string tmpPath = NormalizePath(path); + if(tmpPath.Length < 1) + { + tmpPath = "."; + } + + tmpPath = Path.GetFullPath(tmpPath); + if(!File.Exists(tmpPath) && !Directory.Exists(tmpPath)) + { + throw new ArgumentException("Path could not be resolved: " + tmpPath); + } + + return tmpPath; + } + + /// + /// Normalizes the path. + /// + /// The path. + /// The separator character. + /// + public static string NormalizePath(string path, char separatorCharacter) + { + if(path == null || path == "" || path.Length < 1) + { + return ""; + } + + string tmpPath = path.Replace('\\', '/'); + tmpPath = tmpPath.Replace('/', separatorCharacter); + return tmpPath; + } + + /// + /// Normalizes the path. + /// + /// The path. + /// + public static string NormalizePath(string path) + { + return NormalizePath(path, Path.DirectorySeparatorChar); + } + + /// + /// Ends the path. + /// + /// The path. + /// The separator character. + /// + public static string EndPath(string path, char separatorCharacter) + { + if(path == null || path == "" || path.Length < 1) + { + return ""; + } + + if(!path.EndsWith(separatorCharacter.ToString())) + { + return (path + separatorCharacter); + } + + return path; + } + + /// + /// Ends the path. + /// + /// The path. + /// + public static string EndPath(string path) + { + return EndPath(path, Path.DirectorySeparatorChar); + } + + /// + /// Makes the file path. + /// + /// The path. + /// The name. + /// The ext. + /// + public static string MakeFilePath(string path, string name, string ext) + { + string ret = EndPath(NormalizePath(path)); + + if( name == null ) + { + throw new ArgumentNullException("name"); + } + + ret += name; + if(!name.EndsWith("." + ext)) + { + ret += "." + ext; + } + + //foreach(char c in Path.GetInvalidPathChars()) + //{ + // ret = ret.Replace(c, '_'); + //} + + return ret; + } + + /// + /// Makes the file path. + /// + /// The path. + /// The name. + /// + public static string MakeFilePath(string path, string name) + { + string ret = EndPath(NormalizePath(path)); + + if( name == null ) + { + throw new ArgumentNullException("name"); + } + + ret += name; + + //foreach (char c in Path.GetInvalidPathChars()) + //{ + // ret = ret.Replace(c, '_'); + //} + + return ret; + } + + /// + /// + /// + /// + /// + public static string MakeReferencePath(string path) + { + string ret = EndPath(NormalizePath(path)); + + //foreach (char c in Path.GetInvalidPathChars()) + //{ + // ret = ret.Replace(c, '_'); + //} + + return ret; + } + + /// + /// Sets the current dir. + /// + /// The path. + public static void SetCurrentDir(string path) + { + if( path == null ) + { + throw new ArgumentNullException("path"); + } + if(path.Length < 1) + { + return; + } + + Environment.CurrentDirectory = path; + } + + /// + /// Checks the type. + /// + /// The type to check. + /// The attr. + /// The inter. + /// + public static object CheckType(Type typeToCheck, Type attr, Type inter) + { + if(typeToCheck == null || attr == null) + { + return null; + } + + object[] attrs = typeToCheck.GetCustomAttributes(attr, false); + if(attrs == null || attrs.Length < 1) + { + return null; + } + if( inter == null ) + { + throw new ArgumentNullException("inter"); + } + + if(typeToCheck.GetInterface(inter.FullName) == null) + { + return null; + } + + return attrs[0]; + } + + /// + /// Attributes the value. + /// + /// The node. + /// The attr. + /// The def. + /// + public static string AttributeValue(XmlNode node, string attr, string def) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + if(node.Attributes[attr] == null) + { + return def; + } + string val = node.Attributes[attr].Value; + if(!CheckForOSVariables) + { + return val; + } + + return InterpolateForEnvironmentVariables(val); + } + + /// + /// Parses the boolean. + /// + /// The node. + /// The attr. + /// if set to true [default value]. + /// + public static bool ParseBoolean(XmlNode node, string attr, bool defaultValue) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + if(node.Attributes[attr] == null) + { + return defaultValue; + } + return bool.Parse(node.Attributes[attr].Value); + } + + /// + /// Enums the attribute value. + /// + /// The node. + /// The attr. + /// Type of the enum. + /// The def. + /// + public static object EnumAttributeValue(XmlNode node, string attr, Type enumType, object def) + { + if( def == null ) + { + throw new ArgumentNullException("def"); + } + string val = AttributeValue(node, attr, def.ToString()); + return Enum.Parse(enumType, val, true); + } + + /// + /// + /// + /// + /// + /// + public static string AssemblyFullName(string assemblyName, ProjectType projectType) + { + return assemblyName + (projectType == ProjectType.Library ? ".dll" : ".exe"); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Utilities/Log.cs b/Prebuild/src/Core/Utilities/Log.cs new file mode 100644 index 0000000..4df3def --- /dev/null +++ b/Prebuild/src/Core/Utilities/Log.cs @@ -0,0 +1,276 @@ +#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.IO; + +namespace Prebuild.Core.Utilities +{ + /// + /// + /// + public enum LogType + { + /// + /// + /// + None, + /// + /// + /// + Info, + /// + /// + /// + Warning, + /// + /// + /// + Error + } + + /// + /// + /// + [Flags] + public enum LogTargets + { + /// + /// + /// + None = 0, + /// + /// + /// + Null = 1, + /// + /// + /// + File = 2, + /// + /// + /// + Console = 4 + } + + /// + /// Summary description for Log. + /// + public class Log : IDisposable + { + #region Fields + + private TextWriter m_Writer; + private LogTargets m_Target = LogTargets.Null; + bool disposed; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The target. + /// Name of the file. + public Log(LogTargets target, string fileName) + { + m_Target = target; + + if ((m_Target & LogTargets.File) != 0) + { + m_Writer = new StreamWriter(fileName, false); + } + else if ((m_Target & LogTargets.Console) != 0) + { + // Prevents null reference exceptions when outputing to the log file. + // This seems to only happen when running on a network drive. + m_Writer = Console.Out; + } + } + + #endregion + + #region Public Methods + + /// + /// Writes this instance. + /// + public void Write() + { + Write(string.Empty); + } + + /// + /// Writes the specified MSG. + /// + /// The MSG. + public void Write(string msg) + { + if((m_Target & LogTargets.Null) != 0) + { + return; + } + + if((m_Target & LogTargets.Console) != 0) + { + Console.WriteLine(msg); + } + if((m_Target & LogTargets.File) != 0 && m_Writer != null) + { + m_Writer.WriteLine(msg); + } + } + + /// + /// Writes the specified format. + /// + /// The format. + /// The args. + public void Write(string format, params object[] args) + { + Write(string.Format(format,args)); + } + + /// + /// Writes the specified type. + /// + /// The type. + /// The format. + /// The args. + public void Write(LogType type, string format, params object[] args) + { + if((m_Target & LogTargets.Null) != 0) + { + return; + } + + string str = ""; + switch(type) + { + case LogType.Info: + str = "[I] "; + break; + case LogType.Warning: + str = "[!] "; + break; + case LogType.Error: + str = "[X] "; + break; + } + + Write(str + format,args); + } + + /// + /// Writes the exception. + /// + /// The type. + /// The ex. + public void WriteException(LogType type, Exception ex) + { + if(ex != null) + { + Write(type, ex.Message); + //#if DEBUG + m_Writer.WriteLine("Exception @{0} stack trace [[", ex.TargetSite.Name); + m_Writer.WriteLine(ex.StackTrace); + m_Writer.WriteLine("]]"); + //#endif + } + } + + /// + /// Flushes this instance. + /// + public void Flush() + { + if(m_Writer != null) + { + m_Writer.Flush(); + } + } + + #endregion + + #region IDisposable Members + + /// + /// Performs application-defined tasks associated with freeing, releasing, or + /// resetting unmanaged resources. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Dispose objects + /// + /// + /// If true, it will dispose close the handle + /// + /// + /// Will dispose managed and unmanaged resources. + /// + protected virtual void Dispose(bool disposing) + { + if (!this.disposed) + { + if (disposing) + { + if (m_Writer != null) + { + m_Writer.Close(); + m_Writer = null; + } + } + } + this.disposed = true; + } + + /// + /// + /// + ~Log() + { + this.Dispose(false); + } + + /// + /// Closes and destroys this object + /// + /// + /// Same as Dispose(true) + /// + public void Close() + { + Dispose(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/WarningException.cs b/Prebuild/src/Core/WarningException.cs new file mode 100644 index 0000000..b7c3668 --- /dev/null +++ b/Prebuild/src/Core/WarningException.cs @@ -0,0 +1,84 @@ +#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.Runtime.Serialization; + +namespace Prebuild.Core +{ + /// + /// + /// + [Serializable] + public class WarningException : Exception + { + #region Constructors + + /// + /// + /// + public WarningException() + { + } + + /// + /// + /// + /// + /// + public WarningException(string format, params object[] args) + : base(String.Format(format, args)) + { + } + + /// + /// Exception with specified string + /// + /// Exception message + public WarningException(string message): base(message) + { + } + + /// + /// + /// + /// + /// + public WarningException(string message, Exception exception) : base(message, exception) + { + } + + /// + /// + /// + /// + /// + protected WarningException(SerializationInfo info, StreamingContext context) : base( info, context ) + { + } + + #endregion + } +} -- cgit v1.1