Skip to content

Commit

Permalink
chore(build.bat, appveyor): upgrade to Visual Studio 2017
Browse files Browse the repository at this point in the history
  • Loading branch information
lotem committed Jun 5, 2019
1 parent e8e1247 commit 61e7e2c
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 53 deletions.
76 changes: 46 additions & 30 deletions README-windows.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,75 @@
Rime with Windows
===
# Rime with Windows

## Prerequisites

`librime` is tested to work on Windows with the following combinations of build
tools and libraries:

- Visual Studio 2017
- [Boost](http://www.boost.org/)=1.64
- [cmake](http://www.cmake.org/)>=3.8

and

Prerequisites
---
librime is tested to work on Windows with the following build tools and libraries:
- Visual Studio 2015
- [Boost](http://www.boost.org/)>=1.60
- [cmake](http://www.cmake.org/)>=2.8
[Python](https://python.org)>=2.7 is needed to build opencc dictionaries.
- [Boost](http://www.boost.org/)=1.60
- [cmake](http://www.cmake.org/)>=3.8

Boost and cmake versions need to match higher VS version.

You may need to update Boost when using a higher version of VS.
[Python](https://python.org)>=2.7 is needed to build opencc dictionaries.

You can also build third-party libraries manually, by following instructions in the build script.
## Get the code

Get the code
---
``` batch
git clone --recursive https://github.com/rime/librime.git
```
or [download from GitHub](https://github.com/rime/librime).

Setup a build environment
---
Copy `env.bat.template` to `env.bat` and edit the script according to your setup.
Specifically, make sure `BOOST_ROOT` is set to the path to Boost source directory;
modify `CMAKE_GENERATOR` and `PLATFORM_TOOLSET` if using a different version of Visual Studio;
set `DEVTOOLS_PATH` for build tools installed to a custom location.
## Setup a build environment

Copy `env.bat.template` to `env.bat` and edit the file according to your setup.
Specifically, make sure `BOOST_ROOT` is set to the root directory of Boost
source tree; modify `BJAM_TOOLSET`, `CMAKE_GENERATOR` and `PLATFORM_TOOLSET` if
using a different version of Visual Studio; also set `DEVTOOLS_PATH` for build
tools installed to custom location.

When prepared, run the following commands in a Developer Command Prompt window.
When prepared, do the following in a *Developer Command Prompt* window.

## Build Boost

Build Boost
---
``` batch
build.bat boost
```

Build third-party libraries
---
## Build third-party libraries

``` batch
build.bat thirdparty
```
This builds dependent libraries in `thirdparty\src\*`, and copies artifacts to `thirdparty\lib` and `thirdparty\bin`.
This builds dependent libraries in `thirdparty\src\*`, and copies artifacts to
`thirdparty\lib` and `thirdparty\bin`.

## Build librime

Build librime
---
``` batch
build.bat librime
```
This creates `build\lib\Release\rime.dll`.

Try it in the console
---
Build artifacts - the shared library along with API headers and supporting files
are gathered in `dist` directory.

## Try it in the console

`librime` comes with a REPL application which can be used to test if the library
is working.

``` batch
copy /Y build\lib\Release\rime.dll build\bin
cd build\bin
echo "congmingdeRime{space}shurufa" | Release\rime_api_console.exe > output.txt
echo congmingdeRime{space}shurufa | Release\rime_api_console.exe > output.txt
```

Instead of redirecting output to a file, you can set appropriate code page
(`chcp 65001`) and font in the console to work with the REPL interactively.
15 changes: 5 additions & 10 deletions appveyor.install.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
setlocal

set boost_build_options=toolset=msvc-14.0^
set boost_build_options=toolset=msvc-14.1^
variant=release^
link=static^
threading=multi^
Expand All @@ -17,21 +17,16 @@ set boost_build_options=toolset=msvc-14.0^
set nocache=0

if not exist thirdparty.cached set nocache=1
if not exist %BOOST_ROOT% set nocache=1

git submodule update --init
if not exist %BOOST_ROOT%\stage set nocache=1

if %nocache% == 1 (
pushd C:\Libraries
appveyor DownloadFile https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.7z
7z x boost_1_68_0.7z | find "ing archive"
cd boost_1_68_0
pushd %BOOST_ROOT%
call .\bootstrap.bat
call .\b2.exe --prefix=%BOOST_ROOT% %boost_build_options% -q -d0 install
xcopy /e /i /y /q %BOOST_ROOT%\include\boost-1_68\boost %BOOST_ROOT%\boost
.\b2.exe %boost_build_options% -q -d0 stage
popd
if %ERRORLEVEL% NEQ 0 goto ERROR

git submodule update --init
call .\build.bat thirdparty
if %ERRORLEVEL% NEQ 0 goto ERROR

Expand Down
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ pull_requests:
do_not_increment_build_number: true

version: '{branch} build {build}'
image: Visual Studio 2015
image: Visual Studio 2017

environment:
BOOST_ROOT: C:\Libraries\libboost
BOOST_ROOT: C:\Libraries\boost_1_69_0
CL: /Zc:threadSafeInit-

cache:
Expand All @@ -16,7 +16,7 @@ cache:
- thirdparty\include -> appveyor.install.bat
- thirdparty\lib -> appveyor.install.bat
- thirdparty\share -> appveyor.install.bat
- C:\Libraries\libboost -> appveyor.install.bat
- C:\Libraries\boost_1_69_0\stage -> appveyor.install.bat

init:
- git --version
Expand Down
9 changes: 3 additions & 6 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,17 @@ echo.

if not defined BJAM_TOOLSET (
rem the number actually means platform toolset, not %VisualStudioVersion%
set BJAM_TOOLSET=msvc-14.0
set BJAM_TOOLSET=msvc-14.1
)

if not defined CMAKE_GENERATOR (
set CMAKE_GENERATOR="Visual Studio 14 2015"
set CMAKE_GENERATOR="Visual Studio 15 2017"
)

if not defined PLATFORM_TOOLSET (
set PLATFORM_TOOLSET=v140_xp
set PLATFORM_TOOLSET=v141_xp
)

rem used when building marisa
set VS_LATEST=vs2015

set build=build
set build_boost=0
set build_boost_x64=0
Expand Down
8 changes: 4 additions & 4 deletions env.bat.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ rem Customize your build environment and save the modified copy to env.bat
set RIME_ROOT=%CD%

rem REQUIRED: path to Boost source directory
set BOOST_ROOT=%USERPROFILE%\source\vendor\boost_1_60_0
set BOOST_ROOT=C:\Libraries\boost_1_69_0

rem OPTIONAL: Visual Studio version and platform toolset
rem set BJAM_TOOLSET=msvc-14.0
rem set CMAKE_GENERATOR="Visual Studio 14 2015"
rem set PLATFORM_TOOLSET=v140_xp
rem set BJAM_TOOLSET=msvc-14.1
rem set CMAKE_GENERATOR="Visual Studio 15 2017"
rem set PLATFORM_TOOLSET=v141_xp

rem OPTIONAL: path to additional build tools
rem set DEVTOOLS_PATH=%ProgramFiles%\Git\cmd;%ProgramFiles%\CMake\bin;C:\Python27;

0 comments on commit 61e7e2c

Please sign in to comment.