Skip to content

Commit 8ad518e

Browse files
committed
Override fsharp source location via FSHARP_REPO env var.
1 parent 9a968e8 commit 8ad518e

3 files changed

Lines changed: 40 additions & 7 deletions

File tree

‎FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
<!-- for a local checkout and build of fsharp in CI -->
2424
<TargetPath Condition="Exists('..\fsharp\Build.cmd')">$(MSBuildThisFileDirectory)..\fsharp\artifacts\bin\FSharp.Compiler.Service\Debug\netstandard2.0\FSharp.Compiler.Service.dll</TargetPath>
25+
26+
<!-- for an existing checkout of fsharp, see FSHARP_REPO in build.fsx -->
27+
<TargetPath Condition="'$(FSHARP_REPO)' != '' And Exists('$(FSHARP_REPO)/Build.cmd')">$(FSHARP_REPO)/artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0/FSharp.Compiler.Service.dll</TargetPath>
2528

2629
</PropertyGroup>
2730
<PropertyGroup>

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ You need a .NET 10 SDK to run it. The default pipeline does the following:
2929

3030
To pick up new upstream changes, delete the `fsharp` folder and run the pipeline again.
3131

32+
To generate the docs from a dotnet/fsharp checkout you already have, for example a fork with
33+
docs changes in progress, point `FSHARP_REPO` at it. The clone step is skipped and that checkout
34+
is built and read in place:
35+
36+
FSHARP_REPO=~/Projects/fsharp dotnet fsi build.fsx
37+
3238
Once a build has run, iterate on the docs with live reload:
3339

3440
dotnet fsi build.fsx -- -p Watch

‎build.fsx‎

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@ open Fun.Build
77

88
let root = __SOURCE_DIRECTORY__
99

10-
/// A shallow clone of dotnet/fsharp main. It is git-ignored; the docs are generated from its
11-
/// `docs` folder and from the FSharp.Compiler.Service it builds.
12-
let fsharpDir = Path.Combine(root, "fsharp")
10+
/// Set this to the path of an existing dotnet/fsharp checkout to generate the docs from it
11+
/// instead of the shallow clone the pipeline makes. Handy when iterating on docs changes in
12+
/// a local fork: the clone stage is skipped and the checkout is built and read in place.
13+
let fsharpRepoEnvVar = "FSHARP_REPO"
14+
15+
/// The dotnet/fsharp checkout the docs are generated from: its `docs` folder and the
16+
/// FSharp.Compiler.Service it builds. By default a git-ignored shallow clone of main.
17+
let fsharpRepo = Environment.GetEnvironmentVariable fsharpRepoEnvVar
18+
19+
let fsharpDir =
20+
if String.IsNullOrEmpty fsharpRepo then
21+
Path.Combine(root, "fsharp")
22+
else
23+
Path.GetFullPath fsharpRepo
1324

1425
/// The SDK bootstrap script dotnet/fsharp ships. It runs its arguments with the exact SDK that
1526
/// `fsharp/global.json` asks for, installing it under `fsharp/.dotnet` first when this machine
@@ -25,7 +36,13 @@ let cloneStage =
2536
stage "clone fsharp" {
2637
run (fun ctx ->
2738
async {
28-
if Directory.Exists fsharpDir then
39+
if not (String.IsNullOrEmpty fsharpRepo) then
40+
if Directory.Exists fsharpDir then
41+
printfn $"Using the dotnet/fsharp checkout at {fsharpDir} ({fsharpRepoEnvVar})."
42+
return Ok()
43+
else
44+
return Error $"{fsharpRepoEnvVar} points to {fsharpDir}, which does not exist."
45+
elif Directory.Exists fsharpDir then
2946
printfn "fsharp/ already exists, not cloning. Delete it to start from a fresh checkout."
3047
return Ok()
3148
else
@@ -47,10 +64,16 @@ let restoreStage =
4764

4865
/// fsdocs targets a fixed .NET runtime. Let it run on whatever newer runtime the machine has,
4966
/// prereleases included, so the SDK dotnet/fsharp needs is also enough to run the tool.
67+
/// FSHARP_REPO is passed on so FSharp.Compiler.Service.fsproj resolves the assembly from the
68+
/// same checkout.
5069
let fsdocsEnv =
51-
[ "DOTNET_ROLL_FORWARD", "LatestMajor"; "DOTNET_ROLL_FORWARD_TO_PRERELEASE", "1" ]
70+
[ "DOTNET_ROLL_FORWARD", "LatestMajor"
71+
"DOTNET_ROLL_FORWARD_TO_PRERELEASE", "1"
72+
fsharpRepoEnvVar, fsharpDir ]
5273

53-
let fsdocsArgs = "--eval --sourcefolder fsharp --input fsharp/docs"
74+
let fsdocsArgs =
75+
let docsDir = Path.Combine(fsharpDir, "docs")
76+
$"--eval --sourcefolder \"{fsharpDir}\" --input \"{docsDir}\""
5477

5578
pipeline "Build" {
5679
description "Clone dotnet/fsharp, build FSharp.Compiler.Service and generate the docs into output/."
@@ -60,7 +83,8 @@ pipeline "Build" {
6083
restoreStage
6184
stage "docs" {
6285
envVars fsdocsEnv
63-
run $"dotnet fsdocs build {fsdocsArgs}"
86+
// --clean so pages from a previous build against another checkout never linger in output/.
87+
run $"dotnet fsdocs build --clean {fsdocsArgs}"
6488
}
6589
runIfOnlySpecified false
6690
}

0 commit comments

Comments
 (0)