| 1 | ## Building LibSass with Visual Studio |
| 2 | |
| 3 | ### Requirements: |
| 4 | |
| 5 | The minimum requirement to build LibSass with Visual Studio is "Visual Studio 2013 Express for Desktop". |
| 6 | |
| 7 | Additionally, it is recommended to have `git` installed and available in `PATH`, so to deduce the `libsass` 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 version will result in `[NA]`. |
| 8 | |
| 9 | ### Build Steps: |
| 10 | |
| 11 | #### From Visual Studio: |
| 12 | |
| 13 | On opening the `win\libsass.sln` solution and build (Ctrl+Shift+B) to build `libsass.dll`. |
| 14 | |
| 15 | To Build LibSass as a static Library, it is recommended to set an environment variable `LIBSASS_STATIC_LIB` before launching the project: |
| 16 | |
| 17 | ```cmd |
| 18 | cd path\to\libsass |
| 19 | SET LIBSASS_STATIC_LIB=1 |
| 20 | :: |
| 21 | :: or in PowerShell: |
| 22 | :: $env:LIBSASS_STATIC_LIB=1 |
| 23 | :: |
| 24 | win\libsass.sln |
| 25 | ``` |
| 26 | |
| 27 | Visual Studio will form the filtered source tree as shown below: |
| 28 | |
| 29 |  |
| 30 | |
| 31 | `Header Files` contains the .h and .hpp files, while `Source Files` covers `.c` and `.cpp`. The other used headers/sources will appear under `External Dependencies`. |
| 32 | |
| 33 | If there is a LibSass code file appearing under External Dependencies, it can be changed by altering the `win\libsass.vcxproj.filters` file or dragging in Solution Explorer. |
| 34 | |
| 35 | #### From Command Prompt: |
| 36 | |
| 37 | Notice that in the following commands: |
| 38 | |
| 39 | * If the platform is 32-bit Windows, replace `ProgramFiles(x86)` with `ProgramFiles`. |
| 40 | * To build with Visual Studio 2015, replace `12.0` with `14.0` in the aforementioned command. |
| 41 | |
| 42 | Open a command prompt: |
| 43 | |
| 44 | To build dynamic/shared library (`libsass.dll`): |
| 45 | |
| 46 | ```cmd |
| 47 | :: debug build: |
| 48 | "%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild" win\libsass.sln |
| 49 | |
| 50 | :: release build: |
| 51 | "%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild" win\libsass.sln ^ |
| 52 | /p:Configuration=Release |
| 53 | ``` |
| 54 | |
| 55 | To build static library (`libsass.lib`): |
| 56 | |
| 57 | ```cmd |
| 58 | :: debug build: |
| 59 | "%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild" win\libsass.sln ^ |
| 60 | /p:LIBSASS_STATIC_LIB=1 |
| 61 | |
| 62 | :: release build: |
| 63 | "%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild" win\libsass.sln ^ |
| 64 | /p:LIBSASS_STATIC_LIB=1 /p:Configuration=Release |
| 65 | ``` |
| 66 | |
| 67 | #### From PowerShell: |
| 68 | |
| 69 | To build dynamic/shared library (`libsass.dll`): |
| 70 | |
| 71 | ```powershell |
| 72 | # debug build: |
| 73 | &"${env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild" win\libsass.sln |
| 74 | |
| 75 | # release build: |
| 76 | &"${env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild" win\libsass.sln ` |
| 77 | /p:Configuration=Release |
| 78 | ``` |
| 79 | |
| 80 | To build static library (`libsass.lib`): |
| 81 | |
| 82 | ```powershell |
| 83 | # build: |
| 84 | &"${env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild" win\libsass.sln ` |
| 85 | /p:LIBSASS_STATIC_LIB=1 |
| 86 | |
| 87 | # release build: |
| 88 | &"${env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild" win\libsass.sln ` |
| 89 | /p:LIBSASS_STATIC_LIB=1 /p:Configuration=Release |
| 90 | ``` |