forked from marian-nmt/sentencepiece
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_minexport.bat
55 lines (48 loc) · 2.4 KB
/
test_minexport.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
rem This is a version of the Windows build script (test.bat) that builds a minimal
rem export library of sentencepiece in a shared dll that is linkable to other projects
rem on Windows machines. I tried for way too long to make my changes play nicely with
rem the existing cmake files, but was unsuccessful, so I opted to change in parallel
rem files instead. This file and the two CMakeLists_minexport.txt files in the root
rem directory and the src directory allow the creation of a shared Windows library
rem that does not export all of the symbols in the standard library.
set PROTOBUF_VERSION=3.6.1
set PLATFORM=%1
if "%PLATFORM%"=="" set PLATFORM=x64
set PLATFORM_PREFIX=
if "%PLATFORM%"=="x64" set PLATFORM_PREFIX=-x64
set _CL_=/utf-8
set PATH=c:\Program Files\Git\usr\bin;c:\MinGW\bin;%PATH%
set CURRENT_PATH=%~dp0
set LIBRARY_PATH=%CURRENT_PATH%build\root
mkdir build
copy protobuf-cpp-%PROTOBUF_VERSION%.zip build
cd build
rem curl -O -L https://github.com/google/protobuf/releases/download/v%PROTOBUF_VERSION%/protobuf-cpp-%PROTOBUF_VERSION%.zip
unzip protobuf-cpp-%PROTOBUF_VERSION%.zip
cd protobuf-%PROTOBUF_VERSION%\cmake
cmake . -A %PLATFORM% -DCMAKE_INSTALL_PREFIX=%LIBRARY_PATH% -DBUILD_SHARED_LIBS=true -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -DCMAKE_SYSTEM_VERSION=8.1 || goto :error
rem cmake . -A %PLATFORM% -DCMAKE_INSTALL_PREFIX=%LIBRARY_PATH% || goto :error
cmake --build . --config Release --target install || goto :error
cd ..\..
cmake .. -A %PLATFORM% -DSPM_BUILD_TEST=ON -DSPM_ENABLE_SHARED=ON -DCMAKE_INSTALL_PREFIX=%LIBRARY_PATH% -DBUILD_SHARED_LIBS=true -DSPM_ENABLE_SHARED=true -DSPM_ENABLE_SHARED_MINEXPORT=ON
rem cmake .. -A %PLATFORM% -DSPM_BUILD_TEST=ON -DSPM_ENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=%LIBRARY_PATH%
cmake --build . --config Release --target install || goto :error
ctest -C Release || goto :error
cpack || goto :error
cd ..\python
rem call :BuildPython C:\Python27%PLATFORM_PREFIX%
call :BuildPython C:\Python35%PLATFORM_PREFIX%
call :BuildPython C:\Python36%PLATFORM_PREFIX%
call :BuildPython C:\Python37%PLATFORM_PREFIX%
c:\Python37%PLATFORM_PREFIX%\python setup.py sdist || goto :error
exit
:BuildPython
%1\python -m pip install wheel || goto :error
%1\python setup.py build || goto :error
%1\python setup.py bdist_wheel || goto :error
%1\python setup.py test || goto :error
rmdir /Q /S build
del /S *.pyd
exit /b
:error
exit /b %errorlevel%