Skip to content

Commit a1fac96

Browse files
committed
Initial scaffolding
1 parent 0924f63 commit a1fac96

16 files changed

+462
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,7 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
obj
132+
bin
133+
build

Build.fs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
open Fake.Core
2+
open Fake.IO
3+
4+
open Helpers
5+
6+
initializeContext()
7+
8+
let buildPath = Path.getFullName "src"
9+
let deployPath = Path.getFullName "deploy"
10+
let testsPath = Path.getFullName "test"
11+
12+
Target.create "Clean" (fun _ ->
13+
Shell.cleanDir deployPath
14+
// run dotnet "fable clean --yes" buildPath // Delete *.py files created by Fable
15+
run dotnet "run -c Release -p /Users/dbrattli/Developer/GitHub/Fable/src/Fable.Cli -- clean --yes --lang Python " buildPath
16+
)
17+
18+
Target.create "InstallClient" (fun _ -> run npm "install" ".")
19+
20+
Target.create "Run" (fun _ ->
21+
run dotnet "build" buildPath
22+
)
23+
24+
Target.create "RunTests" (fun _ ->
25+
run dotnet "build" testsPath
26+
[ "native", dotnet "watch run" testsPath
27+
"python", dotnet "run -c Release -p /Users/dbrattli/Developer/GitHub/Fable/src/Fable.Cli -- --lang Python --exclude Fable.Core" testsPath
28+
]
29+
|> runParallel
30+
)
31+
32+
Target.create "Format" (fun _ ->
33+
run dotnet "fantomas . -r" "src"
34+
)
35+
36+
open Fake.Core.TargetOperators
37+
38+
let dependencies = [
39+
"Clean"
40+
==> "InstallClient"
41+
//==> "Bundle"
42+
//==> "Azure"
43+
44+
"Clean"
45+
==> "InstallClient"
46+
==> "Run"
47+
48+
"InstallClient"
49+
==> "RunTests"
50+
]
51+
52+
[<EntryPoint>]
53+
let main args = runOrDefault args

Build.fsproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net5.0</TargetFramework>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<Compile Include="Helpers.fs" />
8+
<Compile Include="Build.fs" />
9+
</ItemGroup>
10+
<Import Project=".paket\Paket.Restore.targets" />
11+
</Project>

Fable.Python.sln

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30114.105
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fable.Python", "src\Fable.Python.fsproj", "{BE5BEBAC-1EBB-4ACF-A3AA-013834CAC95F}"
7+
EndProject
8+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fable.Python.Test", "test\Fable.Python.Test.fsproj", "{B449F60F-C422-40EE-A734-90A1E3084150}"
9+
EndProject
10+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Build", "Build.fsproj", "{492ED4DE-E609-469A-AAAF-8800AB86C224}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Debug|x64 = Debug|x64
16+
Debug|x86 = Debug|x86
17+
Release|Any CPU = Release|Any CPU
18+
Release|x64 = Release|x64
19+
Release|x86 = Release|x86
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
25+
{BE5BEBAC-1EBB-4ACF-A3AA-013834CAC95F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{BE5BEBAC-1EBB-4ACF-A3AA-013834CAC95F}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{BE5BEBAC-1EBB-4ACF-A3AA-013834CAC95F}.Debug|x64.ActiveCfg = Debug|Any CPU
28+
{BE5BEBAC-1EBB-4ACF-A3AA-013834CAC95F}.Debug|x64.Build.0 = Debug|Any CPU
29+
{BE5BEBAC-1EBB-4ACF-A3AA-013834CAC95F}.Debug|x86.ActiveCfg = Debug|Any CPU
30+
{BE5BEBAC-1EBB-4ACF-A3AA-013834CAC95F}.Debug|x86.Build.0 = Debug|Any CPU
31+
{BE5BEBAC-1EBB-4ACF-A3AA-013834CAC95F}.Release|Any CPU.ActiveCfg = Release|Any CPU
32+
{BE5BEBAC-1EBB-4ACF-A3AA-013834CAC95F}.Release|Any CPU.Build.0 = Release|Any CPU
33+
{BE5BEBAC-1EBB-4ACF-A3AA-013834CAC95F}.Release|x64.ActiveCfg = Release|Any CPU
34+
{BE5BEBAC-1EBB-4ACF-A3AA-013834CAC95F}.Release|x64.Build.0 = Release|Any CPU
35+
{BE5BEBAC-1EBB-4ACF-A3AA-013834CAC95F}.Release|x86.ActiveCfg = Release|Any CPU
36+
{BE5BEBAC-1EBB-4ACF-A3AA-013834CAC95F}.Release|x86.Build.0 = Release|Any CPU
37+
{B449F60F-C422-40EE-A734-90A1E3084150}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38+
{B449F60F-C422-40EE-A734-90A1E3084150}.Debug|Any CPU.Build.0 = Debug|Any CPU
39+
{B449F60F-C422-40EE-A734-90A1E3084150}.Debug|x64.ActiveCfg = Debug|Any CPU
40+
{B449F60F-C422-40EE-A734-90A1E3084150}.Debug|x64.Build.0 = Debug|Any CPU
41+
{B449F60F-C422-40EE-A734-90A1E3084150}.Debug|x86.ActiveCfg = Debug|Any CPU
42+
{B449F60F-C422-40EE-A734-90A1E3084150}.Debug|x86.Build.0 = Debug|Any CPU
43+
{B449F60F-C422-40EE-A734-90A1E3084150}.Release|Any CPU.ActiveCfg = Release|Any CPU
44+
{B449F60F-C422-40EE-A734-90A1E3084150}.Release|Any CPU.Build.0 = Release|Any CPU
45+
{B449F60F-C422-40EE-A734-90A1E3084150}.Release|x64.ActiveCfg = Release|Any CPU
46+
{B449F60F-C422-40EE-A734-90A1E3084150}.Release|x64.Build.0 = Release|Any CPU
47+
{B449F60F-C422-40EE-A734-90A1E3084150}.Release|x86.ActiveCfg = Release|Any CPU
48+
{B449F60F-C422-40EE-A734-90A1E3084150}.Release|x86.Build.0 = Release|Any CPU
49+
{492ED4DE-E609-469A-AAAF-8800AB86C224}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50+
{492ED4DE-E609-469A-AAAF-8800AB86C224}.Debug|Any CPU.Build.0 = Debug|Any CPU
51+
{492ED4DE-E609-469A-AAAF-8800AB86C224}.Debug|x64.ActiveCfg = Debug|Any CPU
52+
{492ED4DE-E609-469A-AAAF-8800AB86C224}.Debug|x64.Build.0 = Debug|Any CPU
53+
{492ED4DE-E609-469A-AAAF-8800AB86C224}.Debug|x86.ActiveCfg = Debug|Any CPU
54+
{492ED4DE-E609-469A-AAAF-8800AB86C224}.Debug|x86.Build.0 = Debug|Any CPU
55+
{492ED4DE-E609-469A-AAAF-8800AB86C224}.Release|Any CPU.ActiveCfg = Release|Any CPU
56+
{492ED4DE-E609-469A-AAAF-8800AB86C224}.Release|Any CPU.Build.0 = Release|Any CPU
57+
{492ED4DE-E609-469A-AAAF-8800AB86C224}.Release|x64.ActiveCfg = Release|Any CPU
58+
{492ED4DE-E609-469A-AAAF-8800AB86C224}.Release|x64.Build.0 = Release|Any CPU
59+
{492ED4DE-E609-469A-AAAF-8800AB86C224}.Release|x86.ActiveCfg = Release|Any CPU
60+
{492ED4DE-E609-469A-AAAF-8800AB86C224}.Release|x86.Build.0 = Release|Any CPU
61+
EndGlobalSection
62+
EndGlobal

Helpers.fs

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
module Helpers
2+
3+
open Fake.Core
4+
5+
let initializeContext () =
6+
let execContext = Context.FakeExecutionContext.Create false "build.fsx" [ ]
7+
Context.setExecutionContext (Context.RuntimeContext.Fake execContext)
8+
9+
module Proc =
10+
module Parallel =
11+
open System
12+
13+
let locker = obj()
14+
15+
let colors =
16+
[| ConsoleColor.Blue
17+
ConsoleColor.Yellow
18+
ConsoleColor.Magenta
19+
ConsoleColor.Cyan
20+
ConsoleColor.DarkBlue
21+
ConsoleColor.DarkYellow
22+
ConsoleColor.DarkMagenta
23+
ConsoleColor.DarkCyan |]
24+
25+
let print color (colored: string) (line: string) =
26+
lock locker
27+
(fun () ->
28+
let currentColor = Console.ForegroundColor
29+
Console.ForegroundColor <- color
30+
Console.Write colored
31+
Console.ForegroundColor <- currentColor
32+
Console.WriteLine line)
33+
34+
let onStdout index name (line: string) =
35+
let color = colors.[index % colors.Length]
36+
if isNull line then
37+
print color $"{name}: --- END ---" ""
38+
else if String.isNotNullOrEmpty line then
39+
print color $"{name}: " line
40+
41+
let onStderr name (line: string) =
42+
let color = ConsoleColor.Red
43+
if isNull line |> not then
44+
print color $"{name}: " line
45+
46+
let redirect (index, (name, createProcess)) =
47+
createProcess
48+
|> CreateProcess.redirectOutputIfNotRedirected
49+
|> CreateProcess.withOutputEvents (onStdout index name) (onStderr name)
50+
51+
let printStarting indexed =
52+
for (index, (name, c: CreateProcess<_>)) in indexed do
53+
let color = colors.[index % colors.Length]
54+
let wd =
55+
c.WorkingDirectory
56+
|> Option.defaultValue ""
57+
let exe = c.Command.Executable
58+
let args = c.Command.Arguments.ToStartInfo
59+
print color $"{name}: {wd}> {exe} {args}" ""
60+
61+
let run cs =
62+
cs
63+
|> Seq.toArray
64+
|> Array.indexed
65+
|> fun x -> printStarting x; x
66+
|> Array.map redirect
67+
|> Array.Parallel.map Proc.run
68+
69+
let createProcess exe arg dir =
70+
CreateProcess.fromRawCommandLine exe arg
71+
|> CreateProcess.withWorkingDirectory dir
72+
|> CreateProcess.ensureExitCode
73+
74+
let dotnet = createProcess "dotnet"
75+
let npm =
76+
let npmPath =
77+
match ProcessUtils.tryFindFileOnPath "npm" with
78+
| Some path -> path
79+
| None ->
80+
"npm was not found in path. Please install it and make sure it's available from your path. " +
81+
"See https://safe-stack.github.io/docs/quickstart/#install-pre-requisites for more info"
82+
|> failwith
83+
84+
createProcess npmPath
85+
86+
let run proc arg dir =
87+
proc arg dir
88+
|> Proc.run
89+
|> ignore
90+
91+
let runParallel processes =
92+
processes
93+
|> Proc.Parallel.run
94+
|> ignore
95+
96+
let runOrDefault args =
97+
try
98+
match args with
99+
| [| target |] -> Target.runOrDefault target
100+
| _ -> Target.runOrDefault "Run"
101+
0
102+
with e ->
103+
printfn "%A" e
104+
1

paket.dependencies

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
source https://api.nuget.org/v3/index.json
3+
storage: none
4+
framework: net5.0, netstandard2.0, netstandard2.1
5+
6+
nuget FSharp.Core 5.0.0
7+
8+
group Test
9+
source https://api.nuget.org/v3/index.json
10+
storage: none
11+
framework: net5.0
12+
13+
nuget FSharp.Core 5.0.0
14+
nuget Microsoft.NET.Test.Sdk ~> 16
15+
nuget XUnit ~> 2
16+
nuget xunit.runner.visualstudio ~> 2
17+
18+
19+
group Build
20+
source https://api.nuget.org/v3/index.json
21+
storage: none
22+
framework: net5.0
23+
24+
nuget Fake.Core.Target
25+
nuget Fake.IO.FileSystem

paket.lock

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
STORAGE: NONE
2+
RESTRICTION: || (== net5.0) (== netstandard2.0) (== netstandard2.1)
3+
NUGET
4+
remote: https://api.nuget.org/v3/index.json
5+
FSharp.Core (5.0)
6+
7+
GROUP Build
8+
STORAGE: NONE
9+
RESTRICTION: == net5.0
10+
NUGET
11+
remote: https://api.nuget.org/v3/index.json
12+
Fake.Core.CommandLineParsing (5.20.4)
13+
FParsec (>= 1.1.1)
14+
FSharp.Core (>= 4.7.2)
15+
Fake.Core.Context (5.20.4)
16+
FSharp.Core (>= 4.7.2)
17+
Fake.Core.Environment (5.20.4)
18+
FSharp.Core (>= 4.7.2)
19+
Fake.Core.FakeVar (5.20.4)
20+
Fake.Core.Context (>= 5.20.4)
21+
FSharp.Core (>= 4.7.2)
22+
Fake.Core.Process (5.20.4)
23+
Fake.Core.Environment (>= 5.20.4)
24+
Fake.Core.FakeVar (>= 5.20.4)
25+
Fake.Core.String (>= 5.20.4)
26+
Fake.Core.Trace (>= 5.20.4)
27+
Fake.IO.FileSystem (>= 5.20.4)
28+
FSharp.Core (>= 4.7.2)
29+
System.Collections.Immutable (>= 1.7.1)
30+
Fake.Core.String (5.20.4)
31+
FSharp.Core (>= 4.7.2)
32+
Fake.Core.Target (5.20.4)
33+
Fake.Core.CommandLineParsing (>= 5.20.4)
34+
Fake.Core.Context (>= 5.20.4)
35+
Fake.Core.Environment (>= 5.20.4)
36+
Fake.Core.FakeVar (>= 5.20.4)
37+
Fake.Core.Process (>= 5.20.4)
38+
Fake.Core.String (>= 5.20.4)
39+
Fake.Core.Trace (>= 5.20.4)
40+
FSharp.Control.Reactive (>= 4.4.2)
41+
FSharp.Core (>= 4.7.2)
42+
Fake.Core.Trace (5.20.4)
43+
Fake.Core.Environment (>= 5.20.4)
44+
Fake.Core.FakeVar (>= 5.20.4)
45+
FSharp.Core (>= 4.7.2)
46+
Fake.IO.FileSystem (5.20.4)
47+
Fake.Core.String (>= 5.20.4)
48+
FSharp.Core (>= 4.7.2)
49+
FParsec (1.1.1)
50+
FSharp.Core (>= 4.3.4)
51+
FSharp.Control.Reactive (5.0.2)
52+
FSharp.Core (>= 4.7.2)
53+
System.Reactive (>= 5.0)
54+
FSharp.Core (5.0.2)
55+
System.Collections.Immutable (5.0)
56+
System.Reactive (5.0)
57+
58+
GROUP Test
59+
STORAGE: NONE
60+
RESTRICTION: == net5.0
61+
NUGET
62+
remote: https://api.nuget.org/v3/index.json
63+
FSharp.Core (5.0)
64+
Microsoft.CodeCoverage (16.11)
65+
Microsoft.NET.Test.Sdk (16.11)
66+
Microsoft.CodeCoverage (>= 16.11)
67+
Microsoft.TestPlatform.TestHost (>= 16.11)
68+
Microsoft.NETCore.Platforms (5.0.2)
69+
Microsoft.TestPlatform.ObjectModel (16.11)
70+
NuGet.Frameworks (>= 5.0)
71+
System.Reflection.Metadata (>= 1.6)
72+
Microsoft.TestPlatform.TestHost (16.11)
73+
Microsoft.TestPlatform.ObjectModel (>= 16.11)
74+
Newtonsoft.Json (>= 9.0.1)
75+
NETStandard.Library (2.0.3)
76+
Microsoft.NETCore.Platforms (>= 1.1)
77+
Newtonsoft.Json (13.0.1)
78+
NuGet.Frameworks (5.11)
79+
System.Reflection.Metadata (5.0)
80+
xunit (2.4.1)
81+
xunit.analyzers (>= 0.10)
82+
xunit.assert (2.4.1)
83+
xunit.core (2.4.1)
84+
xunit.abstractions (2.0.3)
85+
xunit.analyzers (0.10)
86+
xunit.assert (2.4.1)
87+
NETStandard.Library (>= 1.6.1)
88+
xunit.core (2.4.1)
89+
xunit.extensibility.core (2.4.1)
90+
xunit.extensibility.execution (2.4.1)
91+
xunit.extensibility.core (2.4.1)
92+
NETStandard.Library (>= 1.6.1)
93+
xunit.abstractions (>= 2.0.3)
94+
xunit.extensibility.execution (2.4.1)
95+
NETStandard.Library (>= 1.6.1)
96+
xunit.extensibility.core (2.4.1)
97+
xunit.runner.visualstudio (2.4.3)

paket.references

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
group Build
2+
3+
Fake.Core.Target
4+
Fake.IO.FileSystem

src/Fable.Python.fsproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
6+
<WarnOn>3390;$(WarnOn)</WarnOn>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<Compile Include="Json.fs" />
10+
</ItemGroup>
11+
<ItemGroup>
12+
<ProjectReference Include="../../Fable/src/Fable.Core/Fable.Core.fsproj" />
13+
</ItemGroup>
14+
<Import Project="..\.paket\Paket.Restore.targets" />
15+
</Project>

0 commit comments

Comments
 (0)