Skip to content

Commit

Permalink
Merge pull request #3751 from ncave/rust
Browse files Browse the repository at this point in the history
Use default value for Fantomas fsharp_array_or_list_multiline_formatter
  • Loading branch information
MangelMaxime authored Feb 11, 2024
2 parents c20e78d + 55dcd94 commit df40a18
Show file tree
Hide file tree
Showing 42 changed files with 672 additions and 5,148 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ fsharp_bar_before_discriminated_union_declaration = true
fsharp_multiline_bracket_style = aligned
fsharp_keep_max_number_of_blank_lines = 2
fsharp_record_multiline_formatter = number_of_items
fsharp_array_or_list_multiline_formatter = number_of_items
fsharp_align_function_signature_to_indentation = true
fsharp_multi_line_lambda_closing_newline = true
fsharp_max_if_then_else_short_width = 0
61 changes: 9 additions & 52 deletions build_old.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,7 @@ let buildLibraryTs () =
let buildDirTs = "./build/fable-library-ts"
let buildDirJs = "./build/fable-library"

cleanDirs
[
buildDirTs
buildDirJs
]
cleanDirs [ buildDirTs; buildDirJs ]

runInDir baseDir "npm install"

Expand Down Expand Up @@ -357,12 +353,7 @@ let buildLibraryDartIfNotExists () =
let testStandaloneFast () =
runFableWithArgs "src/fable-standalone/src" [ "--noCache" ]

runFableWithArgs
"src/fable-compiler-js/src"
[
"--exclude Fable.Core"
"--define LOCAL_TEST"
]
runFableWithArgs "src/fable-compiler-js/src" [ "--exclude Fable.Core"; "--define LOCAL_TEST" ]

let fableJs = "./src/fable-compiler-js/src/app.fs.js"
let testProj = "tests/Js/Main/Fable.Tests.fsproj"
Expand All @@ -389,12 +380,7 @@ let buildWorker
let fableLib = "./build/fable-library"
let distDir = "src/fable-standalone/dist"

runFableWithArgs
(projectDir + "/Worker")
[
"--outDir " + buildDir + "/worker"
"--fableLib " + fableLib
]
runFableWithArgs (projectDir + "/Worker") [ "--outDir " + buildDir + "/worker"; "--fableLib " + fableLib ]

let rollupTarget =
match opts.minify with
Expand Down Expand Up @@ -457,11 +443,7 @@ let buildStandalone

// cleanup
if not opts.watch then
cleanDirs
[
buildDir
distDir
]
cleanDirs [ buildDir; distDir ]

makeDirRecursive distDir

Expand Down Expand Up @@ -514,21 +496,11 @@ let buildCompilerJs (minify: bool) =
watch = false
|}

cleanDirs
[
buildDir
distDir
]
cleanDirs [ buildDir; distDir ]

makeDirRecursive distDir

runFableWithArgs
projectDir
[
"--outDir " + buildDir
"--fableLib " + fableLib
"--exclude Fable.Core"
]
runFableWithArgs projectDir [ "--outDir " + buildDir; "--fableLib " + fableLib; "--exclude Fable.Core" ]

let rollupTarget =
if minify then
Expand Down Expand Up @@ -584,13 +556,7 @@ let compileAndRunTestsWithMocha clean projectName =
if clean then
cleanDirs [ buildDir ]

runFableWithArgs
projectDir
[
"--outDir " + buildDir
"--fableLib " + fableLib
"--exclude Fable.Core"
]
runFableWithArgs projectDir [ "--outDir " + buildDir; "--fableLib " + fableLib; "--exclude Fable.Core" ]

runMocha buildDir

Expand Down Expand Up @@ -649,11 +615,7 @@ let testTypeScript isWatch =
let buildDir2 = "build/tests/TypeScriptCompiled"
let fableLib = "fable-library-ts"

cleanDirs
[
buildDir
buildDir2
]
cleanDirs [ buildDir; buildDir2 ]

copyFile (projectDir </> "tsconfig.json") (buildDir </> "tsconfig.json")

Expand Down Expand Up @@ -1025,12 +987,7 @@ match BUILD_ARGS_LOWER with
let runCmd =
$"npx concurrently \"tsc -w -p {srcDir} --outDir {dirname outPath}\" \"nodemon -w {outPath} {outPath}\""

watchFableWithArgs
srcDir
[
"--lang ts --watch --exclude Fable.Core --noCache --run"
runCmd
]
watchFableWithArgs srcDir [ "--lang ts --watch --exclude Fable.Core --noCache --run"; runCmd ]
| ("quicktest-py" | "quicktest-python") :: _ ->
buildLibraryPyIfNotExists ()

Expand Down
6 changes: 1 addition & 5 deletions src/Fable.AST/Fable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,7 @@ type Type =
| Option(gen, _)
| Array(gen, _)
| List gen -> [ gen ]
| LambdaType(argType, returnType) ->
[
argType
returnType
]
| LambdaType(argType, returnType) -> [ argType; returnType ]
| DelegateType(argTypes, returnType) -> argTypes @ [ returnType ]
| Tuple(gen, _) -> gen
| DeclaredType(_, gen) -> gen
Expand Down
11 changes: 1 addition & 10 deletions src/Fable.Build/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,7 @@ type Path =
/// Resolve a path relative to the repository root
/// </summary>
static member Resolve([<ParamArray>] segments: string array) : string =
let paths =
Array.concat
[
[|
__SOURCE_DIRECTORY__
".."
".."
|]
segments
]
let paths = Array.concat [ [| __SOURCE_DIRECTORY__; ".."; ".." |]; segments ]

// Use GetFullPath to clean the path
Path.GetFullPath(Path.Combine(paths))
Expand Down
7 changes: 1 addition & 6 deletions src/Fable.Build/Utils/ChangelogParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,7 @@ module Transform =
let fromSymbols (symbols: Symbols list) = parse symbols Changelog.Empty

let parse (changelogContent: string) =
changelogContent.Split(
[|
'\r'
'\n'
|]
)
changelogContent.Split([| '\r'; '\n' |])
|> Array.toList
|> Lexer.toSymbols
|> Transform.fromSymbols
Expand Down
9 changes: 1 addition & 8 deletions src/Fable.Cli/BuildalyzerCrackerResolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,7 @@ If you see this file in your project, you can delete it safely"""
// to their expected state
let projDir = IO.Path.GetDirectoryName projectFile

Process.runSync
projDir
"dotnet"
[
"restore"
projectFile
]
|> ignore
Process.runSync projDir "dotnet" [ "restore"; projectFile ] |> ignore

let compilerArgs, result =
csprojResult
Expand Down
53 changes: 12 additions & 41 deletions src/Fable.Cli/Entry.fs
Original file line number Diff line number Diff line change
Expand Up @@ -59,35 +59,23 @@ type CliArgs(args: string list) =
let knownCliArgs () =
[
[ "--cwd" ], [ "Working directory" ]
[
"-o"
"--outDir"
],
[ "Redirect compilation output to a directory" ]
[
"-e"
"--extension"
],
[ "Extension for generated JS files (default .fs.js)" ]
[
"-s"
"--sourceMaps"
],
[ "Enable source maps" ]
[ "-o"; "--outDir" ], [ "Redirect compilation output to a directory" ]
[ "-e"; "--extension" ], [ "Extension for generated JS files (default .fs.js)" ]
[ "-s"; "--sourceMaps" ], [ "Enable source maps" ]
[ "--sourceMapsRoot" ], [ "Set the value of the `sourceRoot` property in generated source maps" ]
[], []
[ "--define" ], [ "Defines a symbol for use in conditional compilation" ]
[
"-c"
"--configuration"
],
[ "-c"; "--configuration" ],
[
"The configuration to use when parsing .fsproj with MSBuild,"
"default is 'Debug' in watch mode, or 'Release' otherwise"
]
[ "--verbose" ], [ "Print more info during compilation" ]
[ "--silent" ], [ "Don't print any log during compilation" ]
[ "--typedArrays" ], [ "Compile numeric arrays as JS typed arrays (default is true for JS, false for TS)" ]
[ "--typedArrays" ],
[
"Compile numeric arrays as JS typed arrays (default is true for JS, false for TS)"
]
[ "--watch" ], [ "Alias of watch command" ]
[ "--watchDelay" ], [ "Delay in ms before recompiling after a file changes (default 200)" ]
[], []
Expand All @@ -110,10 +98,7 @@ let knownCliArgs () =
]
[], []
[ "--optimize" ], [ "Compile with optimized F# AST (experimental)" ]
[
"--lang"
"--language"
],
[ "--lang"; "--language" ],
[
"Choose wich languages to compile to"
""
Expand Down Expand Up @@ -150,11 +135,7 @@ let printKnownCliArgs () =

match desc with
| [] -> [] // Args without description are hidden
| desc :: extraLines ->
[
$" %-18s{args}{desc}"
yield! extraLines |> List.map (sprintf "%20s%s" "")
]
| desc :: extraLines -> [ $" %-18s{args}{desc}"; yield! extraLines |> List.map (sprintf "%20s%s" "") ]
)

let sanitizeCliArgs (args: CliArgs) =
Expand Down Expand Up @@ -297,11 +278,7 @@ type Runner =
| _ -> Ok()

do!
let reservedDirs =
[
Naming.fableModules
"obj"
]
let reservedDirs = [ Naming.fableModules; "obj" ]

let outDirLast =
outDir
Expand Down Expand Up @@ -420,13 +397,7 @@ type Runner =
}

let clean (args: CliArgs) language rootDir =
let ignoreDirs =
set
[
"bin"
"obj"
"node_modules"
]
let ignoreDirs = set [ "bin"; "obj"; "node_modules" ]

let outDir = args.Value("-o", "--outDir")

Expand Down
29 changes: 4 additions & 25 deletions src/Fable.Cli/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,8 @@ module private Util =
let modules =
absPath
.Substring(outDir.Length, absPath.Length - outDir.Length - fileName.Length)
.Trim(
[|
'/'
'\\'
|]
)
.Split(
[|
'/'
'\\'
|]
)
.Trim([| '/'; '\\' |])
.Split([| '/'; '\\' |])

let modules =
match Array.toList modules, cliArgs.FableLibraryPath with
Expand Down Expand Up @@ -276,13 +266,7 @@ open FileWatcher
open FileWatcherUtil

type FsWatcher(delayMs: int) =
let globFilters =
[
"*.fs"
"*.fsi"
"*.fsx"
"*.fsproj"
]
let globFilters = [ "*.fs"; "*.fsi"; "*.fsx"; "*.fsproj" ]

let createWatcher () =
let usePolling =
Expand All @@ -298,12 +282,7 @@ type FsWatcher(delayMs: int) =
Log.always ("Using polling watcher.")
// Ignored for performance reasons:
let ignoredDirectoryNameRegexes =
[
"(?i)node_modules"
"(?i)bin"
"(?i)obj"
"\..+"
]
[ "(?i)node_modules"; "(?i)bin"; "(?i)obj"; "\..+" ]

upcast new ResetablePollingFileWatcher(globFilters, ignoredDirectoryNameRegexes)
else
Expand Down
17 changes: 2 additions & 15 deletions src/Fable.Compiler/Globbing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,7 @@ module Glob =
let normPattern = normalizePath pattern

let patternParts =
normPattern.Split(
[|
'/'
'\\'
|],
StringSplitOptions.RemoveEmptyEntries
)
normPattern.Split([| '/'; '\\' |], StringSplitOptions.RemoveEmptyEntries)

let patternPathParts =
patternParts |> Seq.takeWhile (fun p -> not (p.Contains("*"))) |> Seq.toArray
Expand Down Expand Up @@ -158,14 +152,7 @@ module Glob =

let filePattern = Path.GetFileName(input)

let splits =
input.Split(
[|
'/'
'\\'
|],
StringSplitOptions.None
)
let splits = input.Split([| '/'; '\\' |], StringSplitOptions.None)

let baseItems =
let start, rest =
Expand Down
Loading

0 comments on commit df40a18

Please sign in to comment.