mirror of
https://github.com/boostorg/nowide.git
synced 2026-02-21 15:12:30 +00:00
Merge pull request #76 from Flamefire/standalone
Allow building as standalone (No Boost references at all)
This commit is contained in:
14
.github/workflows/ci_tests.yml
vendored
14
.github/workflows/ci_tests.yml
vendored
@@ -10,6 +10,7 @@ jobs:
|
||||
matrix:
|
||||
os: [ubuntu-16.04, windows-latest]
|
||||
buildType: [Debug, Release]
|
||||
standalone: [Boost, Standalone]
|
||||
shared_lib: [ON, OFF]
|
||||
generator: ['Visual Studio 16 2019', 'MinGW Makefiles', 'Unix Makefiles']
|
||||
exclude:
|
||||
@@ -33,11 +34,12 @@ jobs:
|
||||
key: ${{matrix.os}}-${{matrix.generator}}-${{env.BOOST_VERSION}}
|
||||
# Install newer CMake to be able to find Boost
|
||||
- name: Install CMake
|
||||
if: runner.os == 'Linux' && ! matrix.standalone
|
||||
if: runner.os == 'Linux' && matrix.standalone == 'Boost'
|
||||
run: wget -qO- https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.tar.gz | sudo tar --strip-components=1 -xzC /usr/local
|
||||
# Install Boost, no wget on Windows -.-
|
||||
- name: Download Boost
|
||||
shell: cmake -P {0}
|
||||
if: matrix.standalone == 'Boost'
|
||||
id: downloadBoost
|
||||
run: |
|
||||
string(REPLACE "." "_" filename boost_$ENV{BOOST_VERSION})
|
||||
@@ -54,7 +56,7 @@ jobs:
|
||||
endif()
|
||||
- name: Build Boost
|
||||
shell: bash
|
||||
if: steps.downloadBoost.outputs.update == 1
|
||||
if: matrix.standalone == 'Boost' && steps.downloadBoost.outputs.update == 1
|
||||
working-directory: ${{env.DEP_DIR}}/build
|
||||
run: |
|
||||
7z x boost.7z > /dev/null
|
||||
@@ -67,6 +69,14 @@ jobs:
|
||||
cd "$DEP_DIR"
|
||||
# Workaround for "Device or resource busy" error
|
||||
if ! rm -r build; then sleep 30s; rm -r build || true; fi
|
||||
- name: Create standalone
|
||||
if: matrix.standalone == 'Standalone'
|
||||
shell: bash
|
||||
run: |
|
||||
bash tools/create_standalone.sh "$PWD/../nowide_standalone"
|
||||
rm -rf *
|
||||
cp -r ../nowide_standalone/* .
|
||||
mkdir build
|
||||
- name: Configure
|
||||
working-directory: build
|
||||
run: cmake .. -DBoost_DEBUG=ON -DCMAKE_BUILD_TYPE=${{matrix.buildType}} -DBUILD_SHARED_LIBS=${{matrix.shared_lib}} -DCMAKE_INSTALL_PREFIX=${{runner.workspace}}/../install -G "${{matrix.generator}}" -DCMAKE_SH="CMAKE_SH-NOTFOUND" -DBoost_NO_BOOST_CMAKE=ON
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
# Builds the libraries for Boost.Nowide
|
||||
# Automatically detects if build as standalone or as "part of boost" (with boost namespace)
|
||||
#
|
||||
# Options:
|
||||
# BOOST_NOWIDE_INSTALL
|
||||
# BOOST_NOWIDE_BUILD_TESTS
|
||||
# BOOST_NOWIDE_SYSTEM_INCLUDE
|
||||
# BOOST_NOWIDE_WERROR
|
||||
# BUILD_TESTING
|
||||
#
|
||||
# Created target: Boost::nowide
|
||||
#
|
||||
@@ -24,13 +23,6 @@ endif()
|
||||
|
||||
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
# Find out if we are beeing build as standalone or boost version
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/nowide)
|
||||
set(BOOST_NOWIDE_STANDALONE ON)
|
||||
else()
|
||||
set(BOOST_NOWIDE_STANDALONE OFF)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
||||
# Make sure all binarys (especially exe/dll) are in one directory for tests to work
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
@@ -59,20 +51,16 @@ target_compile_definitions(boost_nowide PUBLIC BOOST_NOWIDE_NO_LIB)
|
||||
target_include_directories(boost_nowide PUBLIC include)
|
||||
boost_add_warnings(boost_nowide pedantic ${BOOST_NOWIDE_WERROR})
|
||||
|
||||
if(BOOST_NOWIDE_STANDALONE)
|
||||
target_compile_features(boost_nowide PUBLIC cxx_std_11)
|
||||
if(BOOST_SUPERPROJECT_SOURCE_DIR)
|
||||
target_link_libraries(boost_nowide PUBLIC Boost::config Boost::smart_ptr Boost::static_assert)
|
||||
set(BOOST_NOWIDE_INSTALL OFF) # smart_ptr does not support installation
|
||||
else()
|
||||
if(BOOST_SUPERPROJECT_SOURCE_DIR)
|
||||
target_link_libraries(boost_nowide PUBLIC Boost::config Boost::smart_ptr Boost::static_assert)
|
||||
set(BOOST_NOWIDE_INSTALL OFF) # smart_ptr does not support installation
|
||||
else()
|
||||
# Default boost libs are static on windows and dynamic on linux
|
||||
if(WIN32 AND NOT DEFINED Boost_USE_STATIC_LIBS)
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
endif()
|
||||
find_package(Boost 1.56 REQUIRED)
|
||||
target_link_libraries(boost_nowide PUBLIC Boost::boost)
|
||||
# Default boost libs are static on windows and dynamic on linux
|
||||
if(WIN32 AND NOT DEFINED Boost_USE_STATIC_LIBS)
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
endif()
|
||||
find_package(Boost 1.56 REQUIRED)
|
||||
target_link_libraries(boost_nowide PUBLIC Boost::boost)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set(_boost_nowide_standalone @BOOST_NOWIDE_STANDALONE@)
|
||||
set(_boost_nowide_superproject "@BOOST_SUPERPROJECT_SOURCE_DIR@")
|
||||
|
||||
if(NOT _boost_nowide_standalone)
|
||||
include(CMakeFindDependencyMacro)
|
||||
if(_boost_nowide_superproject)
|
||||
foreach(dep IN ITEMS boost_config boost_smart_ptr boost_static_assert)
|
||||
find_dependency(${dep})
|
||||
endforeach()
|
||||
else()
|
||||
# Default boost libs are static on windows and dynamic on linux
|
||||
if(WIN32 AND "${Boost_USE_STATIC_LIBS}" STREQUAL "")
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
endif()
|
||||
find_dependency(Boost 1.56)
|
||||
endif()
|
||||
include(CMakeFindDependencyMacro)
|
||||
if(_boost_nowide_superproject)
|
||||
foreach(dep IN ITEMS boost_config boost_smart_ptr boost_static_assert)
|
||||
find_dependency(${dep})
|
||||
endforeach()
|
||||
else()
|
||||
# Default boost libs are static on windows and dynamic on linux
|
||||
if(WIN32 AND "${Boost_USE_STATIC_LIBS}" STREQUAL "")
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
endif()
|
||||
find_dependency(Boost 1.56)
|
||||
endif()
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#endif // BOOST_NOWIDE_SOURCE
|
||||
#else
|
||||
#define BOOST_NOWIDE_DECL
|
||||
#endif // DYN_LINK
|
||||
#endif // BOOST_NOWIDE_DYN_LINK
|
||||
|
||||
//
|
||||
// Automatically link to the correct build variant where possible.
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define BOOST_NOWIDE_CSTDLIB_HPP_INCLUDED
|
||||
|
||||
#include <boost/nowide/config.hpp>
|
||||
#if !BOOST_WINDOWS
|
||||
#if !defined(BOOST_WINDOWS)
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <boost/nowide/cstdlib.hpp>
|
||||
|
||||
#if !BOOST_WINDOWS
|
||||
#if !defined(BOOST_WINDOWS)
|
||||
namespace boost {
|
||||
namespace nowide {
|
||||
int setenv(const char* key, const char* value, int overwrite)
|
||||
|
||||
@@ -1,31 +1,50 @@
|
||||
//
|
||||
// Copyright (c) 2012 Artyom Beilis (Tonkikh)
|
||||
// Copyright (c) 2020 Alexander Grund
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
#ifndef NOWIDE_CONFIG_H_INCLUDED
|
||||
#define NOWIDE_CONFIG_H_INCLUDED
|
||||
#ifndef NOWIDE_CONFIG_HPP_INCLUDED
|
||||
#define NOWIDE_CONFIG_HPP_INCLUDED
|
||||
|
||||
#include <boost/nowide/replacement.hpp>
|
||||
|
||||
#if(defined(__WIN32) || defined(_WIN32) || defined(WIN32)) && !defined(__CYGWIN__)
|
||||
#define NOWIDE_WINDOWS
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define NOWIDE_MSVC
|
||||
#define NOWIDE_MSVC _MSC_VER
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default")))
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_SYMBOL_VISIBLE
|
||||
#define BOOST_SYMBOL_VISIBLE
|
||||
#endif
|
||||
|
||||
#ifdef NOWIDE_WINDOWS
|
||||
#if defined(DLL_EXPORT) || defined(NOWIDE_EXPORT)
|
||||
#ifdef NOWIDE_SOURCE
|
||||
#define NOWIDE_DECL __declspec(dllexport)
|
||||
#define BOOST_SYMBOL_EXPORT __declspec(dllexport)
|
||||
#define BOOST_SYMBOL_IMPORT __declspec(dllimport)
|
||||
#else
|
||||
#define NOWIDE_DECL __declspec(dllimport)
|
||||
#endif // NOWIDE_SOURCE
|
||||
#endif // DYN_LINK
|
||||
#define BOOST_SYMBOL_EXPORT BOOST_SYMBOL_VISIBLE
|
||||
#define BOOST_SYMBOL_IMPORT
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NOWIDE_DYN_LINK)
|
||||
#ifdef BOOST_NOWIDE_SOURCE
|
||||
#define BOOST_NOWIDE_DECL BOOST_SYMBOL_EXPORT
|
||||
#else
|
||||
#define BOOST_NOWIDE_DECL BOOST_SYMBOL_IMPORT
|
||||
#endif // BOOST_NOWIDE_SOURCE
|
||||
#else
|
||||
#define BOOST_NOWIDE_DECL
|
||||
#endif // BOOST_NOWIDE_DYN_LINK
|
||||
|
||||
#ifndef NOWIDE_DECL
|
||||
#define NOWIDE_DECL
|
||||
#endif
|
||||
@@ -39,4 +58,24 @@
|
||||
#define BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT 0
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 7
|
||||
#define BOOST_NOWIDE_FALLTHROUGH __attribute__((fallthrough))
|
||||
#else
|
||||
#define BOOST_NOWIDE_FALLTHROUGH
|
||||
#endif
|
||||
|
||||
// MSVC 2015 (1900) has reasonable C++11 support (especially auto-generated move ctors)
|
||||
#if __cplusplus >= 201103L || (defined(NOWIDE_MSVC) && NOWIDE_MSVC >= 1900)
|
||||
#define BOOST_NOWIDE_CXX11 1
|
||||
#else
|
||||
#define BOOST_NOWIDE_CXX11 0
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_LIKELY)
|
||||
#define BOOST_LIKELY(x) x
|
||||
#endif
|
||||
#if !defined(BOOST_UNLIKELY)
|
||||
#define BOOST_UNLIKELY(x) x
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm -fr nowide nowide_standalone/{CMakeLists.txt,nowide,src,test} nowide_standalone.zip boost_nowide boost_nowide.zip
|
||||
mkdir -p nowide/nowide
|
||||
mkdir -p nowide/src
|
||||
mkdir -p nowide/test
|
||||
|
||||
cp ../include/boost/nowide/*.hpp nowide/nowide
|
||||
cp ../src/*.cpp nowide/src
|
||||
cp ../test/*.cpp ../test/*.hpp nowide/test
|
||||
cp ./*.hpp nowide/nowide/
|
||||
|
||||
SOURCES="nowide/test/* nowide/src/* nowide/nowide/*"
|
||||
|
||||
|
||||
sed 's/BOOST_NOWIDE_/NOWIDE_/g' -i $SOURCES
|
||||
sed 's/BOOST_/NOWIDE_/g' -i $SOURCES
|
||||
sed 's/boost::nowide::/nowide::/g' -i $SOURCES
|
||||
sed 's/boost::nowide/nowide/g' -i $SOURCES
|
||||
sed 's/boost::/nowide::/g' -i $SOURCES
|
||||
sed 's/namespace boost {//' -i $SOURCES
|
||||
sed 's/} *\/\/ *namespace boost//' -i $SOURCES
|
||||
sed 's/<boost\/nowide\//<nowide\//g' -i $SOURCES
|
||||
sed 's/<boost\//<nowide\//g' -i $SOURCES
|
||||
|
||||
cp CMakeLists.txt nowide/
|
||||
cp -a nowide nowide_standalone
|
||||
zip -r nowide_standalone.zip nowide_standalone
|
||||
|
||||
#mkdir boost_nowide
|
||||
#cp -a ../boost ../libs boost_nowide
|
||||
#zip -r boost_nowide.zip boost_nowide
|
||||
12
standalone/cstdint.hpp
Normal file
12
standalone/cstdint.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef NOWIDE_CSTDINT_HPP
|
||||
#define NOWIDE_CSTDINT_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace nowide {
|
||||
typedef std::uint32_t uint32_t;
|
||||
typedef std::uint16_t uint16_t;
|
||||
typedef std::uint8_t uint8_t;
|
||||
} // namespace nowide
|
||||
|
||||
#endif
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
export WINEPATH="/usr/lib/gcc/i686-w64-mingw32/5.3-win32/;/usr/lib/gcc/i686-w64-mingw32/5"
|
||||
|
||||
rm -fr /tmp/nwlin /tmp/nw
|
||||
|
||||
pushd .
|
||||
./convert && mkdir nowide/build && cd nowide/build && cmake -DCMAKE_TOOLCHAIN_FILE=../../MinGW.cmake -DCMAKE_INSTALL_PREFIX=/tmp/nw -DRUN_WITH_WINE=ON .. && make && make test && make install
|
||||
popd
|
||||
|
||||
pushd .
|
||||
./convert && mkdir nowide/build && cd nowide/build && cmake -DLIBDIR=lin64 -DCMAKE_INSTALL_PREFIX=/tmp/nwlin .. && make && make test && make install
|
||||
popd
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
7
standalone/static_assert.hpp
Normal file
7
standalone/static_assert.hpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef NOWIDE_STATIC_ASSERT_HPP
|
||||
#define NOWIDE_STATIC_ASSERT_HPP
|
||||
|
||||
#define NOWIDE_STATIC_ASSERT(c) static_assert(c, #c)
|
||||
#define NOWIDE_STATIC_ASSERT_MSG(c, msg) static_assert(c, msg)
|
||||
|
||||
#endif
|
||||
@@ -31,14 +31,8 @@ else()
|
||||
boost_nowide_add_test(test_internal_fstream_cxx11 SRC test_fstream_cxx11.cpp DEFINITIONS BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT=1)
|
||||
endif()
|
||||
|
||||
if(NOT BOOST_NOWIDE_STANDALONE)
|
||||
if(NOT BOOST_SUPERPROJECT_SOURCE_DIR)
|
||||
find_package(Boost 1.56 REQUIRED COMPONENTS filesystem system)
|
||||
endif()
|
||||
boost_nowide_add_test(test_fs LIBRARIES Boost::filesystem)
|
||||
endif()
|
||||
|
||||
if(NOT BOOST_SUPERPROJECT_SOURCE_DIR)
|
||||
find_package(Boost 1.56 REQUIRED COMPONENTS chrono)
|
||||
find_package(Boost 1.56 REQUIRED COMPONENTS filesystem system chrono)
|
||||
endif()
|
||||
boost_nowide_add_test(test_fs LIBRARIES Boost::filesystem)
|
||||
boost_nowide_add_test(benchmark_fstream COMPILE_ONLY DEFINITIONS BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT=1 LIBRARIES Boost::chrono)
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
#include <boost/nowide/convert.hpp>
|
||||
#include <boost/nowide/cstdio.hpp>
|
||||
#include <boost/nowide/filesystem.hpp>
|
||||
#include <boost/nowide/fstream.hpp>
|
||||
#include <boost/nowide/integration/filesystem.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
64
tools/create_standalone.sh
Normal file
64
tools/create_standalone.sh
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
if ! [ -e "tools/create_standalone.sh" ]; then
|
||||
echo "Could not change to repo root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
targetFolder="${1:-nowide_standalone}"
|
||||
|
||||
# If target folder exists fail, unless it is the default in which case it is removed
|
||||
if [ -e "$targetFolder" ]; then
|
||||
if [[ "$targetFolder" == "nowide_standalone" ]]; then
|
||||
rm -r "$targetFolder"
|
||||
else
|
||||
echo "Target folder $targetFolder exists"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$targetFolder"/include
|
||||
|
||||
cp -r include/boost/nowide "$targetFolder"/include
|
||||
cp -r src test cmake CMakeLists.txt "$targetFolder"
|
||||
cp standalone/*.hpp "$targetFolder"/include/nowide
|
||||
mv "$targetFolder/cmake/BoostAddOptions.cmake" "$targetFolder/cmake/NowideAddOptions.cmake"
|
||||
mv "$targetFolder/cmake/BoostAddWarnings.cmake" "$targetFolder/cmake/NowideAddWarnings.cmake"
|
||||
find "$targetFolder" -name 'Jamfile*' -delete
|
||||
|
||||
SOURCES=$(find "$targetFolder" -type f -not -name '*.txt' -not -name '*.cmake')
|
||||
|
||||
sed 's/BOOST_NOWIDE_/NOWIDE_/g' -i $SOURCES
|
||||
sed 's/BOOST_/NOWIDE_/g' -i $SOURCES
|
||||
sed 's/boost::nowide/nowide/g' -i $SOURCES
|
||||
sed 's/boost::chrono/std::chrono/g' -i $SOURCES
|
||||
sed 's/boost::milli/std::milli/g' -i $SOURCES
|
||||
sed 's/boost::/nowide::/g' -i $SOURCES
|
||||
sed '/namespace boost/d' -i $SOURCES
|
||||
sed 's/<boost\/chrono.hpp/<chrono/g' -i $SOURCES
|
||||
sed 's/<boost\/nowide\//<nowide\//g' -i $SOURCES
|
||||
sed 's/<boost\//<nowide\//g' -i $SOURCES
|
||||
sed '/config\/abi_/d' -i $SOURCES
|
||||
|
||||
CMLs=$(find "$targetFolder" -name 'CMakeLists.txt' -or -name '*.cmake')
|
||||
|
||||
sed 's/ BOOST_ALL_NO_LIB//' -i $CMLs
|
||||
sed 's/BOOST_NOWIDE_/NOWIDE_/g' -i $CMLs
|
||||
sed 's/boost_nowide/nowide/g' -i $CMLs
|
||||
sed 's/boost_/nowide_/g' -i $CMLs
|
||||
sed 's/Boost::nowide/nowide::nowide/g' -i $CMLs
|
||||
sed 's/Boost/Nowide/g' -i $CMLs
|
||||
sed 's/ OR BOOST_SUPERPROJECT_SOURCE_DIR//' -i $CMLs
|
||||
|
||||
sed '/PUBLIC BOOST_NOWIDE_NO_LIB)/d' -i "$targetFolder/CMakeLists.txt"
|
||||
sed '/^if(BOOST_SUPERPROJECT_SOURCE_DIR)/,/^endif/d' -i "$targetFolder/CMakeLists.txt"
|
||||
sed '/add_warnings/atarget_compile_features(nowide PUBLIC cxx_std_11)' -i "$targetFolder/CMakeLists.txt"
|
||||
sed 's/NAMESPACE Nowide CONFIG_FILE.*$/NAMESPACE nowide)/' -i "$targetFolder/CMakeLists.txt"
|
||||
|
||||
sed '/if(NOT BOOST_SUPERPROJECT_SOURCE_DIR)/,/endif/d' -i "$targetFolder/test/CMakeLists.txt"
|
||||
sed 's/ LIBRARIES Nowide::chrono//' -i "$targetFolder/test/CMakeLists.txt"
|
||||
sed '/Nowide::filesystem/d' -i "$targetFolder/test/CMakeLists.txt"
|
||||
Reference in New Issue
Block a user