Skip to content

Avoid copy file when building libsass #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 12 additions & 19 deletions LibSass.NET.Tests/LibSass.NET.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,26 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LibSass.Tests</RootNamespace>
<AssemblyName>LibSass.NET.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>bin\$(Configuration)\obj\</IntermediateOutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<LibSassPath>$(SolutionDir)\bin\$(Configuration)\</LibSassPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down Expand Up @@ -119,13 +115,10 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
-->
<Target Name="AfterBuild">
<Copy SourceFiles="$(SolutionDir)$(OutDir)\libsass32.dll" DestinationFolder="$(TargetDir)" />
<Copy SourceFiles="$(SolutionDir)$(OutDir)\libsass64.dll" DestinationFolder="$(TargetDir)" />
<Copy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I've since hit with this one is DLL in use stuff, so it might be work setting the SkipUnchangedFiles="true"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree; however, most time is consumed on force compilation of LibSass project twice in LibSass.Net.csproj, since we are compiling everytime regardless of C/C++ source changes. The real difference at (solution level or even a single dependent project level) build time would be made when we use Rebuild instead of Build target there in MSBuild task which builds libsass. We cannot do that right now as Rebuild whips out the previous build artifacts (x64 rebuild will delete x86 build artifacts, regardless the TargetFile for x64 has different name..).

Another reason not to compile for many platforms at once.

Going forward, build for every architecture at single compile-time is neither feasible to build nor to test (x86, x64 and in future ARM, ARM64 etc. and then OS Linux-glibc, Linux-musl-libc, Mac, Windows etc. in future..) We would need to build one platform at a time (#47). Fixing #47 is next thing on my todo, after this PR is merged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think probably in Debug it should only compile the current achitecture, and leave the full matrix for the Release. Separate stuff though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate stuff

I have added SkipUnchangedFiles with 16b8f1c.

The problem may still persist as SkipUnchangedFiles checks for modified timestamp to detect the change, which in this case the DLL always gets build and modified so we might not get the desired effect unless we start building for one platform. Hence <MSBuild target="Rebuild" will ultimately fix this problem. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this only helps when your doing a Project Build instead of a Solution build. Thanks for fixing it though!

SourceFiles="$(LibSassPath)libsass32.dll;$(LibSassPath)libsass64.dll"
DestinationFolder="$(OutputPath)"
SkipUnchangedFiles="true" />
</Target>
</Project>
27 changes: 10 additions & 17 deletions LibSass.NET/LibSass.NET.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build;CopyLibSass" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -10,27 +10,24 @@
<RootNamespace>LibSass</RootNamespace>
<AssemblyName>LibSass.NET</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<OutputPath>$(SolutionDir)bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>$(SolutionDir)bin\$(Configuration)\obj\</IntermediateOutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>$(SolutionDir)bin\Debug\</OutputPath>
<IntermediateOutputPath>$(SolutionDir)bin\Debug\obj\</IntermediateOutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>$(SolutionDir)bin\Release\</OutputPath>
<IntermediateOutputPath>$(SolutionDir)bin\Release\obj\</IntermediateOutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Compiler\Context\FunctionHandling.cs" />
Expand Down Expand Up @@ -77,12 +74,8 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- Build LibSass -->
<Target Name="CopyLibSass" DependsOnTargets="BuildLibSass">
<Copy SourceFiles="$(OutDir)x86\libsass.dll" DestinationFiles="$(OutDir)libsass32.dll" />
<Copy SourceFiles="$(OutDir)x64\libsass.dll" DestinationFiles="$(OutDir)libsass64.dll" />
</Target>
<Target Name="BuildLibSass">
<MSBuild Targets="Build" Projects="..\LibSass\win\libsass.sln" BuildInParallel="true" Properties="Configuration=$(Configuration);Platform=Win32;OutDir=$(OutDir)x86\;IntDir=$(OutDir)x86\" />
<MSBuild Targets="Build" Projects="..\LibSass\win\libsass.sln" BuildInParallel="true" Properties="Configuration=$(Configuration);Platform=Win64;OutDir=$(OutDir)x64\;IntDir=$(OutDir)x64\" />
<Target Name="AfterBuild">
<MSBuild Targets="Build" Projects="..\LibSass\win\libsass.sln" BuildInParallel="true" Properties="Configuration=$(Configuration);Platform=Win32;TargetName=libsass32;OutDir=$(OutputPath);IntDir=$(IntermediateOutputPath)" />
<MSBuild Targets="Build" Projects="..\LibSass\win\libsass.sln" BuildInParallel="true" Properties="Configuration=$(Configuration);Platform=Win64;TargetName=libsass64;OutDir=$(OutputPath);IntDir=$(IntermediateOutputPath)" />
</Target>
</Project>
30 changes: 12 additions & 18 deletions contrib/LibSass.NET.Console/LibSass.NET.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,28 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LibSass.Console</RootNamespace>
<AssemblyName>LibSass.NET.Console</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>bin\$(Configuration)\obj\</IntermediateOutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<LibSassPath>$(SolutionDir)\bin\$(Configuration)\</LibSassPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand All @@ -52,13 +49,10 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
-->
<Target Name="AfterBuild">
<Copy SourceFiles="$(SolutionDir)$(OutDir)\libsass32.dll" DestinationFolder="$(TargetDir)" />
<Copy SourceFiles="$(SolutionDir)$(OutDir)\libsass64.dll" DestinationFolder="$(TargetDir)" />
<Copy
SourceFiles="$(LibSassPath)libsass32.dll;$(LibSassPath)libsass64.dll"
DestinationFolder="$(OutputPath)"
SkipUnchangedFiles="true" />
</Target>
</Project>
9 changes: 6 additions & 3 deletions contrib/LibSass.NET.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ namespace LibSass.Console
{
public class Program
{
public static void Main()
public static void Main(string[] args)
{
OutputEncoding = Encoding.Unicode;

const string inputPath = "test.scss";
string inputPath = args.Length > 0 ? args[0] : "test.scss";

if (!File.Exists(inputPath))
{
WriteLine($"Input file '{inputPath}' does not exist.");
WriteLine($"Input file '{inputPath}' does not exist.\n\nPress any key to continue..");
ReadKey();
return;
}
Expand Down Expand Up @@ -150,7 +150,10 @@ public static void Main()

var sass = new SassCompiler(sassOptions);
var result = sass.Compile();

WriteLine(result.ToString());
WriteLine("\n\nPress any key to continue..");

ReadKey();
}

Expand Down
24 changes: 11 additions & 13 deletions contrib/LibSass.NET.Web/LibSass.NET.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@
<RootNamespace>LibSass.Web</RootNamespace>
<AssemblyName>LibSass.NET.Web</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>bin\$(Configuration)\obj\</IntermediateOutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>512</FileAlignment>
<LibSassPath>$(SolutionDir)\bin\$(Configuration)\</LibSassPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down Expand Up @@ -55,13 +56,10 @@
<None Include="web.config.transform" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
-->
<Target Name="AfterBuild">
<Copy SourceFiles="$(SolutionDir)$(OutDir)\libsass32.dll" DestinationFolder="$(TargetDir)" />
<Copy SourceFiles="$(SolutionDir)$(OutDir)\libsass64.dll" DestinationFolder="$(TargetDir)" />
<Copy
SourceFiles="$(LibSassPath)libsass32.dll;$(LibSassPath)libsass64.dll"
DestinationFolder="$(OutputPath)"
SkipUnchangedFiles="true" />
</Target>
</Project>