Skip to content

Commit 19d97ea

Browse files
authored
Merge pull request #201 from sass/build/win/gh-199
Ability to static compile VCR libs
2 parents eeb57a2 + 5ad492f commit 19d97ea

File tree

4 files changed

+90
-72
lines changed

4 files changed

+90
-72
lines changed

docs/building/unix-instructions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The executable will be in the bin folder. To run it, simply try something like
2424
```bash
2525
script/bootstrap
2626
```
27-
Alternately, if you already have libsass cloned or installed, you can edit your .bash_profile to include libsass directory:
27+
Alternately, if you already have libsass cloned or installed, you can edit your `.bash_profile` to include libsass directory:
2828
```bash
2929
export SASS_LIBSASS_PATH=/Users/you/path/libsass
3030
```

docs/building/windows-instructions.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ To build SassC, the following pre-requisites must be met:
77

88
Additionally, it is recommended to have `git` installed and available in `PATH`, so to deduce the `libsass` and `sassc` version information. For instance, if GitHub for Windows (https://windows.github.com/) is installed, the `PATH` will have an entry resembling: `X:\Users\<YOUR_NAME>\AppData\Local\GitHub\PortableGit_<SOME_GUID>\cmd\` (where `X` is the drive letter of system drive). If `git` is not available, inquiring the LibSass and SassC versions will result in `[NA]`.
99

10+
> Note that with `Debug` or `Release` we statically compile VC runtime libraries (e.g. `MSVCP140.dll`) in sassc.exe which result in self-dependent / portable binary that is comparatively large in size. There are separate build configurations for shared runtime: `Debug without static runtime` and `Release without static runtime`, which produce the binary dependent on [VS2015 Redistributable package](https://www.microsoft.com/en-gb/download/details.aspx?id=48145) on the target system. If your target system (where you want to execute sassc.exe) already has VCR (via redistributable pack or Visual Studio itself), it is highly recommended to use this shared configuration. This way when the shared runtime libs receive an updated (performance improvements or bug fixes), the statically compiled image will not be able to take advantage of such updates.
11+
1012
## Obtaining the Sources:
1113

1214
If `git` in available in `PATH`, open `cmd` or `PowerShell` and run:
@@ -40,32 +42,30 @@ Notice that in the following commands:
4042

4143
* If the platform is 32-bit Windows, replace `ProgramFiles(x86)` with `ProgramFiles`.
4244
* To build with Visual Studio 2015, replace `12.0` with `14.0` in the aforementioned command.
45+
* To build 32-bit binary, add `/p:Platform=Win32`.
46+
* To build 64-bit binary, add `/p:platform=Win64`.
4347

44-
In `cmd`, run:
48+
For example, in `cmd`, run:
4549

4650
```cmd
4751
cd projects\libsass\sassc
4852
49-
:: debug build:
50-
"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild" win\sassc.sln
51-
52-
:: or release build:
53-
"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild" win\sassc.sln /p:Configuration=Release
53+
:: 32-bit debug build with statically compiled runtime libs:
54+
"%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild" win\sassc.sln ^
55+
/p:Configuration=Debug /p:Platform=Win32
5456
```
5557

5658
In `PowerShell`, the above variant would be:
5759

5860
```powershell
5961
cd projects\libsass\sassc
6062
61-
# debug build:
62-
&"${env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild" win\sassc.sln
63-
64-
# or release build:
65-
&"${env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild" win\sassc.sln /p:Configuration=Release
63+
# 64-bit release build without statically compiled runtime libs:
64+
&"${env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild" win\sassc.sln `
65+
/p:Configuration='Release without static runtime' /p:Platform=Win64
6666
```
6767

68-
You can also override the `LIBSASS_DIR` path by agumenting msbuild properties, such as: `/p:LIBSASS_DIR=../../some/path/leading/to/libsass;Configuration=Release`.
68+
You can also override the `LIBSASS_DIR` path by augmenting msbuild properties, such as: `/p:LIBSASS_DIR=../../some/path/leading/to/libsass;Configuration=Release`.
6969

7070
The executable will be in the bin folder under sassc (`sassc\bin\sassc.exe`). To run it, simply try something like
7171

win/sassc.sln

+44-1
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,60 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
4+
VisualStudioVersion = 14.0.25420.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sassc", "sassc.vcxproj", "{E4030474-AFC9-4CC6-BEB6-D846F631502B}"
77
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".SolutionItems", ".SolutionItems", "{66CDE359-E53F-46E9-9B1E-EC30B50D30AF}"
9+
ProjectSection(SolutionItems) = preProject
10+
..\.editorconfig = ..\.editorconfig
11+
..\.gitignore = ..\.gitignore
12+
..\.travis.yml = ..\.travis.yml
13+
..\appveyor.yml = ..\appveyor.yml
14+
..\LICENSE = ..\LICENSE
15+
..\Readme.md = ..\Readme.md
16+
..\sassc_version.h.in = ..\sassc_version.h.in
17+
..\version.sh = ..\version.sh
18+
EndProjectSection
19+
EndProject
20+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{5CDEB969-5B7C-4653-BD2D-51D0222BD53D}"
21+
EndProject
22+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "building", "building", "{1B7DFCCC-9806-43B5-8739-5E2D9C55CE42}"
23+
ProjectSection(SolutionItems) = preProject
24+
..\docs\building\unix-instructions.md = ..\docs\building\unix-instructions.md
25+
..\docs\building\windows-instructions.md = ..\docs\building\windows-instructions.md
26+
EndProjectSection
27+
EndProject
28+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testing", "testing", "{4F8D4A73-7FE3-4602-8B46-68FEC98BD69E}"
29+
ProjectSection(SolutionItems) = preProject
30+
..\docs\testing\unix-instructions.md = ..\docs\testing\unix-instructions.md
31+
..\docs\testing\windows-instructions.md = ..\docs\testing\windows-instructions.md
32+
EndProjectSection
33+
EndProject
834
Global
935
GlobalSection(SolutionConfigurationPlatforms) = preSolution
36+
Debug without static runtime|Win32 = Debug without static runtime|Win32
37+
Debug without static runtime|Win64 = Debug without static runtime|Win64
1038
Debug|Win32 = Debug|Win32
1139
Debug|Win64 = Debug|Win64
40+
Release without static runtime|Win32 = Release without static runtime|Win32
41+
Release without static runtime|Win64 = Release without static runtime|Win64
1242
Release|Win32 = Release|Win32
1343
Release|Win64 = Release|Win64
1444
EndGlobalSection
1545
GlobalSection(ProjectConfigurationPlatforms) = postSolution
46+
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Debug without static runtime|Win32.ActiveCfg = Debug without static runtime|Win32
47+
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Debug without static runtime|Win32.Build.0 = Debug without static runtime|Win32
48+
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Debug without static runtime|Win64.ActiveCfg = Debug without static runtime|x64
49+
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Debug without static runtime|Win64.Build.0 = Debug without static runtime|x64
1650
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Debug|Win32.ActiveCfg = Debug|Win32
1751
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Debug|Win32.Build.0 = Debug|Win32
1852
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Debug|Win64.ActiveCfg = Debug|x64
1953
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Debug|Win64.Build.0 = Debug|x64
54+
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Release without static runtime|Win32.ActiveCfg = Release without static runtime|Win32
55+
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Release without static runtime|Win32.Build.0 = Release without static runtime|Win32
56+
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Release without static runtime|Win64.ActiveCfg = Release without static runtime|x64
57+
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Release without static runtime|Win64.Build.0 = Release without static runtime|x64
2058
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Release|Win32.ActiveCfg = Release|Win32
2159
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Release|Win32.Build.0 = Release|Win32
2260
{E4030474-AFC9-4CC6-BEB6-D846F631502B}.Release|Win64.ActiveCfg = Release|x64
@@ -25,4 +63,9 @@ Global
2563
GlobalSection(SolutionProperties) = preSolution
2664
HideSolutionNode = FALSE
2765
EndGlobalSection
66+
GlobalSection(NestedProjects) = preSolution
67+
{5CDEB969-5B7C-4653-BD2D-51D0222BD53D} = {66CDE359-E53F-46E9-9B1E-EC30B50D30AF}
68+
{1B7DFCCC-9806-43B5-8739-5E2D9C55CE42} = {5CDEB969-5B7C-4653-BD2D-51D0222BD53D}
69+
{4F8D4A73-7FE3-4602-8B46-68FEC98BD69E} = {5CDEB969-5B7C-4653-BD2D-51D0222BD53D}
70+
EndGlobalSection
2871
EndGlobal

win/sassc.vcxproj

+33-58
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
<Configuration>Debug</Configuration>
4242
<Platform>x64</Platform>
4343
</ProjectConfiguration>
44+
<ProjectConfiguration Include="Debug without static runtime|Win32">
45+
<Configuration>Debug without static runtime</Configuration>
46+
<Platform>Win32</Platform>
47+
</ProjectConfiguration>
48+
<ProjectConfiguration Include="Debug without static runtime|x64">
49+
<Configuration>Debug without static runtime</Configuration>
50+
<Platform>x64</Platform>
51+
</ProjectConfiguration>
4452
<ProjectConfiguration Include="Release|Win32">
4553
<Configuration>Release</Configuration>
4654
<Platform>Win32</Platform>
@@ -49,6 +57,14 @@
4957
<Configuration>Release</Configuration>
5058
<Platform>x64</Platform>
5159
</ProjectConfiguration>
60+
<ProjectConfiguration Include="Release without static runtime|Win32">
61+
<Configuration>Release without static runtime</Configuration>
62+
<Platform>Win32</Platform>
63+
</ProjectConfiguration>
64+
<ProjectConfiguration Include="Release without static runtime|x64">
65+
<Configuration>Release without static runtime</Configuration>
66+
<Platform>x64</Platform>
67+
</ProjectConfiguration>
5268
</ItemGroup>
5369
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
5470
<PropertyGroup Label="Globals">
@@ -69,34 +85,21 @@
6985
<PropertyGroup Label="VS2015 toolset selection" Condition="'$(VisualStudioVersion)' == '14.0'">
7086
<PlatformToolset>v140</PlatformToolset>
7187
</PropertyGroup>
72-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32' Or '$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
73-
<UseDebugLibraries>true</UseDebugLibraries>
74-
</PropertyGroup>
75-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32' Or '$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
76-
<UseDebugLibraries>false</UseDebugLibraries>
77-
<WholeProgramOptimization>true</WholeProgramOptimization>
78-
</PropertyGroup>
7988
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
8089
<ImportGroup Label="ExtensionSettings">
8190
</ImportGroup>
82-
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
83-
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
84-
</ImportGroup>
85-
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
86-
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
87-
</ImportGroup>
88-
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
89-
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
90-
</ImportGroup>
91-
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
91+
<ImportGroup Label="PropertySheets">
9292
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
9393
</ImportGroup>
9494
<PropertyGroup Label="UserMacros" />
95-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32' Or '$(Configuration)|$(Platform)' == 'Debug|x64'">
95+
<PropertyGroup Condition="$(Configuration.StartsWith('Debug'))">
9696
<LinkIncremental>true</LinkIncremental>
97+
<UseDebugLibraries>true</UseDebugLibraries>
9798
</PropertyGroup>
98-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32' Or '$(Configuration)|$(Platform)' == 'Release|x64'">
99+
<PropertyGroup Condition="$(Configuration.StartsWith('Release'))">
99100
<LinkIncremental>false</LinkIncremental>
101+
<UseDebugLibraries>false</UseDebugLibraries>
102+
<WholeProgramOptimization>true</WholeProgramOptimization>
100103
</PropertyGroup>
101104
<ItemDefinitionGroup>
102105
<ClCompile>
@@ -106,58 +109,30 @@
106109
<XMLDocumentationFileName>$(IntDir)/%(RelativeDir)/</XMLDocumentationFileName>
107110
</ClCompile>
108111
</ItemDefinitionGroup>
109-
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
112+
<ItemDefinitionGroup Condition="$(Configuration.StartsWith('Debug'))">
110113
<ClCompile>
111-
<PrecompiledHeader>
112-
</PrecompiledHeader>
113114
<WarningLevel>Level3</WarningLevel>
115+
<PrecompiledHeader></PrecompiledHeader>
114116
<Optimization>Disabled</Optimization>
115-
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
117+
<PreprocessorDefinitions Condition="'$(Platform)'=='Win32'">WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
118+
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">WIN64;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
119+
<RuntimeLibrary Condition="'$(Configuration)'!='Debug without static runtime'">MultiThreadedDebug</RuntimeLibrary>
116120
</ClCompile>
117121
<Link>
118122
<SubSystem>Console</SubSystem>
119123
<GenerateDebugInformation>true</GenerateDebugInformation>
120124
</Link>
121125
</ItemDefinitionGroup>
122-
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
123-
<ClCompile>
124-
<PrecompiledHeader>
125-
</PrecompiledHeader>
126-
<WarningLevel>Level3</WarningLevel>
127-
<Optimization>Disabled</Optimization>
128-
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
129-
</ClCompile>
130-
<Link>
131-
<SubSystem>Console</SubSystem>
132-
<GenerateDebugInformation>true</GenerateDebugInformation>
133-
</Link>
134-
</ItemDefinitionGroup>
135-
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
136-
<ClCompile>
137-
<WarningLevel>Level3</WarningLevel>
138-
<PrecompiledHeader>
139-
</PrecompiledHeader>
140-
<Optimization>MaxSpeed</Optimization>
141-
<FunctionLevelLinking>true</FunctionLevelLinking>
142-
<IntrinsicFunctions>true</IntrinsicFunctions>
143-
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
144-
</ClCompile>
145-
<Link>
146-
<SubSystem>Console</SubSystem>
147-
<GenerateDebugInformation>true</GenerateDebugInformation>
148-
<EnableCOMDATFolding>true</EnableCOMDATFolding>
149-
<OptimizeReferences>true</OptimizeReferences>
150-
</Link>
151-
</ItemDefinitionGroup>
152-
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
126+
<ItemDefinitionGroup Condition="$(Configuration.StartsWith('Release'))">
153127
<ClCompile>
154128
<WarningLevel>Level3</WarningLevel>
155-
<PrecompiledHeader>
156-
</PrecompiledHeader>
129+
<PrecompiledHeader></PrecompiledHeader>
157130
<Optimization>MaxSpeed</Optimization>
158131
<FunctionLevelLinking>true</FunctionLevelLinking>
159132
<IntrinsicFunctions>true</IntrinsicFunctions>
160-
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
133+
<PreprocessorDefinitions Condition="'$(Platform)'=='Win32'">WIN32;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
134+
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">WIN64;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
135+
<RuntimeLibrary Condition="'$(Configuration)'!='Release without static runtime'">MultiThreadedDebug</RuntimeLibrary>
161136
</ClCompile>
162137
<Link>
163138
<SubSystem>Console</SubSystem>
@@ -177,4 +152,4 @@
177152
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
178153
<ImportGroup Label="ExtensionTargets">
179154
</ImportGroup>
180-
</Project>
155+
</Project>

0 commit comments

Comments
 (0)