From ae8fd7446f9520aed3cec75d04caa9ff94f822ce Mon Sep 17 00:00:00 2001 From: nulano Date: Mon, 30 Sep 2019 10:37:46 +0200 Subject: [PATCH] test-windows.yml raqm --- .github/workflows/test-windows.yml | 35 +++++++++++++++++++++----- winbuild/config.py | 5 ++++ winbuild/fribidi.cmake | 9 +++---- winbuild/raqm.cmake | 40 ++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 11 deletions(-) create mode 100644 winbuild/raqm.cmake diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 4d117cc35..c3bb75e3c 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -76,7 +76,6 @@ jobs: xcopy /s c:\pillow-depends\test_images\* $env:GITHUB_WORKSPACE\tests\images\ cd $env:GITHUB_WORKSPACE/winbuild/ python.exe $env:GITHUB_WORKSPACE\winbuild\build_dep.py - # .\build_deps.cmd env: EXECUTABLE: bin\python.exe shell: pwsh @@ -233,17 +232,20 @@ jobs: copy /Y /B *.lib %INCLIB% - name: Build dependencies / HarfBuzz + if: "!contains(matrix.python-version, 'pypy')" run: | set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\V7.1A\Include set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 set BUILD=%GITHUB_WORKSPACE%\winbuild\build + set INCLUDE=%INCLUDE%;%INCLIB% + set LIB=%LIB%;%INCLIB% cd /D %BUILD%\harfbuzz-2.6.1 call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform-vcvars }} 8.1 echo on echo (gc CMakeLists.txt) -replace 'enable_testing', "add_compile_options(-MT)`r`nenable_testing" ^| Out-File -encoding ASCII CMakeLists.txt > patch.ps1 powershell .\patch.ps1 set CMAKE=cmake.exe -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_RULE_MESSAGES:BOOL=OFF - set CMAKE=%CMAKE% -DCMAKE_BUILD_TYPE=Release + set CMAKE=%CMAKE% -DHB_HAVE_FREETYPE:BOOL=ON -DCMAKE_BUILD_TYPE=Release %CMAKE% -G "NMake Makefiles" . nmake -nologo -f Makefile clean nmake -nologo -f Makefile harfbuzz @@ -251,6 +253,7 @@ jobs: copy /Y /B *.lib %INCLIB% - name: Build dependencies / FriBidi + if: "!contains(matrix.python-version, 'pypy')" run: | set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\V7.1A\Include set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 @@ -267,8 +270,28 @@ jobs: copy /Y /B lib\*.h %INCLIB% copy /Y /B *.lib %INCLIB% + # failing with PyPy3 + - name: Build dependencies / Raqm + if: "!contains(matrix.python-version, 'pypy')" + run: | + set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\V7.1A\Include + set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 + set BUILD=%GITHUB_WORKSPACE%\winbuild\build + set INCLUDE=%INCLUDE%;%INCLIB% + set LIB=%LIB%;%INCLIB% + cd /D %BUILD%\libraqm-0.7.0 + call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform-vcvars }} 8.1 + echo on + copy /Y /B %GITHUB_WORKSPACE%\winbuild\raqm.cmake CMakeLists.txt + set CMAKE=cmake.exe -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_RULE_MESSAGES:BOOL=OFF + set CMAKE=%CMAKE% -DCMAKE_BUILD_TYPE=Release + %CMAKE% -G "NMake Makefiles" . + nmake -nologo -f Makefile clean + nmake -nologo -f Makefile libraqm + copy /Y /B src\*.h %INCLIB% + copy /Y /B libraqm.dll %INCLIB% + - name: Build dependencies / ghostscript - if: false run: | set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\V7.1A\Include set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 @@ -295,21 +318,21 @@ jobs: set INCLUDE=%INCLIB%;%GITHUB_WORKSPACE%\depends\tcl86\include;%INCLUDE% call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform-vcvars }} 8.1 %PYTHON%\python.exe setup.py build_ext install + rem Add GhostScript and Raqm binaries (copied to INCLIB) to PATH. + path %INCLIB%;%PATH% %PYTHON%\python.exe selftest.py --installed - name: Test Pillow run: | set PYTHON=%pythonLocation% set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 - rem Add GhostScript executables (copied to INCLIB) to PATH. + rem Add GhostScript and Raqm binaries (copied to INCLIB) to PATH. path %INCLIB%;%PATH% cd /D %GITHUB_WORKSPACE% %PYTHON%\python.exe -m pytest -vx --cov PIL --cov-report term --cov-report xml Tests - name: Upload coverage run: 'codecov --file "%GITHUB_WORKSPACE%\coverage.xml" --name "%pythonLocation%"' - env: - CODECOV: Scripts\codecov.exe - name: Build wheel id: wheel diff --git a/winbuild/config.py b/winbuild/config.py index 93ccf3806..0eccdc1f0 100644 --- a/winbuild/config.py +++ b/winbuild/config.py @@ -113,6 +113,11 @@ libs = { "filename": PILLOW_DEPENDS_DIR + "fribidi-1.0.7.zip", "dir": "fribidi-1.0.7", }, + "libraqm": { + "url": "https://github.com/HOST-Oman/libraqm/archive/v0.7.0.zip", + "filename": PILLOW_DEPENDS_DIR + "libraqm-0.7.0.zip", + "dir": "libraqm-0.7.0", + }, } compilers = { diff --git a/winbuild/fribidi.cmake b/winbuild/fribidi.cmake index 82d1d9ccb..962badd46 100644 --- a/winbuild/fribidi.cmake +++ b/winbuild/fribidi.cmake @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.13) project(fribidi) add_definitions(-D_CRT_SECURE_NO_WARNINGS) -set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -MT) +add_compile_options(-MT) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(lib) @@ -29,7 +29,7 @@ function(fribidi_conf) set(SIZEOF_INT 4) set(FRIBIDI_MSVC_BUILD_PLACEHOLDER "#define FRIBIDI_BUILT_WITH_MSVC") message("detected ${PACKAGE_NAME} version ${FRIBIDI_VERSION}") - configure_file(lib/fribidi-config.h.in fribidi-config.h @ONLY) + configure_file(lib/fribidi-config.h.in lib/fribidi-config.h @ONLY) endfunction() fribidi_conf() @@ -57,7 +57,7 @@ macro(fribidi_definitions _TGT) endmacro() function(fribidi_gen _NAME _OUTNAME _PARAM) - set(_OUT ${CMAKE_CURRENT_BINARY_DIR}/${_OUTNAME}) + set(_OUT lib/${_OUTNAME}) prepend(_DEP "${CMAKE_CURRENT_SOURCE_DIR}/gen.tab/" ${ARGN}) add_executable(gen-${_NAME} gen.tab/gen-${_NAME}.c @@ -80,7 +80,7 @@ fribidi_gen(unicode-version fribidi-unicode-version.h "" macro(fribidi_tab _NAME) fribidi_gen(${_NAME}-tab ${_NAME}.tab.i 2 ${ARGN}) target_sources(gen-${_NAME}-tab - PRIVATE fribidi-unicode-version.h) + PRIVATE lib/fribidi-unicode-version.h) endmacro() fribidi_tab(bidi-type unidata/UnicodeData.txt) @@ -97,7 +97,6 @@ file(GLOB FRIBIDI_HEADERS lib/*.h) add_library(fribidi STATIC ${FRIBIDI_SOURCES} ${FRIBIDI_HEADERS} - fribidi-config.h ${FRIBIDI_SOURCES_GENERATED}) fribidi_definitions(fribidi) target_compile_definitions(fribidi diff --git a/winbuild/raqm.cmake b/winbuild/raqm.cmake new file mode 100644 index 000000000..39ae915d7 --- /dev/null +++ b/winbuild/raqm.cmake @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.13) + +project(libraqm) + + +find_library(fribidi NAMES fribidi) +find_library(harfbuzz NAMES harfbuzz) +find_library(freetype NAMES freetype) + +add_definitions(-DFRIBIDI_ENTRY=extern) +add_compile_options(-MT) + + +function(raqm_conf) + file(READ configure.ac RAQM_CONF) + string(REGEX MATCH "\\[([0-9]+)\\.([0-9]+)\\.([0-9]+)\\]," _ "${RAQM_CONF}") + set(RAQM_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(RAQM_VERSION_MINOR "${CMAKE_MATCH_2}") + set(RAQM_VERSION_MICRO "${CMAKE_MATCH_3}") + set(RAQM_VERSION "${RAQM_VERSION_MAJOR}.${RAQM_VERSION_MINOR}.${RAQM_VERSION_MICRO}") + message("detected libraqm version ${RAQM_VERSION}") + configure_file(src/raqm-version.h.in src/raqm-version.h @ONLY) +endfunction() +raqm_conf() + + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +set(RAQM_SOURCES + src/raqm.c) +set(RAQM_HEADERS + src/raqm.h + src/raqm-version.h) + +add_library(libraqm SHARED + ${RAQM_SOURCES} + ${RAQM_HEADERS}) +target_link_libraries(libraqm + ${fribidi} + ${harfbuzz} + ${freetype})