├── .gitignore ├── .nuget ├── Microsoft.Build.dll ├── NuGet.Config ├── NuGet.Core.dll ├── NuGet.exe └── NuGet.targets ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── Sake.sln ├── Sakefile.shade ├── build ├── build.cmd ├── examples ├── intro1 │ └── makefile.shade ├── intro2 │ └── makefile.shade └── makefile.shade ├── prerelease └── Spark │ └── lib │ ├── Spark.dll │ └── Spark.pdb ├── src ├── AssemblyVersionInfo.cs ├── Sake.Engine.Tests │ ├── DefaultLoaderTests.cs │ ├── Files │ │ ├── AnotherFolder │ │ │ └── FromAnotherFolder.shade │ │ ├── DependenciesShouldBeRegistered.shade │ │ ├── Sakefile.shade │ │ ├── Shared │ │ │ └── _shouldfindpartialinsharedfolder.shade │ │ ├── ShouldAddTargetAsDependencyToNamedTarget.shade │ │ ├── ShouldFindPartialFilesInCurrentDirectoryOrSharedSubdirectory.shade │ │ ├── ShouldFindPartialFilesInSharedFolderUnderEngineAssembly.shade │ │ ├── ShouldLoadFilesFromIncludeDir.shade │ │ ├── SingleFile │ │ │ ├── UseThisOne.shade │ │ │ ├── _not-this-one.shade │ │ │ └── _or-this-one.shade │ │ └── _shouldfindpartialincurrentfolder.shade │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Sake.Engine.Tests.csproj │ ├── SakeEngineOptionsTests.cs │ ├── SakeEngineTests.cs │ ├── Sakefile.shade │ ├── Starter.cs │ ├── different.shade │ └── packages.config ├── Sake.Engine │ ├── Builder │ │ ├── BuilderBase.cs │ │ ├── IBuilder.cs │ │ └── Target.cs │ ├── ISakeSettings.cs │ ├── Loader │ │ ├── DefaultLoader.cs │ │ ├── ExtensionFactory.cs │ │ ├── FunctionsExtension.cs │ │ ├── ILoader.cs │ │ └── TargetExtension.cs │ ├── Logging │ │ ├── DefaultLog.cs │ │ └── ILog.cs │ ├── Options.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Runner │ │ ├── DefaultRunner.cs │ │ └── IRunner.cs │ ├── Sake.Engine.csproj │ ├── SakeEngine.cs │ ├── SakeSettings.cs │ └── packages.config ├── Sake.Library │ ├── Code │ │ ├── MakefileTargetsDataAttribute.cs │ │ ├── MakefileTests.cs │ │ ├── Program.cs │ │ └── RemoveEscapes.cs │ ├── Data │ │ ├── Asseminfo │ │ │ └── versions.txt │ │ └── Files │ │ │ ├── Sub │ │ │ ├── delta.txt │ │ │ └── gamma.txt │ │ │ ├── alpha.txt │ │ │ ├── another.log │ │ │ └── beta.txt │ ├── Init │ │ ├── Init-BuildCmd.txt │ │ ├── Init-BuildSh.txt │ │ ├── Init-SakefileShade.txt │ │ └── Sakefile.shade │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Sake.Library.Tests.csproj │ ├── Shared │ │ ├── Environment.shade │ │ ├── Files.shade │ │ ├── PathResolver.shade │ │ ├── Regex.shade │ │ ├── _assemblyinfo.shade │ │ ├── _build.shade │ │ ├── _copy.shade │ │ ├── _directory.shade │ │ ├── _exec-clr.shade │ │ ├── _exec.shade │ │ ├── _log.shade │ │ ├── _nuget-install.shade │ │ ├── _nuget-pack.shade │ │ ├── _nuget-push.shade │ │ ├── _nunit.shade │ │ ├── _stylecop.shade │ │ ├── _update-file.shade │ │ ├── _use-standard-goals.shade │ │ ├── _use-standard-lifecycle.shade │ │ ├── _use-teamcity.shade │ │ └── _xunit.shade │ ├── app.config │ ├── packages.config │ ├── test-assemblyinfo.shade │ ├── test-copy.shade │ ├── test-directory.shade │ ├── test-files.shade │ └── test-regex.shade └── Sake │ ├── ConsoleWriter.cs │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Sake.csproj │ ├── Sake.nuspec │ ├── app.config │ └── packages.config └── todo.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *.user 2 | *.suo 3 | _ReSharper* 4 | packages 5 | bin 6 | obj 7 | target 8 | *.userprefs 9 | *.pidb 10 | *.log 11 | 12 | -------------------------------------------------------------------------------- /.nuget/Microsoft.Build.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakeproject/sake/b0dddb601967bbfba59e8bc317f4e9d8fb6cfda0/.nuget/Microsoft.Build.dll -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.nuget/NuGet.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakeproject/sake/b0dddb601967bbfba59e8bc317f4e9d8fb6cfda0/.nuget/NuGet.Core.dll -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakeproject/sake/b0dddb601967bbfba59e8bc317f4e9d8fb6cfda0/.nuget/NuGet.exe -------------------------------------------------------------------------------- /.nuget/NuGet.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildProjectDirectory)\..\ 5 | 6 | 7 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) 8 | $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) 9 | $([System.IO.Path]::Combine($(SolutionDir), "packages")) 10 | 11 | 12 | $(SolutionDir).nuget 13 | packages.config 14 | $(SolutionDir)packages 15 | 16 | 17 | $(NuGetToolsPath)\NuGet.exe 18 | "$(NuGetExePath)" 19 | mono --runtime=v4.0.30319 $(NuGetExePath) 20 | 21 | $(TargetDir.Trim('\\')) 22 | 23 | 24 | "" 25 | 26 | 27 | false 28 | 29 | 30 | false 31 | 32 | 33 | $(NuGetCommand) install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)" 34 | $(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols 35 | 36 | 37 | 38 | RestorePackages; 39 | $(BuildDependsOn); 40 | 41 | 42 | 43 | 44 | $(BuildDependsOn); 45 | BuildPackage; 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 57 | 58 | 61 | 62 | 63 | 64 | 66 | 67 | 70 | 71 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Sake build system 2 | Copyright 2012 Louis DeJardin and Contributors 3 | 4 | I. Included Third-Party Software 5 | 6 | This product includes software developed at 7 | Spark View Engine 8 | (http://sparkviewengine.com). 9 | Copyright 2008-2012 Louis DeJardin and Contributors 10 | Licensed under Apache License 2.0 11 | 12 | This product includes software developed at 13 | NDesk 14 | (http://ndesk.org). 15 | Copyright 2008 Novell 16 | Licensed under The MIT License 17 | 18 | This product includes software developed at 19 | Autofac project 20 | (http://code.google.com/p/autofac/). 21 | Copyright 2011 Autofac Contributors 22 | Licensed under The MIT License 23 | 24 | II. Used Third-Party Software 25 | 26 | This product uses software developed at 27 | ASP.NET Open Source Gallery at Outercurve Foundation 28 | (http://nuget.codeplex.com/) 29 | Copyright 2010-2012 Outercurve Foundation 30 | Licensed under Apache License 2.0 31 | 32 | This product uses software developed at 33 | Microsoft 34 | (http://xunit.codeplex.com/) 35 | Copyright 2007-2012 Microsoft 36 | Licensed under Microsoft Public License (Ms-PL) 37 | 38 | This product uses software developed at 39 | Shouldly project 40 | (http://shouldly.github.com/) 41 | Copyright 2010 Shouldy 42 | Licensed under The BSD License 43 | 44 | III. Overall License Summary 45 | 46 | Redistribution 47 | - Apache License 2.0 48 | - The MIT License 49 | 50 | Uses 51 | - Apache License 2.0 52 | - Microsoft Public License (Ms-PL) 53 | - The BSD License 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # CS Make - Sake 3 | 4 | Welcome to Sake, a C# language enabled make system. 5 | 6 | ## Getting Sake from source and building 7 | 8 | This also a way you can see Sake in action - it downloads itself from the Nuget gallery to build. 9 | 10 | git clone https://github.com/loudej/sake.git && cd sake && build 11 | 12 | Or to build on Mac or Linux 13 | 14 | git clone https://github.com/loudej/sake.git && cd sake && ./build 15 | 16 | 17 | ## Getting Sake on your machine 18 | ### Via Chocolatey 19 | 20 | This is a convenient if you want to run `sake` in any directory from a command line. 21 | 22 | cinst sake -pre 23 | 24 | First, you'll need to get chocolatey if you don't already have it. From a Package Manager Console 25 | 26 | Install-Package chocolatey 27 | Initialize-Chocolatey 28 | Uninstall-Package chocolatey 29 | 30 | Or there are other ways of getting chocolatey, see https://github.com/chocolatey/chocolatey/wiki/Installation 31 | 32 | 33 | ## Getting Sake in your project's build 34 | ### Via build.cmd bootstrapper 35 | 36 | This is another nice technique if you want to use Sake in your project and don't to need people to install anything machine-wide. What you do is use Nuget.exe to download SAKE from the gallery in a pre-build step. This takes three files, `package.config`, `build.cmd`, and `makefile.shade`. 37 | 38 | #### package.config 39 | 40 | 41 | 42 | 43 | 44 | #### build.cmd 45 | @echo off 46 | ".nuget\NuGet.exe" install -OutputDirectory packages .\packages.config 47 | "packages\Sake.0.1.0-alpha\tools\sake.exe" %* 48 | 49 | #### makefile.shade 50 | #default 51 | log info="Hello world!" 52 | 53 | -------------------------------------------------------------------------------- /Sake.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sake", "src\Sake\Sake.csproj", "{9AC10F39-DE9E-46F3-926A-5A158AD322E5}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sake.Engine", "src\Sake.Engine\Sake.Engine.csproj", "{0296FE05-EFEA-4ED2-8B82-62B7795CF309}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sake.Engine.Tests", "src\Sake.Engine.Tests\Sake.Engine.Tests.csproj", "{610D7F7C-EA12-4B1E-8B08-429F838F40E9}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Welcome", ".Welcome", "{7452152B-F437-4719-8C73-9A098C5F4113}" 11 | ProjectSection(SolutionItems) = preProject 12 | todo.txt = todo.txt 13 | EndProjectSection 14 | EndProject 15 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{890674E8-6A33-4781-9978-4F616FE41C02}" 16 | ProjectSection(SolutionItems) = preProject 17 | .nuget\NuGet.exe = .nuget\NuGet.exe 18 | .nuget\NuGet.targets = .nuget\NuGet.targets 19 | EndProjectSection 20 | EndProject 21 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{B84E4C5F-147B-488D-8D69-80EBDB405A79}" 22 | ProjectSection(SolutionItems) = preProject 23 | build.cmd = build.cmd 24 | build = build 25 | Sakefile.shade = Sakefile.shade 26 | EndProjectSection 27 | EndProject 28 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sake.Library.Tests", "src\Sake.Library\Sake.Library.Tests.csproj", "{2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}" 29 | EndProject 30 | Global 31 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 32 | Debug|Any CPU = Debug|Any CPU 33 | Debug|Mixed Platforms = Debug|Mixed Platforms 34 | Debug|x86 = Debug|x86 35 | Release|Any CPU = Release|Any CPU 36 | Release|Mixed Platforms = Release|Mixed Platforms 37 | Release|x86 = Release|x86 38 | Retail|Any CPU = Retail|Any CPU 39 | Retail|Mixed Platforms = Retail|Mixed Platforms 40 | Retail|x86 = Retail|x86 41 | EndGlobalSection 42 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 43 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Debug|Any CPU.ActiveCfg = Debug|x86 44 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 45 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Debug|Mixed Platforms.Build.0 = Debug|x86 46 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Debug|x86.ActiveCfg = Debug|x86 47 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Debug|x86.Build.0 = Debug|x86 48 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Release|Any CPU.ActiveCfg = Release|x86 49 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Release|Mixed Platforms.ActiveCfg = Release|x86 50 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Release|Mixed Platforms.Build.0 = Release|x86 51 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Release|x86.ActiveCfg = Release|x86 52 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Release|x86.Build.0 = Release|x86 53 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Retail|Any CPU.ActiveCfg = Release|x86 54 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Retail|Mixed Platforms.ActiveCfg = Release|x86 55 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Retail|Mixed Platforms.Build.0 = Release|x86 56 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Retail|x86.ActiveCfg = Release|x86 57 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5}.Retail|x86.Build.0 = Release|x86 58 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 59 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Debug|Any CPU.Build.0 = Debug|Any CPU 60 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 61 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 62 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Debug|x86.ActiveCfg = Debug|Any CPU 63 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Release|Any CPU.ActiveCfg = Release|Any CPU 64 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Release|Any CPU.Build.0 = Release|Any CPU 65 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 66 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Release|Mixed Platforms.Build.0 = Release|Any CPU 67 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Release|x86.ActiveCfg = Release|Any CPU 68 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Retail|Any CPU.ActiveCfg = Release|Any CPU 69 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Retail|Any CPU.Build.0 = Release|Any CPU 70 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Retail|Mixed Platforms.ActiveCfg = Release|Any CPU 71 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Retail|Mixed Platforms.Build.0 = Release|Any CPU 72 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309}.Retail|x86.ActiveCfg = Release|Any CPU 73 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 74 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Debug|Any CPU.Build.0 = Debug|Any CPU 75 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 76 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 77 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Debug|x86.ActiveCfg = Debug|Any CPU 78 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Release|Any CPU.ActiveCfg = Release|Any CPU 79 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Release|Any CPU.Build.0 = Release|Any CPU 80 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 81 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Release|Mixed Platforms.Build.0 = Release|Any CPU 82 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Release|x86.ActiveCfg = Release|Any CPU 83 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Retail|Any CPU.ActiveCfg = Release|Any CPU 84 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Retail|Any CPU.Build.0 = Release|Any CPU 85 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Retail|Mixed Platforms.ActiveCfg = Release|Any CPU 86 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Retail|Mixed Platforms.Build.0 = Release|Any CPU 87 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9}.Retail|x86.ActiveCfg = Release|Any CPU 88 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Debug|Any CPU.ActiveCfg = Debug|x86 89 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 90 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Debug|Mixed Platforms.Build.0 = Debug|x86 91 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Debug|x86.ActiveCfg = Debug|x86 92 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Debug|x86.Build.0 = Debug|x86 93 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Release|Any CPU.ActiveCfg = Release|x86 94 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Release|Mixed Platforms.ActiveCfg = Release|x86 95 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Release|Mixed Platforms.Build.0 = Release|x86 96 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Release|x86.ActiveCfg = Release|x86 97 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Release|x86.Build.0 = Release|x86 98 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Retail|Any CPU.ActiveCfg = Release|x86 99 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Retail|Mixed Platforms.ActiveCfg = Release|x86 100 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Retail|Mixed Platforms.Build.0 = Release|x86 101 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Retail|x86.ActiveCfg = Release|x86 102 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB}.Retail|x86.Build.0 = Release|x86 103 | EndGlobalSection 104 | GlobalSection(SolutionProperties) = preSolution 105 | HideSolutionNode = FALSE 106 | EndGlobalSection 107 | GlobalSection(NestedProjects) = preSolution 108 | {890674E8-6A33-4781-9978-4F616FE41C02} = {7452152B-F437-4719-8C73-9A098C5F4113} 109 | {B84E4C5F-147B-488D-8D69-80EBDB405A79} = {7452152B-F437-4719-8C73-9A098C5F4113} 110 | EndGlobalSection 111 | GlobalSection(MonoDevelopProperties) = preSolution 112 | StartupItem = src\Sake.Library\Sake.Library.csproj 113 | EndGlobalSection 114 | EndGlobal 115 | -------------------------------------------------------------------------------- /Sakefile.shade: -------------------------------------------------------------------------------- 1 | 2 | var VERSION='0.2.0' 3 | var FULL_VERSION='${VERSION}' 4 | var AUTHORS='Sake contributors' 5 | 6 | var BASE_DIR='${Directory.GetCurrentDirectory()}' 7 | var TARGET_DIR='${Path.Combine(BASE_DIR, "target")}' 8 | var BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}' 9 | var TEST_DIR='${Path.Combine(TARGET_DIR, "test")}' 10 | 11 | use-standard-lifecycle 12 | use-standard-goals features='xunit,nuget' 13 | 14 | 15 | #add-files-for-packaging target='package-prepare' 16 | copy sourceDir='src/Sake.Library/Init' outputDir='${BUILD_DIR}/Sake' overwrite='${true}' 17 | copy sourceDir='src/Sake.Library/Shared' outputDir='${BUILD_DIR}/Sake/Shared' overwrite='${true}' 18 | 19 | -------------------------------------------------------------------------------- /build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export EnableNuGetPackageRestore=true 4 | mono --runtime=v4.0 "./.nuget/NuGet.exe" install Sake -pre -o packages 5 | mono $(find packages/Sake.*/tools/Sake.exe|sort -r|head -n1) -I "src/Sake.Library/Shared" "$@" 6 | 7 | -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd %~dp0 3 | 4 | setlocal 5 | set EnableNuGetPackageRestore=true 6 | set Configuration=Release 7 | 8 | msbuild /fl /v:Q Sake.sln 9 | 10 | src\Sake\bin\%Configuration%\sake.exe -I src\Sake.Library\Shared %* 11 | set __sake__= 12 | 13 | -------------------------------------------------------------------------------- /examples/intro1/makefile.shade: -------------------------------------------------------------------------------- 1 | 2 | use namespace="System" 3 | use namespace="System.IO" 4 | 5 | @{ 6 | var baseDir = Directory.GetCurrentDirectory(); 7 | var targetDir = Path.Combine(baseDir, "target"); 8 | 9 | var aboutText = @" 10 | This example is mostly showing how you can create a build 11 | file that is almost entirely C# code 12 | "; 13 | 14 | } 15 | 16 | 17 | #default description="First target, which is called when no targets are provided" 18 | @{ 19 | Log.Info("No target specified - calling 'test'"); 20 | CallTarget("test"); 21 | 22 | Log.Info("For more information, run `sake about`"); 23 | } 24 | 25 | 26 | #clean description="Wipe out the ./target subfolder" 27 | @{ 28 | Log.Info("cleaning"); 29 | if (Directory.Exists(targetDir)) 30 | { 31 | Log.Info("Deleting - " + targetDir); 32 | Directory.Delete(targetDir, true); 33 | } 34 | } 35 | 36 | 37 | #build .clean description="Add some files to the ./target subfolder" 38 | @{ 39 | Log.Info("building"); 40 | if (!Directory.Exists(targetDir)) 41 | { 42 | Directory.CreateDirectory(targetDir); 43 | } 44 | for (var index = 0; index != 10; ++index) 45 | { 46 | var fileName = Path.Combine(targetDir, "file_" + index + ".txt"); 47 | Log.Info("Writing - " + fileName); 48 | File.WriteAllText(fileName, "This is file " + index); 49 | } 50 | } 51 | 52 | 53 | #test .build description="Test that files exist in ./target subfolder :)" 54 | @{ 55 | Log.Info("testing"); 56 | var files = Directory.GetFiles(targetDir); 57 | if (files.Length != 10) 58 | { 59 | throw new Exception("Expected 10 files"); 60 | } 61 | } 62 | 63 | 64 | #about description="Provides info about this sample" 65 | @{ 66 | Log.Info(aboutText); 67 | Log.Info("It has the following targets:"); 68 | foreach(var target in Targets.Values) 69 | { 70 | Log.Info(string.Format("{0} - {1}", target.Name, target.Description)); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /examples/intro2/makefile.shade: -------------------------------------------------------------------------------- 1 | 2 | use namespace="System" 3 | use namespace="System.IO" 4 | use namespace="System.Linq" 5 | 6 | var baseDir='${Directory.GetCurrentDirectory()}' 7 | var targetDir='${Path.Combine(baseDir, "target")}' 8 | 9 | var aboutText=' 10 | This example is the same as intro1/makefile.shade but uses 11 | element tags more often than c# code 12 | ' 13 | 14 | 15 | #default description="First target, which is called when no targets are provided" 16 | log info="No target specified - calling 'test'" 17 | -CallTarget("test"); 18 | log info="For more information, run `sake about`" 19 | 20 | 21 | #clean description="Wipe out the ./target subfolder" 22 | log info="cleaning" 23 | test if="Directory.Exists(targetDir)" 24 | log info='Deleting - " + targetDir' 25 | -Directory.Delete(targetDir, true); 26 | 27 | 28 | #build .clean description="Add some files to the ./target subfolder" 29 | log info="building" 30 | test if="!Directory.Exists(targetDir)" 31 | -Directory.CreateDirectory(targetDir); 32 | 33 | for each="var index in Enumerable.Range(0, 10)" 34 | var fileName='${Path.Combine(targetDir, "file_" + index + ".txt")}' 35 | log info="Writing - ${fileName}" 36 | -File.WriteAllText(fileName, "This is file " + index); 37 | 38 | 39 | #test .build description="Test that files exist in ./target subfolder :)" 40 | log info="testing" 41 | var files="${Directory.GetFiles(targetDir)}" 42 | test if='(files.Length != 10)' 43 | -throw new Exception("Expected 10 files"); 44 | 45 | 46 | #about description="Provides info about this sample" 47 | log info='${aboutText}' 48 | log info='It has the following targets:' 49 | log info='${target.Name} - ${target.Description}' each='var target in Targets.Values' 50 | -------------------------------------------------------------------------------- /examples/makefile.shade: -------------------------------------------------------------------------------- 1 | 2 | use namespace='System' 3 | use namespace='System.IO' 4 | 5 | 6 | #default 7 | log info='This is the examples directory' 8 | log info='Run `sake about` to see description of all samples' 9 | log info='Run `sake all` to run the default target in each subfolder' 10 | 11 | 12 | #about 13 | log info='Showing information about every example folder' 14 | for each='var folder in Directory.GetDirectories(Directory.GetCurrentDirectory())' 15 | log info='-' 16 | log info='=== ${Path.GetFileName(folder)} ===' 17 | log info='-' 18 | exec program='sake' workingdir='${folder}' commandline='about' 19 | 20 | 21 | #all 22 | log info='Running the default target in each subfolder' 23 | for each='var folder in Directory.GetDirectories(Directory.GetCurrentDirectory())' 24 | log info='-' 25 | log info='=== ${Path.GetFileName(folder)} ===' 26 | log info='-' 27 | exec program='sake' workingdir='${folder}' 28 | 29 | -------------------------------------------------------------------------------- /prerelease/Spark/lib/Spark.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakeproject/sake/b0dddb601967bbfba59e8bc317f4e9d8fb6cfda0/prerelease/Spark/lib/Spark.dll -------------------------------------------------------------------------------- /prerelease/Spark/lib/Spark.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakeproject/sake/b0dddb601967bbfba59e8bc317f4e9d8fb6cfda0/prerelease/Spark/lib/Spark.pdb -------------------------------------------------------------------------------- /src/AssemblyVersionInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyVersion("0.1.0")] 4 | [assembly: AssemblyFileVersion("0.1.0")] 5 | [assembly: AssemblyInformationalVersion("0.2.0")] 6 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/DefaultLoaderTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using Sake.Engine.Loader; 4 | using Sake.Engine.Logging; 5 | using Shouldly; 6 | using Xunit; 7 | 8 | namespace Sake.Engine.Tests.Loader 9 | { 10 | public class DefaultLoaderTests 11 | { 12 | private readonly DefaultLoader _loader; 13 | private SakeSettings _settings; 14 | 15 | public DefaultLoaderTests() 16 | { 17 | _settings = new SakeSettings { Output = new StringWriter() }; 18 | _loader = new DefaultLoader(new DefaultLog(_settings), _settings); 19 | } 20 | 21 | [Fact] 22 | public void ShouldLoadSparkMakefiles() 23 | { 24 | var options = new Options 25 | { 26 | Makefile = Path.Combine("Files", "Sakefile.shade") 27 | }; 28 | var builder = _loader.Load(options); 29 | builder.ShouldNotBe(null); 30 | } 31 | 32 | [Fact] 33 | public void ShouldFailIfFileNotFound() 34 | { 35 | var options = new Options 36 | { 37 | Makefile = Path.Combine("Files", "no-such-file.shade") 38 | }; 39 | Should.Throw(() => _loader.Load(options)); 40 | } 41 | 42 | [Fact] 43 | public void DependenciesShouldBeRegistered() 44 | { 45 | var options = new Options 46 | { 47 | Makefile = Path.Combine("Files", "DependenciesShouldBeRegistered.shade") 48 | }; 49 | 50 | var builder = _loader.Load(options); 51 | builder.Targets.Count.ShouldBe(2); 52 | 53 | builder.Targets["default"].Description.ShouldBe("Default dependency"); 54 | builder.Targets["default"].Dependencies.ShouldBe(new[] { "another" }); 55 | 56 | builder.Targets["another"].Description.ShouldBe("Another dependency"); 57 | builder.Targets["another"].Dependencies.Count.ShouldBe(0); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Files/AnotherFolder/FromAnotherFolder.shade: -------------------------------------------------------------------------------- 1 |  2 | #from-another-folder 3 | ='WasFoundInAnotherFolder' 4 | 5 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Files/DependenciesShouldBeRegistered.shade: -------------------------------------------------------------------------------- 1 |  2 | 3 | @{ 4 | RegisterTarget("default", "another", "Default dependency", () => 5 | { 6 | Echo("This is default"); 7 | }); 8 | } 9 | 10 | #another description="Another dependency" 11 | ="This is another" 12 | 13 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Files/Sakefile.shade: -------------------------------------------------------------------------------- 1 |  2 | #Default .Another 3 | ="ExecDefault" 4 | ="This is Files\\makefile.shade" 5 | 6 | #Another 7 | ="ExecAnother" 8 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Files/Shared/_shouldfindpartialinsharedfolder.shade: -------------------------------------------------------------------------------- 1 |  2 | ='WasFoundInSharedFolder' 3 | 4 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Files/ShouldAddTargetAsDependencyToNamedTarget.shade: -------------------------------------------------------------------------------- 1 |  2 | 3 | #default 4 | -CallTarget("compile"); 5 | 6 | 7 | #compile 8 | ='Compile' 9 | 10 | #added target="compile" 11 | ='HasBeenAdded' 12 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Files/ShouldFindPartialFilesInCurrentDirectoryOrSharedSubdirectory.shade: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | #testing 6 | shouldfindpartialincurrentfolder 7 | shouldfindpartialinsharedfolder 8 | 9 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Files/ShouldFindPartialFilesInSharedFolderUnderEngineAssembly.shade: -------------------------------------------------------------------------------- 1 |  2 | 3 | #testing 4 | ='one' 5 | shouldfindpartialinassemblyfolder 6 | ='two' 7 | shouldfindpartialinassemblysharedfolder 8 | 9 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Files/ShouldLoadFilesFromIncludeDir.shade: -------------------------------------------------------------------------------- 1 |  2 | 3 | #default .from-another-folder 4 | 5 | use file="FromAnotherFolder" 6 | 7 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Files/SingleFile/UseThisOne.shade: -------------------------------------------------------------------------------- 1 |  2 | #single-file 3 | ='ShouldUseSingleShadeFileAsDefault' 4 | not-this-one 5 | or-this-one 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Files/SingleFile/_not-this-one.shade: -------------------------------------------------------------------------------- 1 |  2 | ='NotThisOne' 3 | 4 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Files/SingleFile/_or-this-one.shade: -------------------------------------------------------------------------------- 1 |  2 | ='OrThisOne' 3 | 4 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Files/_shouldfindpartialincurrentfolder.shade: -------------------------------------------------------------------------------- 1 |  2 | ='WasFoundInCurrentFolder' 3 | 4 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Sake.Engine.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCulture("")] 12 | 13 | // Setting ComVisible to false makes the types in this assembly not visible 14 | // to COM components. If you need to access a type in this assembly from 15 | // COM, set the ComVisible attribute to true on that type. 16 | [assembly: ComVisible(false)] 17 | 18 | // The following GUID is for the ID of the typelib if this project is exposed to COM 19 | [assembly: Guid("1342c2a1-5ab3-4b16-8137-411fb8b2446f")] 20 | 21 | [assembly: AssemblyVersion("0.2.0")] 22 | [assembly: AssemblyFileVersion("0.2.0")] 23 | [assembly: AssemblyInformationalVersion("0.2.0")] 24 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Sake.Engine.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {610D7F7C-EA12-4B1E-8B08-429F838F40E9} 9 | Library 10 | Properties 11 | Sake.Engine.Tests 12 | Sake.Engine.Tests 13 | v4.0 14 | 512 15 | ..\..\ 16 | true 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | ..\..\packages\Autofac.2.6.1.841\lib\NET40\Autofac.dll 45 | 46 | 47 | ..\..\packages\Autofac.2.6.1.841\lib\NET40\Autofac.Configuration.dll 48 | 49 | 50 | ..\..\packages\Shouldly.1.1.1.0\lib\35\Shouldly.dll 51 | 52 | 53 | ..\..\packages\xunit.1.9.0.1566\lib\xunit.dll 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | Always 66 | 67 | 68 | Always 69 | 70 | 71 | Always 72 | 73 | 74 | Always 75 | 76 | 77 | Always 78 | 79 | 80 | Always 81 | 82 | 83 | Always 84 | 85 | 86 | Always 87 | 88 | 89 | Always 90 | Designer 91 | 92 | 93 | Always 94 | 95 | 96 | Always 97 | 98 | 99 | Always 100 | 101 | 102 | Always 103 | 104 | 105 | Always 106 | 107 | 108 | 109 | 110 | 111 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309} 112 | Sake.Engine 113 | 114 | 115 | 116 | 117 | 118 | 125 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/SakeEngineOptionsTests.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using Shouldly; 3 | using Xunit; 4 | 5 | namespace Sake.Engine.Tests 6 | { 7 | public class SakeEngineOptionsTests 8 | { 9 | private readonly IContainer _container; 10 | private readonly SakeEngine _engine; 11 | 12 | public SakeEngineOptionsTests() 13 | { 14 | _container = Starter.CreateContainer(new SakeSettings()); 15 | _engine = _container.Resolve(); 16 | } 17 | 18 | [Fact] 19 | public void VerboseIsRecognized() 20 | { 21 | _engine.Parse("-v").Verbose.ShouldBe(1); 22 | _engine.Parse("--verbose").Verbose.ShouldBe(1); 23 | } 24 | 25 | [Fact] 26 | public void MoreThanOneVerboseMayBePassed() 27 | { 28 | _engine.Parse("-vv").Verbose.ShouldBe(2); 29 | _engine.Parse("-v", "-v").Verbose.ShouldBe(2); 30 | } 31 | 32 | [Fact] 33 | public void PlainOldArgsBecomeTargets() 34 | { 35 | _engine.Parse("this", "is", "a", "test").Targets.ShouldBe(new[] { "this", "is", "a", "test" }); 36 | } 37 | 38 | [Fact] 39 | public void MakeFileMayBePassedIn() 40 | { 41 | var options = _engine.Parse("--file", "hello.txt", "foo"); 42 | options.Targets.ShouldBe(new[] { "foo" }); 43 | options.Makefile.ShouldBe("hello.txt"); 44 | } 45 | 46 | [Fact] 47 | public void CurrentDirectoryMayBeProvided() 48 | { 49 | _engine.Parse("-C", "build").ChangeDirectory.ShouldBe(new[] { "build" }); 50 | _engine.Parse("--directory", "build").ChangeDirectory.ShouldBe(new[] { "build" }); 51 | _engine.Parse("--directory", "build", "-C", "src").ChangeDirectory.ShouldBe(new[] { "build", "src" }); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/SakeEngineTests.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.IO; 3 | using Autofac; 4 | using Shouldly; 5 | using Xunit; 6 | 7 | namespace Sake.Engine.Tests 8 | { 9 | public class SakeEngineTests 10 | { 11 | private readonly IContainer _container; 12 | private readonly SakeEngine _engine; 13 | private readonly StringWriter _writer; 14 | string Output { get { return _writer.ToString(); } } 15 | 16 | public SakeEngineTests() 17 | { 18 | _writer = new StringWriter(); 19 | _container = Starter.CreateContainer(new SakeSettings {Output = _writer}); 20 | _engine = _container.Resolve(); 21 | } 22 | 23 | [Fact] 24 | public void ShouldBeCreated() 25 | { 26 | _engine.ShouldNotBe(null); 27 | } 28 | 29 | [Fact] 30 | public void ShouldLoadMakefileSparkFromCurrentDirectoryByDefault() 31 | { 32 | _engine.Execute(); 33 | Output.ShouldContain("ExecDefaultTask"); 34 | Output.ShouldContain("ExecAnotherTask"); 35 | Output.ShouldContain("ExecYetAnotherTask"); 36 | } 37 | 38 | [Fact] 39 | public void ShouldRunNamedTarget() 40 | { 41 | _engine.Execute("YetAnother"); 42 | Output.ShouldNotContain("ExecDefaultTask"); 43 | Output.ShouldNotContain("ExecAnotherTask"); 44 | Output.ShouldContain("ExecYetAnotherTask"); 45 | } 46 | 47 | [Fact] 48 | public void ShouldLoadDifferentFileIfProvided() 49 | { 50 | _engine.Execute("-f", "different.shade"); 51 | Output.ShouldContain("ExecDifferentFile"); 52 | } 53 | 54 | [Fact] 55 | public void ShouldChangeCurrentDirectoryBeforeLoadingFile() 56 | { 57 | _engine.Execute("-C", "Files"); 58 | Output.ShouldContain("This is Files\\makefile.shade"); 59 | } 60 | 61 | [Fact] 62 | public void ShouldFindPartialFilesInCurrentDirectoryOrSharedSubdirectory() 63 | { 64 | _engine.Execute("-C", "Files", "-f", "ShouldFindPartialFilesInCurrentDirectoryOrSharedSubdirectory.shade"); 65 | Output.ShouldContain("WasFoundInCurrentFolder"); 66 | Output.ShouldContain("WasFoundInSharedFolder"); 67 | } 68 | 69 | 70 | [Fact] 71 | public void ShouldAddTargetAsDependencyToNamedTarget() 72 | { 73 | _engine.Execute("-C", "Files", "-f", "ShouldAddTargetAsDependencyToNamedTarget.shade"); 74 | Output.ShouldContain("Compile"); 75 | Output.ShouldContain("HasBeenAdded"); 76 | } 77 | 78 | 79 | [Fact] 80 | public void ShouldLoadFilesFromIncludeDir() 81 | { 82 | _engine.Execute("-C", "Files", "-f", "ShouldLoadFilesFromIncludeDir.shade", "-I", "AnotherFolder"); 83 | Output.ShouldContain("WasFoundInAnotherFolder"); 84 | } 85 | 86 | 87 | [Fact] 88 | public void ShouldUseSingleShadeFileAsDefault() 89 | { 90 | _engine.Execute("-C", "Files", "-C", "SingleFile"); 91 | Output.ShouldContain("ShouldUseSingleShadeFileAsDefault"); 92 | Output.ShouldContain("NotThisOne"); 93 | Output.ShouldContain("OrThisOne"); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Sakefile.shade: -------------------------------------------------------------------------------- 1 |  2 | #Default .Another 3 | = 'ExecDefaultTask' 4 | 5 | #Another .YetAnother 6 | = 'ExecAnotherTask' 7 | 8 | #YetAnother 9 | = 'ExecYetAnotherTask' 10 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/Starter.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using Sake.Engine.Loader; 3 | using Sake.Engine.Logging; 4 | using Sake.Engine.Runner; 5 | 6 | namespace Sake.Engine.Tests 7 | { 8 | public class Starter 9 | { 10 | public static IContainer CreateContainer(ISakeSettings settings) 11 | { 12 | var builder = new ContainerBuilder(); 13 | builder.RegisterInstance(settings); 14 | builder.RegisterType(); 15 | builder.RegisterType().As(); 16 | builder.RegisterType().As(); 17 | builder.RegisterType().As(); 18 | return builder.Build(); 19 | } 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/different.shade: -------------------------------------------------------------------------------- 1 |  2 | 3 | #build 4 | ='ExecDifferentFile' 5 | -------------------------------------------------------------------------------- /src/Sake.Engine.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Sake.Engine/Builder/BuilderBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Sake.Engine.Logging; 5 | using Spark; 6 | 7 | namespace Sake.Engine.Builder 8 | { 9 | public abstract class BuilderBase : SparkViewBase, IBuilder 10 | { 11 | private readonly IDictionary _targets = new Dictionary(); 12 | 13 | private string _previousTarget; 14 | 15 | public IDictionary Targets 16 | { 17 | get { return _targets; } 18 | } 19 | 20 | public string DefaultTarget { get; set; } 21 | 22 | public void RegisterTarget(string name, string dependencies, string description, Action method) 23 | { 24 | if (string.IsNullOrEmpty(DefaultTarget)) 25 | { 26 | DefaultTarget = name; 27 | } 28 | 29 | Target target; 30 | if (!Targets.TryGetValue(name, out target)) 31 | { 32 | target = new Target { Name = name, Dependencies = new List() }; 33 | Targets.Add(name, target); 34 | } 35 | 36 | if (!string.IsNullOrWhiteSpace(dependencies)) 37 | { 38 | target.Dependencies = target.Dependencies 39 | .Concat(dependencies.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)). 40 | ToList(); 41 | } 42 | 43 | if (!string.IsNullOrWhiteSpace(description)) 44 | { 45 | target.Description = description; 46 | } 47 | 48 | if (method != null) 49 | { 50 | target.Method = method; 51 | } 52 | } 53 | 54 | public virtual void StartingTarget(string name) 55 | { 56 | foreach (var dependency in Targets[name].Dependencies) 57 | { 58 | CallTarget(dependency); 59 | } 60 | 61 | _previousTarget = name; 62 | } 63 | 64 | public void CallTarget(string name) 65 | { 66 | Targets[name].Method.Invoke(); 67 | } 68 | 69 | public void Echo(object value) 70 | { 71 | Log.Info(value); 72 | } 73 | 74 | protected object HTML(object value) 75 | { 76 | return value; 77 | } 78 | 79 | protected object H(object value) 80 | { 81 | Log.Info(value); 82 | return ""; 83 | } 84 | 85 | public ILog Log { get; set; } 86 | 87 | public ISakeSettings SakeSettings { get; set; } 88 | } 89 | 90 | public abstract class BuilderBase : BuilderBase 91 | { 92 | 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/Sake.Engine/Builder/IBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Sake.Engine.Builder 4 | { 5 | public interface IBuilder 6 | { 7 | IDictionary Targets { get; } 8 | string DefaultTarget { get; set; } 9 | void CallTarget(string target); 10 | } 11 | } -------------------------------------------------------------------------------- /src/Sake.Engine/Builder/Target.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Sake.Engine.Builder 5 | { 6 | public class Target 7 | { 8 | public string Name { get; set; } 9 | public string Description { get; set; } 10 | 11 | public IList Dependencies { get; set; } 12 | public Action Method { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/Sake.Engine/ISakeSettings.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace Sake.Engine 4 | { 5 | public interface ISakeSettings 6 | { 7 | TextWriter Output { get; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/Sake.Engine/Loader/DefaultLoader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using Sake.Engine.Builder; 5 | using Sake.Engine.Logging; 6 | using Spark; 7 | using Spark.FileSystem; 8 | 9 | namespace Sake.Engine.Loader 10 | { 11 | public class DefaultLoader : ILoader 12 | { 13 | private readonly ILog _log; 14 | private readonly ISakeSettings _settings; 15 | 16 | public DefaultLoader(ILog log, ISakeSettings settings) 17 | { 18 | _log = log; 19 | _settings = settings; 20 | } 21 | 22 | public IBuilder Load(Options options) 23 | { 24 | var currentDirectory = Environment.CurrentDirectory; 25 | var assemblyDirectory = Path.GetDirectoryName(typeof(SakeEngine).Assembly.Location); 26 | 27 | var settings = new SparkSettings() 28 | .SetPageBaseType(typeof(BuilderBase)) 29 | .SetAutomaticEncoding(true) 30 | .SetAttributeBehaviour(AttributeBehaviour.TextOriented) 31 | .SetDebug(true); 32 | 33 | IViewFolder viewFolder = new FileSystemViewFolder(currentDirectory); 34 | foreach(var includeDir in options.IncludeDirectory) 35 | { 36 | var path = Path.Combine(currentDirectory, includeDir); 37 | viewFolder = new CombinedViewFolder(viewFolder, new FileSystemViewFolder(path)); 38 | foreach (var file in Directory.EnumerateFiles(path, "*.dll")) 39 | { 40 | try 41 | { 42 | Assembly.LoadFile(file); 43 | } 44 | catch 45 | { 46 | } 47 | } 48 | } 49 | 50 | viewFolder = new CombinedViewFolder(viewFolder, new FileSystemViewFolder(assemblyDirectory)); 51 | 52 | var engine = new SparkViewEngine(settings) 53 | { 54 | ViewFolder = viewFolder, 55 | ExtensionFactory = new ExtensionFactory(), 56 | }; 57 | 58 | var descriptor = new SparkViewDescriptor 59 | { 60 | Templates = new[] { options.Makefile } 61 | }; 62 | 63 | var builder = (BuilderBase)engine.CreateInstance(descriptor); 64 | builder.Output = new StringWriter(); 65 | builder.Log = _log; 66 | builder.SakeSettings = _settings; 67 | builder.Render(); 68 | return builder; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Sake.Engine/Loader/ExtensionFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Spark; 3 | using Spark.Compiler.NodeVisitors; 4 | using Spark.Parser.Markup; 5 | 6 | namespace Sake.Engine.Loader 7 | { 8 | public class ExtensionFactory : ISparkExtensionFactory 9 | { 10 | private int _TargetExtensionCount; 11 | public ISparkExtension CreateExtension(VisitorContext context, ElementNode node) 12 | { 13 | if (string.Equals(node.Name, "div", StringComparison.OrdinalIgnoreCase)) 14 | { 15 | return new TargetExtension(context, node, ++_TargetExtensionCount); 16 | } if (string.Equals(node.Name, "functions", StringComparison.OrdinalIgnoreCase)) 17 | { 18 | return new FunctionsExtension(context, node); 19 | } 20 | return null; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Sake.Engine/Loader/FunctionsExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using Spark; 7 | using Spark.Compiler; 8 | using Spark.Compiler.ChunkVisitors; 9 | using Spark.Compiler.CSharp.ChunkVisitors; 10 | using Spark.Compiler.NodeVisitors; 11 | using Spark.Parser.Markup; 12 | 13 | namespace Sake.Engine.Loader 14 | { 15 | public class FunctionsExtension : ISparkExtension 16 | { 17 | private readonly VisitorContext _context; 18 | private readonly ElementNode _node; 19 | 20 | public FunctionsExtension(VisitorContext context, ElementNode node) 21 | { 22 | _context = context; 23 | _node = node; 24 | } 25 | 26 | public void VisitNode(INodeVisitor visitor, IList body, IList chunks) 27 | { 28 | visitor.Accept(body); 29 | } 30 | 31 | public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList body, StringBuilder output) 32 | { 33 | if (location == OutputLocation.ClassMembers) 34 | { 35 | foreach (var snippet in body.OfType().SelectMany(chunk => chunk.Code)) 36 | { 37 | snippet.Value = snippet.Value.Replace("@class", "class"); 38 | } 39 | var source = new SourceWriter(new StringWriter(output)); 40 | var generator = new GeneratedCodeVisitor(source, new Dictionary(), NullBehaviour.Strict); 41 | generator.Accept(body); 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/Sake.Engine/Loader/ILoader.cs: -------------------------------------------------------------------------------- 1 | using Sake.Engine.Builder; 2 | 3 | namespace Sake.Engine.Loader 4 | { 5 | public interface ILoader 6 | { 7 | IBuilder Load(Options options); 8 | } 9 | } -------------------------------------------------------------------------------- /src/Sake.Engine/Loader/TargetExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Spark; 6 | using Spark.Compiler; 7 | using Spark.Compiler.ChunkVisitors; 8 | using Spark.Compiler.NodeVisitors; 9 | using Spark.Parser.Code; 10 | using Spark.Parser.Markup; 11 | 12 | namespace Sake.Engine.Loader 13 | { 14 | public class TargetExtension : ISparkExtension 15 | { 16 | private readonly VisitorContext _context; 17 | private readonly ElementNode _targetElement; 18 | private readonly int _targetExtensionCount; 19 | private readonly AttributeNode _idAttribute; 20 | private readonly AttributeNode _classAttribute; 21 | private readonly AttributeNode _descriptionAttribute; 22 | private AttributeNode _targetAttribute; 23 | 24 | public TargetExtension(VisitorContext context, ElementNode targetElement, int targetExtensionCount) 25 | { 26 | _context = context; 27 | _targetElement = targetElement; 28 | _targetExtensionCount = targetExtensionCount; 29 | _idAttribute = _targetElement.Attributes.SingleOrDefault(attr => attr.Name == "id"); 30 | _classAttribute = _targetElement.Attributes.SingleOrDefault(attr => attr.Name == "class"); 31 | _descriptionAttribute = _targetElement.Attributes.SingleOrDefault(attr => attr.Name == "description"); 32 | _targetAttribute = _targetElement.Attributes.SingleOrDefault(attr => attr.Name == "target"); 33 | } 34 | 35 | public void VisitNode(INodeVisitor visitor, IList body, IList chunks) 36 | { 37 | var registerTarget = string.Format( 38 | @"RegisterTarget(""{0}"", ""{1}"", ""{2}"", __target_{3});", 39 | _idAttribute.Value, 40 | _classAttribute != null ? _classAttribute.Value : "", 41 | _descriptionAttribute != null ? _descriptionAttribute.Value : "", 42 | _targetExtensionCount); 43 | 44 | if (_targetAttribute != null) 45 | { 46 | registerTarget += 47 | Environment.NewLine + 48 | string.Format( 49 | @"RegisterTarget(""{0}"", ""{1}"", null, null);", 50 | _targetAttribute.Value, 51 | _idAttribute.Value); 52 | } 53 | 54 | var beginLambda = string.Format( 55 | @"__target_{0} = () => {{", 56 | _targetExtensionCount); 57 | const string endLambda = "};"; 58 | 59 | var startingTarget = string.Format( 60 | @"StartingTarget(""{0}"");", 61 | _idAttribute.Value); 62 | 63 | var nameAttribute = new AttributeNode("name", _idAttribute.QuotChar, _idAttribute.Nodes) { OriginalNode = _idAttribute }; 64 | 65 | var macroAttributes = _targetElement.Attributes 66 | .Where(x => x != _idAttribute && x != _classAttribute && x != _descriptionAttribute) 67 | .Concat(new[] { nameAttribute }) 68 | .ToList(); 69 | var macroElement = new SpecialNode(new ElementNode("macro", macroAttributes, false)); 70 | 71 | var onceAttribute = new AttributeNode("once", _idAttribute.QuotChar, _idAttribute.Nodes); 72 | var testElement = new SpecialNode(new ElementNode("test", new[] { onceAttribute }, false)); 73 | 74 | 75 | macroElement.Body.Add(testElement); 76 | testElement.Body = body; 77 | testElement.Body.Insert(0, new StatementNode(startingTarget)); 78 | 79 | visitor.Accept(new StatementNode(beginLambda)); 80 | visitor.Accept(testElement); 81 | visitor.Accept(new StatementNode(endLambda)); 82 | visitor.Accept(new StatementNode(registerTarget)); 83 | } 84 | 85 | public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList body, StringBuilder output) 86 | { 87 | switch (location) 88 | { 89 | case OutputLocation.ClassMembers: 90 | output 91 | .Append("global::System.Action __target_") 92 | .Append(_targetExtensionCount) 93 | .AppendLine(";"); 94 | break; 95 | } 96 | visitor.Accept(body); 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /src/Sake.Engine/Logging/DefaultLog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Sake.Engine.Logging 4 | { 5 | public class DefaultLog : ILog 6 | { 7 | private ISakeSettings _settings; 8 | 9 | public DefaultLog(ISakeSettings settings) 10 | { 11 | _settings = settings; 12 | } 13 | 14 | public void Info(object value) 15 | { 16 | _settings.Output.WriteLine("\x1b-\x02info\x1b-\x07: {0}", value); 17 | } 18 | 19 | public void Warn(object value) 20 | { 21 | _settings.Output.WriteLine("\x1b-\x0ewarn\x1b-\x07: {0}", value); 22 | } 23 | 24 | public void Error(object value) 25 | { 26 | _settings.Output.WriteLine("\x1b-\u20cfail\x1b-\x07: {0}", value); 27 | } 28 | 29 | public void Verbose(object value) 30 | { 31 | _settings.Output.WriteLine("\x1b-\x03verbose\x1b-\x07: {0}", value); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Sake.Engine/Logging/ILog.cs: -------------------------------------------------------------------------------- 1 | namespace Sake.Engine.Logging 2 | { 3 | public interface ILog 4 | { 5 | void Info(object value); 6 | void Warn(object value); 7 | void Error(object value); 8 | void Verbose(object value); 9 | } 10 | } -------------------------------------------------------------------------------- /src/Sake.Engine/Options.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | 5 | namespace Sake.Engine 6 | { 7 | public class Options 8 | { 9 | public Options() 10 | { 11 | WriteOptionsDescriptions = _ => { }; 12 | Targets = new List(); 13 | ChangeDirectory = new List(); 14 | IncludeDirectory = new List(); 15 | } 16 | 17 | public bool ShowHelp { get; set; } 18 | public Action WriteOptionsDescriptions { get; set; } 19 | public int Verbose { get; set; } 20 | 21 | public IList ChangeDirectory { get; set; } 22 | public IList IncludeDirectory { get; set; } 23 | public string Makefile { get; set; } 24 | 25 | public IList Targets { get; set; } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Sake.Engine/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Sake.Engine")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCulture("")] 12 | 13 | // Setting ComVisible to false makes the types in this assembly not visible 14 | // to COM components. If you need to access a type in this assembly from 15 | // COM, set the ComVisible attribute to true on that type. 16 | [assembly: ComVisible(false)] 17 | 18 | // The following GUID is for the ID of the typelib if this project is exposed to COM 19 | [assembly: Guid("c7ac7bb6-7ab0-46c9-8232-b2405ac1e3cf")] 20 | -------------------------------------------------------------------------------- /src/Sake.Engine/Runner/DefaultRunner.cs: -------------------------------------------------------------------------------- 1 | using Sake.Engine.Builder; 2 | 3 | namespace Sake.Engine.Runner 4 | { 5 | public class DefaultRunner : IRunner 6 | { 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Sake.Engine/Runner/IRunner.cs: -------------------------------------------------------------------------------- 1 | namespace Sake.Engine.Runner 2 | { 3 | public interface IRunner 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/Sake.Engine/Sake.Engine.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309} 9 | Library 10 | Properties 11 | Sake.Engine 12 | Sake.Engine 13 | v4.0 14 | 512 15 | ..\..\ 16 | true 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | ..\..\packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll 45 | 46 | 47 | False 48 | ..\..\prerelease\Spark\lib\Spark.dll 49 | 50 | 51 | 52 | 53 | Properties\AssemblyVersionInfo.cs 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 85 | -------------------------------------------------------------------------------- /src/Sake.Engine/SakeEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using NDesk.Options; 5 | using Sake.Engine.Loader; 6 | using Sake.Engine.Runner; 7 | 8 | namespace Sake.Engine 9 | { 10 | public class SakeEngine 11 | { 12 | private readonly ISakeSettings _settings; 13 | private readonly ILoader _loader; 14 | private readonly IRunner _runner; 15 | 16 | public SakeEngine(ISakeSettings settings, ILoader loader, IRunner runner) 17 | { 18 | _settings = settings; 19 | _loader = loader; 20 | _runner = runner; 21 | } 22 | 23 | public void Execute(params string[] args) 24 | { 25 | try 26 | { 27 | Execute(Parse(args)); 28 | } 29 | catch (OptionException ex) 30 | { 31 | _settings.Output.Write("Sake: "); 32 | _settings.Output.WriteLine(ex.Message); 33 | _settings.Output.WriteLine("Try 'Sake --help' for more information."); 34 | } 35 | } 36 | 37 | public void Execute(Options options) 38 | { 39 | if (options.ShowHelp) 40 | { 41 | ShowHelp(options); 42 | return; 43 | } 44 | 45 | 46 | var originalDirectory = Directory.GetCurrentDirectory(); 47 | try 48 | { 49 | foreach (var changeDirectory in options.ChangeDirectory) 50 | { 51 | Directory.SetCurrentDirectory(changeDirectory); 52 | } 53 | 54 | if (string.IsNullOrEmpty(options.Makefile)) 55 | { 56 | if (File.Exists("Sakefile.shade")) 57 | { 58 | options.Makefile = "Sakefile.shade"; 59 | } 60 | else 61 | { 62 | var files = Directory.GetFiles(".", "*.shade").Where(name => !Path.GetFileName(name).StartsWith("_")); 63 | options.Makefile = files.Count() == 1 ? files.Single() : "Sakefile.shade"; 64 | } 65 | } 66 | 67 | 68 | var builder = _loader.Load(options); 69 | 70 | var targets = options.Targets; 71 | if (targets == null || !targets.Any()) 72 | { 73 | targets = new[] { builder.DefaultTarget }; 74 | } 75 | 76 | foreach (var target in targets) 77 | { 78 | builder.CallTarget(target); 79 | } 80 | } 81 | finally 82 | { 83 | Directory.SetCurrentDirectory(originalDirectory); 84 | } 85 | } 86 | 87 | public Options Parse(params string[] args) 88 | { 89 | var options = new Options(); 90 | 91 | var optionSet = new OptionSet() 92 | .Add("v|verbose", "increase verbosity", v => ++options.Verbose) 93 | .Add("h|?|help", "show this message and exit", v => options.ShowHelp = v != null) 94 | .Add("f|file|makefile=", "read file as a makefile", v => options.Makefile = v) 95 | .Add("C|directory=", "change current directory", v => options.ChangeDirectory.Add(v)) 96 | .Add("I|include-dir=", "specifies a directory to search for included files", v => options.IncludeDirectory.Add(v)) 97 | ; 98 | 99 | options.Targets = optionSet.Parse(args); 100 | options.WriteOptionsDescriptions = optionSet.WriteOptionDescriptions; 101 | return options; 102 | } 103 | 104 | public void ShowHelp(Options options) 105 | { 106 | _settings.Output.WriteLine("Usage: Sake [OPTIONS]+ [target]+"); 107 | _settings.Output.WriteLine(); 108 | _settings.Output.WriteLine("Options:"); 109 | options.WriteOptionsDescriptions(_settings.Output); 110 | } 111 | 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/Sake.Engine/SakeSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace Sake.Engine 5 | { 6 | public class SakeSettings : ISakeSettings 7 | { 8 | public TextWriter Output { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/Sake.Engine/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/Sake.Library/Code/MakefileTargetsDataAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Reflection; 6 | using Sake.Engine; 7 | using Sake.Engine.Builder; 8 | using Sake.Engine.Loader; 9 | using Sake.Engine.Logging; 10 | using Xunit.Extensions; 11 | 12 | namespace Sake.Library 13 | { 14 | public class MakefileTargetsDataAttribute : DataAttribute 15 | { 16 | public override IEnumerable GetData(MethodInfo methodUnderTest, Type[] parameterTypes) 17 | { 18 | var makefiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "test-*.shade").Select(Path.GetFileName); 19 | var settings = new SakeSettings { Output = Console.Out }; 20 | var loader = new DefaultLoader(new DefaultLog(settings), settings); 21 | foreach (var makefile in makefiles) 22 | { 23 | IBuilder builder; 24 | try 25 | { 26 | builder = loader.Load(new Options { Makefile = makefile }); 27 | } 28 | catch (Exception) 29 | { 30 | builder = null; 31 | } 32 | 33 | if (builder == null) 34 | { 35 | yield return new object[] { makefile, null }; 36 | } 37 | else 38 | { 39 | foreach (var target in builder.Targets.Values.Where(target => target.Name.StartsWith("test-"))) 40 | { 41 | yield return new object[] { makefile, target.Name }; 42 | } 43 | } 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/Sake.Library/Code/MakefileTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Sake.Engine; 3 | using Sake.Engine.Loader; 4 | using Sake.Engine.Logging; 5 | using Sake.Engine.Runner; 6 | using Xunit.Extensions; 7 | 8 | namespace Sake.Library 9 | { 10 | public class MakefileTests 11 | { 12 | [Theory, MakefileTargetsData] 13 | public void MakefileTarget(string makefile, string target) 14 | { 15 | var settings = new SakeSettings { Output = new RemoveEscapes(Console.Out) }; 16 | var loader = new DefaultLoader(new DefaultLog(settings), settings); 17 | var engine = new SakeEngine(settings, loader, new DefaultRunner()); 18 | engine.Execute(new Options { Makefile = makefile, Targets = new[] { target } }); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Sake.Library/Code/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Xml; 5 | 6 | namespace Sake.Library 7 | { 8 | class Program 9 | { 10 | static void Main(string[] args) 11 | { 12 | XmlNode results; 13 | var settings = new XmlWriterSettings 14 | { 15 | Indent = true, 16 | IndentChars = " ", 17 | NewLineOnAttributes = true, 18 | NewLineHandling = NewLineHandling.Replace, 19 | NewLineChars = Environment.NewLine, 20 | }; 21 | using (var writer = XmlWriter.Create(Console.Out, settings)) 22 | { 23 | var executor = new Xunit.ExecutorWrapper( 24 | typeof(Program).Assembly.Location, 25 | AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, 26 | false); 27 | 28 | results = executor.RunAssembly(node => true); 29 | results.WriteTo(writer); 30 | } 31 | Console.WriteLine(); 32 | 33 | var failed = results.Attributes["failed"].Value; 34 | if (failed != "0") 35 | { 36 | 37 | Console.ForegroundColor = ConsoleColor.Red; 38 | Console.WriteLine("{0} Failed", failed); 39 | foreach (var failure in results.SelectNodes("//failure/message").OfType()) 40 | { 41 | Console.WriteLine(failure.ParentNode.ParentNode.Attributes["name"].Value); 42 | Console.WriteLine(failure.InnerText); 43 | } 44 | } 45 | else 46 | { 47 | Console.ForegroundColor = ConsoleColor.Green; 48 | Console.WriteLine("OK"); 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Sake.Library/Code/RemoveEscapes.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Linq; 3 | using System.Text; 4 | 5 | namespace Sake.Library 6 | { 7 | public class RemoveEscapes : TextWriter 8 | { 9 | private readonly TextWriter _writer; 10 | 11 | public RemoveEscapes(TextWriter writer) 12 | { 13 | _writer = writer; 14 | } 15 | 16 | public override Encoding Encoding 17 | { 18 | get { return _writer.Encoding; } 19 | } 20 | 21 | public override void Write(char[] buffer, int index, int count) 22 | { 23 | var sanitized = buffer.Skip(index).Take(count).Where(ch => ch >= ' ' || char.IsWhiteSpace(ch)).ToArray(); 24 | base.Write(sanitized, 0, sanitized.Length); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Sake.Library/Data/Asseminfo/versions.txt: -------------------------------------------------------------------------------- 1 | 2 | [assembly: AssemblyVersion("1.2.3")]//1 3 | [assembly: AssemblyFileVersion("4.5.*")]//2 4 | [assembly: AssemblyInformationalVersion("7.8.9-alpha")]//3 5 | [assembly: AssemblyCopyright("yadda (y) 2001")]//4 6 | -------------------------------------------------------------------------------- /src/Sake.Library/Data/Files/Sub/delta.txt: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /src/Sake.Library/Data/Files/Sub/gamma.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/Sake.Library/Data/Files/alpha.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/Sake.Library/Data/Files/another.log: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/Sake.Library/Data/Files/beta.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/Sake.Library/Init/Init-BuildCmd.txt: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd %~dp0 3 | 4 | set EnableNuGetPackageRestore=true 5 | ".nuget\NuGet.exe" install Sake -pre -o packages 6 | for /f "tokens=*" %%G in ('dir /AD /ON /B "packages\Sake.*"') do set __sake__=%%G 7 | "packages\%__sake__%\tools\Sake.exe" -I src/build -f Sakefile.shade %* 8 | set __sake__= 9 | -------------------------------------------------------------------------------- /src/Sake.Library/Init/Init-BuildSh.txt: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export EnableNuGetPackageRestore=true 4 | mono --runtime=v4.0 ".nuget/NuGet.exe" install Sake -pre -o packages 5 | mono $(find packages/Sake.*/tools/Sake.exe|sort -r|head -n1) -f Sakefile.shade -I src/build "$@" 6 | 7 | -------------------------------------------------------------------------------- /src/Sake.Library/Init/Init-SakefileShade.txt: -------------------------------------------------------------------------------- 1 | 2 | var PROJECT='%CWD%' 3 | var VERSION='0.0.1' 4 | var FULL_VERSION='${VERSION}' 5 | var AUTHORS='${PROJECT} contributors' 6 | 7 | var BASE_DIR='${Directory.GetCurrentDirectory()}' 8 | var TARGET_DIR='${Path.Combine(BASE_DIR, "target")}' 9 | var BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}' 10 | var TEST_DIR='${Path.Combine(TARGET_DIR, "test")}' 11 | 12 | 13 | -// include range of standard general targets. run "sake targets" to display 14 | use-standard-lifecycle 15 | 16 | -// include sets of standard work targets. features include 'nuget,xunit,nunit' 17 | use-standard-goals features='nuget' 18 | 19 | -// additional work targets are defined below 20 | 21 | -------------------------------------------------------------------------------- /src/Sake.Library/Init/Sakefile.shade: -------------------------------------------------------------------------------- 1 | 2 | use namespace='System' 3 | use namespace='System.IO' 4 | use import='Environment' 5 | 6 | #default 7 | log info=' ' 8 | log warn='Sakefile.shade not found' 9 | log warn='and current directory did not contain single .shade file.' 10 | log info=' ' 11 | log info='Please use -f switch to provide .shade file name.' 12 | log info=' ' 13 | log info='Or call `sake init` to create a simple Sakefile.shade file' 14 | log info='with default build.cmd and build.sh files in the current directory.' 15 | log info=' ' 16 | -Environment.Exit(1); 17 | 18 | 19 | #init 20 | content var='initSakefileShade' include href='Init-SakefileShade.txt' parse='text' 21 | content var='initBuildCmd' include href='Init-BuildCmd.txt' parse='text' 22 | content var='initBuildSh' include href='Init-BuildSh.txt' parse='text' 23 | 24 | -initSakefileShade = initSakefileShade.Replace("%CWD%", Path.GetFileName(Directory.GetCurrentDirectory())); 25 | 26 | -WriteFile('Sakefile.shade', initSakefileShade); 27 | -WriteFile('build.cmd', initBuildCmd); 28 | -WriteFile('build.sh', initBuildSh); 29 | 30 | exec program='chmod' commandline='+x Build.sh' if='IsLinux' 31 | 32 | 33 | macro name='WriteFile' fileName='string' fileText='string' 34 | test if='File.Exists(fileName)' 35 | log warn='${fileName} exists. Will not overwrite.' 36 | else 37 | log info='Writing ${fileName}' 38 | -File.WriteAllText(fileName, fileText); 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/Sake.Library/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Sake.Library")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCulture("")] 12 | 13 | // Setting ComVisible to false makes the types in this assembly not visible 14 | // to COM components. If you need to access a type in this assembly from 15 | // COM, set the ComVisible attribute to true on that type. 16 | [assembly: ComVisible(false)] 17 | 18 | // The following GUID is for the ID of the typelib if this project is exposed to COM 19 | [assembly: Guid("db96580b-a8fa-4593-ab2e-b92fc591a131")] 20 | 21 | [assembly: AssemblyVersion("0.2.0")] 22 | [assembly: AssemblyFileVersion("0.2.0")] 23 | [assembly: AssemblyInformationalVersion("0.2.0")] 24 | -------------------------------------------------------------------------------- /src/Sake.Library/Sake.Library.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {2AEB7DA4-82DF-45D2-9991-AF6A47F91ADB} 9 | Library 10 | Properties 11 | Sake.Library.Tests 12 | Sake.Library.Tests 13 | v4.0 14 | 512 15 | ..\..\ 16 | true 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | true 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | ..\..\packages\Shouldly.1.1.1.0\lib\35\Shouldly.dll 51 | 52 | 53 | ..\..\packages\xunit.1.9.0.1566\lib\xunit.dll 54 | 55 | 56 | ..\..\packages\xunit.extensions.1.9.0.1566\lib\xunit.extensions.dll 57 | 58 | 59 | ..\..\packages\xunit.1.9.0.1566\lib\xunit.runner.utility.dll 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | PreserveNewest 73 | 74 | 75 | PreserveNewest 76 | 77 | 78 | PreserveNewest 79 | 80 | 81 | PreserveNewest 82 | 83 | 84 | PreserveNewest 85 | 86 | 87 | PreserveNewest 88 | 89 | 90 | PreserveNewest 91 | 92 | 93 | PreserveNewest 94 | 95 | 96 | PreserveNewest 97 | 98 | 99 | PreserveNewest 100 | 101 | 102 | PreserveNewest 103 | 104 | 105 | PreserveNewest 106 | 107 | 108 | PreserveNewest 109 | 110 | 111 | PreserveNewest 112 | 113 | 114 | PreserveNewest 115 | 116 | 117 | 118 | PreserveNewest 119 | 120 | 121 | PreserveNewest 122 | 123 | 124 | PreserveNewest 125 | 126 | 127 | PreserveNewest 128 | 129 | 130 | PreserveNewest 131 | 132 | 133 | PreserveNewest 134 | 135 | 136 | PreserveNewest 137 | 138 | 139 | PreserveNewest 140 | 141 | 142 | PreserveNewest 143 | 144 | 145 | PreserveNewest 146 | 147 | 148 | PreserveNewest 149 | 150 | 151 | PreserveNewest 152 | 153 | 154 | PreserveNewest 155 | 156 | 157 | 158 | 159 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309} 160 | Sake.Engine 161 | 162 | 163 | 164 | 165 | PreserveNewest 166 | 167 | 168 | PreserveNewest 169 | 170 | 171 | PreserveNewest 172 | 173 | 174 | PreserveNewest 175 | 176 | 177 | PreserveNewest 178 | 179 | 180 | PreserveNewest 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 195 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/Environment.shade: -------------------------------------------------------------------------------- 1 | 2 | use namespace="System" 3 | 4 | functions 5 | @{ 6 | bool IsLinux 7 | { 8 | get 9 | { 10 | var platform = (int) Environment.OSVersion.Platform; 11 | return (platform == 4) || (platform == 6) || (platform == 128); 12 | } 13 | } 14 | bool IsMono 15 | { 16 | get 17 | { 18 | return Type.GetType("Mono.Runtime") != null; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/Files.shade: -------------------------------------------------------------------------------- 1 | 2 | use import="PathResolver" 3 | use namespace="System.Collections" 4 | 5 | functions 6 | @{ 7 | _Files Files {get {return new _Files(Log);}} 8 | 9 | static string ReplaceDirectorySeparatorChar(string path) 10 | { 11 | return path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); 12 | } 13 | 14 | class _Files : IEnumerable 15 | { 16 | string _basePath; 17 | IList _include = new List(); 18 | IList _exclude = new List(); 19 | 20 | Sake.Engine.Logging.ILog Log {get;set;} 21 | public _Files(Sake.Engine.Logging.ILog log) 22 | { 23 | Log = log; 24 | 25 | _basePath = Directory.GetCurrentDirectory(); 26 | } 27 | 28 | public _Files BasePath(string basePath) 29 | { 30 | _basePath = Path.Combine( 31 | Directory.GetCurrentDirectory(), 32 | ReplaceDirectorySeparatorChar(basePath)); 33 | return this; 34 | } 35 | 36 | public _Files Include(params string[] patterns) 37 | { 38 | foreach(var pattern in patterns) 39 | { 40 | _include.Add(ReplaceDirectorySeparatorChar(pattern)); 41 | } 42 | return this; 43 | } 44 | 45 | public _Files Exclude(params string[] patterns) 46 | { 47 | foreach(var pattern in patterns) 48 | { 49 | _exclude.Add(ReplaceDirectorySeparatorChar(pattern)); 50 | } 51 | return this; 52 | } 53 | 54 | IEnumerator IEnumerable.GetEnumerator() 55 | { 56 | return Scan().GetEnumerator(); 57 | } 58 | 59 | IEnumerator IEnumerable.GetEnumerator() 60 | { 61 | return Scan().GetEnumerator(); 62 | } 63 | 64 | IEnumerable Scan() 65 | { 66 | var exclude = _exclude 67 | .SelectMany(PerformSearch) 68 | .Distinct() 69 | .ToList(); 70 | 71 | var include = _include; 72 | if (!include.Any()) 73 | { 74 | include = new[]{ReplaceDirectorySeparatorChar("**/*")}; 75 | } 76 | 77 | var files = include 78 | .SelectMany(PerformSearch) 79 | .Distinct() 80 | .Where(path => !exclude.Contains(path)) 81 | .Select(path => {if (path.StartsWith(_basePath)) {return path.Substring(_basePath.Length + 1);} return path;}) 82 | .ToList(); 83 | 84 | return files; 85 | } 86 | 87 | IEnumerable PerformSearch(string pattern) 88 | { 89 | if (pattern.StartsWith(_basePath)) 90 | { 91 | return PathResolver.PerformWildcardSearch(_basePath, pattern.Substring(_basePath.Length + 1)); 92 | } 93 | return PathResolver.PerformWildcardSearch(_basePath, pattern); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/PathResolver.shade: -------------------------------------------------------------------------------- 1 | 2 | use namespace="System" 3 | use namespace="System.Collections.Generic" 4 | use namespace="System.IO" 5 | use namespace="System.Linq" 6 | use namespace="System.Text.RegularExpressions" 7 | 8 | 9 | functions 10 | -// Copied from http://nuget.codeplex.com/SourceControl/changeset/view/3fed5d03c649#src%2fCore%2fAuthoring%2fPathResolver.cs 11 | @{ 12 | public static class PathResolver 13 | { 14 | /// 15 | /// Returns a collection of files from the source that matches the wildcard. 16 | /// 17 | /// The collection of files to match. 18 | /// Function that returns the path to filter a package file 19 | /// The wildcards to apply to match the path with. 20 | /// 21 | public static IEnumerable GetMatches(IEnumerable source, Func getPath, IEnumerable wildcards) 22 | { 23 | var filters = wildcards.Select(WildcardToRegex); 24 | return source.Where(item => 25 | { 26 | string path = getPath(item); 27 | return filters.Any(f => f.IsMatch(path)); 28 | }); 29 | } 30 | 31 | /* 32 | /// 33 | /// Removes files from the source that match any wildcard. 34 | /// 35 | public static void FilterPackageFiles(ICollection source, Func getPath, IEnumerable wildcards) 36 | { 37 | var matchedFiles = new HashSet(GetMatches(source, getPath, wildcards)); 38 | source.RemoveAll(matchedFiles.Contains); 39 | } 40 | */ 41 | 42 | public static string NormalizeWildcard(string basePath, string wildcard) 43 | { 44 | basePath = NormalizeBasePath(basePath, ref wildcard); 45 | return Path.Combine(basePath, wildcard); 46 | } 47 | 48 | private static Regex WildcardToRegex(string wildcard) 49 | { 50 | var match = Regex.Escape(wildcard); 51 | 52 | if (Path.DirectorySeparatorChar == (char)'/') 53 | { 54 | match = match 55 | .Replace(@"\*\*/", ".*") //For recursive wildcards /**/, include the current directory. 56 | .Replace(@"\*\*", ".*") // For recursive wildcards that don't end in a slash e.g. **.txt would be treated as a .txt file at any depth 57 | .Replace(@"\*", @"[^/]*(/)?") // For non recursive searches, limit it any character that is not a directory separator 58 | .Replace(@"\?", "."); // ? translates to a single any character 59 | } 60 | else 61 | { 62 | match = match 63 | .Replace(@"\*\*\\", ".*") //For recursive wildcards \**\, include the current directory. 64 | .Replace(@"\*\*", ".*") // For recursive wildcards that don't end in a slash e.g. **.txt would be treated as a .txt file at any depth 65 | .Replace(@"\*", @"[^\\]*(\\)?") // For non recursive searches, limit it any character that is not a directory separator 66 | .Replace(@"\?", "."); // ? translates to a single any character 67 | } 68 | return new Regex('^' + match + '$', RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); 69 | } 70 | 71 | /* 72 | internal static IEnumerable ResolveSearchPattern(string basePath, string searchPath, string targetPath) 73 | { 74 | string normalizedBasePath; 75 | IEnumerable files = PerformWildcardSearchInternal(basePath, searchPath, out normalizedBasePath); 76 | 77 | return from file in files 78 | select new PhysicalPackageFile 79 | { 80 | SourcePath = file, 81 | TargetPath = ResolvePackagePath(normalizedBasePath, searchPath, file, targetPath) 82 | }; 83 | } 84 | */ 85 | 86 | public static IEnumerable PerformWildcardSearch(string basePath, string searchPath) 87 | { 88 | string normalizedBasePath; 89 | return PerformWildcardSearchInternal(basePath, searchPath, out normalizedBasePath); 90 | } 91 | 92 | private static IEnumerable PerformWildcardSearchInternal(string basePath, string searchPath, out string normalizedBasePath) 93 | { 94 | if (!searchPath.StartsWith(@"\\", StringComparison.OrdinalIgnoreCase)) 95 | { 96 | // If we aren't dealing with network paths, trim the leading slash. 97 | searchPath = searchPath.TrimStart(Path.DirectorySeparatorChar); 98 | } 99 | basePath = NormalizeBasePath(basePath, ref searchPath); 100 | normalizedBasePath = GetPathToEnumerateFrom(basePath, searchPath); 101 | 102 | // Append the basePath to searchPattern and get the search regex. We need to do this because the search regex is matched from line start. 103 | Regex searchRegex = WildcardToRegex(Path.Combine(basePath, searchPath)); 104 | 105 | // This is a hack to prevent enumerating over the entire directory tree if the only wildcard characters are the ones in the file name. 106 | // If the path portion of the search path does not contain any wildcard characters only iterate over the TopDirectory. 107 | SearchOption searchOption = SearchOption.AllDirectories; 108 | // (a) Path is not recursive search 109 | bool isRecursiveSearch = searchPath.IndexOf("**", StringComparison.OrdinalIgnoreCase) != -1; 110 | // (b) Path does not have any wildcards. 111 | bool isWildcardPath = Path.GetDirectoryName(searchPath).Contains('*'); 112 | if (!isRecursiveSearch && !isWildcardPath) 113 | { 114 | searchOption = SearchOption.TopDirectoryOnly; 115 | } 116 | 117 | // Starting from the base path, enumerate over all files and match it using the wildcard expression provided by the user. 118 | return from file in Directory.GetFiles(normalizedBasePath, "*.*", searchOption) 119 | where searchRegex.IsMatch(file) 120 | select file; 121 | } 122 | 123 | internal static string GetPathToEnumerateFrom(string basePath, string searchPath) 124 | { 125 | string basePathToEnumerate; 126 | int wildcardIndex = searchPath.IndexOf('*'); 127 | if (wildcardIndex == -1) 128 | { 129 | // For paths without wildcard, we could either have base relative paths (such as lib\foo.dll) or paths outside the base path 130 | // (such as basePath: C:\packages and searchPath: D:\packages\foo.dll) 131 | // In this case, Path.Combine would pick up the right root to enumerate from. 132 | var searchRoot = Path.GetDirectoryName(searchPath); 133 | basePathToEnumerate = Path.Combine(basePath, searchRoot); 134 | } 135 | else 136 | { 137 | // If not, find the first directory separator and use the path to the left of it as the base path to enumerate from. 138 | int directorySeparatoryIndex = searchPath.LastIndexOf(Path.DirectorySeparatorChar, wildcardIndex); 139 | if (directorySeparatoryIndex == -1) 140 | { 141 | // We're looking at a path like "NuGet*.dll", NuGet*\bin\release\*.dll 142 | // In this case, the basePath would continue to be the path to begin enumeration from. 143 | basePathToEnumerate = basePath; 144 | } 145 | else 146 | { 147 | string nonWildcardPortion = searchPath.Substring(0, directorySeparatoryIndex); 148 | basePathToEnumerate = Path.Combine(basePath, nonWildcardPortion); 149 | } 150 | } 151 | return basePathToEnumerate; 152 | } 153 | 154 | /// 155 | /// Determins the path of the file inside a package. 156 | /// For recursive wildcard paths, we preserve the path portion beginning with the wildcard. 157 | /// For non-recursive wildcard paths, we use the file name from the actual file path on disk. 158 | /// 159 | internal static string ResolvePackagePath(string searchDirectory, string searchPattern, string fullPath, string targetPath) 160 | { 161 | string packagePath; 162 | bool isWildcardSearch = IsWildcardSearch(searchPattern); 163 | bool isRecursiveWildcardSearch = isWildcardSearch && searchPattern.IndexOf("**", StringComparison.OrdinalIgnoreCase) != -1; 164 | 165 | if (isRecursiveWildcardSearch && fullPath.StartsWith(searchDirectory, StringComparison.OrdinalIgnoreCase)) 166 | { 167 | // The search pattern is recursive. Preserve the non-wildcard portion of the path. 168 | // e.g. Search: X:\foo\**\*.cs results in SearchDirectory: X:\foo and a file path of X:\foo\bar\biz\boz.cs 169 | // Truncating X:\foo\ would result in the package path. 170 | packagePath = fullPath.Substring(searchDirectory.Length).TrimStart(Path.DirectorySeparatorChar); 171 | } 172 | else if (!isWildcardSearch && Path.GetExtension(searchPattern).Equals(Path.GetExtension(targetPath), StringComparison.OrdinalIgnoreCase)) 173 | { 174 | // If the search does not contain wild cards, and the target path shares the same extension, copy it 175 | // e.g. --> Content\css\ie.css 176 | return targetPath; 177 | } 178 | else 179 | { 180 | packagePath = Path.GetFileName(fullPath); 181 | } 182 | return Path.Combine(targetPath ?? String.Empty, packagePath); 183 | } 184 | 185 | internal static string NormalizeBasePath(string basePath, ref string searchPath) 186 | { 187 | const string relativePath = @"..\"; 188 | 189 | // If no base path is provided, use the current directory. 190 | basePath = String.IsNullOrEmpty(basePath) ? @".\" : basePath; 191 | 192 | // If the search path is relative, transfer the ..\ portion to the base path. 193 | // This needs to be done because the base path determines the root for our enumeration. 194 | while (searchPath.StartsWith(relativePath, StringComparison.OrdinalIgnoreCase)) 195 | { 196 | basePath = Path.Combine(basePath, relativePath); 197 | searchPath = searchPath.Substring(relativePath.Length); 198 | } 199 | 200 | return Path.GetFullPath(basePath); 201 | } 202 | 203 | /// 204 | /// Returns true if the path contains any wildcard characters. 205 | /// 206 | internal static bool IsWildcardSearch(string filter) 207 | { 208 | return filter.IndexOf('*') != -1; 209 | } 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/Regex.shade: -------------------------------------------------------------------------------- 1 | 2 | functions 3 | @{ 4 | string RegexReplace(string text, string pattern, string replace) 5 | { 6 | return System.Text.RegularExpressions.Regex.Replace(text, pattern, replace); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_assemblyinfo.shade: -------------------------------------------------------------------------------- 1 | 2 | default updateFile='' 3 | 4 | default assemblyVersion='' 5 | default assemblyFileVersion='${assemblyVersion}' 6 | default assemblyInformationalVersion='${assemblyVersion}' 7 | default assemblyDescription='' 8 | default assemblyTitle='' 9 | default assemblyProduct='${assemblyTitle}' 10 | default assemblyCopyright='' 11 | 12 | use import='Regex' 13 | 14 | update-file if='!string.IsNullOrEmpty(updateFile)' 15 | @{ 16 | System.Action __replace__ = (name, value) => 17 | { 18 | if (!string.IsNullOrWhiteSpace(value)) 19 | updateText = RegexReplace(updateText, name + @"\(""([^""\\]|\\.)*""\)", name + "(\"" + value + "\")"); 20 | }; 21 | 22 | __replace__("AssemblyVersion", assemblyVersion); 23 | __replace__("AssemblyFileVersion", assemblyFileVersion); 24 | __replace__("AssemblyInformationalVersion", assemblyInformationalVersion); 25 | __replace__("AssemblyTitle", assemblyTitle); 26 | __replace__("AssemblyProduct", assemblyProduct); 27 | __replace__("AssemblyCopyright", assemblyCopyright); 28 | __replace__("AssemblyDescription", assemblyDescription); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_build.shade: -------------------------------------------------------------------------------- 1 | @{/* 2 | 3 | build 4 | Executes msbuild or xbuild to compile your project or solution 5 | 6 | projectFile='' 7 | Required. Path to the project or solution file to build. 8 | 9 | configuration='Release' 10 | Determines which configuration to use when building. 11 | 12 | outputDir='' 13 | Directs all compiler outputs into the target path. 14 | 15 | extra='' 16 | Additional commandline parameters for msbuild or xbuild 17 | 18 | */} 19 | 20 | default configuration='Release' 21 | default outputDir='' 22 | default extra='' 23 | 24 | use import="Environment" 25 | use assembly="Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 26 | use namespace="Microsoft.Build.Utilities" 27 | 28 | var buildProgram='' 29 | @{ 30 | if (IsMono) 31 | { 32 | buildProgram = "xbuild"; 33 | } 34 | else 35 | { 36 | buildProgram = ToolLocationHelper.GetPathToDotNetFrameworkFile("msbuild.exe",TargetDotNetFrameworkVersion.Version40); 37 | } 38 | } 39 | 40 | var OutDirProperty='' 41 | set OutDirProperty='OutDir=${outputDir}${Path.DirectorySeparatorChar};' if='!string.IsNullOrWhiteSpace(outputDir)' 42 | 43 | exec program="${buildProgram}" commandline='${projectFile} "/p:${OutDirProperty}Configuration=${configuration}" ${extra}' 44 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_copy.shade: -------------------------------------------------------------------------------- 1 | 2 | use import="Files" 3 | 4 | default include='**/*.*' 5 | default exclude='' 6 | default overwrite='${false}' 7 | 8 | 9 | @{ 10 | var copyFiles = Files.BasePath(Path.GetFullPath(sourceDir)); 11 | if (!string.IsNullOrEmpty(include)) 12 | { 13 | copyFiles = copyFiles.Include(include); 14 | } 15 | if (!string.IsNullOrEmpty(exclude)) 16 | { 17 | copyFiles = copyFiles.Exclude(exclude); 18 | } 19 | foreach(var copyFile in copyFiles) 20 | { 21 | Log.Info(string.Format("Copying {0}", copyFile)); 22 | var sourceFile = Path.Combine(sourceDir, copyFile); 23 | var outputFile = Path.Combine(outputDir, copyFile); 24 | if (!Directory.Exists(Path.GetDirectoryName(outputFile))) 25 | { 26 | Directory.CreateDirectory(Path.GetDirectoryName(outputFile)); 27 | } 28 | File.Copy(sourceFile, outputFile, overwrite); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_directory.shade: -------------------------------------------------------------------------------- 1 | 2 | default delete='' 3 | default create='' 4 | 5 | test if="!string.IsNullOrEmpty(delete) && Directory.Exists(delete)" 6 | @{ 7 | try 8 | { 9 | Directory.Delete(delete, true); 10 | } 11 | catch 12 | { 13 | // blind catch and retry - delete throws "Directory is not empty" sometimes !? 14 | Directory.Delete(delete, true); 15 | } 16 | } 17 | 18 | test if="!string.IsNullOrEmpty(create) && !Directory.Exists(create)" 19 | -Directory.CreateDirectory(create); 20 | 21 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_exec-clr.shade: -------------------------------------------------------------------------------- 1 | 2 | use namespace="System.Diagnostics" 3 | use namespace="System.IO" 4 | use import="Environment" 5 | 6 | default workingdir="${Directory.GetCurrentDirectory()}" 7 | default commandline="" 8 | 9 | log info="Exec" 10 | log info=" program: ${program}" 11 | log info=" commandline: ${commandline}" 12 | log info=" workingdir: ${workingdir}" 13 | 14 | @{ 15 | var processStartInfo = new ProcessStartInfo { 16 | UseShellExecute = false, 17 | WorkingDirectory = workingdir, 18 | FileName = program, 19 | Arguments = commandline 20 | }; 21 | 22 | if (IsMono) 23 | { 24 | processStartInfo.Arguments = 25 | "--runtime=v4.0 " + 26 | processStartInfo.FileName + 27 | " " + 28 | processStartInfo.Arguments; 29 | processStartInfo.FileName = "mono"; 30 | } 31 | 32 | if (__WriteExecOutputToLogger) 33 | { 34 | processStartInfo.RedirectStandardError = true; 35 | processStartInfo.RedirectStandardOutput = true; 36 | } 37 | 38 | using (var process = Process.Start(processStartInfo)) 39 | { 40 | if (__WriteExecOutputToLogger) 41 | { 42 | process.EnableRaisingEvents = true; 43 | process.BeginOutputReadLine(); 44 | process.BeginErrorReadLine(); 45 | 46 | process.ErrorDataReceived += (sender, eventArgs) => 47 | { 48 | if (!string.IsNullOrWhiteSpace(eventArgs.Data)) 49 | { 50 | Log.Error(eventArgs.Data); 51 | } 52 | }; 53 | 54 | process.OutputDataReceived += (sender, eventArgs) => 55 | { 56 | Log.Info(eventArgs.Data); 57 | }; 58 | } 59 | 60 | process.WaitForExit(); 61 | if (process.ExitCode != 0) 62 | { 63 | throw new Exception(string.Format("Exit code {0} from {1}", process.ExitCode, program)); 64 | } 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_exec.shade: -------------------------------------------------------------------------------- 1 | 2 | use namespace="System.Diagnostics" 3 | use namespace="System.IO" 4 | 5 | default workingdir="${Directory.GetCurrentDirectory()}" 6 | default commandline="" 7 | 8 | log info="Exec" 9 | log info=" program: ${program}" 10 | log info=" commandline: ${commandline}" 11 | log info=" workingdir: ${workingdir}" 12 | 13 | 14 | functions 15 | @{ 16 | bool __WriteExecOutputToLogger { get; set; } 17 | } 18 | 19 | @{ 20 | var processStartInfo = new ProcessStartInfo { 21 | UseShellExecute = false, 22 | WorkingDirectory = workingdir, 23 | FileName = program, 24 | Arguments = commandline, 25 | 26 | }; 27 | 28 | if (__WriteExecOutputToLogger) 29 | { 30 | processStartInfo.RedirectStandardError = true; 31 | processStartInfo.RedirectStandardOutput = true; 32 | } 33 | 34 | using (var process = Process.Start(processStartInfo)) 35 | { 36 | if (__WriteExecOutputToLogger) 37 | { 38 | process.EnableRaisingEvents = true; 39 | process.BeginOutputReadLine(); 40 | process.BeginErrorReadLine(); 41 | 42 | process.ErrorDataReceived += (sender, eventArgs) => 43 | { 44 | if (!string.IsNullOrWhiteSpace(eventArgs.Data)) 45 | { 46 | Log.Error(eventArgs.Data); 47 | } 48 | }; 49 | 50 | process.OutputDataReceived += (sender, eventArgs) => 51 | { 52 | Log.Info(eventArgs.Data); 53 | }; 54 | } 55 | 56 | process.WaitForExit(); 57 | 58 | if (process.ExitCode != 0) 59 | { 60 | throw new Exception(string.Format("Exit code {0} from {1}", process.ExitCode, program)); 61 | } 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_log.shade: -------------------------------------------------------------------------------- 1 | 2 | default info="" warn="" 3 | 4 | @{ 5 | if (!string.IsNullOrEmpty(info)) 6 | Log.Info(info); 7 | if (!string.IsNullOrEmpty(warn)) 8 | Log.Warn(warn); 9 | } 10 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_nuget-install.shade: -------------------------------------------------------------------------------- 1 | 2 | default nugetPath='.nuget/NuGet.exe' 3 | 4 | default outputDir='' 5 | default packageVersion='' 6 | default extra='' 7 | 8 | var nugetArgs='install "${package}"' 9 | set nugetArgs='${nugetArgs} -OutputDirectory "${outputDir}"' if='!string.IsNullOrEmpty(outputDir)' 10 | set nugetArgs='${nugetArgs} -Version ${packageVersion}' if='!string.IsNullOrEmpty(packageVersion)' 11 | set nugetArgs='${nugetArgs} ${extra}' if='!string.IsNullOrEmpty(extra)' 12 | 13 | exec-clr program="${nugetPath}" commandline="${nugetArgs}" 14 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_nuget-pack.shade: -------------------------------------------------------------------------------- 1 | @{/* 2 | 3 | nuget-pack 4 | Creates a nupkg file given a nuspec 5 | 6 | nuspecFile='' 7 | Required. Path to the nuspec file detailing package to build. 8 | 9 | packageVersion='' 10 | Provides the resulting version explicitly. Overrides value in nuspec file if any. 11 | 12 | outputDir='' 13 | Output directory for the resulting nupkg file. 14 | 15 | extra='' 16 | Additional commandline parameters 17 | 18 | nugetPath='.nuget/NuGet.exe' 19 | Overrides the path of the nuget.exe program to use 20 | 21 | */} 22 | 23 | default nugetPath='.nuget/NuGet.exe' 24 | 25 | default outputDir='' 26 | default packageVersion='' 27 | default extra='' 28 | 29 | var nugetArgs='pack "${nuspecFile}"' 30 | set nugetArgs='${nugetArgs} -OutputDirectory "${outputDir}"' if='!string.IsNullOrEmpty(outputDir)' 31 | set nugetArgs='${nugetArgs} -Version ${packageVersion}' if='!string.IsNullOrEmpty(packageVersion)' 32 | set nugetArgs='${nugetArgs} ${extra}' if='!string.IsNullOrEmpty(extra)' 33 | 34 | exec-clr program="${nugetPath}" commandline="${nugetArgs}" 35 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_nuget-push.shade: -------------------------------------------------------------------------------- 1 | 2 | default nugetPath='.nuget/NuGet.exe' 3 | 4 | default apiKey='${Environment.GetEnvironmentVariable("APIKEY")}' 5 | default source='' 6 | default extra='' 7 | 8 | var nugetArgs='push "${nupkgFile}"' 9 | set nugetArgs='${nugetArgs} -ApiKey ${apiKey}' if='!string.IsNullOrEmpty(apiKey)' 10 | set nugetArgs='${nugetArgs} -Source ${source}' if='!string.IsNullOrEmpty(source)' 11 | set nugetArgs='${nugetArgs} ${extra}' if='!string.IsNullOrEmpty(extra)' 12 | 13 | exec-clr program="${nugetPath}" commandline="${nugetArgs}" 14 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_nunit.shade: -------------------------------------------------------------------------------- 1 | @{/* 2 | 3 | nunit 4 | Run unit tests in your project. Downloads and executes nunit console runner. 5 | 6 | testFile='' 7 | Required. Path to the test assembly to execute 8 | 9 | extra='' 10 | Additional commandline parameters for nunit 11 | 12 | nunitVersion='2.5.10.11092' 13 | May be passed to override the nuget package version holding xunit console runner. 14 | 15 | nunitProgram='packages/NUnit.${nunitVersion}/tools/nunit-console.exe' 16 | May be passed to override the path to the nunit program that will be executed 17 | 18 | */} 19 | 20 | default nunitVersion='2.5.10.11092' 21 | default nunitProgram='packages/NUnit.${nunitVersion}/tools/nunit-console.exe' 22 | default extra='' 23 | 24 | -// Download nunit from nuget sources if not already present 25 | test if='!System.IO.File.Exists(nunitProgram)' 26 | nuget-install package='NUnit' packageVersion='${nunitVersion}' outputDir='packages' 27 | 28 | exec-clr program='${nunitProgram}' commandline='${testFile} ${extra}' 29 | 30 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_stylecop.shade: -------------------------------------------------------------------------------- 1 | @{/* 2 | 3 | stylecop 4 | Run StyleCop on your project. Downloads and executes as msbuild task. 5 | 6 | stylecopProject='' 7 | Required. Path to the project file to analyze. 8 | 9 | stylecopVersion='4.7.42.1' 10 | May be passed to override the nuget package version holding stylecop msbuild task. 11 | 12 | stylecopTargets='packages/StyleCop.MSBuild.${stylecopVersion}/tools/StyleCop.Targets' 13 | May be passed to override the path to the stylecop targets file that will be imported. 14 | 15 | */} 16 | 17 | default stylecopVersion='4.7.42.1' 18 | default stylecopTargets='packages/StyleCop.MSBuild.${stylecopVersion}/tools/StyleCop.Targets' 19 | 20 | -// Download nunit from nuget sources if not already present 21 | test if='!System.IO.File.Exists(stylecopTargets)' 22 | nuget-install package='StyleCop.MSBuild' packageVersion='${stylecopVersion}' outputDir='packages' 23 | 24 | use namespace='System.IO' 25 | 26 | var projectFile='${Path.Combine(Path.GetDirectoryName(stylecopProject), "stylecop.proj.user")}' 27 | 28 | @{ 29 | File.WriteAllText(projectFile, @" 30 | 31 | 32 | true 33 | false 34 | 35 | 36 | 37 | 38 | "); 39 | } 40 | 41 | - try { 42 | build 43 | - } finally {File.Delete(projectFile);} 44 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_update-file.shade: -------------------------------------------------------------------------------- 1 | 2 | var originalText='${System.IO.File.ReadAllText(updateFile)}' 3 | var updateText='${originalText}' 4 | render 5 | @{ 6 | if (updateText != originalText) 7 | { 8 | Log.Info("Updating " + updateFile); 9 | System.IO.File.WriteAllText(updateFile, updateText); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_use-standard-goals.shade: -------------------------------------------------------------------------------- 1 | 2 | use namespace="System" 3 | use namespace="System.IO" 4 | use import="Files" 5 | 6 | var not_provided='(object)null' 7 | 8 | default features='' 9 | -Func HasFeature = name =>features.Split((char)',').Contains(name); 10 | 11 | default BASE_DIR='${Directory.GetCurrentDirectory()}' 12 | default TARGET_DIR='${Path.Combine(BASE_DIR, "target")}' 13 | default BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}' 14 | default TEST_DIR='${Path.Combine(TARGET_DIR, "test")}' 15 | 16 | default SRC='.' 17 | default ASSEMBLYINFO_FILES='${Files.Include(SRC+"/**/AssemblyInfo.cs")}' 18 | default BUILD_PROJECTS='${Files.Include(SRC+"/**/*.csproj")}' 19 | default TEST_PROJECTS='${Files.Include(SRC+"/**/*.Tests.csproj")}' 20 | default TEST_ASSEMBLIES='${Files.Include("target/test/**/*.Tests.dll")}' 21 | 22 | default NUGET_DEPLOY='' 23 | 24 | #target-dir-clean target="clean" 25 | directory delete="${TARGET_DIR}" 26 | 27 | 28 | #assemblyinfo-initialize target='initialize' if='ASSEMBLYINFO_FILES != null' 29 | assemblyinfo each='var updateFile in ASSEMBLYINFO_FILES' assemblyVersion='${VERSION}' assemblyInformationalVersion='${FULL_VERSION}' 30 | 31 | 32 | #build-compile target='compile' description='Compile primary project' 33 | for each='var projectFile in BUILD_PROJECTS.Except(TEST_PROJECTS)' 34 | var outputDir='${Path.Combine(BUILD_DIR, Path.GetFileNameWithoutExtension(projectFile))}' 35 | build configuration='Release' 36 | copy sourceDir='${Path.GetDirectoryName(projectFile)}' include='*.nuspec' overwrite='${true}' 37 | 38 | 39 | #build-test-compile target='test-compile' description='Compile entire solution for testing' 40 | for each='var projectFile in TEST_PROJECTS' 41 | var outputDir='${Path.Combine(TEST_DIR, Path.GetFileNameWithoutExtension(projectFile))}' 42 | build configuration='Debug' 43 | 44 | #stylecop-validate target="validate" description='Run stylecop validation' if='HasFeature("stylecop")' 45 | stylecop each='var stylecopProject in BUILD_PROJECTS.Except(TEST_PROJECTS)' 46 | 47 | #xunit-test target="test" description='Run xunit tests' if='HasFeature("xunit")' 48 | xunit each='var testFile in TEST_ASSEMBLIES' 49 | 50 | 51 | #nunit-test target="test" description='Run nunit tests' if='HasFeature("nunit")' 52 | nunit each='var testFile in TEST_ASSEMBLIES' 53 | 54 | 55 | #nuget-package target='package' description='Create NuGet packages' if='HasFeature("nuget")' 56 | for each='var file in Files.Include("target/build/**/*.nuspec")' 57 | var baseName='${Path.GetFileNameWithoutExtension(file)}' 58 | nuget-pack nuspecFile='${file}' packageVersion='${FULL_VERSION}' outputDir='${TARGET_DIR}' extra='-NoPackageAnalysis -Properties "id=${baseName};authors=${AUTHORS};author=${AUTHORS};title=${baseName};description=${baseName}"' 59 | 60 | 61 | #nuget-install target='install' description='Copy NuGet packages to local repo' if='HasFeature("nuget")' 62 | default HOME_DIR='${Environment.GetEnvironmentVariable("HOME")}' 63 | set HOME_DIR='${Environment.GetEnvironmentVariable("HOMEDRIVE") + Environment.GetEnvironmentVariable("HOMEPATH")}' if='string.IsNullOrEmpty(HOME_DIR)' 64 | copy sourceDir='${TARGET_DIR}' include='*.nupkg' outputDir='${Path.Combine(HOME_DIR, ".nuget")}' overwrite='${true}' 65 | 66 | 67 | #nuget-deploy target='deploy' description='Upload NuGet packages to gallery' if='HasFeature("nuget")' 68 | nuget-push each='var nupkgFile in Files.Include("target/*.nupkg")' source='${NUGET_DEPLOY}' 69 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_use-standard-lifecycle.shade: -------------------------------------------------------------------------------- 1 | 2 | -// Default target: when cmdline run without a target 3 | #default 4 | @{ 5 | CallTarget("clean"); 6 | CallTarget("test"); 7 | CallTarget("package"); 8 | } 9 | 10 | 11 | -// Default lifecycle: target phases their dependencies 12 | 13 | 14 | #pre-clean 15 | #clean .pre-clean -CallTarget('post-clean'); 16 | #post-clean 17 | 18 | #validate 19 | 20 | #initialize .clean .validate 21 | 22 | #compile .initialize 23 | 24 | #test-compile .compile 25 | #test .test-compile 26 | 27 | #package-prepare 28 | #package .compile .package-prepare 29 | 30 | #pre-integration-test 31 | #integration-test .package .pre-integration-test -CallTarget("post-integration-test"); 32 | #post-integration-test 33 | 34 | #verify .compile .test .package .integration-test 35 | 36 | #install .verify 37 | #deploy .verify 38 | 39 | 40 | functions 41 | @{ 42 | void __DoList__(string name) 43 | { 44 | if (Once(name)) 45 | { 46 | var t = Targets[name]; 47 | foreach(var name2 in t.Dependencies) {__DoList__(name2);} 48 | Log.Info(string.Format("\x1b-\x03{0}\x1b-\x07 {1}", t.Name, t.Description)); 49 | } 50 | } 51 | } 52 | 53 | #targets for each='var t in Targets.Keys' -__DoList__(t); 54 | -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_use-teamcity.shade: -------------------------------------------------------------------------------- 1 | functions 2 | @{ 3 | bool IsTeamCity 4 | { 5 | get { return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TEAMCITY_VERSION")); } 6 | } 7 | 8 | class TeamCityLog : Sake.Engine.Logging.ILog 9 | { 10 | private Sake.Engine.ISakeSettings _settings; 11 | 12 | public TeamCityLog(Sake.Engine.ISakeSettings settings) 13 | { 14 | _settings = settings; 15 | } 16 | 17 | public void Info(object value) 18 | { 19 | _settings.Output.WriteLine(value); 20 | } 21 | 22 | public void Warn(object value) 23 | { 24 | _settings.Output.WriteLine(Format(value, "WARNING")); 25 | } 26 | 27 | public void Error(object value) 28 | { 29 | _settings.Output.WriteLine(Format(value, "ERROR")); 30 | } 31 | 32 | public void Verbose(object value) 33 | { 34 | _settings.Output.WriteLine(value); 35 | } 36 | 37 | public static string Format(object v, string level) 38 | { 39 | if (v == null) 40 | { 41 | return string.Empty; 42 | } 43 | 44 | var value = v.ToString(); 45 | if (value.StartsWith("##teamcity", StringComparison.Ordinal)) 46 | { 47 | return value; 48 | } 49 | 50 | value = value.Replace("|", "||") 51 | .Replace("'", "|'") 52 | .Replace("\r", "|r") 53 | .Replace("\n", "|n") 54 | .Replace("]", "|]"); 55 | 56 | return string.Format(System.Globalization.CultureInfo.InvariantCulture, 57 | "##teamcity[message text='{0}' status='{1}']", 58 | value, 59 | level); 60 | } 61 | } 62 | 63 | private string _previousTarget; 64 | 65 | public override void StartingTarget(string name) 66 | { 67 | if (!IsTeamCity) { base.StartingTarget(name); return ;} 68 | 69 | foreach (var dependency in Targets[name].Dependencies) 70 | { 71 | CallTarget(dependency); 72 | } 73 | 74 | if (_previousTarget != null) 75 | { 76 | Console.WriteLine(string.Format("##teamcity[blockClosed name='{0}']", _previousTarget)); 77 | } 78 | _previousTarget = name; 79 | Console.WriteLine(string.Format("##teamcity[blockOpened name='{0}']", name)); 80 | } 81 | } 82 | 83 | @{ 84 | if (IsTeamCity) 85 | { 86 | Log = new TeamCityLog(SakeSettings); 87 | __WriteExecOutputToLogger = true; 88 | } 89 | } -------------------------------------------------------------------------------- /src/Sake.Library/Shared/_xunit.shade: -------------------------------------------------------------------------------- 1 | @{/* 2 | 3 | xunit 4 | Run unit tests in your project. Downloads and executes xunit console runner. 5 | 6 | testFile='' 7 | Required. Path to the test assembly to execute 8 | 9 | extra='' 10 | Additional commandline parameters for xunit 11 | 12 | xunitVersion='1.9.0.1566' 13 | May be passed to override the nuget package version holding xunit console runner. 14 | 15 | xunitProgram='packages/xunit.runners.${xunitVersion}/tools/xunit.console.clr4.exe' 16 | May be passed to override the path to the xunit program that will be executed 17 | 18 | */} 19 | 20 | default xunitVersion='1.9.0.1566' 21 | default xunitProgram='packages/xunit.runners.${xunitVersion}/tools/xunit.console.clr4.exe' 22 | default extra='' 23 | 24 | use namespace='System.IO' 25 | var xunitDllPath1='${Path.Combine(Path.GetDirectoryName(testFile), "xunit.dll")}' 26 | var xunitDllPath2='${Path.Combine(Path.GetDirectoryName(xunitProgram), "xunit.dll")}' 27 | 28 | -// Download xunit from nuget sources if not already present 29 | test if='!File.Exists(xunitProgram)' 30 | nuget-install package='xunit.runners' packageVersion='${xunitVersion}' outputDir='packages' 31 | 32 | -// Copy xunit.dll from test assembly location to xunit exe location (if missing) 33 | test if='File.Exists(xunitDllPath1) && !File.Exists(xunitDllPath2)' 34 | -File.Copy(xunitDllPath1, xunitDllPath2); 35 | 36 | 37 | exec-clr program='${xunitProgram}' commandline='${testFile} ${extra}' 38 | 39 | -------------------------------------------------------------------------------- /src/Sake.Library/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/Sake.Library/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Sake.Library/test-assemblyinfo.shade: -------------------------------------------------------------------------------- 1 |  2 | use assembly="Shouldly" 3 | use namespace="Shouldly" 4 | 5 | #test-should-update-assembly-info 6 | -System.IO.File.Copy('Data/Asseminfo/versions.txt', 'Data/Asseminfo/dupe.txt', true); 7 | assemblyinfo updateFile='Data/Asseminfo/dupe.txt' assemblyVersion='6.3.4' assemblyCopyright='copy (c) 2003' 8 | var contents='${System.IO.File.ReadAllText('Data/Asseminfo/dupe.txt')}' 9 | -contents.ShouldContain("AssemblyVersion(\"6.3.4\")]//1"); 10 | -contents.ShouldContain("AssemblyFileVersion(\"6.3.4\")]//2"); 11 | -contents.ShouldContain("AssemblyCopyright(\"copy (c) 2003\")]//4"); 12 | -------------------------------------------------------------------------------- /src/Sake.Library/test-copy.shade: -------------------------------------------------------------------------------- 1 |  2 | use assembly="Shouldly" 3 | use namespace="Shouldly" 4 | use namespace="System.Linq" 5 | use namespace="System.IO" 6 | 7 | #reset 8 | @{ 9 | if (Directory.Exists(Path.Combine("Data", "Copy", "Temp"))) 10 | { 11 | Directory.Delete(Path.Combine("Data", "Copy", "Temp"), true); 12 | } 13 | } 14 | 15 | #test-copy-should-find-and-move-files .reset 16 | copy sourceDir="Data/Files" outputDir="Data/Copy/Temp" include="**/*.txt" 17 | @{ 18 | var files = Files.BasePath("Data/Copy/Temp").Include("**/*.txt"); 19 | files.Count().ShouldBe(4); 20 | files.ShouldContain(Path.Combine("alpha.txt")); 21 | files.ShouldContain(Path.Combine("beta.txt")); 22 | files.ShouldContain(Path.Combine("Sub", "gamma.txt")); 23 | files.ShouldContain(Path.Combine("Sub", "delta.txt")); 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Sake.Library/test-directory.shade: -------------------------------------------------------------------------------- 1 |  2 | use assembly="Shouldly" 3 | use namespace="Shouldly" 4 | use namespace="System.IO" 5 | 6 | #test-can-create-directory 7 | directory create='Data/CanCreateDirectory' 8 | -Directory.Exists("Data/CanCreateDirectory").ShouldBe(true); 9 | 10 | #test-create-directory-on-existing-directory-is-okay 11 | directory create='Data/CanCreateExistingDirectory' 12 | -Directory.Exists("Data/CanCreateExistingDirectory").ShouldBe(true); 13 | directory create='Data/CanCreateExistingDirectory' 14 | 15 | #test-can-delete-directory 16 | directory create='Data/CanDeleteDirectory' 17 | -Directory.Exists("Data/CanDeleteDirectory").ShouldBe(true); 18 | directory delete='Data/CanDeleteDirectory' 19 | -Directory.Exists("Data/CanDeleteDirectory").ShouldBe(false); 20 | 21 | #test-delete-directory-on-missing-directory-is-okay 22 | -Directory.Exists("Data/CanDeleteMissingDirectory").ShouldBe(false); 23 | directory delete='Data/CanDeleteMissingDirectory' 24 | -------------------------------------------------------------------------------- /src/Sake.Library/test-files.shade: -------------------------------------------------------------------------------- 1 |  2 | use assembly="Shouldly" 3 | use namespace="Shouldly" 4 | use namespace="System.Linq" 5 | use namespace="System.IO" 6 | use import="Files" 7 | 8 | -//use-file-helpers 9 | 10 | #test-shouldly-can-be-used 11 | -"hello".ShouldBe("hello"); 12 | 13 | #test-includes-should-match-file-patterns 14 | @{ 15 | var files = Files.Include("Data/Files/*.txt"); 16 | files.Count().ShouldBe(2); 17 | files.ShouldContain(Path.Combine("Data", "Files", "alpha.txt")); 18 | files.ShouldContain(Path.Combine("Data", "Files", "beta.txt")); 19 | } 20 | 21 | #test-includes-should-recurse 22 | @{ 23 | var files = Files.Include("Data/Files/**/*.txt"); 24 | files.Count().ShouldBe(4); 25 | files.ShouldContain(Path.Combine("Data", "Files", "alpha.txt")); 26 | files.ShouldContain(Path.Combine("Data", "Files", "beta.txt")); 27 | files.ShouldContain(Path.Combine("Data", "Files", "Sub", "gamma.txt")); 28 | files.ShouldContain(Path.Combine("Data", "Files", "Sub", "delta.txt")); 29 | } 30 | 31 | #test-excludes-should-match-file-patterns 32 | @{ 33 | var files = Files.Include("Data/Files/**/*.txt").Exclude("Data/Files/**/beta.*"); 34 | files.Count().ShouldBe(3); 35 | files.ShouldContain(Path.Combine("Data", "Files", "alpha.txt")); 36 | files.ShouldContain(Path.Combine("Data", "Files", "Sub", "gamma.txt")); 37 | files.ShouldContain(Path.Combine("Data", "Files", "Sub", "delta.txt")); 38 | } 39 | 40 | #test-base-path-should-not-be-in-result 41 | @{ 42 | var files = Files.BasePath("Data/Files").Include("**/*.txt").Exclude("**/beta.*"); 43 | files.Count().ShouldBe(3); 44 | files.ShouldContain(Path.Combine("alpha.txt")); 45 | files.ShouldContain(Path.Combine("Sub", "gamma.txt")); 46 | files.ShouldContain(Path.Combine("Sub", "delta.txt")); 47 | } 48 | 49 | #test-include-takes-multiple-patterns 50 | @{ 51 | var files = Files.BasePath("Data/Files").Include("**/alpha.txt", "**/gamma.txt"); 52 | files.Count().ShouldBe(2); 53 | files.ShouldContain(Path.Combine("alpha.txt")); 54 | files.ShouldContain(Path.Combine("Sub", "gamma.txt")); 55 | } -------------------------------------------------------------------------------- /src/Sake.Library/test-regex.shade: -------------------------------------------------------------------------------- 1 |  2 | use assembly="Shouldly" 3 | use namespace="Shouldly" 4 | use import="Regex" 5 | 6 | #test-regex-replace 7 | -RegexReplace("hello", "he", "je").ShouldBe("jello"); 8 | 9 | -------------------------------------------------------------------------------- /src/Sake/ConsoleWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | 5 | namespace Sake 6 | { 7 | internal class ConsoleWriter : TextWriter 8 | { 9 | public override Encoding Encoding 10 | { 11 | get { return Console.OutputEncoding; } 12 | } 13 | 14 | public override void Write(char[] buffer, int offset, int count) 15 | { 16 | var value = new string(buffer, offset, count); 17 | var index = 0; 18 | for (; ; ) 19 | { 20 | var next = value.IndexOf("\x1b-", index); 21 | if (next == -1) 22 | { 23 | Console.Write(value.Substring(index)); 24 | return; 25 | } 26 | Console.Write(value.Substring(index, next - index)); 27 | index = next + 3; 28 | Console.ForegroundColor=(ConsoleColor)value[next + 2]; 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Sake/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Autofac; 3 | using Sake.Engine; 4 | using Sake.Engine.Loader; 5 | using Sake.Engine.Logging; 6 | using Sake.Engine.Runner; 7 | 8 | namespace Sake 9 | { 10 | class Program 11 | { 12 | static void Main(string[] args) 13 | { 14 | var settings = new SakeSettings 15 | { 16 | Output = new ConsoleWriter(), 17 | }; 18 | 19 | using (var container = CreateContainer(settings)) 20 | { 21 | var engine = container.Resolve(); 22 | try 23 | { 24 | engine.Execute(args); 25 | } 26 | catch (Exception ex) 27 | { 28 | container.Resolve().Error(ex.Message); 29 | container.Resolve().Error("Stack trace: " + Environment.NewLine + ex.StackTrace); 30 | Environment.ExitCode = 1; 31 | } 32 | } 33 | } 34 | 35 | static IContainer CreateContainer(ISakeSettings settings) 36 | { 37 | var builder = new ContainerBuilder(); 38 | builder.RegisterInstance(settings); 39 | builder.RegisterType(); 40 | builder.RegisterType().As(); 41 | builder.RegisterType().As(); 42 | builder.RegisterType().As(); 43 | return builder.Build(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Sake/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Sake")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCulture("")] 12 | 13 | // Setting ComVisible to false makes the types in this assembly not visible 14 | // to COM components. If you need to access a type in this assembly from 15 | // COM, set the ComVisible attribute to true on that type. 16 | [assembly: ComVisible(false)] 17 | 18 | // The following GUID is for the ID of the typelib if this project is exposed to COM 19 | [assembly: Guid("581cea88-35e7-498b-82f5-1af31d0f8965")] 20 | 21 | [assembly: AssemblyVersion("0.2.0")] 22 | [assembly: AssemblyFileVersion("0.2.0")] 23 | [assembly: AssemblyInformationalVersion("0.2.0")] 24 | -------------------------------------------------------------------------------- /src/Sake/Sake.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {9AC10F39-DE9E-46F3-926A-5A158AD322E5} 9 | Exe 10 | Properties 11 | Sake 12 | Sake 13 | v4.0 14 | 512 15 | ..\..\ 16 | true 17 | 18 | 19 | x86 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | x86 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | ..\..\packages\Autofac.2.6.1.841\lib\NET40\Autofac.dll 47 | 48 | 49 | ..\..\packages\Autofac.2.6.1.841\lib\NET40\Autofac.Configuration.dll 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | {0296FE05-EFEA-4ED2-8B82-62B7795CF309} 60 | Sake.Engine 61 | 62 | 63 | 64 | 65 | 66 | 67 | Always 68 | Designer 69 | 70 | 71 | 72 | 73 | 80 | -------------------------------------------------------------------------------- /src/Sake/Sake.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | Sake 4 | 0.0.1-alpha 5 | Louis DeJardin 6 | CSharp-integrated build system 7 | http://loudej.github.com/sake 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Sake/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/Sake/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /todo.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | - bad target name gives "no key in dictionary" error 4 | 5 | - compiler error far too large, put compiler messages to stderr and write 6 | larger test to addtl log file 7 | 8 | --------------------------------------------------------------------------------