Skip to content

Commit

Permalink
Merge branch 'master' into mark_master_builds_as_full_releases
Browse files Browse the repository at this point in the history
  • Loading branch information
qris committed Mar 26, 2018
2 parents 9038c0b + 16a11e8 commit 161ceef
Show file tree
Hide file tree
Showing 23 changed files with 1,128 additions and 225 deletions.
12 changes: 10 additions & 2 deletions appveyor.yml
Expand Up @@ -18,7 +18,7 @@ configuration:
environment:
VisualStudioVersion: 11.0
Generator_Base: Visual Studio 11 2012
OPENSSL_VERSION: 1.0.2f
OPENSSL_VERSION: 1.1.0f
PCRE_VERSION: 8.38
CMAKE_UNIBUILD_DIR: '%APPVEYOR_BUILD_FOLDER%\..\cmake'
BOXBACKUP_VERSION_BASE: 0.12
Expand All @@ -39,6 +39,12 @@ init:

# scripts that run after cloning repository (before the build step, not after!)
install:
# work around sourceforge brokenness by temporarily download some files ourselves:
- ps: New-Item -ItemType Directory -Force -Path $env:TEMP\chocolatey\nsis.portable\3.02.0.20160720
- ps: invoke-webrequest -uri https://10gbps-io.dl.sourceforge.net/project/nsis/NSIS%203%20Pre-release/3.0rc2/nsis-3.0rc2.zip -outfile $env:TEMP\chocolatey\nsis.portable\3.02.0.20160720\download
- ps: New-Item -ItemType Directory -Force -Path ..\cmake\Download\boost
- ps: invoke-webrequest -uri http://download.openpkg.org/components/cache/boost/boost_1_62_0.tar.bz2 -outfile ..\cmake\Download\boost\boost_1_62_0.tar.bz2

# test_bbackupd needs 7zip (or cmake -E tar) to extract tar archives on Windows:
- cinst -y --limit-output 7zip.commandline nsis.portable
- dir "c:\Program Files"
Expand Down Expand Up @@ -106,5 +112,7 @@ deploy:
on:
branch:
- master
- s3_support_merge
- mark_master_builds_as_full_releases

cache:
- '%TEMP%\chocolatey'
1 change: 1 addition & 0 deletions configure.ac
Expand Up @@ -139,6 +139,7 @@ Large files: $box_cv_have_large_file_support
Berkeley DB: $ax_path_bdb_ok
Readline: $have_libreadline
Extended attributes: $ac_cv_header_sys_xattr_h
Debugger: ${with_debugger:-neither GDB nor LLDB detected!}
EOC

cat > config.env <<EOC
Expand Down
135 changes: 133 additions & 2 deletions infrastructure/cmake/CMakeLists.txt
Expand Up @@ -363,6 +363,7 @@ target_compile_definitions(lib_common PUBLIC $<$<CONFIG:Release>:BOX_RELEASE_BUI

include(CheckCXXCompilerFlag)
include(CheckCXXSourceCompiles)
include(CheckCXXSourceRuns)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckLibraryExists)
Expand Down Expand Up @@ -407,7 +408,26 @@ else()
endif()

# Link to OpenSSL
find_package(OpenSSL REQUIRED)
# Workaround for incorrect library suffixes searched by FindOpenSSL:
# https://gitlab.kitware.com/cmake/cmake/issues/17604
if(WIN32 AND MSVC)
find_package(OpenSSL)
set(OPENSSL_SSL_LIBRARY ${SSL_EAY_RELEASE})
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY_RELEASE})
set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} crypt32)
find_package_handle_standard_args(OpenSSL
REQUIRED_VARS
OPENSSL_SSL_LIBRARY
OPENSSL_CRYPTO_LIBRARY
OPENSSL_INCLUDE_DIR
VERSION_VAR
OPENSSL_VERSION
FAIL_MESSAGE
"Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
)
else()
find_package(OpenSSL REQUIRED)
endif()
include_directories(${OPENSSL_INCLUDE_DIR})
target_link_libraries(lib_crypto PUBLIC ${OPENSSL_LIBRARIES})

Expand Down Expand Up @@ -463,7 +483,7 @@ move_file_if_exists(
"${boxconfig_cmake_h_dir}/BoxConfig.cmake.h.bak")

foreach(m4_filename boxbackup_tests.m4 ax_check_mount_point.m4 ax_func_syscall.m4)
file(STRINGS "${base_dir}/infrastructure/m4/${m4_filename}" m4_functions REGEX "^ *AC[_A-Z]+\\(.*\\)$")
file(STRINGS "${base_dir}/infrastructure/m4/${m4_filename}" m4_functions REGEX "^ *(AC|AX|BOX)_[A-Z_]+\\(.*\\)$")
foreach(m4_function ${m4_functions})
if(DEBUG)
message(STATUS "Processing m4_function: ${m4_function}")
Expand Down Expand Up @@ -545,6 +565,22 @@ foreach(m4_filename boxbackup_tests.m4 ax_check_mount_point.m4 ax_func_syscall.m
}
]=] "HAVE_${platform_var_name}")
file(APPEND "${boxconfig_h_file}" "#cmakedefine HAVE_${platform_var_name}\n")
elseif(m4_function MATCHES "^ *BOX_CHECK_CXX_FLAG\\((-[A-Za-z_,=-]+)\\)")
if(DEBUG)
message(STATUS "Processing BOX_CHECK_CXX_FLAG: ${CMAKE_MATCH_1}")
endif()

if(NOT CMAKE_MATCH_1 STREQUAL "-Wall")
set(flag "${CMAKE_MATCH_1}")
string(TOLOWER "have_flag_${flag}" have_flag_var_name)
string(REGEX REPLACE "[^a-z_]" "_" have_flag_var_name ${have_flag_var_name})
string(REGEX REPLACE "__+" "_" have_flag_var_name ${have_flag_var_name})

CHECK_CXX_COMPILER_FLAG(${flag} ${have_flag_var_name})
if(${have_flag_var_name})
add_definitions("${flag}")
endif()
endif()
endif()
endforeach()

Expand Down Expand Up @@ -596,6 +632,7 @@ CHECK_CXX_SOURCE_COMPILES([=[
}
]=] "HAVE_STRUCT_STATFS_F_MNTONNAME")
file(APPEND "${boxconfig_h_file}" "#cmakedefine HAVE_STRUCT_STATFS_F_MNTONNAME\n")

CHECK_CXX_SOURCE_COMPILES([=[
#include "BoxConfig.cmake.h"
#ifdef HAVE_SYS_PARAM_H
Expand All @@ -609,6 +646,7 @@ CHECK_CXX_SOURCE_COMPILES([=[
}
]=] "HAVE_STRUCT_STATVFS_F_MNTONNAME")
file(APPEND "${boxconfig_h_file}" "#cmakedefine HAVE_STRUCT_STATVFS_F_MNTONNAME\n")

if(HAVE_STRUCT_STATFS_F_MNTONNAME OR
HAVE_STRUCT_STATVFS_F_MNTONNAME OR
HAVE_STRUCT_MNTENT_MNT_DIR OR
Expand All @@ -635,6 +673,34 @@ file(APPEND "${boxconfig_h_file}" "#cmakedefine HAVE_RANDOM_DEVICE\n")
# Build an intermediate version of BoxConfig.cmake.h for use in the following tests:
configure_file("${boxconfig_h_file}" "${boxconfig_cmake_h_dir}/BoxConfig.cmake.h")

# Emulate ax_func_syscall.m4: Autoconf's AC_CHECK_FUNC (which we emulate above,
# using check_function_exists) defines the function when testing for its
# presence, so HAVE___SYSCALL will be true even if __syscall has no definition
# in the system libraries, and this is precisely the case that we want to test
# for, so now we test whether a test program compiles with no explicit
# definition (only the system headers) and if that fails, we set
# HAVE___SYSCALL_NEED_DEFN to 1.

CHECK_CXX_SOURCE_COMPILES(
[=[
#include "BoxConfig.cmake.h"

#ifdef HAVE_SYS_SYSCALL_H
# include <sys/syscall.h>
#endif

int main()
{
__syscall(SYS_exit, 0);
return 0;
}
]=] HAVE___SYSCALL_NO_DEFN)
set(HAVE___SYSCALL_NEED_DEFN !HAVE___SYSCALL_NO_DEFN)
file(APPEND "${boxconfig_h_file}" "#cmakedefine HAVE___SYSCALL_NEED_DEFN\n")

# Build an intermediate version of BoxConfig.cmake.h for use in the following tests:
configure_file("${boxconfig_h_file}" "${boxconfig_cmake_h_dir}/BoxConfig.cmake.h")

foreach(struct_member_name "struct ucred.uid" "struct ucred.cr_uid")
string(REGEX MATCH "(.*)\\.(.*)" dummy_var ${struct_member_name})
set(struct_name "${CMAKE_MATCH_1}")
Expand Down Expand Up @@ -670,6 +736,71 @@ foreach(struct_member_name "struct ucred.uid" "struct ucred.cr_uid")
]=] "HAVE_${platform_var_name}")
file(APPEND "${boxconfig_h_file}" "#cmakedefine HAVE_${platform_var_name}\n")
endforeach()

function(AX_TRY_RUN_FD code var)
CHECK_CXX_SOURCE_RUNS([=[
#include "BoxConfig.cmake.h"
#include <fcntl.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>

#ifdef HAVE___SYSCALL_NEED_DEFN
extern "C" off_t __syscall(quad_t number, ...);
#endif

#ifdef HAVE___SYSCALL // always use it if we have it
# undef syscall
# define syscall __syscall
#endif

int main()
{
int fd = creat("lseektest", 0600);
int res = 1;
if(fd>=0)
{
${code}
close(fd);
}
unlink("lseektest");
return res;
}
]=] ${var})
file(APPEND "${boxconfig_h_file}" "#cmakedefine ${var}\n")
endfunction()

AX_TRY_RUN_FD(
[=[
// This test tries first to seek to position 0, with NO "dummy
// argument". If lseek does actually require a dummy argument,
// then it will eat SEEK_SET for the offset and try to use 99
// as whence, which is invalid, so res will be 0, the program
// will return 0 and we will define HAVE_LSEEK_DUMMY_PARAM
// (whew! that took 1 hour to figure out) The "dummy argument"
// probably means that it takes a 64-bit offset.
res = (syscall(SYS_lseek, fd, (int32_t)10, SEEK_SET, 99) == 10) ? 2 : 0;
]=] HAVE_LSEEK_DUMMY_PARAM)

AX_TRY_RUN_FD(
[=[
// Try to seek to a position that requires a 64-bit
// representation, and check the return value, which is the
// current position.
if(syscall(SYS_lseek, fd, (int64_t)5, SEEK_SET) != 5)
{
res = 2;
}
else if(syscall(SYS_lseek, fd, (int64_t)10, SEEK_CUR) != 15)
{
res = 3;
}
else
{
res = 0;
}
]=] HAVE_LSEEK_64_BIT)

set(CMAKE_REQUIRED_INCLUDES "")

# Build the final version of BoxConfig.cmake.h, as a temporary file.
Expand Down
23 changes: 16 additions & 7 deletions infrastructure/cmake/windows/CMakeLists.txt
Expand Up @@ -15,9 +15,9 @@ set(ZLIB_VERSION 1.2.11)
set(ZLIB_HASH SHA256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1)

# Version of OpenSSL to download, build, and compile Box Backup against:
set(OPENSSL_VERSION 1.0.2j)
set(OPENSSL_VERSION 1.1.0g)
# Hash of openssl-${OPENSSL_VERSION}.tar.gz, to be verified after download:
set(OPENSSL_HASH SHA256=e7aff292be21c259c6af26469c7a9b3ba26e9abaaffd325e3dccc9785256c431)
set(OPENSSL_HASH SHA256=de4d501267da39310905cb6dc8c6121f7a2cad45a7707f76df828fe1b85073af)

# Version of PCRE to download, build, and compile Box Backup against:
set(PCRE_VERSION 8.39)
Expand Down Expand Up @@ -49,15 +49,21 @@ if(WIN32)
URL "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz"
URL_HASH ${OPENSSL_HASH}
DOWNLOAD_NO_PROGRESS 1
CONFIGURE_COMMAND perl Configure debug-VC-WIN32 no-asm --prefix=${install_dir}
COMMAND cmd /c ms\\do_ms.bat
CONFIGURE_COMMAND perl Configure debug-VC-WIN32 no-asm no-shared
--prefix=${install_dir}
--openssldir=etc
# Run tests before install, but don't make the main target depend on them, so that
# we don't have to run them whenever we build manually on Windows.
TEST_BEFORE_INSTALL 1
TEST_EXCLUDE_FROM_MAIN 1
# You would expect us to use nt.mak to compile a static library here, but mk1mf.pl uses the /MT[d]
# CRT in that case, which is incompatible with our dynamic runtime, /MD[d]. It seems that the libs
# built by ntdll.mak, which are compiled with /MD[d], are full libraries and not import libs,
# so we can link statically against them and still get a dynamic runtime.
BUILD_IN_SOURCE 1
BUILD_COMMAND nmake /s /f ms\\nt.mak
INSTALL_COMMAND nmake /s /f ms\\nt.mak install
BUILD_COMMAND nmake /s
TEST_COMMAND nmake /s test
INSTALL_COMMAND nmake /s install
)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
ExternalProject_Add(openssl
Expand Down Expand Up @@ -100,6 +106,8 @@ ExternalProject_Add(boost
URL "http://downloads.sourceforge.net/project/boost/boost/${BOOST_VERSION}/boost_${BOOST_VERSION_UNDERSCORES}.tar.bz2"
URL_HASH ${BOOST_HASH}
# DOWNLOAD_NO_PROGRESS 1
# Disable automatic updating (untarring) as it's slow and not necessary
UPDATE_DISCONNECTED 1
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "No configure step needed"
BUILD_COMMAND ${CMAKE_COMMAND} -E echo "No build step needed"
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "No install step needed"
Expand All @@ -124,5 +132,6 @@ ExternalProject_Add(boxbackup
-DDEBUG=${DEBUG}
${boxbackup_cmake_args}
${SUB_CMAKE_EXTRA_ARGS}
STEP_TARGETS configure build install
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "No install step needed"
STEP_TARGETS configure build
)

0 comments on commit 161ceef

Please sign in to comment.