Skip to content

Commit

Permalink
fix rebuild of files (#3614)
Browse files Browse the repository at this point in the history
* fix rebuild of files

* don't rebuild project system
  • Loading branch information
dsyme authored Sep 20, 2017
1 parent 194fa62 commit 966bd7f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ if "%OSARCH%"=="AMD64" set SYSWOW64=SysWoW64

if not "%OSARCH%"=="x86" set REGEXE32BIT=%WINDIR%\syswow64\reg.exe

echo SDK environment vars from Registry
echo SDK environment vars from Registry (note: ignore "ERROR: The system was unable to find ....")
echo ==================================
FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\WOW6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.6.2\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B
if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\WOW6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B
Expand Down
64 changes: 37 additions & 27 deletions src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,21 @@ open Printf

let generateResxAndSource (filename:string) =
try
let printMessage message = printfn "FSharpEmbedResourceText: %s" message
let justfilename = Path.GetFileNameWithoutExtension(filename) // .txt
if justfilename |> Seq.exists (System.Char.IsLetterOrDigit >> not) then
Err(filename, 0, sprintf "The filename '%s' is not allowed; only letters and digits can be used, as the filename also becomes the namespace for the SR class" justfilename)
let outFilename = Path.Combine(_outputPath, justfilename + ".fs")
let outXmlFilename = Path.Combine(_outputPath, justfilename + ".resx")
let printMessage message = printfn "FSharpEmbedResourceText: %s" message
let justfilename = Path.GetFileNameWithoutExtension(filename) // .txt
if justfilename |> Seq.exists (System.Char.IsLetterOrDigit >> not) then
Err(filename, 0, sprintf "The filename '%s' is not allowed; only letters and digits can be used, as the filename also becomes the namespace for the SR class" justfilename)
let outFilename = Path.Combine(_outputPath, justfilename + ".fs")
let outXmlFilename = Path.Combine(_outputPath, justfilename + ".resx")

if File.Exists(outFilename) &&
File.Exists(outXmlFilename) &&
File.Exists(filename) &&
File.GetLastWriteTime(filename) <= File.GetLastWriteTime(outFilename) &&
File.GetLastWriteTime(filename) <= File.GetLastWriteTime(outXmlFilename) then
printMessage (sprintf "Skipping generation of %s and %s since up-to-date" outFilename outXmlFilename)
Some (outFilename, outXmlFilename)
else

printMessage (sprintf "Reading %s" filename)
let lines = File.ReadAllLines(filename)
Expand Down Expand Up @@ -472,27 +481,28 @@ open Printf
with get() = _hostObject
and set(value) = _hostObject <- value
member this.Execute() =
let sourceItem (source:string) (originalItem:string) =
let item = TaskItem(source)
item.SetMetadata("AutoGen", "true")
item.SetMetadata("DesignTime", "true")
item.SetMetadata("DependentUpon", originalItem)
item :> ITaskItem
let resxItem (resx:string) =
let item = TaskItem(resx)
item.SetMetadata("ManifestResourceName", Path.GetFileNameWithoutExtension(resx))
item :> ITaskItem
let generatedFiles, generatedResult =

let generatedFiles =
this.EmbeddedText
|> Array.fold (fun (resultList, aggregateResult) item ->
match generateResxAndSource item.ItemSpec with
| Some (source, resx) -> (((source, resx) :: resultList), aggregateResult)
| None -> (resultList, false)
) ([], true)
|> Array.choose (fun item -> generateResxAndSource item.ItemSpec)

let generatedSource, generatedResx =
generatedFiles
|> List.map (fun (source, resx) -> (sourceItem source resx, resxItem resx))
|> List.fold (fun (sources, resxs) (source, resx) -> (source :: sources, resx:: resxs)) ([], [])
_generatedSource <- generatedSource |> List.rev |> List.toArray
_generatedResx <- generatedResx |> List.rev |> List.toArray
[| for (source, resx) in generatedFiles do
let sourceItem =
let item = TaskItem(source)
item.SetMetadata("AutoGen", "true")
item.SetMetadata("DesignTime", "true")
item.SetMetadata("DependentUpon", resx)
item :> ITaskItem
let resxItem =
let item = TaskItem(resx)
item.SetMetadata("ManifestResourceName", Path.GetFileNameWithoutExtension(resx))
item :> ITaskItem
yield (sourceItem, resxItem) |]
|> Array.unzip

let generatedResult = (generatedFiles.Length = this.EmbeddedText.Length)

_generatedSource <- generatedSource
_generatedResx <- generatedResx
generatedResult
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<PropertyGroup>
<Win32Resource>$(IntermediateOutputPath)\ProjectResources.rc.res</Win32Resource>
</PropertyGroup>
<Target Name="BeforeBuild">
<Target Name="BeforeBuild" Condition="!Exists('$(IntermediateOutputPath)$(RCResourceFile).res')">
<Exec Command="&quot;$(ProgramFiles)\Windows Kits\8.1\bin\x86\rc.exe&quot; /fo $(IntermediateOutputPath)$(RCResourceFile).res $(RCResourceFile)" Condition="Exists('$(ProgramFiles)\Windows Kits\8.1\bin\x86\rc.exe')" />
<Exec Command="&quot;$(ProgramFiles)\Windows Kits\10\bin\x86\rc.exe&quot; /fo $(IntermediateOutputPath)$(RCResourceFile).res $(RCResourceFile)" Condition="Exists('$(ProgramFiles)\Windows Kits\10\bin\x86\rc.exe')" />
<Exec Command="&quot;$(ProgramFiles)\Windows Kits\10\bin\10.0.15063.0\x86\rc.exe&quot; /fo $(IntermediateOutputPath)$(RCResourceFile).res $(RCResourceFile)" Condition="Exists('$(ProgramFiles)\Windows Kits\10\bin\10.0.15063.0\x86\rc.exe')" />
Expand Down

0 comments on commit 966bd7f

Please sign in to comment.