From 2bac47e293d822db2b98b0cd196d89f4d93c3f09 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Thu, 5 Sep 2024 15:16:03 +0800 Subject: [PATCH] WIP2 --- fsxc/Fsxc.fs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/fsxc/Fsxc.fs b/fsxc/Fsxc.fs index b23a619..140e32a 100644 --- a/fsxc/Fsxc.fs +++ b/fsxc/Fsxc.fs @@ -45,6 +45,8 @@ type ProgramInvocationType = | FsxLauncherScript | FsxcPureInvocation +type ExtraExtension = string + exception NoScriptProvided module Program = @@ -210,7 +212,7 @@ module Program = let GetBinFolderForAScript(script: FileInfo) = DirectoryInfo(Path.Combine(script.Directory.FullName, "bin")) - let GetAutoGenerationTargets (orig: FileInfo) (extension: string) = + let GetAutoGenerationTargets (orig: FileInfo) (extension: ExtraExtension) = let binDir = GetBinFolderForAScript(orig) let autogeneratedFileName = @@ -477,7 +479,7 @@ module Program = let preprocessScriptContents (origScript: FileInfo) (contents: List) - : List * FileInfo = + : List * List * FileInfo = #if LEGACY_FRAMEWORK // from "Microsoft.Build", "16.11.0" to .../packages/Microsoft.Build.16.11.0/lib/net472/Microsoft.Build.dll @@ -586,8 +588,8 @@ module FsxScriptInit type FsiStub = { CommandLineArgs: array } let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() } """ - - let autogeneratedFile = GetAutoGenerationTargets origScript "fs" + let extraExtensionForMain: ExtraExtension = "fs" + let autogeneratedFile = GetAutoGenerationTargets origScript extraExtensionForMain let binFolder = autogeneratedFile.Directory @@ -602,9 +604,12 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() } """ ) - let initFile = GetAutoGenerationTargets origScript "init.fs" + let extraExtensionForInitFile: ExtraExtension = "init.fs" + let initFile = GetAutoGenerationTargets origScript extraExtensionForInitFile File.WriteAllText(initFile.FullName, initialFileContent) + let extraExtensions = [extraExtensionForInitFile ; extraExtensionForMain] + seq { // for !LEGACY_FRAMEWORK, this init file will be added to the fsproj file #if LEGACY_FRAMEWORK @@ -690,6 +695,7 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() } ) } |> List.ofSeq, + extraExtensions, autogeneratedFile #if LEGACY_FRAMEWORK @@ -715,6 +721,7 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() } let generateProjectFile (origScript: FileInfo) (contents: List) + (extraExtensions: seq) : FileInfo = let projectFile = GetAutoGenerationTargets origScript "fsproj" @@ -813,7 +820,8 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() } iterate contents - addFile(sprintf "%s.fs" origScript.Name) + for ext in extraExtensions do + addFile(sprintf "%s.%s" origScript.Name ext) File.AppendAllText(projectFile.FullName, "") @@ -825,7 +833,7 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() } let binFolder = GetBinFolderForAScript script - let compilerInputs, autoGenFile = + let compilerInputs, extraExtensions, autoGenFile = preprocessScriptContents script contents Console.WriteLine( @@ -837,7 +845,7 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() } Console.WriteLine("_________________END AUTOGEN FILE_________________") #if !LEGACY_FRAMEWORK - let projectFile = generateProjectFile script contents + let projectFile = generateProjectFile script contents extraExtensions #endif let exitCode, exeTarget =