• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Copyright 2019 - 2020 Alexander Grund
4# Distributed under the Boost Software License, Version 1.0.
5# (See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt)
6
7set -euo pipefail
8
9cd "$(dirname "$0")/.."
10
11if ! [ -e "tools/create_standalone.sh" ]; then
12  echo "Could not change to repo root"
13  exit 1
14fi
15
16targetFolder="${1:-nowide_standalone}"
17
18# If target folder exists fail, unless it is the default in which case it is removed
19if [ -e "$targetFolder" ]; then
20  if [[ "$targetFolder" == "nowide_standalone" ]]; then
21    rm -r "$targetFolder"
22  else
23    echo "Target folder $targetFolder exists"
24    exit 1
25  fi
26fi
27
28mkdir -p "$targetFolder"/include
29
30cp -r include/boost/nowide "$targetFolder"/include
31cp -r src test cmake CMakeLists.txt LICENSE README.md "$targetFolder"
32cp standalone/*.hpp "$targetFolder"/include/nowide
33mv "$targetFolder/cmake/BoostAddOptions.cmake"  "$targetFolder/cmake/NowideAddOptions.cmake"
34mv "$targetFolder/cmake/BoostAddWarnings.cmake" "$targetFolder/cmake/NowideAddWarnings.cmake"
35find "$targetFolder" -name 'Jamfile*' -delete
36
37SOURCES=$(find "$targetFolder" -name '*.hpp' -or -name '*.cpp')
38SOURCES_NO_BOOST=$(echo "$SOURCES" | grep -v 'filesystem.hpp')
39
40sed 's/BOOST_NOWIDE_/NOWIDE_/g' -i $SOURCES
41sed 's/BOOST_/NOWIDE_/g' -i $SOURCES
42sed 's/boost::nowide/nowide/g' -i $SOURCES
43sed 's/boost::/nowide::/g' -i $SOURCES_NO_BOOST
44sed '/namespace boost/d' -i $SOURCES
45sed 's/<boost\/nowide\//<nowide\//g' -i $SOURCES
46sed 's/<boost\//<nowide\//g' -i $SOURCES_NO_BOOST
47sed '/config\/abi_/d' -i $SOURCES
48
49CMLs=$(find "$targetFolder" -name 'CMakeLists.txt' -or -name '*.cmake')
50
51sed 's/ BOOST_ALL_NO_LIB//' -i $CMLs
52sed 's/BOOST_NOWIDE_/NOWIDE_/g' -i $CMLs
53sed 's/Boost_NOWIDE_/NOWIDE_/g' -i $CMLs
54sed 's/boost_nowide/nowide/g' -i $CMLs
55sed 's/boost_/nowide_/g' -i $CMLs
56sed 's/Boost::nowide/nowide::nowide/g' -i $CMLs
57sed 's/Boost/Nowide/g' -i $CMLs
58sed 's/ OR BOOST_SUPERPROJECT_SOURCE_DIR//' -i $CMLs
59
60sed '/PUBLIC BOOST_NOWIDE_NO_LIB)/d' -i "$targetFolder/CMakeLists.txt"
61sed '/^if(BOOST_SUPERPROJECT_SOURCE_DIR)/,/^endif/d' -i "$targetFolder/CMakeLists.txt"
62sed 's/NAMESPACE Nowide CONFIG_FILE.*$/NAMESPACE nowide)/' -i "$targetFolder/CMakeLists.txt"
63
64sed '/^if(NOT BOOST_SUPERPROJECT_SOURCE_DIR)/,/^endif/d' -i "$targetFolder/test/CMakeLists.txt"
65sed '/Nowide::filesystem/d' -i "$targetFolder/test/CMakeLists.txt"
66