Skip to content

Commit

Permalink
add project for dotnet-mechanic
Browse files Browse the repository at this point in the history
  • Loading branch information
jichang committed Mar 18, 2018
1 parent 77e696c commit 2357662
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Mechanic.NetcoreCliTool/Mechanic.NetcoreCliTool.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyName>dotnet-mechanic</AssemblyName>
<PackageId>DotNetMechanic</PackageId>
<PackageVersion>0.0.1</PackageVersion>
<PackageType>DotnetCliTool</PackageType>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Mechanic\Mechanic.fsproj" />
</ItemGroup>

</Project>
47 changes: 47 additions & 0 deletions src/Mechanic.NetcoreCliTool/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
open System
open System.IO
open Mechanic
open Mechanic.Files
open Mechanic.GraphAlg
open Mechanic.Files

[<EntryPoint>]
let main argv =
let projectDirectory =
if argv.Length = 0 then
Environment.CurrentDirectory
else
Path.Combine (Environment.CurrentDirectory, argv.[0])

let solve (n, m) projectFile =
printfn "Project %s" projectFile.FileName

projectFile
|> ProjectFile.getSourceFiles
|> SymbolGraph.solveOrder (fun f -> f.FullName)
|> function
| TopologicalOrderResult.TopologicalOrder xs ->
ProjectFile.updateProjectFile xs projectFile
TopologicalOrderResult.TopologicalOrder (xs |> List.map (fun f -> f.FullName))
|> printfn "%A"
(n + 1, m)
| TopologicalOrderResult.Cycle xs ->
TopologicalOrderResult.Cycle (xs |> List.map (fun f -> f.FullName))
|> printfn "%A"
(n, m + 1)

let projectFiles =
Directory.EnumerateFiles projectDirectory
|> Seq.map ProjectFile.tryLoad
|> Seq.filter Option.isSome
|> Seq.map (fun projectFile -> projectFile.Value)

if Seq.isEmpty projectFiles then
printfn "No *.fsproj files found in %s" Environment.CurrentDirectory
else
projectFiles
|> Seq.fold solve (0, 0)
|> fun (n, m) ->
printfn "\nupdate %i projects, %i projects untouched because of cycle dependency" n m

0 // return an integer exit code
2 changes: 2 additions & 0 deletions src/Mechanic.NetcoreCliTool/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FSharp.Core
FSharp.Compiler.Service
14 changes: 14 additions & 0 deletions src/Mechanic.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Mechanic", "Mechanic\Mechan
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Mechanic.Tests", "Mechanic.Tests\Mechanic.Tests.fsproj", "{E1B1B3E7-B2C8-4E70-BCB9-F56FAA24EA93}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Mechanic.NetcoreCliTool", "Mechanic.NetcoreCliTool\Mechanic.NetcoreCliTool.fsproj", "{D5FA2636-5CC7-4986-BEDA-72ADC8C86C49}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -63,5 +65,17 @@ Global
{E1B1B3E7-B2C8-4E70-BCB9-F56FAA24EA93}.Release|x64.Build.0 = Release|x64
{E1B1B3E7-B2C8-4E70-BCB9-F56FAA24EA93}.Release|x86.ActiveCfg = Release|x86
{E1B1B3E7-B2C8-4E70-BCB9-F56FAA24EA93}.Release|x86.Build.0 = Release|x86
{D5FA2636-5CC7-4986-BEDA-72ADC8C86C49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5FA2636-5CC7-4986-BEDA-72ADC8C86C49}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5FA2636-5CC7-4986-BEDA-72ADC8C86C49}.Debug|x64.ActiveCfg = Debug|x64
{D5FA2636-5CC7-4986-BEDA-72ADC8C86C49}.Debug|x64.Build.0 = Debug|x64
{D5FA2636-5CC7-4986-BEDA-72ADC8C86C49}.Debug|x86.ActiveCfg = Debug|x86
{D5FA2636-5CC7-4986-BEDA-72ADC8C86C49}.Debug|x86.Build.0 = Debug|x86
{D5FA2636-5CC7-4986-BEDA-72ADC8C86C49}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5FA2636-5CC7-4986-BEDA-72ADC8C86C49}.Release|Any CPU.Build.0 = Release|Any CPU
{D5FA2636-5CC7-4986-BEDA-72ADC8C86C49}.Release|x64.ActiveCfg = Release|x64
{D5FA2636-5CC7-4986-BEDA-72ADC8C86C49}.Release|x64.Build.0 = Release|x64
{D5FA2636-5CC7-4986-BEDA-72ADC8C86C49}.Release|x86.ActiveCfg = Release|x86
{D5FA2636-5CC7-4986-BEDA-72ADC8C86C49}.Release|x86.Build.0 = Release|x86
EndGlobalSection
EndGlobal

0 comments on commit 2357662

Please sign in to comment.