From e0f5c553b48f9f9f0fdc79c235431791c2b4bb72 Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 6 Dec 2023 16:42:31 +0100 Subject: [PATCH] Remove temporary sample project. --- Fable.sln | 7 -- tests/FCSTest/FCSTest.fsproj | 23 ---- tests/FCSTest/Program.fs | 211 ----------------------------------- 3 files changed, 241 deletions(-) delete mode 100644 tests/FCSTest/FCSTest.fsproj delete mode 100644 tests/FCSTest/Program.fs diff --git a/Fable.sln b/Fable.sln index ea3c74f1bf..b9aba20c23 100644 --- a/Fable.sln +++ b/Fable.sln @@ -64,8 +64,6 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fable.Build", "src\Fable.Bu EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fable.Compiler", "src\Fable.Compiler\Fable.Compiler.fsproj", "{942DD29B-07C0-4ACF-891E-85C1235A9BE0}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FCSTest", "tests\FCSTest\FCSTest.fsproj", "{81642B88-A7A2-4BBB-8EAD-0584C018D370}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -168,10 +166,6 @@ Global {942DD29B-07C0-4ACF-891E-85C1235A9BE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {942DD29B-07C0-4ACF-891E-85C1235A9BE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {942DD29B-07C0-4ACF-891E-85C1235A9BE0}.Release|Any CPU.Build.0 = Release|Any CPU - {81642B88-A7A2-4BBB-8EAD-0584C018D370}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {81642B88-A7A2-4BBB-8EAD-0584C018D370}.Debug|Any CPU.Build.0 = Debug|Any CPU - {81642B88-A7A2-4BBB-8EAD-0584C018D370}.Release|Any CPU.ActiveCfg = Release|Any CPU - {81642B88-A7A2-4BBB-8EAD-0584C018D370}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -202,7 +196,6 @@ Global {C90E23AF-4B5B-44A7-ADCC-3BF89547395B} = {DA29278E-3808-42DE-8333-964F129F295D} {F2E323CE-FDF3-4A1E-AE97-B723D2E63763} = {C8CB96CF-68A8-4083-A0F8-319275CF8097} {942DD29B-07C0-4ACF-891E-85C1235A9BE0} = {C8CB96CF-68A8-4083-A0F8-319275CF8097} - {81642B88-A7A2-4BBB-8EAD-0584C018D370} = {CF0A8EC3-841F-4A54-B9FC-8D174CCD4A90} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {58DF9285-8523-4EAC-B598-BE5B02A76A00} diff --git a/tests/FCSTest/FCSTest.fsproj b/tests/FCSTest/FCSTest.fsproj deleted file mode 100644 index 98daab645f..0000000000 --- a/tests/FCSTest/FCSTest.fsproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - Exe - net8.0 - - - - - - - - - - - - - - - - - - diff --git a/tests/FCSTest/Program.fs b/tests/FCSTest/Program.fs deleted file mode 100644 index 9e3143a9c2..0000000000 --- a/tests/FCSTest/Program.fs +++ /dev/null @@ -1,211 +0,0 @@ -open System -open System.Diagnostics -open System.IO -open System.Text.Json -open FSharp.Compiler.SourceCodeServices -open FSharp.Compiler.CodeAnalysis -open Fable -open Fable.Compiler.Util -open Fable.Compiler.ProjectCracker -open Fable.Compiler.CodeServices - -let pwd = @"C:\Users\nojaf\Projects\vite-plugin-fable\sample-project" -let fsprojPath = Path.Combine(pwd, "App.fsproj") - -// module CoolCatProjectCracking = -// -// let fsharpFiles = set [| ".fs"; ".fsi"; ".fsx" |] -// -// let isFSharpFile (file: string) = -// Seq.exists (fun (ext: string) -> file.EndsWith ext) fsharpFiles -// -// let mkOptions (fsproj: string) (compilerArgs: string array) = -// let projectDir = Path.GetDirectoryName(fsproj) -// -// let sourceFiles = -// compilerArgs -// |> Array.choose (fun (line: string) -> -// let filePath = Path.Combine(projectDir, line) -// -// if -// isFSharpFile line -// && File.Exists filePath -// && not (filePath.Contains "obj") -// then -// Some(Path.normalizeFullPath filePath) -// else -// None -// ) -// -// let otherOptions = [| -// yield! -// compilerArgs -// |> Array.filter (fun line -> not (isFSharpFile line)) -// yield "--define:FABLE_COMPILER" -// yield "--define:FABLE_COMPILER_4" -// yield "--define:FABLE_COMPILER_JAVASCRIPT" -// |] -// -// { -// ProjectFileName = "Project" -// ProjectId = None -// SourceFiles = sourceFiles -// OtherOptions = otherOptions -// ReferencedProjects = [||] -// IsIncompleteTypeCheckEnvironment = false -// UseScriptResolutionRules = false -// LoadTime = DateTime.Now -// UnresolvedReferences = None -// OriginalLoadReferences = [] -// Stamp = None -// } -// -// let dotnet pwd args = -// let psi = ProcessStartInfo "dotnet" -// psi.WorkingDirectory <- pwd -// psi.Arguments <- args -// psi.RedirectStandardOutput <- true -// psi.UseShellExecute <- false -// use ps = new Process() -// ps.StartInfo <- psi -// ps.Start() |> ignore -// let output = ps.StandardOutput.ReadToEnd() -// ps.WaitForExit() -// output.Trim() -// -// let mkOptionsFromDesignTimeBuild -// (fsproj: string) -// (additionalArguments: string) -// = -// if not (File.Exists fsproj) then -// invalidArg (nameof fsproj) $"\"%s{fsproj}\" does not exist." -// -// // Move fsproj to temp folder -// let pwd = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString "N") -// -// try -// let dir = DirectoryInfo pwd -// dir.Create() -// -// let version = dotnet pwd "--version" -// -// if version <> "8.0.100-rc.2.23502.2" then -// failwith -// $"Expected the SDK to be 8.0.100-rc.2.23502.2 in %s{pwd}" -// -// let tmpFsproj = Path.Combine(pwd, Path.GetFileName fsproj) -// File.Copy(fsproj, tmpFsproj) -// -// let targets = -// "Restore,ResolveAssemblyReferencesDesignTime,ResolveProjectReferencesDesignTime,ResolvePackageDependenciesDesignTime,FindReferenceAssembliesForReferences,_GenerateCompileDependencyCache,_ComputeNonExistentFileProperty,BeforeBuild,BeforeCompile,CoreCompile" -// -// let json = -// dotnet -// pwd -// $"msbuild /t:%s{targets} /p:DesignTimeBuild=True /p:SkipCompilerExecution=True /p:ProvideCommandLineArgs=True --getItem:FscCommandLineArgs %s{additionalArguments}" -// -// let jsonDocument = JsonDocument.Parse json -// -// let options = -// jsonDocument.RootElement -// |> fun root -> -// root -// .GetProperty("Items") -// .GetProperty("FscCommandLineArgs") -// .EnumerateArray() -// |> Seq.map (fun arg -> arg.GetProperty("Identity").GetString()) -// |> Seq.toArray -// -// mkOptions fsproj options -// finally -// if Directory.Exists pwd then -// Directory.Delete(pwd, true) -// -// let fsprojOptions = -// let sw = Stopwatch() -// sw.Start() -// -// let options = -// CoolCatProjectCracking.mkOptionsFromDesignTimeBuild fsprojPath "" -// -// sw.Stop() -// printfn "Cracking took: %A" sw.Elapsed -// options - -// let crackerResponse: CrackerResponse = { -// FableLibDir = -// @$"{pwd}\fable_modules\fable-library.4.3.0" -// FableModulesDir = @$"{pwd}\fable_modules" -// References = [] -// ProjectOptions = fsprojOptions -// OutputType = OutputType.Library -// TargetFramework = "net6.0" -// PrecompiledInfo = None -// CanReuseCompiledFiles = false -// } - -let cliArgs: CliArgs = { - ProjectFile = @$"{pwd}\App.fsproj" - RootDir = pwd - OutDir = None - IsWatch = false - Precompile = false - PrecompiledLib = None - PrintAst = false - FableLibraryPath = None - Configuration = "Release" - NoRestore = true - NoCache = true - NoParallelTypeCheck = false - SourceMaps = false - SourceMapsRoot = None - Exclude = [] - Replace = Map.empty - CompilerOptions = { - TypedArrays = false - ClampByteArrays = false - Language = Language.JavaScript - Define = [ - "FABLE_COMPILER" - "FABLE_COMPILER_4" - "FABLE_COMPILER_JAVASCRIPT" - ] - DebugMode = false - OptimizeFSharpAst = false - Verbosity = Verbosity.Verbose - FileExtension = ".js" - TriggeredByDependency = false - NoReflection = false - } - RunProcess = None -} - -let crackerOptions = CrackerOptions(cliArgs) -let crackerResponse = getFullProjectOpts crackerOptions -let checker = InteractiveChecker.Create(crackerResponse.ProjectOptions) - -let sourceReader = - Fable.Compiler.File.MakeSourceReader( - Array.map Fable.Compiler.File crackerResponse.ProjectOptions.SourceFiles - ) - |> snd - -let dummyPathResolver = - { new PathResolver with - member _.TryPrecompiledOutPath(_sourceDir, _relativePath) = None - member _.GetOrAddDeduplicateTargetDir(_importDir, _addTargetDir) = "" - } - -let compiledFiles = - compileProjectToJavaScript - sourceReader - checker - dummyPathResolver - cliArgs - crackerResponse - |> Async.RunSynchronously - -let libKey = compiledFiles.Keys |> Seq.find (fun f -> f.EndsWith("Library.fs")) -let javascript = compiledFiles.[libKey] - -printfn "this is javascript:\n%s" javascript