| 1 | We support builds via MingGW and via Visual Studio Community 2013. |
| 2 | Both should be considered experimental (MinGW was better tested)! |
| 3 | |
| 4 | ## Building via MingGW (makefiles) |
| 5 | |
| 6 | First grab the latest [MinGW for windows][1] installer. Once it is installed, you can click on continue or open the Installation Manager via `bin\mingw-get.exe`. |
| 7 | |
| 8 | You need to have the following components installed: |
| 9 |  |
| 10 | |
| 11 | Next we need to install [git for windows][2]. You probably want to check the option to add it to the global path, but you do not need to install the unix tools. |
| 12 | |
| 13 | If you want to run the spec test-suite you also need [ruby][3] and a few gems available. Grab the [latest installer][3] and make sure to add it the global path. Then install the missing gems: |
| 14 | |
| 15 | ```bash |
| 16 | gem install minitest |
| 17 | ``` |
| 18 | |
| 19 | ### Mount the mingw root directory |
| 20 | |
| 21 | As mentioned in the [MinGW Getting Started](http://www.mingw.org/wiki/Getting_Started#toc5) guide, you should edit `C:\MinGW\msys\1.0\etc\fstab` to contain the following line: |
| 22 | |
| 23 | ``` |
| 24 | C:\MinGW /mingw |
| 25 | ``` |
| 26 | |
| 27 | ### Starting a "MingGW" console |
| 28 | |
| 29 | Create a batch file with this content: |
| 30 | ```bat |
| 31 | @echo off |
| 32 | set PATH=C:\MinGW\bin;%PATH% |
| 33 | REM only needed if not already available |
| 34 | set PATH=%PROGRAMFILES%\git\bin;%PATH% |
| 35 | REM C:\MinGW\msys\1.0\msys.bat |
| 36 | cmd |
| 37 | ``` |
| 38 | |
| 39 | Execute it and make sure these commands can be called: `git`, `mingw32-make`, `rm` and `gcc`! Once this is all set, you should be ready to compile `libsass`! |
| 40 | |
| 41 | ### Get the sources |
| 42 | |
| 43 | ```bash |
| 44 | # using git is preferred |
| 45 | git clone https://github.com/sass/libsass.git |
| 46 | # only needed for sassc and/or testsuite |
| 47 | git clone https://github.com/sass/sassc.git libsass/sassc |
| 48 | git clone https://github.com/sass/sass-spec.git libsass/sass-spec |
| 49 | ``` |
| 50 | |
| 51 | ### Decide for static or shared library |
| 52 | |
| 53 | `libsass` can be built and linked as a `static` or as a `shared` library. The default is `static`. To change it you can set the `BUILD` environment variable: |
| 54 | |
| 55 | ```bat |
| 56 | set BUILD="shared" |
| 57 | ``` |
| 58 | |
| 59 | ### Compile the library |
| 60 | ```bash |
| 61 | mingw32-make -C libsass |
| 62 | ``` |
| 63 | |
| 64 | ### Results can be found in |
| 65 | ```bash |
| 66 | $ ls libsass/lib |
| 67 | libsass.a libsass.dll libsass.so |
| 68 | ``` |
| 69 | |
| 70 | ### Run the spec test-suite |
| 71 | ```bash |
| 72 | mingw32-make -C libsass test_build |
| 73 | ``` |
| 74 | |
| 75 | ## Building via MingGW 64bit (makefiles) |
| 76 | Building libass to dll on window 64bit. |
| 77 | |
| 78 | + downloads [MinGW64 for windows7 64bit](http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/x86_64-4.9.2-release-win32-seh-rt_v3-rev0.7z/download) , and unzip to "C:\mingw64". |
| 79 | |
| 80 | + Create a batch file with this content: |
| 81 | |
| 82 | ```bat |
| 83 | @echo off |
| 84 | set PATH=C:\mingw64\bin;%PATH% |
| 85 | set CC=gcc |
| 86 | REM only needed if not already available |
| 87 | set PATH=%PROGRAMFILES%\Git\bin;%PATH% |
| 88 | REM C:\MinGW\msys\1.0\msys.bat |
| 89 | cmd |
| 90 | ``` |
| 91 | |
| 92 | + By default , mingw64 dll will depends on "mingwm10.dll、 libgcc_s_dw2-1.dll" , we can modify Makefile to fix this:(add "-static") |
| 93 | |
| 94 | ``` bash |
| 95 | lib/libsass.dll: $(COBJECTS) $(OBJECTS) $(RCOBJECTS) |
| 96 | $(MKDIR) lib |
| 97 | $(CXX) -shared $(LDFLAGS) -o $@ $(COBJECTS) $(OBJECTS) $(RCOBJECTS) $(LDLIBS) -s -static -Wl,--subsystem,windows,--out-implib,lib/libsass.a |
| 98 | ``` |
| 99 | |
| 100 | + Compile the library |
| 101 | |
| 102 | ```bash |
| 103 | mingw32-make -C libsass |
| 104 | ``` |
| 105 | |
| 106 | By the way , if you are using java jna , [JNAerator](http://jnaerator.googlecode.com/) is a good tool. |
| 107 | |
| 108 | ## Building via Visual Studio Community 2013 |
| 109 | |
| 110 | Open a Visual Studio 2013 command prompt: |
| 111 | - `VS2013 x86 Native Tools Command Prompt` |
| 112 | |
| 113 | Note: When I installed the community edition, I only got the 2012 command prompts. I copied them from the Startmenu to the Desktop and adjusted the paths from `Visual Studio 11.0` to `Visual Studio 12.0`. Since `libsass` uses some `C++11` features, you need at least a MSVC 2013 compiler (v120). |
| 114 | |
| 115 | ### Get the source |
| 116 | ```bash |
| 117 | # using git is preferred |
| 118 | git clone https://github.com/sass/libsass.git |
| 119 | git clone https://github.com/sass/sassc.git libsass/sassc |
| 120 | # only needed if you want to run the testsuite |
| 121 | git clone https://github.com/sass/sass-spec.git libsass/sass-spec |
| 122 | ``` |
| 123 | |
| 124 | ### Compile sassc |
| 125 | |
| 126 | Sometimes `msbuild` seems not available from the command prompt. Just search for it and add it to the global path. It seems to be included in the .net folders too. |
| 127 | |
| 128 | ```bat |
| 129 | cd libsass |
| 130 | REM set PATH=%PATH%;%PROGRAMFILES%\MSBuild\12.0\Bin |
| 131 | msbuild /m:4 /p:Configuration=Release win\libsass.sln |
| 132 | REM running the spec test-suite manually (needs ruby and minitest gem) |
| 133 | ruby sass-spec\sass-spec.rb -c win\bin\sassc.exe -s --impl libsass sass-spec/spec |
| 134 | cd .. |
| 135 | ``` |
| 136 | |
| 137 | [1]: http://sourceforge.net/projects/mingw/files/latest/download?source=files |
| 138 | [2]: https://msysgit.github.io/ |
| 139 | [3]: http://rubyinstaller.org/ |