Skip to content

Commit

Permalink
Merge from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
soroshsabz committed Jul 31, 2020
2 parents 5b30337 + 4748f6e commit 080d6d3
Show file tree
Hide file tree
Showing 38 changed files with 2,721 additions and 781 deletions.
77 changes: 62 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,25 @@ matrix:
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"

- os: linux
dist: bionic
compiler: gcc-10
env: TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,20
addons:
apt:
packages:
- g++-10
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"

- os: linux
dist: bionic
compiler: gcc-UBSAN
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,20 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-9
- g++-10
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"

Expand Down Expand Up @@ -302,48 +313,62 @@ matrix:
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main"
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

- os: linux
dist: xenial
compiler: clang-10
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,20
addons:
apt:
packages:
- clang-10
- libstdc++-9-dev
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main"
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

- os: linux
dist: xenial
compiler: clang-UBSAN
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,20 UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-9
- clang-10
- libstdc++-9-dev
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main"
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main"
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

- os: linux
dist: xenial
compiler: clang-libc++
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a CXXFLAGS="-stdlib=libc++" LINKFLAGS="-stdlib=libc++"
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,20 CXXFLAGS="-stdlib=libc++" LINKFLAGS="-stdlib=libc++"
addons:
apt:
packages:
- clang-9
- libc++-9-dev
- libc++abi-9-dev
- clang-10
- libc++-10-dev
- libc++abi-10-dev
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main"
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main"
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

- os: linux
dist: xenial
compiler: clang-libc++-UBSAN
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 CXXFLAGS="-stdlib=libc++" LINKFLAGS="-stdlib=libc++"
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,20 UBSAN_OPTIONS=print_stacktrace=1 CXXFLAGS="-stdlib=libc++" LINKFLAGS="-stdlib=libc++"
addons:
apt:
packages:
- clang-9
- libc++-9-dev
- libc++abi-9-dev
- clang-10
- libc++-10-dev
- libc++abi-10-dev
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main"
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main"
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

# clang, OS X
Expand All @@ -360,6 +385,28 @@ matrix:
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,17
osx_image: xcode11.2

# clang, FreeBSD
- os: freebsd
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,17

# cmake self-test
- os: linux
env: TEST_CMAKE=1
addons:
apt:
packages:
- cmake
script:
- BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
- mkdir __build_static__ && cd __build_static__
- cmake ../libs/filesystem/test/test_cmake
- cmake --build . --target boost_filesystem_cmake_self_test -j $BUILD_JOBS
- cd ..
- mkdir __build_shared__ && cd __build_shared__
- cmake -DBUILD_SHARED_LIBS=On ../libs/filesystem/test/test_cmake
- cmake --build . --target boost_filesystem_cmake_self_test -j $BUILD_JOBS


install:
- GIT_FETCH_JOBS=8
- BOOST_BRANCH=develop
Expand Down
64 changes: 54 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
# Copyright 2019 Mike Dev
# Copyright 2020 Andrey Semashev
#
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
#
# NOTE: CMake support for Boost.Filesystem is currently experimental at best
# and the interface is likely to change in the future

cmake_minimum_required( VERSION 3.5 )
project( BoostFilesystem )
cmake_minimum_required(VERSION 3.5)
project(BoostFilesystem VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)

include(CheckCXXSourceCompiles)

add_library( boost_filesystem
check_cxx_source_compiles("#include <${CMAKE_CURRENT_SOURCE_DIR}/config/has_stat_st_mtim.cpp>" BOOST_FILESYSTEM_HAS_STAT_ST_MTIM)
check_cxx_source_compiles("#include <${CMAKE_CURRENT_SOURCE_DIR}/config/has_stat_st_mtimensec.cpp>" BOOST_FILESYSTEM_HAS_STAT_ST_MTIMENSEC)
check_cxx_source_compiles("#include <${CMAKE_CURRENT_SOURCE_DIR}/config/has_stat_st_mtimespec.cpp>" BOOST_FILESYSTEM_HAS_STAT_ST_MTIMESPEC)
if(WIN32)
# Note: We can't use the Boost::library targets here as they may not yet be included by the superproject when this CMakeLists.txt is included.
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/../..")
set(CMAKE_REQUIRED_LIBRARIES bcrypt)
check_cxx_source_compiles("#include <${CMAKE_CURRENT_SOURCE_DIR}/config/has_bcrypt.cpp>" BOOST_FILESYSTEM_HAS_BCRYPT)
unset(CMAKE_REQUIRED_LIBRARIES)
unset(CMAKE_REQUIRED_INCLUDES)
endif()

add_library(boost_filesystem
src/codecvt_error_category.cpp
src/exception.cpp
src/operations.cpp
Expand All @@ -21,11 +37,12 @@ add_library( boost_filesystem
src/windows_file_codecvt.cpp
)

add_library( Boost::filesystem ALIAS boost_filesystem )
add_library(Boost::filesystem ALIAS boost_filesystem)

target_include_directories( boost_filesystem PUBLIC include )
target_include_directories(boost_filesystem PUBLIC include)
target_include_directories(boost_filesystem PRIVATE src)

target_compile_definitions( boost_filesystem
target_compile_definitions(boost_filesystem
PUBLIC
# NOTE:
# We deactivate autolinking, because cmake based builds don't need it
Expand All @@ -39,7 +56,17 @@ target_compile_definitions( boost_filesystem
BOOST_FILESYSTEM_SOURCE
)

target_link_libraries( boost_filesystem
if(BOOST_FILESYSTEM_HAS_STAT_ST_MTIM)
target_compile_definitions(boost_filesystem PRIVATE BOOST_FILESYSTEM_HAS_STAT_ST_MTIM)
endif()
if(BOOST_FILESYSTEM_HAS_STAT_ST_MTIMENSEC)
target_compile_definitions(boost_filesystem PRIVATE BOOST_FILESYSTEM_HAS_STAT_ST_MTIMENSEC)
endif()
if(BOOST_FILESYSTEM_HAS_STAT_ST_MTIMESPEC)
target_compile_definitions(boost_filesystem PRIVATE BOOST_FILESYSTEM_HAS_STAT_ST_MTIMESPEC)
endif()

target_link_libraries(boost_filesystem
PUBLIC
Boost::assert
Boost::config
Expand All @@ -51,9 +78,26 @@ target_link_libraries( boost_filesystem
Boost::smart_ptr
Boost::system
Boost::type_traits
)

target_link_libraries( boost_filesystem
PRIVATE
Boost::winapi
Boost::predef
)

if(WIN32)
if(BOOST_FILESYSTEM_HAS_BCRYPT)
target_compile_definitions(boost_filesystem PRIVATE BOOST_FILESYSTEM_HAS_BCRYPT)
target_link_libraries(boost_filesystem PRIVATE bcrypt)
else()
target_compile_definitions(boost_filesystem PRIVATE BOOST_FILESYSTEM_HAS_WINCRYPT)
if(NOT WINCE)
target_link_libraries(boost_filesystem PRIVATE advapi32)
else()
target_link_libraries(boost_filesystem PRIVATE coredll)
endif()
endif()

target_link_libraries(boost_filesystem
PRIVATE
Boost::winapi
)
endif()
16 changes: 16 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ environment:
CXXSTD: 03,11,14,1z
ADDPATH: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TEST_CMAKE: 1
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019

install:
- set GIT_FETCH_JOBS=8
Expand All @@ -79,3 +81,17 @@ test_script:
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j %NUMBER_OF_PROCESSORS% libs/filesystem/test toolset=%TOOLSET% %CXXSTD% %ADDRMD%

for:
- matrix:
only: [TEST_CMAKE: 1]
test_script:
- mkdir __build_static__
- cd __build_static__
- cmake ../libs/filesystem/test/test_cmake
- cmake --build . --target boost_filesystem_cmake_self_test -j %NUMBER_OF_PROCESSORS%
- cd ..
- mkdir __build_shared__
- cd __build_shared__
- cmake -DBUILD_SHARED_LIBS=On ../libs/filesystem/test/test_cmake
- cmake --build . --target boost_filesystem_cmake_self_test -j %NUMBER_OF_PROCESSORS%
46 changes: 45 additions & 1 deletion build/Jamfile.v2
Original file line number Diff line number Diff line change
@@ -1,13 +1,56 @@
# Boost Filesystem Library Build Jamfile

# (C) Copyright Beman Dawes 2002-2006
# (C) Copyright Andrey Semashev 2020
# Distributed under the Boost Software License, Version 1.0.
# See www.boost.org/LICENSE_1_0.txt

# See library home page at http://www.boost.org/libs/filesystem

import project ;
import configure ;

lib bcrypt ;
lib advapi32 ;
lib coredll ;
explicit bcrypt advapi32 coredll ;

# The rule checks we're building for Windows and selects crypto API to be used
rule select-windows-crypto-api ( properties * )
{
local result ;

if <target-os>windows in $(properties) || <target-os>cygwin in $(properties)
{
if [ configure.builds ../config//has_bcrypt : $(properties) : "has BCrypt API" ]
{
result = <define>BOOST_FILESYSTEM_HAS_BCRYPT <library>bcrypt ;
}
else
{
result = <define>BOOST_FILESYSTEM_HAS_WINCRYPT ;
if [ configure.builds ../config//is_windows_ce : $(properties) : "is Windows CE" ]
{
result += <library>coredll ;
}
else
{
result += <library>advapi32 ;
}
}
}

#ECHO Result: $(result) ;
return $(result) ;
}

project boost/filesystem
: requirements <host-os>hpux,<toolset>gcc:<define>_INCLUDE_STDC__SOURCE_199901
: requirements
<host-os>hpux,<toolset>gcc:<define>_INCLUDE_STDC__SOURCE_199901
[ check-target-builds ../config//has_stat_st_mtim "has stat::st_mtim" : <define>BOOST_FILESYSTEM_HAS_STAT_ST_MTIM ]
[ check-target-builds ../config//has_stat_st_mtimensec "has stat::st_mtimensec" : <define>BOOST_FILESYSTEM_HAS_STAT_ST_MTIMENSEC ]
[ check-target-builds ../config//has_stat_st_mtimespec "has stat::st_mtimespec" : <define>BOOST_FILESYSTEM_HAS_STAT_ST_MTIMESPEC ]
<conditional>@select-windows-crypto-api
: source-location ../src
: usage-requirements # pass these requirement to dependents (i.e. users)
<link>shared:<define>BOOST_FILESYSTEM_DYN_LINK=1
Expand All @@ -30,6 +73,7 @@ SOURCES =
lib boost_filesystem
: $(SOURCES).cpp
: <define>BOOST_FILESYSTEM_SOURCE
<include>../src
<link>shared:<define>BOOST_FILESYSTEM_DYN_LINK=1
<link>static:<define>BOOST_FILESYSTEM_STATIC_LINK=1
:
Expand Down
17 changes: 17 additions & 0 deletions config/Jamfile.v2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright Andrey Semashev 2020.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#

obj has_stat_st_mtim : has_stat_st_mtim.cpp ;
explicit has_stat_st_mtim ;
obj has_stat_st_mtimensec : has_stat_st_mtimensec.cpp ;
explicit has_stat_st_mtimensec ;
obj has_stat_st_mtimespec : has_stat_st_mtimespec.cpp ;
explicit has_stat_st_mtimespec ;
obj has_bcrypt : has_bcrypt.cpp ;
explicit has_bcrypt ;
obj is_windows_ce : is_windows_ce.cpp ;
explicit is_windows_ce ;
32 changes: 32 additions & 0 deletions config/has_bcrypt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2020 Andrey Semashev

// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt

// See library home page at http://www.boost.org/libs/filesystem

// Include Boost.Predef first so that windows.h is guaranteed to be not included
#include <boost/predef/os/windows.h>
#include <boost/predef/os/cygwin.h>
#if !BOOST_OS_WINDOWS && !BOOST_OS_CYGWIN
#error "This config test is for Windows only"
#endif

#include <boost/winapi/config.hpp>
#include <boost/predef/platform.h>
#if !(BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 && BOOST_WINAPI_PARTITION_APP_SYSTEM)
#error "No BCrypt API"
#endif

#include <cstddef>
#include <boost/winapi/basic_types.hpp>
#include <boost/winapi/bcrypt.hpp>

int main()
{
unsigned char buf[16] = {};
boost::winapi::BCRYPT_ALG_HANDLE_ handle;
boost::winapi::NTSTATUS_ status = boost::winapi::BCryptOpenAlgorithmProvider(&handle, boost::winapi::BCRYPT_RNG_ALGORITHM_, NULL, 0);
status = boost::winapi::BCryptGenRandom(handle, reinterpret_cast<boost::winapi::PUCHAR_>(static_cast<unsigned char*>(buf)), static_cast<boost::winapi::ULONG_>(sizeof(buf)), 0);
boost::winapi::BCryptCloseAlgorithmProvider(handle, 0);
}
16 changes: 16 additions & 0 deletions config/has_stat_st_mtim.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2020 Andrey Semashev

// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt

// See library home page at http://www.boost.org/libs/filesystem

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

int main()
{
struct stat st;
st.st_mtim.tv_nsec = 10;
}
Loading

0 comments on commit 080d6d3

Please sign in to comment.