From a53ba03f795743a81e010e8a7d5fd775ff9faa24 Mon Sep 17 00:00:00 2001 From: David Turner Date: Mon, 18 May 2020 09:33:38 +0200 Subject: [PATCH 01/19] Set up CI with Azure Pipelines --- CMakeLists.txt | 12 +- azure-pipelines.yml | 186 +++++++++ build.yml | 59 +++ builds/cmake/iOS.cmake | 916 ++++++++++++++++++++++++++++++----------- 4 files changed, 935 insertions(+), 238 deletions(-) create mode 100644 azure-pipelines.yml create mode 100644 build.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index c9befb421..b6abebd65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,13 +110,7 @@ include(CheckIncludeFile) # CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which # configures the base build environment and references the toolchain file if (APPLE) - if (DEFINED IOS_PLATFORM) - if (NOT "${IOS_PLATFORM}" STREQUAL "OS" - AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR" - AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR64") - message(FATAL_ERROR - "IOS_PLATFORM must be set to either OS, SIMULATOR, or SIMULATOR64") - endif () + if (DEFINED PLATFORM) if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode") message(AUTHOR_WARNING "You should use Xcode generator with IOS_PLATFORM enabled to get Universal builds.") @@ -199,7 +193,9 @@ if (BUILD_FRAMEWORK) message(FATAL_ERROR "You should use Xcode generator with BUILD_FRAMEWORK enabled") endif () - set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)") + set(CMAKE_OSX_ARCHITECTURES "x86_64") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(BUILD_SHARED_LIBS ON) endif () diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..e99d4c383 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,186 @@ +# This file is responsible for seting up several compiler enviorments. +# Once setup is done, the template "build.yml" is invoked to test freetype +# compiles successfully on various operating systems and compilers liststed +# below. Artifacts of all builds are also published to azure. + +# TODO: Add functionality tests + +trigger: +- master + +variables: + vcpkgGitRef: a41c53c14794bb32cb03269069cdd3b66fedda5f # Update this git ref to update vcpkg + vckpgPackages: zlib bzip2 libpng harfbuzz + +jobs: + +## Linux ## + +- job: ArchLinux + pool: + vmImage: ubuntu-latest + strategy: + matrix: + shared: + BUILD_SHARED_LIBS: true + static: + BUILD_SHARED_LIBS: false + + steps: + - checkout: self + path: freetype2 + + - bash: | + set -e + cd $(Build.BinariesDirectory) + ARCH_URL=`curl -s https://mirrors.acm.wpi.edu/archlinux/iso/latest/ | egrep -o 'archlinux-bootstrap-([0-9._]+)-x86_64.tar.gz' | head -n1` + echo https://mirrors.acm.wpi.edu/archlinux/iso/latest/$ARCH_URL + curl https://mirrors.acm.wpi.edu/archlinux/iso/latest/$ARCH_URL -o arch.tar.gz + sudo tar xzf arch.tar.gz + sudo mount --bind ./root.x86_64/ ./root.x86_64/ + sudo cp -R $(Agent.BuildDirectory)/freetype2 ./root.x86_64/ + sudo mkdir -p ./root.x86_64/$(Build.BinariesDirectory) + sudo mount --bind $(Build.BinariesDirectory) ./root.x86_64/$(Build.BinariesDirectory) + cat << EOF | sudo ./root.x86_64/bin/arch-chroot ./root.x86_64/ + set -e + echo 'Server = https://mirrors.kernel.org/archlinux/\$repo/os/\$arch' >> /etc/pacman.d/mirrorlist + pacman-key --init + pacman-key --populate archlinux + pacman -Syu --noconfirm base base-devel git gcc cmake harfbuzz zlib libpng + EOF + displayName: 'Bootstrap Archlinux' + + - template: build.yml + parameters: + preCMD: 'cd $(Build.BinariesDirectory) && cat << EOF | sudo ./root.x86_64/bin/arch-chroot ./root.x86_64/' + srcDIR: freetype2 + postCMD: 'EOF' + cmakeArgs: '-G "Unix Makefiles" -D BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)' + +## Windows ## + +- job: MSVC_2019 + displayName: "MVSC 2019" + pool: + vmImage: windows-latest + strategy: + matrix: + i686_shared: + TRIPLET: x86-windows + BUILD_SHARED_LIBS: true + ARCH: Win32 + x86_64_shared: + TRIPLET: x64-windows + BUILD_SHARED_LIBS: true + ARCH: x64 + i686_static: + TRIPLET: x86-windows-static + BUILD_SHARED_LIBS: false + ARCH: Win32 + x86_64_static: + TRIPLET: x64-windows-static + BUILD_SHARED_LIBS: false + ARCH: x64 + + steps: + - task: Cache@2 + displayName: 'Cache VCPKG Artifacts' + inputs: + key: '"$(TRIPLET)" | "$(vckpgPackages)" | "$(vcpkgGitRef)" | "$(Agent.OS)"' + path: '$(Build.BinariesDirectory)/vcpkg' + + - task: run-vcpkg@0 + displayName: 'Run VCPKG' + inputs: + vcpkgArguments: --triplet $(TRIPLET) $(vckpgPackages) + vcpkgGitCommitId: $(vcpkgGitRef) + vcpkgGitURL: https://github.com/microsoft/vcpkg.git + + - template: build.yml + parameters: + cmakeArgs: '-G "Visual Studio 16 2019" -A $(ARCH) -D CMAKE_TOOLCHAIN_FILE=$(Build.BinariesDirectory)\vcpkg\scripts\buildsystems\vcpkg.cmake -D VCPKG_ROOT=$(Build.BinariesDirectory)\vcpkg -D VCPKG_TARGET_TRIPLET=$(TRIPLET) -D BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)' + +- job: MINGW + pool: + vmImage: windows-latest + strategy: + matrix: + i686_shared: + MINGW_UPPER: MINGW32 + MINGW_LOWER: mingw32 + MINGW_ARCH: i686 + BUILD_SHARED_LIBS: true + x86_64_shared: + MINGW_UPPER: MINGW64 + MINGW_LOWER: mingw64 + MINGW_ARCH: x86_64 + BUILD_SHARED_LIBS: true + i686_static: + MINGW_UPPER: MINGW32 + MINGW_LOWER: mingw32 + MINGW_ARCH: i686 + BUILD_SHARED_LIBS: false + x86_64_static: + MINGW_UPPER: MINGW64 + MINGW_LOWER: mingw64 + MINGW_ARCH: x86_64 + BUILD_SHARED_LIBS: false + + steps: + - script: | + git clone https://github.com/msys2/msys2-ci-base.git %CD:~0,2%\msys64 + %CD:~0,2%\msys64\usr\bin\rm -rf %CD:~0,2%\msys64\.git + displayName: Install MSYS2 + + - script: | + set PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem + %CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Syyuu + displayName: Update MSYS2 + + - script: | + set PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem + %CD:~0,2%\msys64\usr\bin\pacman --noconfirm --needed -S git base-devel mingw-w64-$(MINGW_ARCH)-toolchain mingw-w64-$(MINGW_ARCH)-cmake mingw-w64-$(MINGW_ARCH)-harfbuzz + %CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Scc + displayName: Install Toolchain + + - template: build.yml + parameters: + mingw: true + cmakeArgs: '-G \"MSYS Makefiles\" -D BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)' + +## MacOS X ## + +- job: MacOS_X + displayName: "MacOS X" + pool: + vmImage: macos-latest + + steps: + - template: build.yml + parameters: + cmakeArgs: '-G Xcode -D BUILD_FRAMEWORK:BOOL=true' + +### iOS ## + +- job: iOS + pool: + vmImage: macos-latest + strategy: + matrix: + OS: + IOS_PLATFORM: OS + Simulator: + IOS_PLATFORM: SIMULATOR64 + TV_OS: + IOS_PLATFORM: TVOS + TV_OS_Simulator: + IOS_PLATFORM: SIMULATOR_TVOS + Watch_OS: + IOS_PLATFORM: WATCHOS + Watch_OS_Simulator: + IOS_PLATFORM: SIMULATOR_WATCHOS + + steps: + - template: build.yml + parameters: + cmakeArgs: '-G Xcode -D PLATFORM=$(IOS_PLATFORM)' diff --git a/build.yml b/build.yml new file mode 100644 index 000000000..7eade8e76 --- /dev/null +++ b/build.yml @@ -0,0 +1,59 @@ +# This is a template for building and publishing freetype2 build artifacts using CMake + +parameters: +- name: cmakeArgs # CMake configure flags + default: '' +- name: mingw # Mingw requires special enviormental setup + type: boolean + default: false +- name: preCMD # Command(s) executed before calling CMake + default: '' +- name: srcDIR # Location of freetype2 sources + default: '.' +- name: postCMD # Command(s) executed after calling CMake + default: '' + +steps: +- ${{ if eq(parameters.mingw, true) }}: + - script: | + set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem + cd $(Build.SourcesDirectory) + %CD:~0,2%\msys64\usr\bin\bash -lc "cmake . ${{ parameters.cmakeArgs }} -B $(echo \"$(Build.BinariesDirectory)\" | tr '\\' '/') -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=install" + displayName: 'CMake Configure' + env: + MSYSTEM: $(MINGW_UPPER) + CHERE_INVOKING: yes + MINGW_INSTALLS: $(MINGW_LOWER) + + - script: | + set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem + %CD:~0,2%\msys64\usr\bin\bash -lc "cmake --build $(echo \"$(Build.BinariesDirectory)\" | tr '\\' '/') --config Release --target package" + displayName: 'CMake Build and Package' + env: + MSYSTEM: $(MINGW_UPPER) + CHERE_INVOKING: yes + MINGW_INSTALLS: $(MINGW_LOWER) + +- ${{ if eq(parameters.mingw, false) }}: + - script: | + ${{ parameters.preCMD }} + cd ${{ parameters.srcDIR }} + cmake . ${{ parameters.cmakeArgs }} -B $(Build.BinariesDirectory) -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=install + ${{ parameters.postCMD }} + displayName: 'CMake Configure' + + - script: | + ${{ parameters.preCMD }} + cd ${{ parameters.srcDIR }} + cmake --build $(Build.BinariesDirectory) --config Release --target package + ${{ parameters.postCMD }} + displayName: 'CMake Build and Package' + +- script: mv $(Build.BinariesDirectory)/freetype-* $(Build.ArtifactStagingDirectory) + displayName: 'Stage Artifacts' + +- task: PublishBuildArtifacts@1 + displayName: 'Push Build Artifacts' + inputs: + pathtoPublish: $(Build.ArtifactStagingDirectory) + artifactName: $(Agent.JobName) diff --git a/builds/cmake/iOS.cmake b/builds/cmake/iOS.cmake index 6f46836ad..0178556d6 100644 --- a/builds/cmake/iOS.cmake +++ b/builds/cmake/iOS.cmake @@ -1,270 +1,726 @@ -# iOS.cmake +# This file is part of the ios-cmake project. It was retrieved from +# https://github.com/cristeab/ios-cmake.git, which is a fork of +# https://code.google.com/p/ios-cmake/. Which in turn is based off of +# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which +# are included with CMake 2.8.4 # -# Copyright (C) 2014-2020 by -# David Turner, Robert Wilhelm, and Werner Lemberg. +# The ios-cmake project is licensed under the new BSD license. # -# Written by David Wimsey +# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software, +# Kitware, Inc., Insight Software Consortium. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. # -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. # +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. # -# This file is derived from the files `Platform/Darwin.cmake' and -# `Platform/UnixPaths.cmake', which are part of CMake 2.8.4. It has been -# altered for iOS development. - - -# Options -# ------- +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# This file is based off of the Platform/Darwin.cmake and +# Platform/UnixPaths.cmake files which are included with CMake 2.8.4 +# It has been altered for iOS development. +# +# Updated by Alex Stewart (alexs.mac@gmail.com) +# +# ***************************************************************************** +# Now maintained by Alexander Widerberg (widerbergaren [at] gmail.com) +# under the BSD-3-Clause license +# https://github.com/leetal/ios-cmake +# ***************************************************************************** +# +# INFORMATION / HELP +# +# The following arguments control the behaviour of this toolchain: +# +# PLATFORM: (default "OS") +# OS = Build for iPhoneOS. +# OS64 = Build for arm64 iphoneOS. +# OS64COMBINED = Build for arm64 x86_64 iphoneOS. Combined into FAT STATIC lib (supported on 3.14+ of CMakewith "-G Xcode" argument ONLY) +# SIMULATOR = Build for x86 i386 iphoneOS Simulator. +# SIMULATOR64 = Build for x86_64 iphoneOS Simulator. +# TVOS = Build for arm64 tvOS. +# TVOSCOMBINED = Build for arm64 x86_64 tvOS. Combined into FAT STATIC lib (supported on 3.14+ of CMake with "-G Xcode" argument ONLY) +# SIMULATOR_TVOS = Build for x86_64 tvOS Simulator. +# WATCHOS = Build for armv7k arm64_32 for watchOS. +# WATCHOSCOMBINED = Build for armv7k arm64_32 x86_64 watchOS. Combined into FAT STATIC lib (supported on 3.14+ of CMake with "-G Xcode" argument ONLY) +# SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator. +# +# CMAKE_OSX_SYSROOT: Path to the SDK to use. By default this is +# automatically determined from PLATFORM and xcodebuild, but +# can also be manually specified (although this should not be required). # -# IOS_PLATFORM = OS | SIMULATOR +# CMAKE_DEVELOPER_ROOT: Path to the Developer directory for the platform +# being compiled for. By default this is automatically determined from +# CMAKE_OSX_SYSROOT, but can also be manually specified (although this should +# not be required). # -# This decides whether SDKS are selected from the `iPhoneOS.platform' or -# `iPhoneSimulator.platform' folders. +# DEPLOYMENT_TARGET: Minimum SDK version to target. Default 2.0 on watchOS and 9.0 on tvOS+iOS # -# OS - the default, used to build for iPhone and iPad physical devices, -# which have an ARM architecture. -# SIMULATOR - used to build for the Simulator platforms, which have an -# x86 architecture. +# ENABLE_BITCODE: (1|0) Enables or disables bitcode support. Default 1 (true) # -# CMAKE_IOS_DEVELOPER_ROOT = /path/to/platform/Developer folder +# ENABLE_ARC: (1|0) Enables or disables ARC support. Default 1 (true, ARC enabled by default) # -# By default, this location is automatically chosen based on the -# IOS_PLATFORM value above. If you manually set this variable, it -# overrides the default location and forces the use of a particular -# Developer Platform. +# ENABLE_VISIBILITY: (1|0) Enables or disables symbol visibility support. Default 0 (false, visibility hidden by default) # -# CMAKE_IOS_SDK_ROOT = /path/to/platform/Developer/SDKs/SDK folder +# ENABLE_STRICT_TRY_COMPILE: (1|0) Enables or disables strict try_compile() on all Check* directives (will run linker +# to actually check if linking is possible). Default 0 (false, will set CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY) # -# By default, this location is automatically chosen based on the -# CMAKE_IOS_DEVELOPER_ROOT value. In this case it is always the most -# up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path. If you -# manually set this variable, it forces the use of a specific SDK -# version. +# ARCHS: (armv7 armv7s armv7k arm64 arm64_32 i386 x86_64) If specified, will override the default architectures for the given PLATFORM +# OS = armv7 armv7s arm64 (if applicable) +# OS64 = arm64 (if applicable) +# SIMULATOR = i386 +# SIMULATOR64 = x86_64 +# TVOS = arm64 +# SIMULATOR_TVOS = x86_64 (i386 has since long been deprecated) +# WATCHOS = armv7k arm64_32 (if applicable) +# SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated) # +# This toolchain defines the following variables for use externally: # -# Macros -# ------ +# XCODE_VERSION: Version number (not including Build version) of Xcode detected. +# SDK_VERSION: Version of SDK being used. +# CMAKE_OSX_ARCHITECTURES: Architectures being compiled for (generated from PLATFORM). +# APPLE_TARGET_TRIPLE: Used by autoconf build systems. NOTE: If "ARCHS" are overridden, this will *NOT* be set! # -# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE) +# This toolchain defines the following macros for use externally: # -# A convenience macro for setting Xcode specific properties on targets. +# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE XCODE_VARIANT) +# A convenience macro for setting xcode specific properties on targets. +# Available variants are: All, Release, RelWithDebInfo, Debug, MinSizeRel +# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1" "all"). # -# Example: +# find_host_package (PROGRAM ARGS) +# A macro used to find executable programs on the host system, not within the +# environment. Thanks to the android-cmake project for providing the +# command. # -# set_xcode_property(myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1") +# ******************************** DEPRECATIONS ******************************* # -# find_host_package (PROGRAM ARGS) +# IOS_DEPLOYMENT_TARGET: (Deprecated) Alias to DEPLOYMENT_TARGET +# CMAKE_IOS_DEVELOPER_ROOT: (Deprecated) Alias to CMAKE_DEVELOPER_ROOT +# IOS_PLATFORM: (Deprecated) Alias to PLATFORM +# IOS_ARCH: (Deprecated) Alias to ARCHS # -# A macro to find executable programs on the host system, not within the -# iOS environment. Thanks to the `android-cmake' project for providing -# the command. - - -# standard settings -set(CMAKE_SYSTEM_NAME Darwin) -set(CMAKE_SYSTEM_VERSION 1) -set(UNIX True) -set(APPLE True) -set(IOS True) - -# required as of cmake 2.8.10 -set(CMAKE_OSX_DEPLOYMENT_TARGET "" - CACHE STRING "Force unset of the deployment target for iOS" FORCE -) - -# determine the cmake host system version so we know where to find the iOS -# SDKs -find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin) -if (CMAKE_UNAME) - exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) - string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" - DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}") -endif (CMAKE_UNAME) - -# skip the platform compiler checks for cross compiling -set(CMAKE_CXX_COMPILER_WORKS TRUE) -set(CMAKE_C_COMPILER_WORKS TRUE) - -# all iOS/Darwin specific settings - some may be redundant +# ***************************************************************************** +# + +# Fix for PThread library not in path +set(CMAKE_THREAD_LIBS_INIT "-lpthread") +set(CMAKE_HAVE_THREADS_LIBRARY 1) +set(CMAKE_USE_WIN32_THREADS_INIT 0) +set(CMAKE_USE_PTHREADS_INIT 1) + +# Cache what generator is used +set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}" CACHE STRING "Expose CMAKE_GENERATOR" FORCE) + +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14") + set(MODERN_CMAKE YES) +endif() + +# Get the Xcode version being used. +execute_process(COMMAND xcodebuild -version + OUTPUT_VARIABLE XCODE_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION "${XCODE_VERSION}") +string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION "${XCODE_VERSION}") + +######## ALIASES (DEPRECATION WARNINGS) + +if(DEFINED IOS_PLATFORM) + set(PLATFORM ${IOS_PLATFORM}) + message(DEPRECATION "IOS_PLATFORM argument is DEPRECATED. Consider using the new PLATFORM argument instead.") +endif() + +if(DEFINED IOS_DEPLOYMENT_TARGET) + set(DEPLOYMENT_TARGET ${IOS_DEPLOYMENT_TARGET}) + message(DEPRECATION "IOS_DEPLOYMENT_TARGET argument is DEPRECATED. Consider using the new DEPLOYMENT_TARGET argument instead.") +endif() + +if(DEFINED CMAKE_IOS_DEVELOPER_ROOT) + set(CMAKE_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT}) + message(DEPRECATION "CMAKE_IOS_DEVELOPER_ROOT argument is DEPRECATED. Consider using the new CMAKE_DEVELOPER_ROOT argument instead.") +endif() + +if(DEFINED IOS_ARCH) + set(ARCHS ${IOS_ARCH}) + message(DEPRECATION "IOS_ARCH argument is DEPRECATED. Consider using the new ARCHS argument instead.") +endif() + +######## END ALIASES + +# Unset the FORCE on cache variables if in try_compile() +set(FORCE_CACHE FORCE) +get_property(_CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE) +if(_CMAKE_IN_TRY_COMPILE) + unset(FORCE_CACHE) +endif() + +# Default to building for iPhoneOS if not specified otherwise, and we cannot +# determine the platform from the CMAKE_OSX_ARCHITECTURES variable. The use +# of CMAKE_OSX_ARCHITECTURES is such that try_compile() projects can correctly +# determine the value of PLATFORM from the root project, as +# CMAKE_OSX_ARCHITECTURES is propagated to them by CMake. +if(NOT DEFINED PLATFORM) + if (CMAKE_OSX_ARCHITECTURES) + if(CMAKE_OSX_ARCHITECTURES MATCHES ".*arm.*" AND CMAKE_OSX_SYSROOT MATCHES ".*iphoneos.*") + set(PLATFORM "OS") + elseif(CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_SYSROOT MATCHES ".*iphonesimulator.*") + set(PLATFORM "SIMULATOR") + elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" AND CMAKE_OSX_SYSROOT MATCHES ".*iphonesimulator.*") + set(PLATFORM "SIMULATOR64") + elseif(CMAKE_OSX_ARCHITECTURES MATCHES "arm64" AND CMAKE_OSX_SYSROOT MATCHES ".*appletvos.*") + set(PLATFORM "TVOS") + elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" AND CMAKE_OSX_SYSROOT MATCHES ".*appletvsimulator.*") + set(PLATFORM "SIMULATOR_TVOS") + elseif(CMAKE_OSX_ARCHITECTURES MATCHES ".*armv7k.*" AND CMAKE_OSX_SYSROOT MATCHES ".*watchos.*") + set(PLATFORM "WATCHOS") + elseif(CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_SYSROOT MATCHES ".*watchsimulator.*") + set(PLATFORM "SIMULATOR_WATCHOS") + endif() + endif() + if (NOT PLATFORM) + set(PLATFORM "OS") + endif() +endif() + +set(PLATFORM_INT "${PLATFORM}" CACHE STRING "Type of platform for which the build targets.") + +# Handle the case where we are targeting iOS and a version above 10.3.4 (32-bit support dropped officially) +if(PLATFORM_INT STREQUAL "OS" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4) + set(PLATFORM_INT "OS64") + message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.") +elseif(PLATFORM_INT STREQUAL "SIMULATOR" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4) + set(PLATFORM_INT "SIMULATOR64") + message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.") +endif() + +# Determine the platform name and architectures for use in xcodebuild commands +# from the specified PLATFORM name. +if(PLATFORM_INT STREQUAL "OS") + set(SDK_NAME iphoneos) + if(NOT ARCHS) + set(ARCHS armv7 armv7s arm64) + set(APPLE_TARGET_TRIPLE_INT arm-apple-ios) + endif() +elseif(PLATFORM_INT STREQUAL "OS64") + set(SDK_NAME iphoneos) + if(NOT ARCHS) + if (XCODE_VERSION VERSION_GREATER 10.0) + set(ARCHS arm64) # Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missung bitcode markers for example + else() + set(ARCHS arm64) + endif() + set(APPLE_TARGET_TRIPLE_INT aarch64-apple-ios) + endif() +elseif(PLATFORM_INT STREQUAL "OS64COMBINED") + set(SDK_NAME iphoneos) + if(MODERN_CMAKE) + if(NOT ARCHS) + if (XCODE_VERSION VERSION_GREATER 10.0) + set(ARCHS arm64 x86_64) # Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missung bitcode markers for example + else() + set(ARCHS arm64 x86_64) + endif() + set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-ios) + endif() + else() + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the OS64COMBINED setting work") + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATOR") + set(SDK_NAME iphonesimulator) + if(NOT ARCHS) + set(ARCHS i386) + set(APPLE_TARGET_TRIPLE_INT i386-apple-ios) + endif() + message(DEPRECATION "SIMULATOR IS DEPRECATED. Consider using SIMULATOR64 instead.") +elseif(PLATFORM_INT STREQUAL "SIMULATOR64") + set(SDK_NAME iphonesimulator) + if(NOT ARCHS) + set(ARCHS x86_64) + set(APPLE_TARGET_TRIPLE_INT x86_64-apple-ios) + endif() +elseif(PLATFORM_INT STREQUAL "TVOS") + set(SDK_NAME appletvos) + if(NOT ARCHS) + set(ARCHS arm64) + set(APPLE_TARGET_TRIPLE_INT aarch64-apple-tvos) + endif() +elseif (PLATFORM_INT STREQUAL "TVOSCOMBINED") + set(SDK_NAME appletvos) + if(MODERN_CMAKE) + if(NOT ARCHS) + set(ARCHS arm64 x86_64) + set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-tvos) + endif() + else() + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the TVOSCOMBINED setting work") + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS") + set(SDK_NAME appletvsimulator) + if(NOT ARCHS) + set(ARCHS x86_64) + set(APPLE_TARGET_TRIPLE_INT x86_64-apple-tvos) + endif() +elseif(PLATFORM_INT STREQUAL "WATCHOS") + set(SDK_NAME watchos) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fgnu-inline-asm") + if(NOT ARCHS) + if (XCODE_VERSION VERSION_GREATER 10.0) + set(ARCHS armv7k arm64_32) + set(APPLE_TARGET_TRIPLE_INT aarch64_32-apple-watchos) + else() + set(ARCHS armv7k) + set(APPLE_TARGET_TRIPLE_INT arm-apple-watchos) + endif() + endif() +elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED") + set(SDK_NAME watchos) + if(MODERN_CMAKE) + if(NOT ARCHS) + if (XCODE_VERSION VERSION_GREATER 10.0) + set(ARCHS armv7k arm64_32 i386) + set(APPLE_TARGET_TRIPLE_INT aarch64_32-i386-apple-watchos) + else() + set(ARCHS armv7k i386) + set(APPLE_TARGET_TRIPLE_INT arm-i386-apple-watchos) + endif() + endif() + else() + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the WATCHOSCOMBINED setting work") + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS") + set(SDK_NAME watchsimulator) + if(NOT ARCHS) + set(ARCHS i386) + set(APPLE_TARGET_TRIPLE_INT i386-apple-watchos) + endif() +else() + message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}") +endif() + +if(MODERN_CMAKE AND PLATFORM_INT MATCHES ".*COMBINED" AND NOT USED_CMAKE_GENERATOR MATCHES "Xcode") + message(FATAL_ERROR "The COMBINED options only work with Xcode generator, -G Xcode") +endif() + +# If user did not specify the SDK root to use, then query xcodebuild for it. +execute_process(COMMAND xcodebuild -version -sdk ${SDK_NAME} Path + OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_INT + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +if (NOT DEFINED CMAKE_OSX_SYSROOT_INT AND NOT DEFINED CMAKE_OSX_SYSROOT) + message(SEND_ERROR "Please make sure that Xcode is installed and that the toolchain" + "is pointing to the correct path. Please run:" + "sudo xcode-select -s /Applications/Xcode.app/Contents/Developer" + "and see if that fixes the problem for you.") + message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} " + "does not exist.") +elseif(DEFINED CMAKE_OSX_SYSROOT_INT) + set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "") +endif() + +# Set Xcode property for SDKROOT as well if Xcode generator is used +if(USED_CMAKE_GENERATOR MATCHES "Xcode") + set(CMAKE_OSX_SYSROOT "${SDK_NAME}" CACHE INTERNAL "") + if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM) + set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "123456789A" CACHE INTERNAL "") + endif() +endif() + +# Specify minimum version of deployment target. +if(NOT DEFINED DEPLOYMENT_TARGET) + if (PLATFORM_INT STREQUAL "WATCHOS" OR PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS") + # Unless specified, SDK version 2.0 is used by default as minimum target version (watchOS). + set(DEPLOYMENT_TARGET "2.0" + CACHE STRING "Minimum SDK version to build for." ) + else() + # Unless specified, SDK version 9.0 is used by default as minimum target version (iOS, tvOS). + set(DEPLOYMENT_TARGET "9.0" + CACHE STRING "Minimum SDK version to build for." ) + endif() + message(STATUS "Using the default min-version since DEPLOYMENT_TARGET not provided!") +endif() + +# Use bitcode or not +if(NOT DEFINED ENABLE_BITCODE AND NOT ARCHS MATCHES "((^|;|, )(i386|x86_64))+") + # Unless specified, enable bitcode support by default + message(STATUS "Enabling bitcode support by default. ENABLE_BITCODE not provided!") + set(ENABLE_BITCODE TRUE) +elseif(NOT DEFINED ENABLE_BITCODE) + message(STATUS "Disabling bitcode support by default on simulators. ENABLE_BITCODE not provided for override!") + set(ENABLE_BITCODE FALSE) +endif() +set(ENABLE_BITCODE_INT ${ENABLE_BITCODE} CACHE BOOL "Whether or not to enable bitcode" ${FORCE_CACHE}) +# Use ARC or not +if(NOT DEFINED ENABLE_ARC) + # Unless specified, enable ARC support by default + set(ENABLE_ARC TRUE) + message(STATUS "Enabling ARC support by default. ENABLE_ARC not provided!") +endif() +set(ENABLE_ARC_INT ${ENABLE_ARC} CACHE BOOL "Whether or not to enable ARC" ${FORCE_CACHE}) +# Use hidden visibility or not +if(NOT DEFINED ENABLE_VISIBILITY) + # Unless specified, disable symbols visibility by default + set(ENABLE_VISIBILITY FALSE) + message(STATUS "Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!") +endif() +set(ENABLE_VISIBILITY_INT ${ENABLE_VISIBILITY} CACHE BOOL "Whether or not to hide symbols (-fvisibility=hidden)" ${FORCE_CACHE}) +# Set strict compiler checks or not +if(NOT DEFINED ENABLE_STRICT_TRY_COMPILE) + # Unless specified, disable strict try_compile() + set(ENABLE_STRICT_TRY_COMPILE FALSE) + message(STATUS "Using NON-strict compiler checks by default. ENABLE_STRICT_TRY_COMPILE not provided!") +endif() +set(ENABLE_STRICT_TRY_COMPILE_INT ${ENABLE_STRICT_TRY_COMPILE} CACHE BOOL "Whether or not to use strict compiler checks" ${FORCE_CACHE}) +# Get the SDK version information. +execute_process(COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion + OUTPUT_VARIABLE SDK_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + +# Find the Developer root for the specific iOS platform being compiled for +# from CMAKE_OSX_SYSROOT. Should be ../../ from SDK specified in +# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain +# this information from xcrun or xcodebuild. +if (NOT DEFINED CMAKE_DEVELOPER_ROOT AND NOT USED_CMAKE_GENERATOR MATCHES "Xcode") + get_filename_component(PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT} PATH) + get_filename_component(CMAKE_DEVELOPER_ROOT ${PLATFORM_SDK_DIR} PATH) + if (NOT DEFINED CMAKE_DEVELOPER_ROOT) + message(FATAL_ERROR "Invalid CMAKE_DEVELOPER_ROOT: " + "${CMAKE_DEVELOPER_ROOT} does not exist.") + endif() +endif() +# Find the C & C++ compilers for the specified SDK. +if(NOT CMAKE_C_COMPILER) + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang + OUTPUT_VARIABLE CMAKE_C_COMPILER + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}") +endif() +if(NOT CMAKE_CXX_COMPILER) + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++ + OUTPUT_VARIABLE CMAKE_CXX_COMPILER + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}") +endif() +# Find (Apple's) libtool. +execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find libtool + OUTPUT_VARIABLE BUILD_LIBTOOL + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +message(STATUS "Using libtool: ${BUILD_LIBTOOL}") +# Configure libtool to be used instead of ar + ranlib to build static libraries. +# This is required on Xcode 7+, but should also work on previous versions of +# Xcode. +set(CMAKE_C_CREATE_STATIC_LIBRARY + "${BUILD_LIBTOOL} -static -o ") +set(CMAKE_CXX_CREATE_STATIC_LIBRARY + "${BUILD_LIBTOOL} -static -o ") +# Find the toolchain's provided install_name_tool if none is found on the host +if(NOT CMAKE_INSTALL_NAME_TOOL) + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find install_name_tool + OUTPUT_VARIABLE CMAKE_INSTALL_NAME_TOOL_INT + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL_INT} CACHE STRING "" ${FORCE_CACHE}) +endif() +# Get the version of Darwin (OS X) of the host. +execute_process(COMMAND uname -r + OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(SDK_NAME MATCHES "iphone") + set(CMAKE_SYSTEM_NAME iOS CACHE INTERNAL "" ${FORCE_CACHE}) +endif() +# CMake 3.14+ support building for iOS, watchOS and tvOS out of the box. +if(MODERN_CMAKE) + if(SDK_NAME MATCHES "appletv") + set(CMAKE_SYSTEM_NAME tvOS CACHE INTERNAL "" ${FORCE_CACHE}) + elseif(SDK_NAME MATCHES "watch") + set(CMAKE_SYSTEM_NAME watchOS CACHE INTERNAL "" ${FORCE_CACHE}) + endif() + # Provide flags for a combined FAT library build on newer CMake versions + if(PLATFORM_INT MATCHES ".*COMBINED") + set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "NO" CACHE INTERNAL "" ${FORCE_CACHE}) + set(CMAKE_IOS_INSTALL_COMBINED YES CACHE INTERNAL "" ${FORCE_CACHE}) + message(STATUS "Will combine built (static) artifacts into FAT lib...") + endif() +elseif(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.10") + # Legacy code path prior to CMake 3.14 or fallback if no SDK_NAME specified + set(CMAKE_SYSTEM_NAME iOS CACHE INTERNAL "" ${FORCE_CACHE}) +else() + # Legacy code path prior to CMake 3.14 or fallback if no SDK_NAME specified + set(CMAKE_SYSTEM_NAME Darwin CACHE INTERNAL "" ${FORCE_CACHE}) +endif() +# Standard settings. +set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "") +set(UNIX TRUE CACHE BOOL "") +set(APPLE TRUE CACHE BOOL "") +set(IOS TRUE CACHE BOOL "") +set(CMAKE_AR ar CACHE FILEPATH "" FORCE) +set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE) +set(CMAKE_STRIP strip CACHE FILEPATH "" FORCE) +# Set the architectures for which to build. +set(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE STRING "Build architecture for iOS") +# Change the type of target generated for try_compile() so it'll work when cross-compiling, weak compiler checks +if(ENABLE_STRICT_TRY_COMPILE_INT) + message(STATUS "Using strict compiler checks (default in CMake).") +else() + set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) +endif() +# All iOS/Darwin specific settings - some may be redundant. +set(CMAKE_MACOSX_BUNDLE YES) +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_SHARED_LIBRARY_PREFIX "lib") set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") set(CMAKE_SHARED_MODULE_PREFIX "lib") set(CMAKE_SHARED_MODULE_SUFFIX ".so") +set(CMAKE_C_COMPILER_ABI ELF) +set(CMAKE_CXX_COMPILER_ABI ELF) +set(CMAKE_C_HAS_ISYSROOT 1) +set(CMAKE_CXX_HAS_ISYSROOT 1) set(CMAKE_MODULE_EXISTS 1) set(CMAKE_DL_LIBS "") - -set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG - "-compatibility_version ") -set(CMAKE_C_OSX_CURRENT_VERSION_FLAG - "-current_version ") -set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG - "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") -set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG - "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") - -# hidden visibility is required for cxx on iOS -set(CMAKE_C_FLAGS_INIT "") -set(CMAKE_CXX_FLAGS_INIT - "-headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden") - -set(CMAKE_C_LINK_FLAGS - "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") -set(CMAKE_CXX_LINK_FLAGS - "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}") +set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") +set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ") +set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") +set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") + +if(ARCHS MATCHES "((^|;|, )(arm64|arm64e|x86_64))+") + set(CMAKE_C_SIZEOF_DATA_PTR 8) + set(CMAKE_CXX_SIZEOF_DATA_PTR 8) + if(ARCHS MATCHES "((^|;|, )(arm64|arm64e))+") + set(CMAKE_SYSTEM_PROCESSOR "aarch64") + else() + set(CMAKE_SYSTEM_PROCESSOR "x86_64") + endif() +else() + set(CMAKE_C_SIZEOF_DATA_PTR 4) + set(CMAKE_CXX_SIZEOF_DATA_PTR 4) + set(CMAKE_SYSTEM_PROCESSOR "arm") +endif() + +# Note that only Xcode 7+ supports the newer more specific: +# -m${SDK_NAME}-version-min flags, older versions of Xcode use: +# -m(ios/ios-simulator)-version-min instead. +if(${CMAKE_VERSION} VERSION_LESS "3.11") + if(PLATFORM_INT STREQUAL "OS" OR PLATFORM_INT STREQUAL "OS64") + if(XCODE_VERSION VERSION_LESS 7.0) + set(SDK_NAME_VERSION_FLAGS + "-mios-version-min=${DEPLOYMENT_TARGET}") + else() + # Xcode 7.0+ uses flags we can build directly from SDK_NAME. + set(SDK_NAME_VERSION_FLAGS + "-m${SDK_NAME}-version-min=${DEPLOYMENT_TARGET}") + endif() + elseif(PLATFORM_INT STREQUAL "TVOS") + set(SDK_NAME_VERSION_FLAGS + "-mtvos-version-min=${DEPLOYMENT_TARGET}") + elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS") + set(SDK_NAME_VERSION_FLAGS + "-mtvos-simulator-version-min=${DEPLOYMENT_TARGET}") + elseif(PLATFORM_INT STREQUAL "WATCHOS") + set(SDK_NAME_VERSION_FLAGS + "-mwatchos-version-min=${DEPLOYMENT_TARGET}") + elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS") + set(SDK_NAME_VERSION_FLAGS + "-mwatchos-simulator-version-min=${DEPLOYMENT_TARGET}") + else() + # SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min. + set(SDK_NAME_VERSION_FLAGS + "-mios-simulator-version-min=${DEPLOYMENT_TARGET}") + endif() +else() + # Newer versions of CMake sets the version min flags correctly + set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET} CACHE STRING + "Set CMake deployment target" ${FORCE_CACHE}) +endif() + +if(DEFINED APPLE_TARGET_TRIPLE_INT) + set(APPLE_TARGET_TRIPLE ${APPLE_TARGET_TRIPLE_INT} CACHE STRING + "Autoconf target triple compatible variable" ${FORCE_CACHE}) +endif() + +if(ENABLE_BITCODE_INT) + set(BITCODE "-fembed-bitcode") + set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode" CACHE INTERNAL "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES" CACHE INTERNAL "") +else() + set(BITCODE "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO" CACHE INTERNAL "") +endif() + +if(ENABLE_ARC_INT) + set(FOBJC_ARC "-fobjc-arc") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES" CACHE INTERNAL "") +else() + set(FOBJC_ARC "-fno-objc-arc") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "NO" CACHE INTERNAL "") +endif() + +if(NOT ENABLE_VISIBILITY_INT) + set(VISIBILITY "-fvisibility=hidden") + set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "YES" CACHE INTERNAL "") +else() + set(VISIBILITY "") + set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "NO" CACHE INTERNAL "") +endif() + +if(NOT IOS_TOOLCHAIN_HAS_RUN) + #Check if Xcode generator is used, since that will handle these flags automagically + if(USED_CMAKE_GENERATOR MATCHES "Xcode") + message(STATUS "Not setting any manual command-line buildflags, since Xcode is selected as generator.") + else() + set(CMAKE_C_FLAGS + "${SDK_NAME_VERSION_FLAGS} ${BITCODE} -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_C_FLAGS}") + # Hidden visibilty is required for C++ on iOS. + set(CMAKE_CXX_FLAGS + "${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} -fvisibility-inlines-hidden -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g ${CMAKE_CXX_FLAGS_DEBUG}") + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG -Os -ffast-math ${CMAKE_CXX_FLAGS_MINSIZEREL}") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG -O2 -g -ffast-math ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG -O3 -ffast-math ${CMAKE_CXX_FLAGS_RELEASE}") + set(CMAKE_C_LINK_FLAGS "${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") + set(CMAKE_CXX_LINK_FLAGS "${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}") + set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp") + + # In order to ensure that the updated compiler flags are used in try_compile() + # tests, we have to forcibly set them in the CMake cache, not merely set them + # in the local scope. + set(VARS_TO_FORCE_IN_CACHE + CMAKE_C_FLAGS + CMAKE_CXX_FLAGS + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS_MINSIZEREL + CMAKE_CXX_FLAGS_RELEASE + CMAKE_C_LINK_FLAGS + CMAKE_CXX_LINK_FLAGS) + foreach(VAR_TO_FORCE ${VARS_TO_FORCE_IN_CACHE}) + set(${VAR_TO_FORCE} "${${VAR_TO_FORCE}}" CACHE STRING "" ${FORCE_CACHE}) + endforeach() + endif() + + ## Print status messages to inform of the current state + message(STATUS "Configuring ${SDK_NAME} build for platform: ${PLATFORM_INT}, architecture(s): ${ARCHS}") + message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT_INT}") + if(DEFINED APPLE_TARGET_TRIPLE) + message(STATUS "Autoconf target triple: ${APPLE_TARGET_TRIPLE}") + endif() + message(STATUS "Using minimum deployment version: ${DEPLOYMENT_TARGET}" + " (SDK version: ${SDK_VERSION})") + if(MODERN_CMAKE) + message(STATUS "Merging integrated CMake 3.14+ iOS,tvOS,watchOS,macOS toolchain(s) with this toolchain!") + endif() + if(USED_CMAKE_GENERATOR MATCHES "Xcode") + message(STATUS "Using Xcode version: ${XCODE_VERSION}") + endif() + if(DEFINED SDK_NAME_VERSION_FLAGS) + message(STATUS "Using version flags: ${SDK_NAME_VERSION_FLAGS}") + endif() + message(STATUS "Using a data_ptr size of: ${CMAKE_CXX_SIZEOF_DATA_PTR}") + message(STATUS "Using install_name_tool: ${CMAKE_INSTALL_NAME_TOOL}") + if(ENABLE_BITCODE_INT) + message(STATUS "Enabling bitcode support.") + else() + message(STATUS "Disabling bitcode support.") + endif() + + if(ENABLE_ARC_INT) + message(STATUS "Enabling ARC support.") + else() + message(STATUS "Disabling ARC support.") + endif() + + if(NOT ENABLE_VISIBILITY_INT) + message(STATUS "Hiding symbols (-fvisibility=hidden).") + endif() +endif() set(CMAKE_PLATFORM_HAS_INSTALLNAME 1) -set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS - "-dynamiclib -headerpad_max_install_names") -set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS - "-bundle -headerpad_max_install_names") -set(CMAKE_SHARED_MODULE_LOADER_C_FLAG - "-Wl,-bundle_loader,") -set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG - "-Wl,-bundle_loader,") -set(CMAKE_FIND_LIBRARY_SUFFIXES - ".dylib" ".so" ".a") - -# hack: If a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old -# build tree (where `install_name_tool' was hardcoded), and where -# CMAKE_INSTALL_NAME_TOOL isn't in the cache and still cmake didn't -# fail in `CMakeFindBinUtils.cmake' (because it isn't rerun), hardcode -# CMAKE_INSTALL_NAME_TOOL here to `install_name_tool' so it behaves as -# it did before. -if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL) - find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool) -endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL) - -# set up iOS platform unless specified manually with IOS_PLATFORM -if (NOT DEFINED IOS_PLATFORM) - set(IOS_PLATFORM "OS") -endif (NOT DEFINED IOS_PLATFORM) - -set(IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform") - -# check the platform selection and setup for developer root -if (${IOS_PLATFORM} STREQUAL "OS") - set(IOS_PLATFORM_LOCATION "iPhoneOS.platform") - - # this causes the installers to properly locate the output libraries - set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos") - -elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR") - set(IOS_PLATFORM_LOCATION "iPhoneSimulator.platform") - - # this causes the installers to properly locate the output libraries - set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator") - -else (${IOS_PLATFORM} STREQUAL "OS") - message(FATAL_ERROR - "Unsupported IOS_PLATFORM value selected. Please choose OS or SIMULATOR.") - -endif (${IOS_PLATFORM} STREQUAL "OS") - -# set up iOS developer location unless specified manually with -# CMAKE_IOS_DEVELOPER_ROOT -- -# note that Xcode 4.3 changed the installation location; choose the most -# recent one available -set(XCODE_POST_43_ROOT - "/Applications/Xcode.app/Contents/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer") -set(XCODE_PRE_43_ROOT - "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer") - -if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) - if (EXISTS ${XCODE_POST_43_ROOT}) - set(CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT}) - elseif (EXISTS ${XCODE_PRE_43_ROOT}) - set(CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT}) - endif (EXISTS ${XCODE_POST_43_ROOT}) -endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) - -set(CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} - CACHE PATH "Location of iOS Platform" -) - -# find and use the most recent iOS SDK unless specified manually with -# CMAKE_IOS_SDK_ROOT -if (NOT DEFINED CMAKE_IOS_SDK_ROOT) - file(GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*") - if (_CMAKE_IOS_SDKS) - list(SORT _CMAKE_IOS_SDKS) - list(REVERSE _CMAKE_IOS_SDKS) - list(GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT) - else (_CMAKE_IOS_SDKS) - message(FATAL_ERROR - "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.") - endif (_CMAKE_IOS_SDKS) - - message(STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}") -endif (NOT DEFINED CMAKE_IOS_SDK_ROOT) - -set(CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} - CACHE PATH "Location of the selected iOS SDK" -) - -# set the sysroot default to the most recent SDK -set(CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} - CACHE PATH "Sysroot used for iOS support" -) - -# set the architecture for iOS -- -# note that currently both ARCHS_STANDARD_32_BIT and -# ARCHS_UNIVERSAL_IPHONE_OS set armv7 only, so set both manually -if (${IOS_PLATFORM} STREQUAL "OS") - set(IOS_ARCH $(ARCHS_STANDARD_32_64_BIT)) -else (${IOS_PLATFORM} STREQUAL "OS") - set(IOS_ARCH i386) -endif (${IOS_PLATFORM} STREQUAL "OS") - -set(CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} - CACHE string "Build architecture for iOS" -) - -# set the find root to the iOS developer roots and to user defined paths -set(CMAKE_FIND_ROOT_PATH - ${CMAKE_IOS_DEVELOPER_ROOT} - ${CMAKE_IOS_SDK_ROOT} - ${CMAKE_PREFIX_PATH} - CACHE string "iOS find search path root" -) - -# default to searching for frameworks first +set(CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks") +set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names") +set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names") +set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,") +set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a") +set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name") + +# Set the find root to the iOS developer roots and to user defined paths. +set(CMAKE_FIND_ROOT_PATH ${CMAKE_OSX_SYSROOT_INT} ${CMAKE_PREFIX_PATH} CACHE STRING "Root path that will be prepended + to all search paths") +# Default to searching for frameworks first. set(CMAKE_FIND_FRAMEWORK FIRST) +# Set up the default search directories for frameworks. +set(CMAKE_FRAMEWORK_PATH + ${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks + ${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks + ${CMAKE_FRAMEWORK_PATH} CACHE STRING "Frameworks search paths" ${FORCE_CACHE}) + +set(IOS_TOOLCHAIN_HAS_RUN TRUE CACHE BOOL "Has the CMake toolchain run already?" ${FORCE_CACHE}) + +# By default, search both the specified iOS SDK and the remainder of the host filesystem. +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH CACHE STRING "" ${FORCE_CACHE}) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH CACHE STRING "" ${FORCE_CACHE}) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH CACHE STRING "" ${FORCE_CACHE}) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH CACHE STRING "" ${FORCE_CACHE}) +endif() -# set up the default search directories for frameworks -set(CMAKE_SYSTEM_FRAMEWORK_PATH - ${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks - ${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks - ${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks -) - -# only search the iOS SDKs, not the remainder of the host filesystem -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) - -# this little macro lets you set any Xcode specific property -macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) - set_property(TARGET ${TARGET} - PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE}) +# +# Some helper-macros below to simplify and beautify the CMakeFile +# + +# This little macro lets you set any Xcode specific property. +macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION) + set(XCODE_RELVERSION_I "${XCODE_RELVERSION}") + if(XCODE_RELVERSION_I STREQUAL "All") + set_property(TARGET ${TARGET} PROPERTY + XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}") + else() + set_property(TARGET ${TARGET} PROPERTY + XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}") + endif() endmacro(set_xcode_property) -# this macro lets you find executable programs on the host system +# This macro lets you find executable programs on the host system. macro(find_host_package) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER) set(IOS FALSE) - find_package(${ARGN}) - set(IOS TRUE) - set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) endmacro(find_host_package) - -# eof From 69a2a77c24a2cceaa336172535e39e4de6ce5453 Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Tue, 23 Jun 2020 01:18:42 -0400 Subject: [PATCH 02/19] Add autotools tests for big 3 OS and build demos on them as we;; --- arch-setup.yml | 20 +++++++ azure-pipelines.yml | 124 +++++++++++++++++++++++++------------------- build-autotools.yml | 80 ++++++++++++++++++++++++++++ build-cmake.yml | 59 +++++++++++++++++++++ build.yml | 56 ++++---------------- mingw-setup.yml | 16 ++++++ 6 files changed, 257 insertions(+), 98 deletions(-) create mode 100644 arch-setup.yml create mode 100644 build-autotools.yml create mode 100644 build-cmake.yml create mode 100644 mingw-setup.yml diff --git a/arch-setup.yml b/arch-setup.yml new file mode 100644 index 000000000..6b3db729e --- /dev/null +++ b/arch-setup.yml @@ -0,0 +1,20 @@ +steps: + - bash: | + set -e + cd $(Build.BinariesDirectory) + ARCH_URL=`curl -s https://mirrors.acm.wpi.edu/archlinux/iso/latest/ | egrep -o 'archlinux-bootstrap-([0-9._]+)-x86_64.tar.gz' | head -n1` + echo https://mirrors.acm.wpi.edu/archlinux/iso/latest/$ARCH_URL + curl https://mirrors.acm.wpi.edu/archlinux/iso/latest/$ARCH_URL -o arch.tar.gz + sudo tar xzf arch.tar.gz + sudo mount --bind ./root.x86_64/ ./root.x86_64/ + sudo cp -R $(Agent.BuildDirectory)/freetype2 ./root.x86_64/ + sudo mkdir -p ./root.x86_64/$(Build.BinariesDirectory) + sudo mount --bind $(Build.BinariesDirectory) ./root.x86_64/$(Build.BinariesDirectory) + cat << EOF | sudo ./root.x86_64/bin/arch-chroot ./root.x86_64/ + set -e + echo 'Server = https://mirrors.kernel.org/archlinux/\$repo/os/\$arch' >> /etc/pacman.d/mirrorlist + pacman-key --init + pacman-key --populate archlinux + pacman -Syu --noconfirm base base-devel git gcc cmake harfbuzz zlib libpng + EOF + displayName: 'Bootstrap Archlinux' diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e99d4c383..7ed859898 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,5 +1,5 @@ # This file is responsible for seting up several compiler enviorments. -# Once setup is done, the template "build.yml" is invoked to test freetype +# Once setup is done, the template "build-cmake.yml" is invoked to test freetype # compiles successfully on various operating systems and compilers liststed # below. Artifacts of all builds are also published to azure. @@ -16,13 +16,27 @@ jobs: ## Linux ## -- job: ArchLinux +- job: ArchLinux_Autotools + displayName: "Archlinux Autotools" + pool: + vmImage: ubuntu-latest + steps: + - checkout: self + path: freetype2 + + - template: arch-setup.yml + + - template: build-autotools.yml + +- job: ArchLinux_Cmake + displayName: "Archlinux CMake" pool: vmImage: ubuntu-latest strategy: matrix: shared: BUILD_SHARED_LIBS: true + BUILD_ARGS: '-G "Unix Makefiles" -D BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)' static: BUILD_SHARED_LIBS: false @@ -30,37 +44,19 @@ jobs: - checkout: self path: freetype2 - - bash: | - set -e - cd $(Build.BinariesDirectory) - ARCH_URL=`curl -s https://mirrors.acm.wpi.edu/archlinux/iso/latest/ | egrep -o 'archlinux-bootstrap-([0-9._]+)-x86_64.tar.gz' | head -n1` - echo https://mirrors.acm.wpi.edu/archlinux/iso/latest/$ARCH_URL - curl https://mirrors.acm.wpi.edu/archlinux/iso/latest/$ARCH_URL -o arch.tar.gz - sudo tar xzf arch.tar.gz - sudo mount --bind ./root.x86_64/ ./root.x86_64/ - sudo cp -R $(Agent.BuildDirectory)/freetype2 ./root.x86_64/ - sudo mkdir -p ./root.x86_64/$(Build.BinariesDirectory) - sudo mount --bind $(Build.BinariesDirectory) ./root.x86_64/$(Build.BinariesDirectory) - cat << EOF | sudo ./root.x86_64/bin/arch-chroot ./root.x86_64/ - set -e - echo 'Server = https://mirrors.kernel.org/archlinux/\$repo/os/\$arch' >> /etc/pacman.d/mirrorlist - pacman-key --init - pacman-key --populate archlinux - pacman -Syu --noconfirm base base-devel git gcc cmake harfbuzz zlib libpng - EOF - displayName: 'Bootstrap Archlinux' + - template: arch-setup.yml - - template: build.yml + - template: build-cmake.yml parameters: preCMD: 'cd $(Build.BinariesDirectory) && cat << EOF | sudo ./root.x86_64/bin/arch-chroot ./root.x86_64/' srcDIR: freetype2 postCMD: 'EOF' - cmakeArgs: '-G "Unix Makefiles" -D BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)' + buildArgs: $(BUILD_ARGS) ## Windows ## -- job: MSVC_2019 - displayName: "MVSC 2019" +- job: MSVC_2019_CMake + displayName: "MVSC 2019 CMake" pool: vmImage: windows-latest strategy: @@ -96,11 +92,34 @@ jobs: vcpkgGitCommitId: $(vcpkgGitRef) vcpkgGitURL: https://github.com/microsoft/vcpkg.git - - template: build.yml + - template: build-cmake.yml + parameters: + buildArgs: '-G "Visual Studio 16 2019" -A $(ARCH) -D CMAKE_TOOLCHAIN_FILE=$(Build.BinariesDirectory)\vcpkg\scripts\buildsystems\vcpkg.cmake -D VCPKG_ROOT=$(Build.BinariesDirectory)\vcpkg -D VCPKG_TARGET_TRIPLET=$(TRIPLET) -D BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)' + +- job: MINGW_Autotools + displayName: "Mingw Autotools" + pool: + vmImage: windows-latest + strategy: + matrix: + i686: + MINGW_UPPER: MINGW32 + MINGW_LOWER: mingw32 + MINGW_ARCH: i686 + x86_64: + MINGW_UPPER: MINGW64 + MINGW_LOWER: mingw64 + MINGW_ARCH: x86_64 + + steps: + - template: mingw-setup.yml + + - template: build-autotools.yml parameters: - cmakeArgs: '-G "Visual Studio 16 2019" -A $(ARCH) -D CMAKE_TOOLCHAIN_FILE=$(Build.BinariesDirectory)\vcpkg\scripts\buildsystems\vcpkg.cmake -D VCPKG_ROOT=$(Build.BinariesDirectory)\vcpkg -D VCPKG_TARGET_TRIPLET=$(TRIPLET) -D BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)' + mingw: true -- job: MINGW +- job: MINGW_CMake + displayName: "MingGW CMake" pool: vmImage: windows-latest strategy: @@ -127,42 +146,43 @@ jobs: BUILD_SHARED_LIBS: false steps: - - script: | - git clone https://github.com/msys2/msys2-ci-base.git %CD:~0,2%\msys64 - %CD:~0,2%\msys64\usr\bin\rm -rf %CD:~0,2%\msys64\.git - displayName: Install MSYS2 - - - script: | - set PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem - %CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Syyuu - displayName: Update MSYS2 - - - script: | - set PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem - %CD:~0,2%\msys64\usr\bin\pacman --noconfirm --needed -S git base-devel mingw-w64-$(MINGW_ARCH)-toolchain mingw-w64-$(MINGW_ARCH)-cmake mingw-w64-$(MINGW_ARCH)-harfbuzz - %CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Scc - displayName: Install Toolchain + - template: mingw-setup.yml - - template: build.yml + - template: build-cmake.yml parameters: mingw: true - cmakeArgs: '-G \"MSYS Makefiles\" -D BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)' + buildArgs: '-G \"MSYS Makefiles\" -D BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)' ## MacOS X ## -- job: MacOS_X - displayName: "MacOS X" +- job: MacOS_X_Autotools + displayName: "MacOS X Autotools" + pool: + vmImage: macos-latest + + steps: + - script: | + curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh + bash ./install.sh + brew install autoconf automake + displayName: 'Install Brew' + + - template: build-autotools.yml + +- job: MacOS_X_CMake + displayName: "MacOS X CMake" pool: vmImage: macos-latest steps: - - template: build.yml + - template: build-cmake.yml parameters: - cmakeArgs: '-G Xcode -D BUILD_FRAMEWORK:BOOL=true' + buildArgs: '-G Xcode -D BUILD_FRAMEWORK:BOOL=true' ### iOS ## -- job: iOS +- job: iOS_CMake + displayName: "iOS CMake" pool: vmImage: macos-latest strategy: @@ -181,6 +201,6 @@ jobs: IOS_PLATFORM: SIMULATOR_WATCHOS steps: - - template: build.yml + - template: build-cmake.yml parameters: - cmakeArgs: '-G Xcode -D PLATFORM=$(IOS_PLATFORM)' + buildArgs: '-G Xcode -D PLATFORM=$(IOS_PLATFORM)' diff --git a/build-autotools.yml b/build-autotools.yml new file mode 100644 index 000000000..3c2a0a55b --- /dev/null +++ b/build-autotools.yml @@ -0,0 +1,80 @@ +# This is a template for building and publishing freetype2 build artifacts using autotools +parameters: +- name: buildArgs # Configure flags + default: '' +- name: mingw # Mingw requires special enviormental setup + type: boolean + default: false +- name: preCMD # Command(s) executed before calling configure + default: '' +- name: srcDIR # Location of freetype2 sources + default: '.' +- name: postCMD # Command(s) executed after calling make + default: '' + +steps: +- ${{ if eq(parameters.mingw, true) }}: + - script: | + set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem + cd $(Build.SourcesDirectory) + %CD:~0,2%\msys64\usr\bin\bash -lc "./autogen.sh && ./configure" + displayName: 'Configure' + env: + MSYSTEM: $(MINGW_UPPER) + CHERE_INVOKING: yes + MINGW_INSTALLS: $(MINGW_LOWER) + + - script: | + set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem + %CD:~0,2%\msys64\usr\bin\bash -lc "make && make install DESTDIR=$(echo \"$(Build.BinariesDirectory)/install\" | tr '\\' '/') && zip freetype-build.zip $(Build.BinariesDirectory)" + displayName: 'Build and Package' + env: + MSYSTEM: $(MINGW_UPPER) + CHERE_INVOKING: yes + MINGW_INSTALLS: $(MINGW_LOWER) + + - script: | + set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem + %CD:~0,2%\msys64\usr\bin\bash -lc "git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git && cd freetype2-demos && ln -s ${{ parameters.srcDIR }} ../freetype2 && make && mv bin/ $(Build.BinariesDirectory)/install/demos" + displayName: 'Build Demos' + env: + MSYSTEM: $(MINGW_UPPER) + CHERE_INVOKING: yes + MINGW_INSTALLS: $(MINGW_LOWER) + +- ${{ if eq(parameters.mingw, false) }}: + - script: | + ${{ parameters.preCMD }} + cd ${{ parameters.srcDIR }} + ./autogen.sh + ./configure ${{ parameters.buildArgs }} + ${{ parameters.postCMD }} + displayName: 'Configure' + + - script: | + ${{ parameters.preCMD }} + cd ${{ parameters.srcDIR }} + make + make install DESTDIR=$(Build.BinariesDirectory)/install + ${{ parameters.postCMD }} + displayName: 'Build and Install' + + - script: | + cd ${{ parameters.srcDIR }} + git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git + cd freetype2-demos + ln -s ${{ parameters.srcDIR }} ../freetype2 + make + mv bin/ $(Build.BinariesDirectory)/install/demos + displayName: 'Build Demos' + + +- script: | + zip -r $(Build.ArtifactStagingDirectory)/freetype-build.zip $(Build.BinariesDirectory)/install + displayName: 'Stage Artifacts' + +- task: PublishBuildArtifacts@1 + displayName: 'Push Build Artifacts' + inputs: + pathtoPublish: $(Build.ArtifactStagingDirectory) + artifactName: $(Agent.JobName) diff --git a/build-cmake.yml b/build-cmake.yml new file mode 100644 index 000000000..001a4799b --- /dev/null +++ b/build-cmake.yml @@ -0,0 +1,59 @@ +# This is a template for building and publishing freetype2 build artifacts using CMake + +parameters: +- name: buildArgs # CMake configure flags + default: '' +- name: mingw # Mingw requires special enviormental setup + type: boolean + default: false +- name: preCMD # Command(s) executed before calling CMake + default: '' +- name: srcDIR # Location of freetype2 sources + default: '.' +- name: postCMD # Command(s) executed after calling CMake + default: '' + +steps: +- ${{ if eq(parameters.mingw, true) }}: + - script: | + set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem + cd $(Build.SourcesDirectory) + %CD:~0,2%\msys64\usr\bin\bash -lc "cmake . ${{ parameters.buildArgs }} -B $(echo \"$(Build.BinariesDirectory)\" | tr '\\' '/') -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=install" + displayName: 'CMake Configure' + env: + MSYSTEM: $(MINGW_UPPER) + CHERE_INVOKING: yes + MINGW_INSTALLS: $(MINGW_LOWER) + + - script: | + set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem + %CD:~0,2%\msys64\usr\bin\bash -lc "cmake --build $(echo \"$(Build.BinariesDirectory)\" | tr '\\' '/') --config Release --target package" + displayName: 'CMake Build and Package' + env: + MSYSTEM: $(MINGW_UPPER) + CHERE_INVOKING: yes + MINGW_INSTALLS: $(MINGW_LOWER) + +- ${{ if eq(parameters.mingw, false) }}: + - script: | + ${{ parameters.preCMD }} + cd ${{ parameters.srcDIR }} + cmake . ${{ parameters.buildArgs }} -B $(Build.BinariesDirectory) -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=install + ${{ parameters.postCMD }} + displayName: 'CMake Configure' + + - script: | + ${{ parameters.preCMD }} + cd ${{ parameters.srcDIR }} + cmake --build $(Build.BinariesDirectory) --config Release --target package + ${{ parameters.postCMD }} + displayName: 'CMake Build and Package' + +- script: mv $(Build.BinariesDirectory)/freetype-* $(Build.ArtifactStagingDirectory) + displayName: 'Stage Artifacts' + +- task: PublishBuildArtifacts@1 + displayName: 'Push Build Artifacts' + inputs: + pathtoPublish: $(Build.ArtifactStagingDirectory) + artifactName: $(Agent.JobName) diff --git a/build.yml b/build.yml index 7eade8e76..56b534986 100644 --- a/build.yml +++ b/build.yml @@ -1,7 +1,9 @@ -# This is a template for building and publishing freetype2 build artifacts using CMake +# passthrough templateto call other build templates parameters: -- name: cmakeArgs # CMake configure flags +- name: buildArgs # CMake configure flags + default: '' +- name: buildArgs # CMake configure flags default: '' - name: mingw # Mingw requires special enviormental setup type: boolean @@ -13,47 +15,9 @@ parameters: - name: postCMD # Command(s) executed after calling CMake default: '' -steps: -- ${{ if eq(parameters.mingw, true) }}: - - script: | - set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem - cd $(Build.SourcesDirectory) - %CD:~0,2%\msys64\usr\bin\bash -lc "cmake . ${{ parameters.cmakeArgs }} -B $(echo \"$(Build.BinariesDirectory)\" | tr '\\' '/') -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=install" - displayName: 'CMake Configure' - env: - MSYSTEM: $(MINGW_UPPER) - CHERE_INVOKING: yes - MINGW_INSTALLS: $(MINGW_LOWER) - - - script: | - set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem - %CD:~0,2%\msys64\usr\bin\bash -lc "cmake --build $(echo \"$(Build.BinariesDirectory)\" | tr '\\' '/') --config Release --target package" - displayName: 'CMake Build and Package' - env: - MSYSTEM: $(MINGW_UPPER) - CHERE_INVOKING: yes - MINGW_INSTALLS: $(MINGW_LOWER) - -- ${{ if eq(parameters.mingw, false) }}: - - script: | - ${{ parameters.preCMD }} - cd ${{ parameters.srcDIR }} - cmake . ${{ parameters.cmakeArgs }} -B $(Build.BinariesDirectory) -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=install - ${{ parameters.postCMD }} - displayName: 'CMake Configure' - - - script: | - ${{ parameters.preCMD }} - cd ${{ parameters.srcDIR }} - cmake --build $(Build.BinariesDirectory) --config Release --target package - ${{ parameters.postCMD }} - displayName: 'CMake Build and Package' - -- script: mv $(Build.BinariesDirectory)/freetype-* $(Build.ArtifactStagingDirectory) - displayName: 'Stage Artifacts' - -- task: PublishBuildArtifacts@1 - displayName: 'Push Build Artifacts' - inputs: - pathtoPublish: $(Build.ArtifactStagingDirectory) - artifactName: $(Agent.JobName) +- template: build-autotools.yml + parameters: + preCMD: ${{ parameters.preCMD }} + srcDIR: ${{ parameters.srcDIR }} + postCMD: ${{ parameters.postCMD }} + buildArgs: ${{ parameters.buildArgs }} diff --git a/mingw-setup.yml b/mingw-setup.yml new file mode 100644 index 000000000..fc1c69fb0 --- /dev/null +++ b/mingw-setup.yml @@ -0,0 +1,16 @@ +steps: + - script: | + git clone https://github.com/msys2/msys2-ci-base.git %CD:~0,2%\msys64 + %CD:~0,2%\msys64\usr\bin\rm -rf %CD:~0,2%\msys64\.git + displayName: Install MSYS2 + + - script: | + set PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem + %CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Syyuu + displayName: Update MSYS2 + + - script: | + set PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem + %CD:~0,2%\msys64\usr\bin\pacman --noconfirm --needed -S git base-devel mingw-w64-$(MINGW_ARCH)-toolchain mingw-w64-$(MINGW_ARCH)-cmake mingw-w64-$(MINGW_ARCH)-harfbuzz + %CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Scc + displayName: Install Toolchain From ec3cb3126fa1412eed6386148e46fbbb836deb08 Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Wed, 15 Jul 2020 20:50:44 -0400 Subject: [PATCH 03/19] start regression --- ft-regression.sh | 65 +++++++++++++++++++++++++++++ ft-report.sh | 106 +++++++++++++++++++++++++++++++++++++++++++++++ ft-test-font.sh | 66 +++++++++++++++++++++++++++++ ft-test.sh | 19 +++++++++ 4 files changed, 256 insertions(+) create mode 100755 ft-regression.sh create mode 100755 ft-report.sh create mode 100755 ft-test-font.sh create mode 100755 ft-test.sh diff --git a/ft-regression.sh b/ft-regression.sh new file mode 100755 index 000000000..a7c789c3b --- /dev/null +++ b/ft-regression.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +function build() { + set -e # exit on error + ./autogen.sh + ./configure + make + pushd .. + [[ -d ./freetype2-demos ]] || git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git + pushd freetype2-demos + make + popd + popd + set +e +} + +if [ -z "$1" ]; then + echo "No commit specified to check out master for regression tests." + echo "Aborting!" + exit 1 +fi + +if [ -z "$2" ]; then + echo "No directory specified to check out master for regression tests." + echo "Aborting!" + exit 1 +fi + +export COMP_COMMIT_DIR="$2" + +if [ -d "${COMP_COMMIT_DIR}" ]; then + read -p "Remove existing directory ${COMP_COMMIT_DIR} (y/n)? " CONT + if [ "$CONT" = "y" ]; then + rm -rf "${COMP_COMMIT_DIR}" + fi +fi + +PREV_GIT_HASH=$(git log --pretty=format:'%h' -n 1) + +build +./ft-test.sh + +echo "Copying ${PWD} to ${COMP_COMMIT_DIR}" +cp -p -r "${PWD}" "${COMP_COMMIT_DIR}" + +PREVIOUS_PWD=${PWD} +pushd "${COMP_COMMIT_DIR}" + +# clean before we checkout +make clean + +if [[ "${PWD}" == "${COMP_COMMIT_DIR}" ]]; then + git stash + git clean -f -d + git checkout "$1" + GIT_HASH=$(git log --pretty=format:'%h' -n 1) + build + ./ft-test.sh ${PREV_GIT_HASH} ${GIT_HASH} + popd +else + echo "Failed to change directory to ${COMP_COMMIT_DIR}. Something is horribly wrong..." + echo "Aborting!" + exit 1 +fi + diff --git a/ft-report.sh b/ft-report.sh new file mode 100755 index 000000000..38543319c --- /dev/null +++ b/ft-report.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +# Arguments + +FONT=$1 +SIZE=$2 +COMMIT_A=$3 +COMMIT_B=$4 + +OUTDIR_A="/tmp/ft-tests/${COMMIT_A}/$(basename ${FONT})/${SIZE}/" +OUTDIR_B="/tmp/ft-tests/${COMMIT_B}/$(basename ${FONT})/${SIZE}/" + +function write_img_comp() { + echo " + + + + + +

Comparison of $(basename $1) between commits

+
+ + " +} + +echo " + + + + + + +

Freetype2 Difference Report

+ +" + +PASS=() +FAIL=() +FILES=${OUTDIR_A}/* + +for f in $FILES +do + derp=$(diff $f ${OUTDIR_B}/$(basename $f)) # we only care about return result + result=$? + if [ "$result" -eq "0" ]; + then + PASS+="$f " + else + FAIL+="$f " + fi +done + +echo "" + +for f in $FAIL +do + PAGE="$(basename $f .png).html" + write_img_comp $f &> $PAGE + echo " + + + " +done + +echo "" + +for f in $PASS +do + echo " + + + " +done + +echo " +
FAIL
$(basename $f)
PASS
$(basename $f)
+ + +" diff --git a/ft-test-font.sh b/ft-test-font.sh new file mode 100755 index 000000000..eba3896b1 --- /dev/null +++ b/ft-test-font.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# Arguments +COMMIT=$1 +FONT=$2 +SIZE=$3 +DPI=$4 +BENCH=$5 +VIEW=$6 +STRING=$7 +START_C=$8 +END_C=$9 + +DEMOSDIR="../freetype2-demos/bin" +OUTDIR="/tmp/ft-tests/${COMMIT}/$(basename ${FONT})/${SIZE}/" + +function startX { + Xvfb :"$1" -screen 0 1024x768x24 & + XVFB_PIDS+=( $! ) + DISPLAY=:"$1" xfwm4 & + sleep 2 +} + +function xvfbRunAndScreenShot { + display="$1" + shift + screenshot_name="$1" + shift + DISPLAY=:"$display" $@ & + PID=$! + sleep 1 + DISPLAY=:"$display" xwd -root -silent | convert -trim xwd:- png:${OUTDIR}/${screenshot_name} + kill $PID +} + +mkdir -p $OUTDIR + +WORKERS=10 + +for worker in $(seq 1 $WORKERS) +do + startX $((98 + ${worker})) & +done + +if [[ "$BENCH" -eq 1 ]]; then + $DEMOSDIR/ftbench ${FONT} &> ${OUTDIR}/bench.txt +fi + +if [[ "$STRING" -eq 1 ]]; then + xvfbRunAndScreenShot 99 "$ftstring.png" $DEMOSDIR/ftstring -r $DPI ${SIZE} ${FONT} +fi + +if [[ "$VIEW" -eq 1 ]]; then + xvfbRunAndScreenShot 99 "ftview.png" $DEMOSDIR/ftview -r $DPI ${SIZE} ${FONT} +fi + +for char in $(seq ${START_C} ${END_C}) +do + ((i=i%WORKERS)); ((i++==0)) && wait + char_padded=$(printf "%03d" ${char}) + xvfbRunAndScreenShot $((98 + ${i})) "ftgrid_${char_padded}.png" $DEMOSDIR/ftgrid -r $DPI -f ${char} ${SIZE} ${FONT} & +done + +sleep 2 # wait for workers to finish up + +killall Xvfb diff --git a/ft-test.sh b/ft-test.sh new file mode 100755 index 000000000..3decb68e8 --- /dev/null +++ b/ft-test.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Arguments +#COMMIT=$1 +#FONT=$2 +#SIZE=$3 +#DPI=$4 +#BENCH=$5 +#VIEW=$6 +#STRING=$7 +#START_C=$8 +#END_C=$9 + +GIT_HASH=$(git log --pretty=format:'%h' -n 1) + +./ft-test-font.sh ${GIT_HASH} /home/greg/Inconsolata-Regular.ttf 16 72 1 1 1 0 963 +if [ ! -z "$1" ]; then + ./ft-report.sh /home/greg/Inconsolata-Regular.ttf 16 ${1} ${2} &> /tmp/ft-report.html +fi From d9ab3dd705bb3be55009766a7cd70cedd316060a Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Fri, 17 Jul 2020 15:58:29 -0400 Subject: [PATCH 04/19] start tests --- ft-regression.sh | 4 ++-- ft-test-font.sh | 1 + ft-test.sh | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ft-regression.sh b/ft-regression.sh index a7c789c3b..c8b823b99 100755 --- a/ft-regression.sh +++ b/ft-regression.sh @@ -36,6 +36,7 @@ if [ -d "${COMP_COMMIT_DIR}" ]; then fi PREV_GIT_HASH=$(git log --pretty=format:'%h' -n 1) +export PREVIOUS_PWD=${PWD} build ./ft-test.sh @@ -43,7 +44,6 @@ build echo "Copying ${PWD} to ${COMP_COMMIT_DIR}" cp -p -r "${PWD}" "${COMP_COMMIT_DIR}" -PREVIOUS_PWD=${PWD} pushd "${COMP_COMMIT_DIR}" # clean before we checkout @@ -55,7 +55,7 @@ if [[ "${PWD}" == "${COMP_COMMIT_DIR}" ]]; then git checkout "$1" GIT_HASH=$(git log --pretty=format:'%h' -n 1) build - ./ft-test.sh ${PREV_GIT_HASH} ${GIT_HASH} + ${PREVIOUS_PWD}/ft-test.sh ${PREV_GIT_HASH} ${GIT_HASH} popd else echo "Failed to change directory to ${COMP_COMMIT_DIR}. Something is horribly wrong..." diff --git a/ft-test-font.sh b/ft-test-font.sh index eba3896b1..3d068bc1b 100755 --- a/ft-test-font.sh +++ b/ft-test-font.sh @@ -57,6 +57,7 @@ fi for char in $(seq ${START_C} ${END_C}) do ((i=i%WORKERS)); ((i++==0)) && wait + echo "ftgrid ${char}" char_padded=$(printf "%03d" ${char}) xvfbRunAndScreenShot $((98 + ${i})) "ftgrid_${char_padded}.png" $DEMOSDIR/ftgrid -r $DPI -f ${char} ${SIZE} ${FONT} & done diff --git a/ft-test.sh b/ft-test.sh index 3decb68e8..6039bff46 100755 --- a/ft-test.sh +++ b/ft-test.sh @@ -13,7 +13,7 @@ GIT_HASH=$(git log --pretty=format:'%h' -n 1) -./ft-test-font.sh ${GIT_HASH} /home/greg/Inconsolata-Regular.ttf 16 72 1 1 1 0 963 +${PREVIOUS_PWD}/ft-test-font.sh ${GIT_HASH} /home/greg/Inconsolata-Regular.ttf 16 72 1 1 1 0 963 if [ ! -z "$1" ]; then - ./ft-report.sh /home/greg/Inconsolata-Regular.ttf 16 ${1} ${2} &> /tmp/ft-report.html + ${PREVIOUS_PWD}/ft-report.sh /home/greg/Inconsolata-Regular.ttf 16 ${1} ${2} &> /tmp/ft-report.html fi From 5f99a5b22113df808f3c72273848678369d47087 Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Tue, 28 Jul 2020 03:05:26 -0400 Subject: [PATCH 05/19] ci version 1 --- arch-setup.yml => CI/arch-setup.yml | 5 +- build-autotools.yml => CI/build-autotools.yml | 0 build-cmake.yml => CI/build-cmake.yml | 0 build.yml => CI/build.yml | 0 CI/ft-regression.sh | 91 ++++++++++ CI/ft-report.sh | 160 ++++++++++++++++++ CI/ft-test-font.sh | 92 ++++++++++ CI/ft-test.sh | 104 ++++++++++++ mingw-setup.yml => CI/mingw-setup.yml | 0 CI/regression-test.yml | 37 ++++ azure-pipelines.yml | 43 +++-- ft-regression.sh | 65 ------- ft-report.sh | 106 ------------ ft-test-font.sh | 67 -------- ft-test.sh | 19 --- 15 files changed, 516 insertions(+), 273 deletions(-) rename arch-setup.yml => CI/arch-setup.yml (89%) rename build-autotools.yml => CI/build-autotools.yml (100%) rename build-cmake.yml => CI/build-cmake.yml (100%) rename build.yml => CI/build.yml (100%) create mode 100755 CI/ft-regression.sh create mode 100755 CI/ft-report.sh create mode 100755 CI/ft-test-font.sh create mode 100755 CI/ft-test.sh rename mingw-setup.yml => CI/mingw-setup.yml (100%) create mode 100644 CI/regression-test.yml delete mode 100755 ft-regression.sh delete mode 100755 ft-report.sh delete mode 100755 ft-test-font.sh delete mode 100755 ft-test.sh diff --git a/arch-setup.yml b/CI/arch-setup.yml similarity index 89% rename from arch-setup.yml rename to CI/arch-setup.yml index 6b3db729e..afa428576 100644 --- a/arch-setup.yml +++ b/CI/arch-setup.yml @@ -9,12 +9,13 @@ steps: sudo mount --bind ./root.x86_64/ ./root.x86_64/ sudo cp -R $(Agent.BuildDirectory)/freetype2 ./root.x86_64/ sudo mkdir -p ./root.x86_64/$(Build.BinariesDirectory) - sudo mount --bind $(Build.BinariesDirectory) ./root.x86_64/$(Build.BinariesDirectory) + sudo mount --bind $(Build.BinariesDirectory) ./root.x86_64/$(Build.BinariesDirectory) cat << EOF | sudo ./root.x86_64/bin/arch-chroot ./root.x86_64/ set -e echo 'Server = https://mirrors.kernel.org/archlinux/\$repo/os/\$arch' >> /etc/pacman.d/mirrorlist pacman-key --init pacman-key --populate archlinux - pacman -Syu --noconfirm base base-devel git gcc cmake harfbuzz zlib libpng + pacman -Syu --noconfirm base base-devel git gcc cmake harfbuzz zlib libpng xorg-server-xvfb imagemagick npm xorg-xwd + npm install -g pretty-diff EOF displayName: 'Bootstrap Archlinux' diff --git a/build-autotools.yml b/CI/build-autotools.yml similarity index 100% rename from build-autotools.yml rename to CI/build-autotools.yml diff --git a/build-cmake.yml b/CI/build-cmake.yml similarity index 100% rename from build-cmake.yml rename to CI/build-cmake.yml diff --git a/build.yml b/CI/build.yml similarity index 100% rename from build.yml rename to CI/build.yml diff --git a/CI/ft-regression.sh b/CI/ft-regression.sh new file mode 100755 index 000000000..d95602e4e --- /dev/null +++ b/CI/ft-regression.sh @@ -0,0 +1,91 @@ +#!/bin/bash + +# Usage: ./CI/ft-regression.sh + +# The following script checks the source code in the current folder for +# regressions or changes against previous commits. This is the main script you +# should be calling and the rest are more for utility. + +# These scripts requires xvfb (for capturing demos), imagick +# (for comparing images) and pretty-diff which can be installed via npm +# (for diffing text) + +# Below is utility function used to build both versions of freetype and +# respective demos exes linked against the specific builds +function build() { + # Here we set the script to exit on any failed command because if the build + # fails, then there's nothing to compare so no point in continuing. + set -e + ./autogen.sh + ./configure + make + pushd .. + [[ -d ./freetype2-demos ]]\ + || git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git + pushd freetype2-demos + make + popd + popd + # Unset exit on error so the tests will continue to run despie any errors. + set +e +} + +# The script wasn't passed a git hash to compare so we exit early and print. +if [ -z "$1" ]; then + echo "No commit specified to check out master for regression tests." + echo "Aborting!" + exit 1 +fi + +# This is where we build the commit of freetype we wish to compare against. We +# export it here because this variable is used in other scripts invoked later. +export COMP_COMMIT_DIR="/tmp/freetype2" + +# We want a fresh checkout and work dir in order to prevent any stale changes +# from slipping through. +rm -rf "${COMP_COMMIT_DIR}" "/tmp/ft-test/" + +# Here we store the current directories shortened commit hash which is used as +# the subdirectory name for where to dump the logs and images. +PREV_GIT_HASH=$(git log --pretty=format:'%h' -n 1) + +# Again we export this because it's used in the other scripts later. +export PREVIOUS_PWD=${PWD} + +# This is the first build/run of the current dir that will dump our "A" +# metricts. +build +./CI/ft-test.sh + +# Next we set up our "B" directory by copyiing our current sources. +echo "Copying ${PWD} to ${COMP_COMMIT_DIR}" +cp -p -r "${PWD}" "${COMP_COMMIT_DIR}" +pushd "${COMP_COMMIT_DIR}" + +# Clean before we checkout +make clean + +# Here we stash / clean in the copied "B" directory to prevent any issues +# checking out the desired test commit. +if [[ "${PWD}" == "${COMP_COMMIT_DIR}" ]]; then + git stash + git clean -f -d + git checkout "$1" + GIT_HASH=$(git log --pretty=format:'%h' -n 1) + # Here we start the build / metrics for build "B" + build + # We call the scripts from the current directory as they may not exist in + # previous commits and to prevent confusion when modifying them. One set of + # scripts is called but on each call they call different versions of the demos + # exes. + ${PREVIOUS_PWD}/CI/ft-test.sh ${PREV_GIT_HASH} ${GIT_HASH} + EXIT=$? + popd +else + echo "Failed to change directory to ${COMP_COMMIT_DIR}.\ + Something is horribly wrong..." + echo "Aborting!" + exit 1 +fi + +exit 0 diff --git a/CI/ft-report.sh b/CI/ft-report.sh new file mode 100755 index 000000000..3a9925795 --- /dev/null +++ b/CI/ft-report.sh @@ -0,0 +1,160 @@ +#!/bin/bash + +# Arguments +FONT=$1 +SIZE=$2 +COMMIT_A=$3 +COMMIT_B=$4 + +# This script generates diffs and html reports from the metrics previously +# generated. + +EXIT=0 + +metrics_dir="$(basename ${FONT})/${SIZE}/" +diff_dir="/tmp/ft-tests/${COMMIT_A}_${COMMIT_B}_diffs/${metrics_dir}" +mkdir -p "${diff_dir}" + +OUTDIR_A="/tmp/ft-tests/${COMMIT_A}/$(basename ${FONT})/${SIZE}/" +OUTDIR_B="/tmp/ft-tests/${COMMIT_B}/$(basename ${FONT})/${SIZE}/" + +# Function below generates a page to compare images. The image should change +# between the two versions on mouse over to easily spot differences. +function write_img_comp() { + echo " + + + + + +

+ Comparison of $(basename $1) between commits ${COMMIT_A} and ${COMMIT_B} +

+
+ + " +} + +# Here we start generating html report. It is just a simple table of pass / fail +# results. +echo " + + + + + + +

Freetype2 Difference Report

+

+Commit A: ${COMMIT_A} +Commit B: ${COMMIT_B} +

+

+Font: $(basename $1) +

+

+Size: $2 +

+" + +PASS=() +FAIL=() +FILES=${OUTDIR_A}/* + +for f in $FILES +do + filename=$(basename $f) + extension="${filename##*.}" + + # If is png compare with imagick + if [[ "$extension" == "png" ]]; + then + diif_cmd=$(compare -metric AE $f ${OUTDIR_B}/$(basename $f)\ + "${diff_dir}/$(basename $f .png)_diff.png" &> /dev/null) + result=$? + # Else if txt compare with + else + diif_cmd=$(diff $f ${OUTDIR_B}/$(basename $f) &>\ + $diff_dir/$(basename $f .$extension).diff) # we only care about return result + result=$? + fi + + # Generate approriate diff page + PAGE="$(basename $f .$extension).html" + if [ "$result" -eq "0" ]; + then + PASS+="$f " + else + if [[ "$extension" == "png" ]]; + then + write_img_comp $f &> "${diff_dir}/$PAGE" + else + DISPLAY=-1 pretty-diff $f ${OUTDIR_B}/$(basename $f) + mv /tmp/diff.html "${diff_dir}/$PAGE" + fi + FAIL+="$f " + fi +done + +# Below we fill out the results table +echo "" + +for f in $FAIL +do + filename=$(basename $f) + extension="${filename##*.}" + if [[ "$filename" != "bench.txt" ]]; + then + EXIT=1 + fi + PAGE="$(basename $f .$extension).html" + echo " + + + " +done + +echo "" + +for f in $PASS +do + echo " + + + " +done + +echo " +
FAIL
$(basename $f)
PASS
$(basename $f)
+ + +" + +exit $EXIT diff --git a/CI/ft-test-font.sh b/CI/ft-test-font.sh new file mode 100755 index 000000000..c6eb6c53f --- /dev/null +++ b/CI/ft-test-font.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +# Arguments +COMMIT=$1 +FONT=$2 +SIZE=$3 +DPI=$4 +DUMP=$5 +BENCH=$6 +VIEW=$7 +STRING=$8 +START_GLYPH=$9 +END_GLYPH=${10} + +# This script dumps specified metrics for a specified font. The arguments listed +# above allow you to specify which metricts to dum when this script is called +# from ft-test.sh + +DEMOSDIR="../freetype2-demos/bin" +OUTDIR="/tmp/ft-tests/${COMMIT}/$(basename ${FONT})/${SIZE}/" + +# Below sets up a virtual X framebuffer to run the demos in. It is 1024x768 at +# 24b depth. If you need a larget screen to fit the demos change the resolution +# here. +function startX { + if [ ! -f "/tmp/.X${1}-lock" ]; then + Xvfb :"$1" -screen 0 1024x768x24 & + # Wait 2 seconds to ensure X is ready. + sleep 2 + fi +} + +# Below is a utility function to run a command inside the virtual frame buffer, +# wait 1 second and capture the screen and kill it.The first two arguments are +# the xvfb ID and the output image file name. +function xvfbRunAndScreenShot { + display="$1" + shift + screenshot_name="$1" + shift + DISPLAY=:"$display" $@ & + PID=$! + sleep 1 + DISPLAY=:"$display" xwd -root -silent\ + | convert -trim xwd:- png:${OUTDIR}/${screenshot_name} + kill $PID +} + +# Ensure directory we want to write to exists. +mkdir -p $OUTDIR + +# Because witing 1 second for every command can be slow we set up multiple xvfbs +# in order to expedite the proccess. +WORKERS=10 +for worker in $(seq 1 $WORKERS) +do + startX $((98 + ${worker})) & +done + +# Below are simple metricts to test that only require one run per font. +if [[ "$DUMP" -eq 1 ]]; then + $DEMOSDIR/ftdump ${FONT} &> ${OUTDIR}/dump.txt +fi + +if [[ "$BENCH" -eq 1 ]]; then + $DEMOSDIR/ftbench ${FONT} &> ${OUTDIR}/bench.txt +fi + +if [[ "$STRING" -eq 1 ]]; then + xvfbRunAndScreenShot 99 "ftstring.png" $DEMOSDIR/ftstring\ + -r $DPI ${SIZE} ${FONT} +fi + +if [[ "$VIEW" -eq 1 ]]; then + xvfbRunAndScreenShot 99 "ftview.png" $DEMOSDIR/ftview -r $DPI ${SIZE} ${FONT} +fi + +# For ftgrid we run it on thousands of glyphys so this loop takes advantage of +# the above mentioned xvfb workers to speed it up. +for GLYPH in $(seq ${START_GLYPH} ${END_GLYPH}) +do + ((i=i%WORKERS)); ((i++==0)) && wait + echo "$(basename $FONT) ftgrid ${GLYPH}" + # Pad name with 0s to maintain order + GLYPH_padded=$(printf "%04d" ${GLYPH}) + xvfbRunAndScreenShot $((98 + ${i})) "ftgrid_${GLYPH_padded}.png"\ + $DEMOSDIR/ftgrid -r $DPI -f ${GLYPH} ${SIZE} ${FONT} & +done + +sleep 2 # wait for workers to finish up +killall Xvfb +sleep 2 # wait for all xvfb to die diff --git a/CI/ft-test.sh b/CI/ft-test.sh new file mode 100755 index 000000000..b9899779a --- /dev/null +++ b/CI/ft-test.sh @@ -0,0 +1,104 @@ +#!/bin/bash + +# Arguments to /ft-test-font.sh +#COMMIT=$1 +#FONT=$2 +#SIZE=$3 +#DPI=$4 +#DUMP=$5 +#BENCH=$6 +#VIEW=$7 +#STRING=$8 +#START_GLYPH=$9 +#END_GLYPH=$10 + +# This script is where one might add additional tests. Currently, it cycles +# through the below directory and call the metric dumping script for any files +# in that directory. Currently, it only tests all files at pt 16 and dpi 72 and +# with ft-grid's default rendering mode. + +FILES=~/test-fonts/* + +GIT_HASH=$(git log --pretty=format:'%h' -n 1) + +EXIT=0 +DEMOSDIR="../freetype2-demos/bin" +PASS=() +FAIL=() + +for f in $FILES +do + GLYPHCOUNT=$(${DEMOSDIR}/ftdump $f | grep "glyph count" | sed 's/\s*glyph count:\s*\([0-9]\+\)/\1/') + ${PREVIOUS_PWD}/CI/ft-test-font.sh ${GIT_HASH} $f 16 72 1 1 1 1 0 ${GLYPHCOUNT} + if [ ! -z "$1" ]; then + ${PREVIOUS_PWD}/CI/ft-report.sh $f 16 ${1} ${2}\ + &> /tmp/ft-tests/ft-$(basename $f)-16-report.html + result=$? + if [ "$result" -eq "0" ]; + then + RESULT_STR="PASS" + PASS+="ft-$(basename $f)-16-report.html " + else + RESULT_STR="FAIL" + FAIL+="ft-$(basename $f)-16-report.html " + # We store any failure to use later in the exit command. + EXIT=1 + fi + echo "ft-$(basename $f)-16-report.html [$RESULT_STR]" + fi +done + +# Below we generate an index of all reports generated +echo " + + + + + +

Freetype2 Difference Reports Index

+" &> "/tmp/ft-tests/index.html" + +echo "" &>> "/tmp/ft-tests/index.html" + +for f in $FAIL +do + echo " + + + " &>> "/tmp/ft-tests/index.html" +done + +echo "" &>> "/tmp/ft-tests/index.html" + +for f in $PASS +do + echo " + + + " &>> "/tmp/ft-tests/index.html" +done + +echo " +
FAIL
$(basename $f .html)
PASS
$(basename $f .html)
+ + +" &>> "/tmp/ft-tests/index.html" + +exit $EXIT diff --git a/mingw-setup.yml b/CI/mingw-setup.yml similarity index 100% rename from mingw-setup.yml rename to CI/mingw-setup.yml diff --git a/CI/regression-test.yml b/CI/regression-test.yml new file mode 100644 index 000000000..9a9d18ea6 --- /dev/null +++ b/CI/regression-test.yml @@ -0,0 +1,37 @@ +# This is a template for building, running and publishing freetype2 build +# regression test artifacts +parameters: +- name: preCMD # Command(s) executed before calling configure + default: '' +- name: srcDIR # Location of freetype2 sources + default: '.' +- name: postCMD # Command(s) executed after calling make + default: '' + +steps: + - script: | + ${{ parameters.preCMD }} + curl https://releases.pagure.org/liberation-fonts/liberation-fonts-ttf-2.00.1.tar.gz -o /tmp/fonts.tar.gz + tar -xf /tmp/fonts.tar.gz + mkdir -p ~/test-fonts/ + mv liberation-fonts-*/*.ttf ~/test-fonts/ + cd ${{ parameters.srcDIR }} + git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git + cd freetype2-demos + ln -s ${{ parameters.srcDIR }} ../freetype2 + cd /freetype2 + ./CI/ft-regression.sh master + chmod -R 755 /tmp/ft-tests/ + mv /tmp/ft-tests/ / + ${{ parameters.postCMD }} + displayName: 'Run Regression Tests' + + - script: | + cp -R $(Build.BinariesDirectory)/root.x86_64/ft-tests $(Build.ArtifactStagingDirectory) + displayName: 'Stage Artifacts' + + - task: PublishBuildArtifacts@1 + displayName: 'Push Build Artifacts' + inputs: + pathtoPublish: $(Build.ArtifactStagingDirectory) + artifactName: $(Agent.JobName) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7ed859898..ef968431f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,5 +1,5 @@ # This file is responsible for seting up several compiler enviorments. -# Once setup is done, the template "build-cmake.yml" is invoked to test freetype +# Once setup is done, the template "CI/build-cmake.yml" is invoked to test freetype # compiles successfully on various operating systems and compilers liststed # below. Artifacts of all builds are also published to azure. @@ -15,7 +15,22 @@ variables: jobs: ## Linux ## - +- job: ArchLinux_Regression + displayName: "Archlinux Regression tests" + pool: + vmImage: ubuntu-latest + steps: + - checkout: self + path: freetype2 + + - template: CI/arch-setup.yml + + - template: CI/regression-test.yml + parameters: + preCMD: 'cd $(Build.BinariesDirectory) && cat << EOF | sudo ./root.x86_64/bin/arch-chroot ./root.x86_64/' + srcDIR: freetype2 + postCMD: 'EOF' + - job: ArchLinux_Autotools displayName: "Archlinux Autotools" pool: @@ -24,9 +39,9 @@ jobs: - checkout: self path: freetype2 - - template: arch-setup.yml + - template: CI/arch-setup.yml - - template: build-autotools.yml + - template: CI/build-autotools.yml - job: ArchLinux_Cmake displayName: "Archlinux CMake" @@ -44,9 +59,9 @@ jobs: - checkout: self path: freetype2 - - template: arch-setup.yml + - template: CI/arch-setup.yml - - template: build-cmake.yml + - template: CI/build-cmake.yml parameters: preCMD: 'cd $(Build.BinariesDirectory) && cat << EOF | sudo ./root.x86_64/bin/arch-chroot ./root.x86_64/' srcDIR: freetype2 @@ -92,7 +107,7 @@ jobs: vcpkgGitCommitId: $(vcpkgGitRef) vcpkgGitURL: https://github.com/microsoft/vcpkg.git - - template: build-cmake.yml + - template: CI/build-cmake.yml parameters: buildArgs: '-G "Visual Studio 16 2019" -A $(ARCH) -D CMAKE_TOOLCHAIN_FILE=$(Build.BinariesDirectory)\vcpkg\scripts\buildsystems\vcpkg.cmake -D VCPKG_ROOT=$(Build.BinariesDirectory)\vcpkg -D VCPKG_TARGET_TRIPLET=$(TRIPLET) -D BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)' @@ -112,9 +127,9 @@ jobs: MINGW_ARCH: x86_64 steps: - - template: mingw-setup.yml + - template: CI/mingw-setup.yml - - template: build-autotools.yml + - template: CI/build-autotools.yml parameters: mingw: true @@ -146,9 +161,9 @@ jobs: BUILD_SHARED_LIBS: false steps: - - template: mingw-setup.yml + - template: CI/mingw-setup.yml - - template: build-cmake.yml + - template: CI/build-cmake.yml parameters: mingw: true buildArgs: '-G \"MSYS Makefiles\" -D BUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS)' @@ -167,7 +182,7 @@ jobs: brew install autoconf automake displayName: 'Install Brew' - - template: build-autotools.yml + - template: CI/build-autotools.yml - job: MacOS_X_CMake displayName: "MacOS X CMake" @@ -175,7 +190,7 @@ jobs: vmImage: macos-latest steps: - - template: build-cmake.yml + - template: CI/build-cmake.yml parameters: buildArgs: '-G Xcode -D BUILD_FRAMEWORK:BOOL=true' @@ -201,6 +216,6 @@ jobs: IOS_PLATFORM: SIMULATOR_WATCHOS steps: - - template: build-cmake.yml + - template: CI/build-cmake.yml parameters: buildArgs: '-G Xcode -D PLATFORM=$(IOS_PLATFORM)' diff --git a/ft-regression.sh b/ft-regression.sh deleted file mode 100755 index c8b823b99..000000000 --- a/ft-regression.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash - -function build() { - set -e # exit on error - ./autogen.sh - ./configure - make - pushd .. - [[ -d ./freetype2-demos ]] || git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git - pushd freetype2-demos - make - popd - popd - set +e -} - -if [ -z "$1" ]; then - echo "No commit specified to check out master for regression tests." - echo "Aborting!" - exit 1 -fi - -if [ -z "$2" ]; then - echo "No directory specified to check out master for regression tests." - echo "Aborting!" - exit 1 -fi - -export COMP_COMMIT_DIR="$2" - -if [ -d "${COMP_COMMIT_DIR}" ]; then - read -p "Remove existing directory ${COMP_COMMIT_DIR} (y/n)? " CONT - if [ "$CONT" = "y" ]; then - rm -rf "${COMP_COMMIT_DIR}" - fi -fi - -PREV_GIT_HASH=$(git log --pretty=format:'%h' -n 1) -export PREVIOUS_PWD=${PWD} - -build -./ft-test.sh - -echo "Copying ${PWD} to ${COMP_COMMIT_DIR}" -cp -p -r "${PWD}" "${COMP_COMMIT_DIR}" - -pushd "${COMP_COMMIT_DIR}" - -# clean before we checkout -make clean - -if [[ "${PWD}" == "${COMP_COMMIT_DIR}" ]]; then - git stash - git clean -f -d - git checkout "$1" - GIT_HASH=$(git log --pretty=format:'%h' -n 1) - build - ${PREVIOUS_PWD}/ft-test.sh ${PREV_GIT_HASH} ${GIT_HASH} - popd -else - echo "Failed to change directory to ${COMP_COMMIT_DIR}. Something is horribly wrong..." - echo "Aborting!" - exit 1 -fi - diff --git a/ft-report.sh b/ft-report.sh deleted file mode 100755 index 38543319c..000000000 --- a/ft-report.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash - -# Arguments - -FONT=$1 -SIZE=$2 -COMMIT_A=$3 -COMMIT_B=$4 - -OUTDIR_A="/tmp/ft-tests/${COMMIT_A}/$(basename ${FONT})/${SIZE}/" -OUTDIR_B="/tmp/ft-tests/${COMMIT_B}/$(basename ${FONT})/${SIZE}/" - -function write_img_comp() { - echo " - - - - - -

Comparison of $(basename $1) between commits

-
- - " -} - -echo " - - - - - - -

Freetype2 Difference Report

- -" - -PASS=() -FAIL=() -FILES=${OUTDIR_A}/* - -for f in $FILES -do - derp=$(diff $f ${OUTDIR_B}/$(basename $f)) # we only care about return result - result=$? - if [ "$result" -eq "0" ]; - then - PASS+="$f " - else - FAIL+="$f " - fi -done - -echo "" - -for f in $FAIL -do - PAGE="$(basename $f .png).html" - write_img_comp $f &> $PAGE - echo " - - - " -done - -echo "" - -for f in $PASS -do - echo " - - - " -done - -echo " -
FAIL
$(basename $f)
PASS
$(basename $f)
- - -" diff --git a/ft-test-font.sh b/ft-test-font.sh deleted file mode 100755 index 3d068bc1b..000000000 --- a/ft-test-font.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -# Arguments -COMMIT=$1 -FONT=$2 -SIZE=$3 -DPI=$4 -BENCH=$5 -VIEW=$6 -STRING=$7 -START_C=$8 -END_C=$9 - -DEMOSDIR="../freetype2-demos/bin" -OUTDIR="/tmp/ft-tests/${COMMIT}/$(basename ${FONT})/${SIZE}/" - -function startX { - Xvfb :"$1" -screen 0 1024x768x24 & - XVFB_PIDS+=( $! ) - DISPLAY=:"$1" xfwm4 & - sleep 2 -} - -function xvfbRunAndScreenShot { - display="$1" - shift - screenshot_name="$1" - shift - DISPLAY=:"$display" $@ & - PID=$! - sleep 1 - DISPLAY=:"$display" xwd -root -silent | convert -trim xwd:- png:${OUTDIR}/${screenshot_name} - kill $PID -} - -mkdir -p $OUTDIR - -WORKERS=10 - -for worker in $(seq 1 $WORKERS) -do - startX $((98 + ${worker})) & -done - -if [[ "$BENCH" -eq 1 ]]; then - $DEMOSDIR/ftbench ${FONT} &> ${OUTDIR}/bench.txt -fi - -if [[ "$STRING" -eq 1 ]]; then - xvfbRunAndScreenShot 99 "$ftstring.png" $DEMOSDIR/ftstring -r $DPI ${SIZE} ${FONT} -fi - -if [[ "$VIEW" -eq 1 ]]; then - xvfbRunAndScreenShot 99 "ftview.png" $DEMOSDIR/ftview -r $DPI ${SIZE} ${FONT} -fi - -for char in $(seq ${START_C} ${END_C}) -do - ((i=i%WORKERS)); ((i++==0)) && wait - echo "ftgrid ${char}" - char_padded=$(printf "%03d" ${char}) - xvfbRunAndScreenShot $((98 + ${i})) "ftgrid_${char_padded}.png" $DEMOSDIR/ftgrid -r $DPI -f ${char} ${SIZE} ${FONT} & -done - -sleep 2 # wait for workers to finish up - -killall Xvfb diff --git a/ft-test.sh b/ft-test.sh deleted file mode 100755 index 6039bff46..000000000 --- a/ft-test.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# Arguments -#COMMIT=$1 -#FONT=$2 -#SIZE=$3 -#DPI=$4 -#BENCH=$5 -#VIEW=$6 -#STRING=$7 -#START_C=$8 -#END_C=$9 - -GIT_HASH=$(git log --pretty=format:'%h' -n 1) - -${PREVIOUS_PWD}/ft-test-font.sh ${GIT_HASH} /home/greg/Inconsolata-Regular.ttf 16 72 1 1 1 0 963 -if [ ! -z "$1" ]; then - ${PREVIOUS_PWD}/ft-report.sh /home/greg/Inconsolata-Regular.ttf 16 ${1} ${2} &> /tmp/ft-report.html -fi From 78ec41ec8d2f75b5c34ef5676da7186ab4dd50db Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Tue, 28 Jul 2020 18:24:47 -0400 Subject: [PATCH 06/19] increase time --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ef968431f..fd298fccf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -19,6 +19,7 @@ jobs: displayName: "Archlinux Regression tests" pool: vmImage: ubuntu-latest + timeoutInMinutes: 360 steps: - checkout: self path: freetype2 From 0adbd9b55310d5cdf7e6dfc44ea35c3c731a6ecf Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Tue, 28 Jul 2020 18:36:19 -0400 Subject: [PATCH 07/19] speed things up --- CI/ft-test-font.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CI/ft-test-font.sh b/CI/ft-test-font.sh index c6eb6c53f..e76c972b9 100755 --- a/CI/ft-test-font.sh +++ b/CI/ft-test-font.sh @@ -51,7 +51,7 @@ mkdir -p $OUTDIR # Because witing 1 second for every command can be slow we set up multiple xvfbs # in order to expedite the proccess. -WORKERS=10 +WORKERS=100 for worker in $(seq 1 $WORKERS) do startX $((98 + ${worker})) & @@ -88,5 +88,5 @@ do done sleep 2 # wait for workers to finish up -killall Xvfb +#killall Xvfb sleep 2 # wait for all xvfb to die From 849ba2c05d7477db5b9121c631fd9e384ed534e4 Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Tue, 28 Jul 2020 18:42:39 -0400 Subject: [PATCH 08/19] 100 was too much try 50 --- CI/ft-test-font.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/ft-test-font.sh b/CI/ft-test-font.sh index e76c972b9..98fd75c00 100755 --- a/CI/ft-test-font.sh +++ b/CI/ft-test-font.sh @@ -51,7 +51,7 @@ mkdir -p $OUTDIR # Because witing 1 second for every command can be slow we set up multiple xvfbs # in order to expedite the proccess. -WORKERS=100 +WORKERS=50 for worker in $(seq 1 $WORKERS) do startX $((98 + ${worker})) & From 5dafda9b9f6ecb9a82a9da777ea96054d401bf82 Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Mon, 24 Aug 2020 17:21:33 -0400 Subject: [PATCH 09/19] config file and some fixes --- CI/ft-regression.sh | 23 ++++++++++----- CI/ft-report.sh | 39 ++++++++++++++++++------- CI/ft-test-font.sh | 26 +++++++++-------- CI/ft-test.sh | 66 +++++++++++++++++++++++++++--------------- CI/ft-tests.config | 39 +++++++++++++++++++++++++ CI/mingw-setup.yml | 10 ++++++- CI/regression-test.yml | 2 ++ azure-pipelines.yml | 10 +++++++ 8 files changed, 160 insertions(+), 55 deletions(-) create mode 100755 CI/ft-tests.config diff --git a/CI/ft-regression.sh b/CI/ft-regression.sh index d95602e4e..4aa0c81da 100755 --- a/CI/ft-regression.sh +++ b/CI/ft-regression.sh @@ -1,6 +1,9 @@ #!/bin/bash -# Usage: ./CI/ft-regression.sh +# Include our configuration +. ./CI/ft-tests.config + +# Usage: ./CI/ft-regression.sh # The following script checks the source code in the current folder for # regressions or changes against previous commits. This is the main script you @@ -21,8 +24,9 @@ function build() { make pushd .. [[ -d ./freetype2-demos ]]\ - || git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git + || git clone ${DEMOS_URL} pushd freetype2-demos + git checkout `git rev-list -n 1 --first-parent --before="$(git show -s --format=%ci $1)" master` make popd popd @@ -37,13 +41,16 @@ if [ -z "$1" ]; then exit 1 fi -# This is where we build the commit of freetype we wish to compare against. We -# export it here because this variable is used in other scripts invoked later. -export COMP_COMMIT_DIR="/tmp/freetype2" +if [ -z "$2" ]; then + echo "No tests specified running all tests" + export RUN_TEST="all" +else + export RUN_TEST="$2" +fi # We want a fresh checkout and work dir in order to prevent any stale changes # from slipping through. -rm -rf "${COMP_COMMIT_DIR}" "/tmp/ft-test/" +rm -rf "${COMP_COMMIT_DIR}" "${TEST_OUTDIR}" # Here we store the current directories shortened commit hash which is used as # the subdirectory name for where to dump the logs and images. @@ -54,7 +61,7 @@ export PREVIOUS_PWD=${PWD} # This is the first build/run of the current dir that will dump our "A" # metricts. -build +build ${PREV_GIT_HASH} ./CI/ft-test.sh # Next we set up our "B" directory by copyiing our current sources. @@ -73,7 +80,7 @@ if [[ "${PWD}" == "${COMP_COMMIT_DIR}" ]]; then git checkout "$1" GIT_HASH=$(git log --pretty=format:'%h' -n 1) # Here we start the build / metrics for build "B" - build + build ${GIT_HASH} # We call the scripts from the current directory as they may not exist in # previous commits and to prevent confusion when modifying them. One set of # scripts is called but on each call they call different versions of the demos diff --git a/CI/ft-report.sh b/CI/ft-report.sh index 3a9925795..745df6f89 100755 --- a/CI/ft-report.sh +++ b/CI/ft-report.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Include our configuration +. ${PREVIOUS_PWD}/CI/ft-tests.config + # Arguments FONT=$1 SIZE=$2 @@ -12,11 +15,14 @@ COMMIT_B=$4 EXIT=0 metrics_dir="$(basename ${FONT})/${SIZE}/" -diff_dir="/tmp/ft-tests/${COMMIT_A}_${COMMIT_B}_diffs/${metrics_dir}" +diff_dir="${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs/${metrics_dir}" mkdir -p "${diff_dir}" -OUTDIR_A="/tmp/ft-tests/${COMMIT_A}/$(basename ${FONT})/${SIZE}/" -OUTDIR_B="/tmp/ft-tests/${COMMIT_B}/$(basename ${FONT})/${SIZE}/" +OUTDIR_A="${TEST_OUTDIR}/${COMMIT_A}/$(basename ${FONT})/${SIZE}/" +OUTDIR_B="${TEST_OUTDIR}/${COMMIT_B}/$(basename ${FONT})/${SIZE}/" + +RELATIVE_OUTDIR_A="${COMMIT_A}/$(basename ${FONT})/${SIZE}/" +RELATIVE_OUTDIR_B="${COMMIT_B}/$(basename ${FONT})/${SIZE}/" # Function below generates a page to compare images. The image should change # between the two versions on mouse over to easily spot differences. @@ -28,11 +34,17 @@ function write_img_comp() { .comp { width: $(identify -format '%w' $1)px; height: $(identify -format '%h' $1)px; - background: url(\"$1\") no-repeat; + background: url(\"${RELATIVE_OUTDIR_A}/$(basename $1)\") no-repeat; display: inline-block; } .comp:hover { - background: url(\"${OUTDIR_B}/$(basename $1)\") no-repeat; + background: url(\"${RELATIVE_OUTDIR_B}/$(basename $1)\") no-repeat; + } + .diff { + width: $(identify -format '%w' $1)px; + height: $(identify -format '%h' $1)px; + background: url(\"${diff_dir}/$(basename $1 .png)_diff.png\") no-repeat; + display: inline-block; } @@ -41,6 +53,7 @@ function write_img_comp() { Comparison of $(basename $1) between commits ${COMMIT_A} and ${COMMIT_B}
+
" } @@ -96,7 +109,7 @@ do # If is png compare with imagick if [[ "$extension" == "png" ]]; then - diif_cmd=$(compare -metric AE $f ${OUTDIR_B}/$(basename $f)\ + diif_cmd=$(compare -metric AE -highlight-color Red -lowlight-color PaleGreen $f ${OUTDIR_B}/$(basename $f)\ "${diff_dir}/$(basename $f .png)_diff.png" &> /dev/null) result=$? # Else if txt compare with @@ -107,17 +120,17 @@ do fi # Generate approriate diff page - PAGE="$(basename $f .$extension).html" + PAGE="$(basename $f .$extension)_${COMMIT_A}_${COMMIT_B}_diff.html" if [ "$result" -eq "0" ]; then PASS+="$f " else if [[ "$extension" == "png" ]]; then - write_img_comp $f &> "${diff_dir}/$PAGE" + write_img_comp $f &> "${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs/$PAGE" else DISPLAY=-1 pretty-diff $f ${OUTDIR_B}/$(basename $f) - mv /tmp/diff.html "${diff_dir}/$PAGE" + mv /tmp/diff.html "${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs/$PAGE" fi FAIL+="$f " fi @@ -137,7 +150,7 @@ do PAGE="$(basename $f .$extension).html" echo " - $(basename $f) + $(basename $f) " done @@ -147,7 +160,7 @@ for f in $PASS do echo " - $(basename $f) + $(basename $f) " done @@ -157,4 +170,8 @@ echo " " +# Move our tests results into dir so html refrences work +ln -s ${TEST_OUTDIR}/${COMMIT_A}/ ${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs &> /dev/null +ln -s ${TEST_OUTDIR}/${COMMIT_B}/ ${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs &> /dev/null + exit $EXIT diff --git a/CI/ft-test-font.sh b/CI/ft-test-font.sh index 98fd75c00..273fc437f 100755 --- a/CI/ft-test-font.sh +++ b/CI/ft-test-font.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Include our configuration +. ${PREVIOUS_PWD}/CI/ft-tests.config + # Arguments COMMIT=$1 FONT=$2 @@ -12,12 +15,15 @@ STRING=$8 START_GLYPH=$9 END_GLYPH=${10} +OUT_DIR="${TEST_OUTDIR}/${COMMIT}/$(basename ${FONT})/${SIZE}/" + +# Ensure directory we want to write to exists. +mkdir -p $OUT_DIR + # This script dumps specified metrics for a specified font. The arguments listed # above allow you to specify which metricts to dum when this script is called # from ft-test.sh -DEMOSDIR="../freetype2-demos/bin" -OUTDIR="/tmp/ft-tests/${COMMIT}/$(basename ${FONT})/${SIZE}/" # Below sets up a virtual X framebuffer to run the demos in. It is 1024x768 at # 24b depth. If you need a larget screen to fit the demos change the resolution @@ -42,16 +48,12 @@ function xvfbRunAndScreenShot { PID=$! sleep 1 DISPLAY=:"$display" xwd -root -silent\ - | convert -trim xwd:- png:${OUTDIR}/${screenshot_name} + | convert -colorspace sRGB -define png:color-type=2 -trim xwd:- png:${OUT_DIR}/${screenshot_name} kill $PID } -# Ensure directory we want to write to exists. -mkdir -p $OUTDIR - # Because witing 1 second for every command can be slow we set up multiple xvfbs # in order to expedite the proccess. -WORKERS=50 for worker in $(seq 1 $WORKERS) do startX $((98 + ${worker})) & @@ -59,20 +61,20 @@ done # Below are simple metricts to test that only require one run per font. if [[ "$DUMP" -eq 1 ]]; then - $DEMOSDIR/ftdump ${FONT} &> ${OUTDIR}/dump.txt + ${DEMOS_DIR}/ftdump ${FONT} &> ${OUT_DIR}/dump.txt fi if [[ "$BENCH" -eq 1 ]]; then - $DEMOSDIR/ftbench ${FONT} &> ${OUTDIR}/bench.txt + ${DEMOS_DIR}/ftbench ${FONT} &> ${OUT_DIR}/bench.txt fi if [[ "$STRING" -eq 1 ]]; then - xvfbRunAndScreenShot 99 "ftstring.png" $DEMOSDIR/ftstring\ + xvfbRunAndScreenShot 99 "ftstring.png" ${DEMOS_DIR}/ftstring\ -r $DPI ${SIZE} ${FONT} fi if [[ "$VIEW" -eq 1 ]]; then - xvfbRunAndScreenShot 99 "ftview.png" $DEMOSDIR/ftview -r $DPI ${SIZE} ${FONT} + xvfbRunAndScreenShot 99 "ftview.png" ${DEMOS_DIR}/ftview -r $DPI ${SIZE} ${FONT} fi # For ftgrid we run it on thousands of glyphys so this loop takes advantage of @@ -84,7 +86,7 @@ do # Pad name with 0s to maintain order GLYPH_padded=$(printf "%04d" ${GLYPH}) xvfbRunAndScreenShot $((98 + ${i})) "ftgrid_${GLYPH_padded}.png"\ - $DEMOSDIR/ftgrid -r $DPI -f ${GLYPH} ${SIZE} ${FONT} & + ${DEMOS_DIR}/ftgrid -r $DPI -f ${GLYPH} ${SIZE} ${FONT} & done sleep 2 # wait for workers to finish up diff --git a/CI/ft-test.sh b/CI/ft-test.sh index b9899779a..6f208a70c 100755 --- a/CI/ft-test.sh +++ b/CI/ft-test.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Include our configuration +. ${PREVIOUS_PWD}/CI/ft-tests.config + # Arguments to /ft-test-font.sh #COMMIT=$1 #FONT=$2 @@ -17,36 +20,57 @@ # in that directory. Currently, it only tests all files at pt 16 and dpi 72 and # with ft-grid's default rendering mode. -FILES=~/test-fonts/* - GIT_HASH=$(git log --pretty=format:'%h' -n 1) EXIT=0 -DEMOSDIR="../freetype2-demos/bin" PASS=() FAIL=() -for f in $FILES -do - GLYPHCOUNT=$(${DEMOSDIR}/ftdump $f | grep "glyph count" | sed 's/\s*glyph count:\s*\([0-9]\+\)/\1/') - ${PREVIOUS_PWD}/CI/ft-test-font.sh ${GIT_HASH} $f 16 72 1 1 1 1 0 ${GLYPHCOUNT} +# Ensure directory we want to write to exists. +mkdir -p $TEST_OUTDIR + +if [[ "$RUN_TEST" == "all" ]]; then + for ((i = 0; i < ${#FT_TESTS[@]}; i++)) + do + args=(${FT_TESTS[$i]}) + ${PREVIOUS_PWD}/CI/ft-test-font.sh ${GIT_HASH} ${FT_TESTS[$i]} + if [ ! -z "$1" ]; then + ${PREVIOUS_PWD}/CI/ft-report.sh ${args[0]} ${args[1]} ${1} ${2}\ + &> ${TEST_OUTDIR}/ft-$(basename ${args[0]})-${args[1]}-report.html + result=$? + if [ "$result" -eq "0" ]; + then + RESULT_STR="PASS" + PASS+="ft-$(basename ${args[0]})-${args[1]}-report.html " + else + RESULT_STR="FAIL" + FAIL+="ft-$(basename ${args[0]})-${args[1]}-report.html " + # We store any failure to use later in the exit command. + EXIT=1 + fi + echo "ft-$(basename ${args[0]})-${args[1]}-report.html [$RESULT_STR]" + fi + done +else + args=(${FT_TESTS[$RUN_TEST]}) + ${PREVIOUS_PWD}/CI/ft-test-font.sh ${GIT_HASH} ${FT_TESTS[$RUN_TEST]} if [ ! -z "$1" ]; then - ${PREVIOUS_PWD}/CI/ft-report.sh $f 16 ${1} ${2}\ - &> /tmp/ft-tests/ft-$(basename $f)-16-report.html + ${PREVIOUS_PWD}/CI/ft-report.sh ${args[0]} ${args[1]} ${1} ${2}\ + &> ${TEST_OUTDIR}/ft-$(basename ${args[0]})-${args[1]}-report.html result=$? if [ "$result" -eq "0" ]; then RESULT_STR="PASS" - PASS+="ft-$(basename $f)-16-report.html " + PASS+="ft-$(basename ${args[0]})-${args[1]}-report.html " else RESULT_STR="FAIL" - FAIL+="ft-$(basename $f)-16-report.html " + FAIL+="ft-$(basename ${args[0]})-${args[1]}-report.html " # We store any failure to use later in the exit command. EXIT=1 fi - echo "ft-$(basename $f)-16-report.html [$RESULT_STR]" + echo "ft-$(basename ${args[0]})-${args[1]}-report.html [$RESULT_STR]" fi -done +fi # Below we generate an index of all reports generated echo " @@ -60,45 +84,41 @@ table, tr { margin-left:auto; width:100%; } - th.fail { color: red } - th.pass { color: green } -

Freetype2 Difference Reports Index

-" &> "/tmp/ft-tests/index.html" +
" &> "${TEST_OUTDIR}/index.html" -echo "" &>> "/tmp/ft-tests/index.html" +echo "" &>> "${TEST_OUTDIR}/index.html" for f in $FAIL do echo " - " &>> "/tmp/ft-tests/index.html" + " &>> "${TEST_OUTDIR}/index.html" done -echo "" &>> "/tmp/ft-tests/index.html" +echo "" &>> "${TEST_OUTDIR}/index.html" for f in $PASS do echo " - " &>> "/tmp/ft-tests/index.html" + " &>> "${TEST_OUTDIR}/index.html" done echo "
FAIL
FAIL
$(basename $f .html)
PASS
PASS
$(basename $f .html)
- -" &>> "/tmp/ft-tests/index.html" +" &>> "${TEST_OUTDIR}/index.html" exit $EXIT diff --git a/CI/ft-tests.config b/CI/ft-tests.config new file mode 100755 index 000000000..658bae4c5 --- /dev/null +++ b/CI/ft-tests.config @@ -0,0 +1,39 @@ +#!/bin/bash + +# URL to clone demos from +DEMOS_URL="git://git.sv.nongnu.org/freetype/freetype2-demos.git" + +# Directory of demos relative to freetype +DEMOS_DIR="../freetype2-demos/bin" + +# Base directory to ouptut test results +TEST_OUTDIR="/tmp/ft-tests" + +# This is where we build the commit of freetype we wish to compare against. We +# export it here because this variable is used in other scripts invoked later. +COMP_COMMIT_DIR="/tmp/freetype2" + +# Number of xvfb threads to use +WORKERS=20 + +function GlyphCount() { + echo $(${DEMOS_DIR}/ftdump $1 | grep "glyph count" | sed 's/\s*glyph count:\s*\([0-9]\+\)/\1/') +} + +# List of tests Below +## Arguments (in order) +### FONT: path to ttf +### SIZE: size to render test at +### DPI: dpi to render test at +### DUMP: boolean, run dump test +### BENCH: boolean, run bench test +### VIEW: boolean, run dump view test +### STRING: boolean, run string test +### START_GLYPH: first glyph to use in ftview tests +### END_GLYPH: last glyph to use in ftview tests + +FT_TESTS=( +"${HOME}/test-fonts/LiberationSerif-Regular.ttf 16 72 1 1 1 1 0 10" +"${HOME}/test-fonts/LiberationSans-Bold.ttf 32 72 1 1 1 1 10 30" +"${HOME}/test-fonts/LiberationMono-BoldItalic.ttf 32 72 1 1 1 1 0 $(GlyphCount ${HOME}/test-fonts/LiberationMono-BoldItalic.ttf)" +) diff --git a/CI/mingw-setup.yml b/CI/mingw-setup.yml index fc1c69fb0..64112be72 100644 --- a/CI/mingw-setup.yml +++ b/CI/mingw-setup.yml @@ -6,11 +6,19 @@ steps: - script: | set PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem + %CD:~0,2%\msys64\usr\bin\curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz + %CD:~0,2%\msys64\usr\bin\curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig + %CD:~0,2%\msys64\usr\bin\pacman-key --verify msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig + %CD:~0,2%\msys64\usr\bin\pacman --overwrite='*' --noconfirm -U msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz %CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Syyuu displayName: Update MSYS2 + + - script: taskkill /f /fi "MODULES eq msys-2.0.dll" || exit /b 0s + displayName: Reset MSYS2 - script: | set PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem - %CD:~0,2%\msys64\usr\bin\pacman --noconfirm --needed -S git base-devel mingw-w64-$(MINGW_ARCH)-toolchain mingw-w64-$(MINGW_ARCH)-cmake mingw-w64-$(MINGW_ARCH)-harfbuzz + %CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Syyuu + %CD:~0,2%\msys64\usr\bin\pacman --noconfirm --needed -S zip git base-devel mingw-w64-$(MINGW_ARCH)-toolchain mingw-w64-$(MINGW_ARCH)-cmake mingw-w64-$(MINGW_ARCH)-harfbuzz %CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Scc displayName: Install Toolchain diff --git a/CI/regression-test.yml b/CI/regression-test.yml index 9a9d18ea6..f564e3a19 100644 --- a/CI/regression-test.yml +++ b/CI/regression-test.yml @@ -7,6 +7,8 @@ parameters: default: '.' - name: postCMD # Command(s) executed after calling make default: '' +- name: testNum # Test number to run + default: '0' steps: - script: | diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fd298fccf..07ce919fd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -19,6 +19,15 @@ jobs: displayName: "Archlinux Regression tests" pool: vmImage: ubuntu-latest + strategy: + matrix: + Test1: + TEST=0 + Test2: + TEST=1 + Test3: + TEST=2 + timeoutInMinutes: 360 steps: - checkout: self @@ -31,6 +40,7 @@ jobs: preCMD: 'cd $(Build.BinariesDirectory) && cat << EOF | sudo ./root.x86_64/bin/arch-chroot ./root.x86_64/' srcDIR: freetype2 postCMD: 'EOF' + testNum: $(TEST) - job: ArchLinux_Autotools displayName: "Archlinux Autotools" From 4fb08ddd14ce6ebce0eb78aca7615b3de1f729d3 Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Mon, 24 Aug 2020 17:23:16 -0400 Subject: [PATCH 10/19] config file and some fixes --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 07ce919fd..4dc53c549 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,11 +22,11 @@ jobs: strategy: matrix: Test1: - TEST=0 + TEST: 0 Test2: - TEST=1 + TEST: 1 Test3: - TEST=2 + TEST: 2 timeoutInMinutes: 360 steps: From b6daba96953e06c0e214712e2fc96190a8074920 Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Mon, 24 Aug 2020 17:24:37 -0400 Subject: [PATCH 11/19] config file and some fixes --- CI/mingw-setup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/mingw-setup.yml b/CI/mingw-setup.yml index 64112be72..506adcd31 100644 --- a/CI/mingw-setup.yml +++ b/CI/mingw-setup.yml @@ -14,7 +14,7 @@ steps: displayName: Update MSYS2 - script: taskkill /f /fi "MODULES eq msys-2.0.dll" || exit /b 0s - displayName: Reset MSYS2 + displayName: Reset MSYS2 - script: | set PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem From 0782fb9a962b5f208f52cd3a67537de9f156d2f5 Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Mon, 24 Aug 2020 17:43:53 -0400 Subject: [PATCH 12/19] config file and some fixes --- CI/build-autotools.yml | 16 ++++++++-------- CI/ft-tests.config | 6 +----- CI/regression-test.yml | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/CI/build-autotools.yml b/CI/build-autotools.yml index 3c2a0a55b..fdb34ce8f 100644 --- a/CI/build-autotools.yml +++ b/CI/build-autotools.yml @@ -69,12 +69,12 @@ steps: displayName: 'Build Demos' -- script: | - zip -r $(Build.ArtifactStagingDirectory)/freetype-build.zip $(Build.BinariesDirectory)/install - displayName: 'Stage Artifacts' + - script: | + zip -r $(Build.ArtifactStagingDirectory)/freetype-build.zip $(Build.BinariesDirectory)/install + displayName: 'Stage Artifacts' -- task: PublishBuildArtifacts@1 - displayName: 'Push Build Artifacts' - inputs: - pathtoPublish: $(Build.ArtifactStagingDirectory) - artifactName: $(Agent.JobName) + - task: PublishBuildArtifacts@1 + displayName: 'Push Build Artifacts' + inputs: + pathtoPublish: $(Build.ArtifactStagingDirectory) + artifactName: $(Agent.JobName) diff --git a/CI/ft-tests.config b/CI/ft-tests.config index 658bae4c5..611e9fbe6 100755 --- a/CI/ft-tests.config +++ b/CI/ft-tests.config @@ -16,10 +16,6 @@ COMP_COMMIT_DIR="/tmp/freetype2" # Number of xvfb threads to use WORKERS=20 -function GlyphCount() { - echo $(${DEMOS_DIR}/ftdump $1 | grep "glyph count" | sed 's/\s*glyph count:\s*\([0-9]\+\)/\1/') -} - # List of tests Below ## Arguments (in order) ### FONT: path to ttf @@ -35,5 +31,5 @@ function GlyphCount() { FT_TESTS=( "${HOME}/test-fonts/LiberationSerif-Regular.ttf 16 72 1 1 1 1 0 10" "${HOME}/test-fonts/LiberationSans-Bold.ttf 32 72 1 1 1 1 10 30" -"${HOME}/test-fonts/LiberationMono-BoldItalic.ttf 32 72 1 1 1 1 0 $(GlyphCount ${HOME}/test-fonts/LiberationMono-BoldItalic.ttf)" +"${HOME}/test-fonts/LiberationMono-BoldItalic.ttf 32 72 1 1 1 1 0 2394" ) diff --git a/CI/regression-test.yml b/CI/regression-test.yml index f564e3a19..70947d8be 100644 --- a/CI/regression-test.yml +++ b/CI/regression-test.yml @@ -22,7 +22,7 @@ steps: cd freetype2-demos ln -s ${{ parameters.srcDIR }} ../freetype2 cd /freetype2 - ./CI/ft-regression.sh master + ./CI/ft-regression.sh master ${{ parameters.testNum }} chmod -R 755 /tmp/ft-tests/ mv /tmp/ft-tests/ / ${{ parameters.postCMD }} From f3087418e9bde1606d0c9b9bb04119b41641e14f Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Mon, 24 Aug 2020 17:54:17 -0400 Subject: [PATCH 13/19] config file and some fixes --- CI/ft-report.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CI/ft-report.sh b/CI/ft-report.sh index 745df6f89..d3f9c9779 100755 --- a/CI/ft-report.sh +++ b/CI/ft-report.sh @@ -171,7 +171,7 @@ echo " " # Move our tests results into dir so html refrences work -ln -s ${TEST_OUTDIR}/${COMMIT_A}/ ${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs &> /dev/null -ln -s ${TEST_OUTDIR}/${COMMIT_B}/ ${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs &> /dev/null +cp -R ${TEST_OUTDIR}/${COMMIT_A}/ ${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs &> /dev/null +cp -R ${TEST_OUTDIR}/${COMMIT_B}/ ${TEST_OUTDIR}/${COMMIT_A}_${COMMIT_B}_diffs &> /dev/null exit $EXIT From 01bf253fe9ea2bf2d0ba89c4229cca8e168eed9f Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Tue, 25 Aug 2020 07:49:12 -0400 Subject: [PATCH 14/19] fix mingw builds --- CI/build-autotools.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/CI/build-autotools.yml b/CI/build-autotools.yml index fdb34ce8f..70f7b3122 100644 --- a/CI/build-autotools.yml +++ b/CI/build-autotools.yml @@ -26,7 +26,7 @@ steps: - script: | set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem - %CD:~0,2%\msys64\usr\bin\bash -lc "make && make install DESTDIR=$(echo \"$(Build.BinariesDirectory)/install\" | tr '\\' '/') && zip freetype-build.zip $(Build.BinariesDirectory)" + %CD:~0,2%\msys64\usr\bin\bash -lc "make && make install DESTDIR=$(echo \"$(Build.BinariesDirectory)/install\" | tr '\\' '/')" displayName: 'Build and Package' env: MSYSTEM: $(MINGW_UPPER) @@ -41,6 +41,11 @@ steps: MSYSTEM: $(MINGW_UPPER) CHERE_INVOKING: yes MINGW_INSTALLS: $(MINGW_LOWER) + + - script: | + set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem" + %CD:~0,2%\msys64\usr\bin\bash -lc "zip -r $(echo \"$(Build.ArtifactStagingDirectory)/freetype-build.zip\" | tr '\\' '/') $(echo \"$(Build.BinariesDirectory)/install\" | tr '\\' '/')" + displayName: 'Stage Artifacts' - ${{ if eq(parameters.mingw, false) }}: - script: | @@ -68,13 +73,12 @@ steps: mv bin/ $(Build.BinariesDirectory)/install/demos displayName: 'Build Demos' - - script: | zip -r $(Build.ArtifactStagingDirectory)/freetype-build.zip $(Build.BinariesDirectory)/install displayName: 'Stage Artifacts' - - task: PublishBuildArtifacts@1 - displayName: 'Push Build Artifacts' - inputs: - pathtoPublish: $(Build.ArtifactStagingDirectory) - artifactName: $(Agent.JobName) +- task: PublishBuildArtifacts@1 + displayName: 'Push Build Artifacts' + inputs: + pathtoPublish: $(Build.ArtifactStagingDirectory) + artifactName: $(Agent.JobName) From 1ef5bfc898ac31614d1aac27148ae1a0c532e6e5 Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Tue, 25 Aug 2020 08:06:22 -0400 Subject: [PATCH 15/19] try more mingw fixes --- CI/build-autotools.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/build-autotools.yml b/CI/build-autotools.yml index 70f7b3122..a196d24e4 100644 --- a/CI/build-autotools.yml +++ b/CI/build-autotools.yml @@ -35,7 +35,7 @@ steps: - script: | set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem - %CD:~0,2%\msys64\usr\bin\bash -lc "git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git && cd freetype2-demos && ln -s ${{ parameters.srcDIR }} ../freetype2 && make && mv bin/ $(Build.BinariesDirectory)/install/demos" + %CD:~0,2%\msys64\usr\bin\bash -lc "git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git && cd freetype2-demos && cp -R ${{ parameters.srcDIR }} ../freetype2 && make && mv bin/ $(Build.BinariesDirectory)/install/demos" displayName: 'Build Demos' env: MSYSTEM: $(MINGW_UPPER) From 806745d2bf256c19098cd6582da0bed5d42f629b Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Tue, 25 Aug 2020 08:26:52 -0400 Subject: [PATCH 16/19] try more mingw fixes --- CI/build-autotools.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/build-autotools.yml b/CI/build-autotools.yml index a196d24e4..fd9367a33 100644 --- a/CI/build-autotools.yml +++ b/CI/build-autotools.yml @@ -35,7 +35,7 @@ steps: - script: | set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem - %CD:~0,2%\msys64\usr\bin\bash -lc "git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git && cd freetype2-demos && cp -R ${{ parameters.srcDIR }} ../freetype2 && make && mv bin/ $(Build.BinariesDirectory)/install/demos" + %CD:~0,2%\msys64\usr\bin\bash -lc "git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git && cd freetype2-demos && cp -R ${{ parameters.srcDIR }} ../freetype2 && make && mv bin/ $(echo \"$(Build.BinariesDirectory)/install/demos\" | tr '\\' '/')" displayName: 'Build Demos' env: MSYSTEM: $(MINGW_UPPER) From 696e5de9e3cb3cd83267131c1feb2baaa3341fe5 Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Tue, 25 Aug 2020 08:56:30 -0400 Subject: [PATCH 17/19] try again --- CI/build-autotools.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CI/build-autotools.yml b/CI/build-autotools.yml index fd9367a33..81e196678 100644 --- a/CI/build-autotools.yml +++ b/CI/build-autotools.yml @@ -27,6 +27,7 @@ steps: - script: | set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem %CD:~0,2%\msys64\usr\bin\bash -lc "make && make install DESTDIR=$(echo \"$(Build.BinariesDirectory)/install\" | tr '\\' '/')" + %CD:~0,2%\msys64\usr\bin\bash -lc "cp -R ${{ parameters.srcDIR }} $(echo \"$(Build.BinariesDirectory)/freetype2\" | tr '\\' '/')" displayName: 'Build and Package' env: MSYSTEM: $(MINGW_UPPER) @@ -35,7 +36,7 @@ steps: - script: | set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem - %CD:~0,2%\msys64\usr\bin\bash -lc "git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git && cd freetype2-demos && cp -R ${{ parameters.srcDIR }} ../freetype2 && make && mv bin/ $(echo \"$(Build.BinariesDirectory)/install/demos\" | tr '\\' '/')" + %CD:~0,2%\msys64\usr\bin\bash -lc "cd $(echo \"$(Build.BinariesDirectory)\" | tr '\\' '/') && git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git && cd freetype2-demos && make && mv bin/ $(echo \"$(Build.BinariesDirectory)/install/demos\" | tr '\\' '/')" displayName: 'Build Demos' env: MSYSTEM: $(MINGW_UPPER) From 7b8f9524e633898afcedf8a909340d7dd580df26 Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Tue, 25 Aug 2020 09:32:37 -0400 Subject: [PATCH 18/19] disable demos for now --- CI/build-autotools.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/CI/build-autotools.yml b/CI/build-autotools.yml index 81e196678..90d1131fd 100644 --- a/CI/build-autotools.yml +++ b/CI/build-autotools.yml @@ -34,14 +34,15 @@ steps: CHERE_INVOKING: yes MINGW_INSTALLS: $(MINGW_LOWER) - - script: | - set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem - %CD:~0,2%\msys64\usr\bin\bash -lc "cd $(echo \"$(Build.BinariesDirectory)\" | tr '\\' '/') && git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git && cd freetype2-demos && make && mv bin/ $(echo \"$(Build.BinariesDirectory)/install/demos\" | tr '\\' '/')" - displayName: 'Build Demos' - env: - MSYSTEM: $(MINGW_UPPER) - CHERE_INVOKING: yes - MINGW_INSTALLS: $(MINGW_LOWER) + # Building Demos in mingw seems broken do to configuration error of it including termios.h in ttdebug.c which doesn't exist in mingw + #- script: | + # set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem + # %CD:~0,2%\msys64\usr\bin\bash -lc "cd $(echo \"$(Build.BinariesDirectory)\" | tr '\\' '/') && git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git && cd freetype2-demos && make && mv bin/ $(echo \"$(Build.BinariesDirectory)/install/demos\" | tr '\\' '/')" + # displayName: 'Build Demos' + # env: + # MSYSTEM: $(MINGW_UPPER) + # CHERE_INVOKING: yes + # MINGW_INSTALLS: $(MINGW_LOWER) - script: | set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem" From 37d3d3c96182c70cec893566ae01f96a27ac53b3 Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Sun, 30 Aug 2020 12:39:32 -0400 Subject: [PATCH 19/19] Create Readme.md --- CI/Readme.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 CI/Readme.md diff --git a/CI/Readme.md b/CI/Readme.md new file mode 100644 index 000000000..81372fd96 --- /dev/null +++ b/CI/Readme.md @@ -0,0 +1,30 @@ +# Freetype2 CI + +Continuous integration is a tool used in software development to ensure that your application and/or library builds and runs correctly. Continuous deployment takes this a step further and uses the builds from the CI to create releases for developers and other users to download and use. In this folder are several configuration files and scripts drafted by Greg Williamson for a 2020 GSoC project: https://summerofcode.withgoogle.com/projects/#5724074732421120 + +# How it works + +Upon each commit, several builds are triggered for various operating systems and build configurations. Each build status is then reported back to the developers in the Pull Request comment section on GitLab or GitHub. Each build creates artifacts containing the newly-built FreeType libraries for developers and users to download. There are also special pipeline phases called "Regression Tests" that run FreeType's built-in demo programs to compare visual outputs between commits. An HTML report that contains a table of the results is uploaded as an artifact for these tests. For text output there is an HTML page displaying a .diff generated and for images a special page is generated that shows both images, layered, so that you can mouse over each to see differences. There is also a generated heatmap image which will draw matching regions of the image in green, and any mismatching regions in red. + +# Running locally + +All of the "Regression Tests" can be run locally (Currently only on Linux-based platforms). You will need to have xvfb, imagemagick, and prettydiff installed. You can find more details about this in CI/ft-regression.sh. You will also need "Liberation Fonts" which can be found here: https://releases.pagure.org/liberation-fonts/. The current tests expect the .ttf files to be extracted to ${HOME}/test-fonts. Once set up, you can run all tests by running ./CI/ft-regression.sh , where TEST_INDEX is the index of the test you wish to run (or "all" to run all tests). Run this command from inside the directory you cloned FreeType to. An HTML report will then be generated to /tmp/ft-test for you to inspect. + +# Adding / Changing Tests + +All regular build tests are listed and configured in azure-pipelines.yml and the several templates it includes in the CI/ folder. If you wish to add an additional platform or build configuration, azure-pipelines.yml is the place to do so. For "Regression Tests", there exists a configuration file at CI/ft-tests.config that contains an array where you can add, remove or change test configurations. Each line in the array is a separate test. In order to have Azure run new tests, you will also need to modify azure-pipelines.yml at the root of the project to add/remove tests from the matrix. For each test, you will need to add a line to the yaml like so: + +```yaml + strategy: + matrix: + Test1: + TEST: 0 + Test2: + TEST: 1 + Test3: + TEST: 2 +``` + +# Todo + +Savannah doesn't allow for integration with any modern CI so this cannot be implemented directly until FreeType moves to GitLab or GitHub. GitHub makes integrating this as simple as a few mouse clicks. For the GitLab route, however, we may need to port my yaml configurations to their CI's format. Another alternative is mirroring the repo. GitLab does have some mirroring capabilities, but for Savannah, developers would need to upload their commits to both manually.