diff options
Diffstat (limited to 'windows/msvc')
-rw-r--r-- | windows/msvc/common.props | 22 | ||||
-rw-r--r-- | windows/msvc/debug.props | 13 | ||||
-rw-r--r-- | windows/msvc/genhdr.targets | 76 | ||||
-rw-r--r-- | windows/msvc/release.props | 16 | ||||
-rw-r--r-- | windows/msvc/snprintf.c | 44 | ||||
-rw-r--r-- | windows/msvc/sources.props | 17 | ||||
-rw-r--r-- | windows/msvc/unistd.h | 28 |
7 files changed, 216 insertions, 0 deletions
diff --git a/windows/msvc/common.props b/windows/msvc/common.props new file mode 100644 index 0000000000..300de46a53 --- /dev/null +++ b/windows/msvc/common.props @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ImportGroup Label="PropertySheets" />
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <OutDir>$(ProjectDir)</OutDir>
+ <IntDir>$(ProjectDir)build\$(Configuration)$(Platform)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalIncludeDirectories>.\;.\build;.\msvc;..\py</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>false</SDLCheck>
+ <WarningLevel>Level1</WarningLevel>
+ <ExceptionHandling>false</ExceptionHandling>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup />
+</Project>
\ No newline at end of file diff --git a/windows/msvc/debug.props b/windows/msvc/debug.props new file mode 100644 index 0000000000..c0a22be854 --- /dev/null +++ b/windows/msvc/debug.props @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ImportGroup Label="PropertySheets" /> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + </PropertyGroup> + <ItemDefinitionGroup> + <ClCompile> + <PreprocessorDefinitions>DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + </ItemDefinitionGroup> + <ItemGroup /> +</Project> diff --git a/windows/msvc/genhdr.targets b/windows/msvc/genhdr.targets new file mode 100644 index 0000000000..453d2ff1eb --- /dev/null +++ b/windows/msvc/genhdr.targets @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="GenerateHeaders"> + + <Target Name="GenerateHeaders" DependsOnTargets="MakeQstrData;MakeVersionHeader"> + </Target> + + <PropertyGroup> + <SrcDir>$(MsBuildThisFileDirectory)..\..\py\</SrcDir> + <DestDir>$(MsBuildThisFileDirectory)..\build\genhdr\</DestDir> + </PropertyGroup> + + <Target Name="MakeDestDir"> + <MakeDir Directories="$(DestDir)"/> + </Target> + + <!--don't let regenerating these files trigger builds--> + <UsingTask TaskName="MakeSameWriteTime" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" > + <ParameterGroup> + <SourceFile Required="true" ParameterType="System.String"/> + <DestFile Required="true" ParameterType="System.String"/> + </ParameterGroup> + <Task> + <Code Type="Fragment" Language="cs"> + <![CDATA[ + System.IO.File.SetLastWriteTime( DestFile, System.IO.File.GetLastWriteTime( SourceFile ) ); + ]]> + </Code> + </Task> + </UsingTask> + + <!--see py/py.mk under #qstr data--> + <Target Name="MakeQstrData" DependsOnTargets="MakeDestDir"> + <PropertyGroup> + <PreProc>$(DestDir)qstrdefs.preprocessed.h</PreProc> + <QstrDefs>$(MsBuildThisFileDirectory)..\..\unix\qstrdefsport.h</QstrDefs> + <DestFile>$(DestDir)qstrdefs.generated.h</DestFile> + </PropertyGroup> + <Exec Command="cl /I$(SrcDir) /I$(MsBuildThisFileDirectory).. /Fi$(PreProc) /P $(SrcDir)qstrdefs.h"/> + <Exec Command="python $(SrcDir)makeqstrdata.py $(PreProc) $(QstrDefs) > $(DestFile)"/> + <MakeSameWriteTime SourceFile="$(MsBuildThisFile)" DestFile="$(DestFile)"/> + </Target> + + <!--see py/py-version.sh--> + <Target Name="GetGitState"> + <Exec Command="git describe --dirty --always" ConsoleToMSBuild="true" IgnoreExitCode="true"> + <Output TaskParameter="ConsoleOutput" PropertyName="GitTag" /> + </Exec> + <Exec Command="git rev-parse --short HEAD 2>NUL || echo unknown" ConsoleToMSBuild="true" IgnoreExitCode="true"> + <Output TaskParameter="ConsoleOutput" PropertyName="GitHash" /> + </Exec> + <Exec Command="git diff --no-ext-diff --quiet --exit-code 2>NUL || echo 0" ConsoleToMSBuild="true" IgnoreExitCode="true"> + <Output TaskParameter="ConsoleOutput" PropertyName="GitFilesAreClean" /> + </Exec> + <Exec Command="git diff-index --cached --quiet HEAD -- 2>NUL || echo 0" ConsoleToMSBuild="true" IgnoreExitCode="true" Condition="'$(GitFilesAreClean)'==''"> + <Output TaskParameter="ConsoleOutput" PropertyName="GitFilesAreClean" /> + </Exec> + </Target> + + <Target Name="MakeVersionHeader" DependsOnTargets="MakeDestDir;GetGitState"> + <PropertyGroup Condition="'$(GitFilesAreClean)'=='0'"> + <GitHash>$(GitHash)-dirty</GitHash> + </PropertyGroup> + <PropertyGroup> + <DestFile>$(DestDir)py-version.h</DestFile> + </PropertyGroup> + <ItemGroup> + <Lines Include="// This file was generated by $([System.IO.Path]::GetFileName(`$(MsBuildThisFile)`))"/> + <Lines Include="#define MICROPY_GIT_TAG "$(GitTag)""/> + <Lines Include="#define MICROPY_GIT_HASH "$(GitHash)""/> + <Lines Include="#define MICROPY_BUILD_DATE "$([System.DateTime]::Now.ToString(`yyyy-MM-dd`))""/> + </ItemGroup> + <WriteLinesToFile Lines="@(Lines)" File="$(DestFile)" Overwrite="true"/> + <MakeSameWriteTime SourceFile="$(MsBuildThisFile)" DestFile="$(DestFile)"/> + </Target> + +</Project> diff --git a/windows/msvc/release.props b/windows/msvc/release.props new file mode 100644 index 0000000000..ea0bf433d3 --- /dev/null +++ b/windows/msvc/release.props @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ImportGroup Label="PropertySheets" /> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup /> + <ItemDefinitionGroup> + <Link> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + </Link> + <ClCompile> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + </ItemDefinitionGroup> + <ItemGroup /> +</Project> diff --git a/windows/msvc/snprintf.c b/windows/msvc/snprintf.c new file mode 100644 index 0000000000..d200a4cbc8 --- /dev/null +++ b/windows/msvc/snprintf.c @@ -0,0 +1,44 @@ +/* +* This file is part of the Micro Python project, http://micropython.org/ +* +* The MIT License (MIT) +* +* Copyright (c) 2013, 2014 Damien P. George +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include <stdarg.h> +#include <stdio.h> +#include <malloc.h> + +// _snprintf/vsnprintf are fine, except the 'F' specifier is not handled +int snprintf(char *dest, size_t count, const char *format, ...) { + const size_t fmtLen = strlen(format) + 1; + char *fixedFmt = alloca(fmtLen); + for (size_t i = 0; i < fmtLen; ++i) + fixedFmt[i] = format[i] == 'F' ? 'f' : format[i]; + + va_list args; + va_start(args, format); + const int ret = vsnprintf(dest, count, fixedFmt, args); + va_end(args); + + return ret; +} diff --git a/windows/msvc/sources.props b/windows/msvc/sources.props new file mode 100644 index 0000000000..9af7d6e117 --- /dev/null +++ b/windows/msvc/sources.props @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <PyBaseDir>$(MsbuildThisFileDirectory)..\..\</PyBaseDir> + </PropertyGroup> + <ItemGroup> + <ClCompile Include="$(PyBaseDir)py\*.c" /> + <ClCompile Include="$(PyBaseDir)unix\*.c" Exclude="$(PyBaseDir)unix\mod*.c" /> + <ClCompile Include="$(PyBaseDir)windows\*.c" /> + <ClCompile Include="$(PyBaseDir)windows\msvc\*.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="$(PyBaseDir)py\*.h" /> + <ClInclude Include="$(PyBaseDir)windows\*.h" /> + <ClInclude Include="$(PyBaseDir)windows\msvc\*.h" /> + </ItemGroup> +</Project> diff --git a/windows/msvc/unistd.h b/windows/msvc/unistd.h new file mode 100644 index 0000000000..ece86fa749 --- /dev/null +++ b/windows/msvc/unistd.h @@ -0,0 +1,28 @@ +/* +* This file is part of the Micro Python project, http://micropython.org/ +* +* The MIT License (MIT) +* +* Copyright (c) 2013, 2014 Damien P. George +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +// There's no unistd.h, but this is the equivalent +#include <io.h> |