Browse Source

Get rid of in-source boost::nowide. Use upstream instead

tamasmeszaros 2 years ago
parent
commit
bffa3f8578

+ 1 - 1
CMakeLists.txt

@@ -366,7 +366,7 @@ endif()
 # boost::process was introduced first in version 1.64.0,
 # boost::beast::detail::base64 was introduced first in version 1.66.0
 set(MINIMUM_BOOST_VERSION "1.66.0")
-set(_boost_components "system;filesystem;thread;log;locale;regex;chrono;atomic;date_time;iostreams")
+set(_boost_components "system;filesystem;thread;log;locale;regex;chrono;atomic;date_time;iostreams;nowide")
 find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS ${_boost_components})
 
 add_library(boost_libs INTERFACE)

+ 0 - 2
src/CMakeLists.txt

@@ -4,8 +4,6 @@ project(PrusaSlicer-native)
 add_subdirectory(build-utils)
 add_subdirectory(admesh)
 add_subdirectory(avrdude)
-# boost/nowide
-add_subdirectory(boost)
 add_subdirectory(clipper)
 add_subdirectory(miniz)
 add_subdirectory(glu-libtess)

+ 2 - 2
src/PrusaSlicer.cpp

@@ -29,9 +29,9 @@
 #include <boost/algorithm/string/predicate.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/nowide/args.hpp>
-#include <boost/nowide/cenv.hpp>
+#include <boost/nowide/cstdlib.hpp>
 #include <boost/nowide/iostream.hpp>
-#include <boost/nowide/integration/filesystem.hpp>
+#include <boost/nowide/filesystem.hpp>
 #include <boost/dll/runtime_symbol_info.hpp>
 
 #include "unix/fhs.hpp"  // Generated by CMake from ../platform/unix/fhs.hpp.in

+ 0 - 24
src/boost/CMakeLists.txt

@@ -1,24 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12)
-project(nowide)
-
-add_library(nowide STATIC
-    nowide/args.hpp
-    nowide/cenv.hpp
-    nowide/config.hpp
-    nowide/convert.hpp
-    nowide/cstdio.hpp
-    nowide/cstdlib.hpp
-    nowide/filebuf.hpp
-    nowide/fstream.hpp
-    nowide/integration/filesystem.hpp
-    nowide/iostream.cpp
-    nowide/iostream.hpp
-    nowide/stackstring.hpp
-    nowide/system.hpp
-    nowide/utf8_codecvt.hpp
-    nowide/windows.hpp
-)
-
-target_link_libraries(nowide PUBLIC boost_headeronly)
-
-

+ 0 - 167
src/boost/nowide/args.hpp

@@ -1,167 +0,0 @@
-//
-//  Copyright (c) 2012 Artyom Beilis (Tonkikh)
-//
-//  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 BOOST_NOWIDE_ARGS_HPP_INCLUDED
-#define BOOST_NOWIDE_ARGS_HPP_INCLUDED
-
-#include <boost/config.hpp>
-#include <boost/nowide/stackstring.hpp>
-#include <vector>
-#ifdef BOOST_WINDOWS
-#include <boost/nowide/windows.hpp>
-#endif
-
-namespace boost {
-namespace nowide {
-    #if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN)
-    class args {
-    public:
-        args(int &,char **&) {}
-        args(int &,char **&,char **&){}
-        ~args() {}
-    };
-
-    #else
-
-    ///
-    /// \brief args is a class that fixes standard main() function arguments and changes them to UTF-8 under 
-    /// Microsoft Windows.
-    ///
-    /// The class uses \c GetCommandLineW(), \c CommandLineToArgvW() and \c GetEnvironmentStringsW()
-    /// in order to obtain the information. It does not relates to actual values of argc,argv and env
-    /// under Windows.
-    ///
-    /// It restores the original values in its destructor
-    ///
-    /// \note the class owns the memory of the newly allocated strings
-    ///
-    class args {
-    public:
-        
-        ///
-        /// Fix command line agruments 
-        ///
-        args(int &argc,char **&argv) :
-            old_argc_(argc),
-            old_argv_(argv),
-            old_env_(0),
-            old_argc_ptr_(&argc),
-            old_argv_ptr_(&argv),
-            old_env_ptr_(0)
-        {
-            fix_args(argc,argv);
-        }
-        ///
-        /// Fix command line agruments and environment
-        ///
-        args(int &argc,char **&argv,char **&en) :
-            old_argc_(argc),
-            old_argv_(argv),
-            old_env_(en),
-            old_argc_ptr_(&argc),
-            old_argv_ptr_(&argv),
-            old_env_ptr_(&en)
-        {
-            fix_args(argc,argv);
-            fix_env(en);
-        }
-        ///
-        /// Restore original argc,argv,env values, if changed
-        ///
-        ~args()
-        {
-            if(old_argc_ptr_)
-                *old_argc_ptr_ = old_argc_;
-            if(old_argv_ptr_)
-                *old_argv_ptr_ = old_argv_;
-            if(old_env_ptr_) 
-                *old_env_ptr_ = old_env_;
-        }
-    private:    
-        void fix_args(int &argc,char **&argv)
-        {
-                int wargc;
-                wchar_t **wargv = CommandLineToArgvW(GetCommandLineW(),&wargc);
-            if(!wargv) {
-                argc = 0;
-                static char *dummy = 0;
-                argv = &dummy;
-                return;
-            }
-            try{ 
-                args_.resize(wargc+1,0);
-                arg_values_.resize(wargc);
-                for(int i=0;i<wargc;i++) {
-                    if(!arg_values_[i].convert(wargv[i])) {
-                        wargc = i;
-                        break;
-                    }
-                    args_[i] = arg_values_[i].c_str();
-                }
-                argc = wargc;
-                argv = &args_[0];
-            }
-            catch(...) {
-                LocalFree(wargv);
-                throw;
-            }
-            LocalFree(wargv);
-        }
-        void fix_env(char **&en)
-        {
-            static char *dummy = 0;
-            en = &dummy;
-            wchar_t *wstrings = GetEnvironmentStringsW();
-            if(!wstrings)
-                return;
-            try {
-                wchar_t *wstrings_end = 0;
-                int count = 0;
-                for(wstrings_end = wstrings;*wstrings_end;wstrings_end+=wcslen(wstrings_end)+1)
-                        count++;
-                if(env_.convert(wstrings,wstrings_end)) {
-                    envp_.resize(count+1,0);
-                    char *p=env_.c_str();
-                    int pos = 0;
-                    for(int i=0;i<count;i++) {
-                        if(*p!='=')
-                            envp_[pos++] = p;
-                        p+=strlen(p)+1;
-                    }
-                    en = &envp_[0];
-                }
-            }
-            catch(...) {
-                FreeEnvironmentStringsW(wstrings);
-                throw;
-            }
-            FreeEnvironmentStringsW(wstrings);
-
-        }
-
-        std::vector<char *> args_;
-        std::vector<short_stackstring> arg_values_;
-        stackstring env_;
-        std::vector<char *> envp_;
-
-        int old_argc_;
-        char **old_argv_;
-        char **old_env_;
-
-        int  *old_argc_ptr_;
-        char ***old_argv_ptr_;
-        char ***old_env_ptr_;
-    };
-
-    #endif
-
-} // nowide
-} // namespace boost
-#endif
-
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4

+ 0 - 124
src/boost/nowide/cenv.hpp

@@ -1,124 +0,0 @@
-//
-//  Copyright (c) 2012 Artyom Beilis (Tonkikh)
-//
-//  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 BOOST_NOWIDE_CENV_H_INCLUDED
-#define BOOST_NOWIDE_CENV_H_INCLUDED
-
-#include <string>
-#include <stdexcept>
-#include <stdlib.h>
-#include <boost/config.hpp>
-#include <boost/nowide/stackstring.hpp>
-#include <vector>
-
-#ifdef BOOST_WINDOWS
-#include <boost/nowide/windows.hpp>
-#endif
-
-namespace boost {
-namespace nowide {
-    #if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN)
-    using ::getenv;
-    using ::setenv;
-    using ::unsetenv;
-    using ::putenv;
-    #else
-    ///
-    /// \brief UTF-8 aware getenv. Returns 0 if the variable is not set.
-    ///
-    /// This function is not thread safe or reenterable as defined by the standard library
-    ///
-    inline char *getenv(char const *key)
-    {
-        static stackstring value;
-        
-        wshort_stackstring name;
-        if(!name.convert(key))
-            return 0;
-
-        static const size_t buf_size = 64;
-        wchar_t buf[buf_size];
-        std::vector<wchar_t> tmp;
-        wchar_t *ptr = buf;
-        size_t n = GetEnvironmentVariableW(name.c_str(),buf,buf_size);
-        if(n == 0 && GetLastError() == 203) // ERROR_ENVVAR_NOT_FOUND
-            return 0;
-        if(n >= buf_size) {
-            tmp.resize(n+1,L'\0');
-            n = GetEnvironmentVariableW(name.c_str(),&tmp[0],static_cast<unsigned>(tmp.size() - 1));
-            // The size may have changed
-            if(n >= tmp.size() - 1)
-                return 0;
-            ptr = &tmp[0];
-        }
-        if(!value.convert(ptr))
-            return 0;
-        return value.c_str();
-    }
-    ///
-    /// \brief  UTF-8 aware setenv, \a key - the variable name, \a value is a new UTF-8 value,
-    /// 
-    /// if override is not 0, that the old value is always overridded, otherwise,
-    /// if the variable exists it remains unchanged
-    ///
-    inline int setenv(char const *key,char const *value,int override)
-    {
-        wshort_stackstring name;
-        if(!name.convert(key))
-            return -1;
-        if(!override) {
-            wchar_t unused[2];
-            if(!(GetEnvironmentVariableW(name.c_str(),unused,2)==0 && GetLastError() == 203)) // ERROR_ENVVAR_NOT_FOUND
-                return 0;
-        }
-        wstackstring wval;
-        if(!wval.convert(value))
-            return -1;
-        if(SetEnvironmentVariableW(name.c_str(),wval.c_str()))
-            return 0;
-        return -1;
-    }
-    ///
-    /// \brief Remove enviroment variable \a key
-    ///
-    inline int unsetenv(char const *key)
-    {
-        wshort_stackstring name;
-        if(!name.convert(key))
-            return -1;
-        if(SetEnvironmentVariableW(name.c_str(),0))
-            return 0;
-        return -1;
-    }
-    ///
-    /// \brief UTF-8 aware putenv implementation, expects string in format KEY=VALUE
-    ///
-    inline int putenv(char *string)
-    {
-        char const *key = string;
-        char const *key_end = string;
-        while(*key_end != '=' && *key_end != 0)
-            ++ key_end;
-        if(*key_end == 0)
-            return -1;
-        wshort_stackstring wkey;
-        if(!wkey.convert(key,key_end))
-            return -1;
-        wstackstring wvalue;
-        if(!wvalue.convert(key_end+1))
-            return -1;
-        if(SetEnvironmentVariableW(wkey.c_str(),wvalue.c_str()))
-            return 0;
-        return -1;
-    }
-    #endif
-} // nowide
-} // namespace boost
-
-#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4

+ 0 - 54
src/boost/nowide/config.hpp

@@ -1,54 +0,0 @@
-//
-//  Copyright (c) 2012 Artyom Beilis (Tonkikh)
-//
-//  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 BOOST_NOWIDE_CONFIG_HPP_INCLUDED
-#define BOOST_NOWIDE_CONFIG_HPP_INCLUDED
-
-#include <boost/config.hpp>
-
-#ifndef BOOST_SYMBOL_VISIBLE
-# define BOOST_SYMBOL_VISIBLE
-#endif
-
-#ifdef BOOST_HAS_DECLSPEC 
-#   if defined(BOOST_ALL_DYN_LINK) || 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
-#   endif  // DYN_LINK
-#endif  // BOOST_HAS_DECLSPEC
-
-#ifndef BOOST_NOWIDE_DECL
-#   define BOOST_NOWIDE_DECL
-#endif
-
-//
-// Automatically link to the correct build variant where possible. 
-// 
-#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_NOWIDE_NO_LIB) && !defined(BOOST_NOWIDE_SOURCE)
-//
-// Set the name of our library, this will get undef'ed by auto_link.hpp
-// once it's done with it:
-//
-#define BOOST_LIB_NAME boost_nowide
-//
-// If we're importing code from a dll, then tell auto_link.hpp about it:
-//
-#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_NOWIDE_DYN_LINK)
-#  define BOOST_DYN_LINK
-#endif
-//
-// And include the header that does the work:
-//
-#include <boost/config/auto_link.hpp>
-#endif  // auto-linking disabled
-
-
-#endif // boost/nowide/config.hpp
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4

+ 0 - 154
src/boost/nowide/convert.hpp

@@ -1,154 +0,0 @@
-//
-//  Copyright (c) 2012 Artyom Beilis (Tonkikh)
-//
-//  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 BOOST_NOWIDE_CONVERT_H_INCLUDED
-#define BOOST_NOWIDE_CONVERT_H_INCLUDED
-
-#include <string>
-#include <boost/locale/encoding_utf.hpp>
-
-namespace boost {
-namespace nowide {
-    ///
-    /// \brief Template function that converts a buffer of UTF sequences in range [source_begin,source_end)
-    /// to the output \a buffer of size \a buffer_size.
-    ///
-    /// In case of success a NULL terminated string is returned (buffer), otherwise 0 is returned.
-    ///
-    /// If there is not enough room in the buffer or the source sequence contains invalid UTF,
-    /// 0 is returned, and the contents of the buffer are undefined.
-    ///
-    template<typename CharOut,typename CharIn>
-    CharOut *basic_convert(CharOut *buffer,size_t buffer_size,CharIn const *source_begin,CharIn const *source_end)
-    {
-        CharOut *rv = buffer;
-        if(buffer_size == 0)
-            return 0;
-        buffer_size --;
-        while(source_begin!=source_end) {
-            using namespace boost::locale::utf;
-            code_point c = utf_traits<CharIn>::template decode<CharIn const *>(source_begin,source_end);
-            if(c==illegal || c==incomplete) {
-                rv = 0;
-                break;
-            }
-            size_t width = utf_traits<CharOut>::width(c);
-            if(buffer_size < width) {
-                rv=0;
-                break;
-            }
-            buffer = utf_traits<CharOut>::template encode<CharOut *>(c,buffer);
-            buffer_size -= width;
-        }
-        *buffer++ = 0;
-        return rv;
-    }
-
-    /// \cond INTERNAL
-    namespace details {
-        //
-        // wcslen defined only in C99... So we will not use it
-        //
-        template<typename Char>
-        Char const *basic_strend(Char const *s)
-        {
-            while(*s)
-                s++;
-            return s;
-        }
-    }
-    /// \endcond
-
-    ///
-    /// Convert NULL terminated UTF source string to NULL terminated \a output string of size at
-    /// most output_size (including NULL)
-    /// 
-    /// In case of success output is returned, if the input sequence is illegal,
-    /// or there is not enough room NULL is returned 
-    ///
-    inline char *narrow(char *output,size_t output_size,wchar_t const *source)
-    {
-        return basic_convert(output,output_size,source,details::basic_strend(source));
-    }
-    ///
-    /// Convert UTF text in range [begin,end) to NULL terminated \a output string of size at
-    /// most output_size (including NULL)
-    /// 
-    /// In case of success output is returned, if the input sequence is illegal,
-    /// or there is not enough room NULL is returned 
-    ///
-    inline char *narrow(char *output,size_t output_size,wchar_t const *begin,wchar_t const *end)
-    {
-        return basic_convert(output,output_size,begin,end);
-    }
-    ///
-    /// Convert NULL terminated UTF source string to NULL terminated \a output string of size at
-    /// most output_size (including NULL)
-    /// 
-    /// In case of success output is returned, if the input sequence is illegal,
-    /// or there is not enough room NULL is returned 
-    ///
-    inline wchar_t *widen(wchar_t *output,size_t output_size,char const *source)
-    {
-        return basic_convert(output,output_size,source,details::basic_strend(source));
-    }
-    ///
-    /// Convert UTF text in range [begin,end) to NULL terminated \a output string of size at
-    /// most output_size (including NULL)
-    /// 
-    /// In case of success output is returned, if the input sequence is illegal,
-    /// or there is not enough room NULL is returned 
-    ///
-    inline wchar_t *widen(wchar_t *output,size_t output_size,char const *begin,char const *end)
-    {
-        return basic_convert(output,output_size,begin,end);
-    }
-
-
-    ///
-    /// Convert between Wide - UTF-16/32 string and UTF-8 string.
-    ///
-    /// boost::locale::conv::conversion_error is thrown in a case of a error
-    ///
-    inline std::string narrow(wchar_t const *s)
-    {
-        return boost::locale::conv::utf_to_utf<char>(s);
-    }
-    ///
-    /// Convert between UTF-8 and UTF-16 string, implemented only on Windows platform
-    ///
-    /// boost::locale::conv::conversion_error is thrown in a case of a error
-    ///
-    inline std::wstring widen(char const *s)
-    {
-        return boost::locale::conv::utf_to_utf<wchar_t>(s);
-    }
-    ///
-    /// Convert between Wide - UTF-16/32 string and UTF-8 string
-    ///
-    /// boost::locale::conv::conversion_error is thrown in a case of a error
-    ///
-    inline std::string narrow(std::wstring const &s) 
-    {
-        return boost::locale::conv::utf_to_utf<char>(s);
-    }
-    ///
-    /// Convert between UTF-8 and UTF-16 string, implemented only on Windows platform
-    ///
-    /// boost::locale::conv::conversion_error is thrown in a case of a error
-    ///
-    inline std::wstring widen(std::string const &s) 
-    {
-        return boost::locale::conv::utf_to_utf<wchar_t>(s);
-    }
-
-} // nowide
-} // namespace boost
-
-#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4

+ 0 - 101
src/boost/nowide/cstdio.hpp

@@ -1,101 +0,0 @@
-//
-//  Copyright (c) 2012 Artyom Beilis (Tonkikh)
-//
-//  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 BOOST_NOWIDE_CSTDIO_H_INCLUDED
-#define BOOST_NOWIDE_CSTDIO_H_INCLUDED
-
-#include <cstdio>
-#include <stdio.h>
-#include <boost/config.hpp>
-#include <boost/nowide/convert.hpp>
-#include <boost/nowide/stackstring.hpp>
-#include <errno.h>
-
-#ifdef BOOST_MSVC
-#  pragma warning(push)
-#  pragma warning(disable : 4996)
-#endif
-
-
-namespace boost {
-namespace nowide {
-#if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN)
-    using std::fopen;
-    using std::freopen;
-    using std::remove;
-    using std::rename;
-#else
-
-///
-/// \brief Same as freopen but file_name and mode are UTF-8 strings
-///
-/// If invalid UTF-8 given, NULL is returned and errno is set to EINVAL
-///
-inline FILE *freopen(char const *file_name,char const *mode,FILE *stream)
-{
-    wstackstring wname;
-    wshort_stackstring wmode;
-    if(!wname.convert(file_name) || !wmode.convert(mode)) {
-        errno = EINVAL;
-        return 0;
-    }
-    return _wfreopen(wname.c_str(),wmode.c_str(),stream);
-}
-///
-/// \brief Same as fopen but file_name and mode are UTF-8 strings
-///
-/// If invalid UTF-8 given, NULL is returned and errno is set to EINVAL
-///
-inline FILE *fopen(char const *file_name,char const *mode)
-{
-    wstackstring wname;
-    wshort_stackstring wmode;
-    if(!wname.convert(file_name) || !wmode.convert(mode)) {
-        errno = EINVAL;
-        return 0;
-    }
-    return _wfopen(wname.c_str(),wmode.c_str());
-}
-///
-/// \brief Same as rename but old_name and new_name are UTF-8 strings
-///
-/// If invalid UTF-8 given, -1 is returned and errno is set to EINVAL
-///
-inline int rename(char const *old_name,char const *new_name)
-{
-    wstackstring wold,wnew;
-    if(!wold.convert(old_name) || !wnew.convert(new_name)) {
-        errno = EINVAL;
-        return -1;
-    }
-    return _wrename(wold.c_str(),wnew.c_str());
-}
-///
-/// \brief Same as rename but name is UTF-8 string
-///
-/// If invalid UTF-8 given, -1 is returned and errno is set to EINVAL
-///
-inline int remove(char const *name)
-{
-    wstackstring wname;
-    if(!wname.convert(name)) {
-        errno = EINVAL;
-        return -1;
-    }
-    return _wremove(wname.c_str());
-}
-#endif
-} // nowide
-} // namespace boost
-
-#ifdef BOOST_MSVC
-#pragma warning(pop)
-#endif
-
-#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4

+ 0 - 16
src/boost/nowide/cstdlib.hpp

@@ -1,16 +0,0 @@
-//
-//  Copyright (c) 2012 Artyom Beilis (Tonkikh)
-//
-//  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 BOOST_NOWIDE_CSTDLIB_HPP_INCLUDED
-#define BOOST_NOWIDE_CSTDLIB_HPP_INCLUDED
-
-#include <boost/nowide/cenv.hpp>
-#include <boost/nowide/system.hpp>
-
-#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4

Some files were not shown because too many files changed in this diff