summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstijn <stijn@ignitron.net>2020-09-10 12:11:58 +0200
committerDamien George <damien@micropython.org>2020-09-11 10:52:35 +1000
commit2a9ea69fa93b1b940b802f981f8835f6decdb085 (patch)
tree13599e7220c8556ffd135bf4b6fe0dc0374a667d
parent4b35aa5730cf26992453e3ce7cf74ced4128fe20 (diff)
windows/msvc: Support freezing modules.
Support freezing modules via manifest.py for consistency with the other ports. In essence this comes down to calling makemanifest.py and adding the resulting .c file to the build. Note the file with preprocessed qstrs has been renamed to match what makemanifest.py expects and which is also the name all other ports use.
-rw-r--r--ports/windows/micropython.vcxproj2
-rw-r--r--ports/windows/msvc/genhdr.targets17
2 files changed, 15 insertions, 4 deletions
diff --git a/ports/windows/micropython.vcxproj b/ports/windows/micropython.vcxproj
index f70fe9615..73a837a84 100644
--- a/ports/windows/micropython.vcxproj
+++ b/ports/windows/micropython.vcxproj
@@ -104,7 +104,7 @@
</ItemGroup>
<Import Project="msvc/genhdr.targets" />
<Import Project="$(CustomPropsFile)" Condition="exists('$(CustomPropsFile)')" />
- <Target Name="GenHeaders" BeforeTargets="BuildGenerateSources" DependsOnTargets="GenerateHeaders">
+ <Target Name="GenerateMicroPythonSources" BeforeTargets="BuildGenerateSources" DependsOnTargets="GenerateHeaders;FreezeModules">
</Target>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/ports/windows/msvc/genhdr.targets b/ports/windows/msvc/genhdr.targets
index 327f922e4..3af0ea263 100644
--- a/ports/windows/msvc/genhdr.targets
+++ b/ports/windows/msvc/genhdr.targets
@@ -55,7 +55,7 @@ using(var outFile = System.IO.File.CreateText(OutputFile)) {
<ItemGroup>
<PyIncDirs Include="$(PyIncDirs)"/>
<PreProcDefs Include="%(ClCompile.PreProcessorDefinitions);NO_QSTR"/>
- <PyQstrSourceFiles Include="@(ClCompile)">
+ <PyQstrSourceFiles Include="@(ClCompile)" Exclude="$(PyBuildDir)\frozen_content.c">
<OutFile>$([System.String]::new('%(FullPath)').Replace('$(PyBaseDir)', '$(DestDir)qstr\'))</OutFile>
</PyQstrSourceFiles>
<PyQstrSourceFiles>
@@ -101,8 +101,8 @@ using(var outFile = System.IO.File.CreateText(OutputFile)) {
<PropertyGroup>
<TmpFile>$(QstrGen).tmp</TmpFile>
</PropertyGroup>
- <Exec Command="$(PyClTool) /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D') /E $(PyQstrDefs) $(QstrDefs) > $(DestDir)qstrdefspreprocessed.h"/>
- <Exec Command="$(PyPython) $(PySrcDir)makeqstrdata.py $(DestDir)qstrdefspreprocessed.h $(QstrDefsCollected) > $(TmpFile)"/>
+ <Exec Command="$(PyClTool) /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D') /E $(PyQstrDefs) $(QstrDefs) > $(DestDir)qstrdefs.preprocessed.h"/>
+ <Exec Command="$(PyPython) $(PySrcDir)makeqstrdata.py $(DestDir)qstrdefs.preprocessed.h $(QstrDefsCollected) > $(TmpFile)"/>
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(QstrGen)"/>
</Target>
@@ -115,6 +115,17 @@ using(var outFile = System.IO.File.CreateText(OutputFile)) {
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/>
</Target>
+ <Target Name="FreezeModules" Condition="'$(FrozenManifest)' != ''" DependsOnTargets="MakeQstrData" Inputs="$(FrozenManifest)" Outputs="$(PyBuildDir)frozen_content.c">
+ <ItemGroup>
+ <ClCompile Include="$(PyBuildDir)frozen_content.c"/>
+ <ClCompile>
+ <PreprocessorDefinitions>MICROPY_MODULE_FROZEN_MPY=1;MICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ </ItemGroup>
+ <Exec Command="$(PyPython) $(PyBaseDir)tools\makemanifest.py -v MPY_DIR=$(PyBaseDir) -v MPY_LIB_DIR=$(PyBaseDir)../micropython-lib -v PORT_DIR=$(PyWinDir) -f&quot;-mcache-lookup-bc&quot; -o $(PyBuildDir)frozen_content.c -b $(PyBuildDir) $(FrozenManifest)"/>
+ <WriteLinesToFile File="$(TLogLocation)frozen.read.1.tlog" Lines="$(FrozenManifest)" Overwrite="True"/>
+ </Target>
+
<Target Name="RemoveGeneratedFiles" AfterTargets="Clean">
<RemoveDir Directories="$(DestDir)"/>
</Target>