Browse code

Fix compile errors by win_check()

uly55e5 authored on 24/01/2022 17:18:46
Showing 6 changed files

... ...
@@ -39,7 +39,6 @@ Suggests:
39 39
 VignetteBuilder: knitr
40 40
 LinkingTo:
41 41
     Rcpp,
42
-    zlibbioc,
43 42
     Rhdf5lib (>= 1.1.4)
44 43
 RcppModules:
45 44
     Pwiz,
... ...
@@ -38,6 +38,8 @@ PWIZOBJECTS=\
38 38
 ./boost/filesystem/src/codecvt_error_category.o \
39 39
 ./boost/thread/win32/thread.o \
40 40
 ./boost_aux/boost/nowide/iostream.o \
41
+./boost_aux/boost/nowide/filebuf.o \
42
+./boost_aux/libs/nowide/src/cstdio.o \
41 43
 ./pwiz/data/common/MemoryIndex.o \
42 44
 ./pwiz/data/common/CVTranslator.o \
43 45
 ./pwiz/data/common/cv.o \
... ...
@@ -105,6 +107,6 @@ all: libpwiz.a
105 107
 
106 108
 libpwiz.a: $(PWIZOBJECTS)
107 109
 	ar -rc $@ $(PWIZOBJECTS)
108
-	
110
+
109 111
 clean:
110
-	rm -rf $(PWIZOBJECTS)
111 112
\ No newline at end of file
113
+	rm -rf $(PWIZOBJECTS)
... ...
@@ -102,14 +102,21 @@ ARCH_OBJS=./boost/libs/filesystem/src/path_traits.o \
102 102
 ./boost/libs/thread/src/win32/tss_pe.o \
103 103
 ./boost/libs/thread/src/win32/tss_dll.o \
104 104
 ./boost/libs/thread/src/win32/thread.o \
105
-./boost_aux/libs/nowide/src/iostream.o
105
+./boost_aux/libs/nowide/src/iostream.o \
106
+./boost_aux/libs/nowide/src/cstdio.o \
107
+./boost_aux/libs/nowide/src/filebuf.o
106 108
 ARCH_CPPFLAGS=-fpermissive -DWINDOWS_NATIVE -DWIN32 -DBOOST_HAS_WINTHREADS -DBOOST_THREAD_BUILD_LIB
107 109
 ARCH_LIBS=-lws2_32 -lz
108
-RHDF5_LIBS=$(shell echo 'Rhdf5lib::pkgconfig("PKG_CXX_LIBS")'| "${R_HOME}/bin/R" --vanilla --slave)  
110
+RHDF5_LIBS=$(shell echo 'Rhdf5lib::pkgconfig("PKG_CXX_LIBS")'| "${R_HOME}/bin/R" --vanilla --slave)
111
+ZLIB_CFLAGS=$(shell echo 'zlibbioc::pkgconfig("PKG_CFLAGS")'| "${R_HOME}/bin/R" --vanilla --slave)
112
+ZLIB_LIBS=$(shell echo 'zlibbioc::pkgconfig("PKG_LIBS_shared")' | "${R_HOME}/bin/R" --vanilla --slave)
109 113
 else
110 114
 ARCH_OBJS=./boost/libs/thread/src/pthread/once.o \
111 115
 ./boost/libs/thread/src/pthread/thread.o
112 116
 RHDF5_LIBS=$(shell echo 'Rhdf5lib::pkgconfig("PKG_CXX_LIBS")'| "${R_HOME}/bin/R" --vanilla --slave)
117
+ZLIB_CFLAGS=$(shell echo 'zlibbioc::pkgconfig("PKG_CFLAGS")'|\
118
+"${R_HOME}/bin/R" --vanilla --slave)
119
+ZLIB_LIBS=$(shell echo 'zlibbioc::pkgconfig("PKG_LIBS_shared")' | "${R_HOME}/bin/R" --vanilla --slave)
113 120
 endif
114 121
 
115 122
 MZROBJECTS= RcppPwiz.o RcppPwizModule.o RcppIdent.o RcppIdentModule.o
... ...
@@ -117,7 +124,7 @@ MZROBJECTS= RcppPwiz.o RcppPwizModule.o RcppIdent.o RcppIdentModule.o
117 124
 OBJECTS= $(MZROBJECTS) $(PWIZOBJECTS) $(ARCH_OBJS)
118 125
 
119 126
 ## Generate dependency files
120
-#DEPFLAGS = -MT $@ -MMD -MP 
127
+#DEPFLAGS = -MT $@ -MMD -MP
121 128
 
122 129
 ##
123 130
 ## R complains about assert(), hence -D_NODEBUG
124 131
new file mode 100644
... ...
@@ -0,0 +1,141 @@
1
+PWIZOBJECTS=\
2
+./boost/libs/system/src/error_code.o \
3
+./boost/libs/regex/src/posix_api.o \
4
+./boost/libs/regex/src/regex_debug.o \
5
+./boost/libs/regex/src/regex.o \
6
+./boost/libs/regex/src/wide_posix_api.o \
7
+./boost/libs/regex/src/static_mutex.o \
8
+./boost/libs/iostreams/src/zlib.o \
9
+./boost/libs/iostreams/src/file_descriptor.o \
10
+./boost/libs/filesystem/src/operations.o \
11
+./boost/libs/filesystem/src/directory.o \
12
+./boost/libs/filesystem/src/exception.o \
13
+./boost/libs/filesystem/src/path.o \
14
+./boost/libs/filesystem/src/unique_path.o \
15
+./boost/libs/filesystem/src/utf8_codecvt_facet.o \
16
+./boost/libs/chrono/src/chrono.o \
17
+./boost/libs/chrono/src/process_cpu_clocks.o \
18
+./boost/libs/chrono/src/thread_clock.o \
19
+./pwiz/data/msdata/Version.o \
20
+./pwiz/data/identdata/Version.o \
21
+./pwiz/data/common/MemoryIndex.o \
22
+./pwiz/data/common/CVTranslator.o \
23
+./pwiz/data/common/cv.o \
24
+./pwiz/data/common/ParamTypes.o \
25
+./pwiz/data/common/BinaryIndexStream.o \
26
+./pwiz/data/common/diff_std.o \
27
+./pwiz/data/common/Unimod.o \
28
+./pwiz/data/msdata/mz5/Configuration_mz5.o \
29
+./pwiz/data/msdata/mz5/Connection_mz5.o \
30
+./pwiz/data/msdata/mz5/Datastructures_mz5.o \
31
+./pwiz/data/msdata/mz5/ReferenceRead_mz5.o \
32
+./pwiz/data/msdata/mz5/ReferenceWrite_mz5.o \
33
+./pwiz/data/msdata/mz5/Translator_mz5.o \
34
+./pwiz/data/msdata/DefaultReaderList.o \
35
+./pwiz/data/msdata/ChromatogramList_mzML.o \
36
+./pwiz/data/msdata/ChromatogramList_mz5.o \
37
+./pwiz/data/msdata/examples.o \
38
+./pwiz/data/msdata/Serializer_mzML.o \
39
+./pwiz/data/msdata/Serializer_MSn.o \
40
+./pwiz/data/msdata/Reader.o \
41
+./pwiz/data/msdata/Serializer_mz5.o \
42
+./pwiz/data/msdata/Serializer_MGF.o \
43
+./pwiz/data/msdata/Serializer_mzXML.o \
44
+./pwiz/data/msdata/SpectrumListBase.o \
45
+./pwiz/data/msdata/SpectrumList_MGF.o \
46
+./pwiz/data/msdata/SpectrumList_mzML.o \
47
+./pwiz/data/msdata/SpectrumList_MSn.o \
48
+./pwiz/data/msdata/SpectrumList_mz5.o \
49
+./pwiz/data/msdata/BinaryDataEncoder.o \
50
+./pwiz/data/msdata/Diff.o \
51
+./pwiz/data/msdata/MSData.o \
52
+./pwiz/data/msdata/References.o \
53
+./pwiz/data/msdata/SpectrumList_mzXML.o \
54
+./pwiz/data/msdata/IO.o \
55
+./pwiz/data/msdata/SpectrumList_BTDX.o \
56
+./pwiz/data/msdata/SpectrumInfo.o \
57
+./pwiz/data/msdata/LegacyAdapter.o \
58
+./pwiz/data/msdata/SpectrumIterator.o \
59
+./pwiz/data/msdata/MSDataFile.o \
60
+./pwiz/data/msdata/MSNumpress.o \
61
+./pwiz/data/msdata/SpectrumListCache.o \
62
+./pwiz/data/msdata/Index_mzML.o \
63
+./pwiz/data/msdata/SpectrumWorkerThreads.o \
64
+./pwiz/data/identdata/IdentDataFile.o \
65
+./pwiz/data/identdata/IdentData.o \
66
+./pwiz/data/identdata/DefaultReaderList.o \
67
+./pwiz/data/identdata/Reader.o \
68
+./pwiz/data/identdata/Serializer_protXML.o \
69
+./pwiz/data/identdata/Serializer_pepXML.o \
70
+./pwiz/data/identdata/Serializer_mzid.o \
71
+./pwiz/data/identdata/IO.o \
72
+./pwiz/data/identdata/References.o \
73
+./pwiz/data/identdata/MascotReader.o \
74
+./pwiz/data/proteome/Modification.o \
75
+./pwiz/data/proteome/Digestion.o \
76
+./pwiz/data/proteome/Peptide.o \
77
+./pwiz/data/proteome/AminoAcid.o \
78
+./pwiz/utility/minimxml/XMLWriter.o \
79
+./pwiz/utility/minimxml/SAXParser.o \
80
+./pwiz/utility/chemistry/Chemistry.o \
81
+./pwiz/utility/chemistry/ChemistryData.o \
82
+./pwiz/utility/chemistry/MZTolerance.o \
83
+./pwiz/utility/misc/IntegerSet.o \
84
+./pwiz/utility/misc/Base64.o \
85
+./pwiz/utility/misc/BinaryData.o \
86
+./pwiz/utility/misc/IterationListener.o \
87
+./pwiz/utility/misc/MSIHandler.o \
88
+./pwiz/utility/misc/Filesystem.o \
89
+./pwiz/utility/misc/TabReader.o \
90
+./pwiz/utility/misc/random_access_compressed_ifstream.o \
91
+./pwiz/utility/misc/SHA1.o \
92
+./pwiz/utility/misc/SHA1Calculator.o \
93
+./pwiz/utility/misc/sha1calc.o \
94
+./pwiz/utility/misc/String.o \
95
+./RcppExports.o
96
+
97
+
98
+ifeq ($(OS),Windows_NT)
99
+ARCH_OBJS=./boost/libs/filesystem/src/path_traits.o \
100
+./boost/libs/filesystem/src/windows_file_codecvt.o \
101
+./boost/libs/filesystem/src/codecvt_error_category.o \
102
+./boost/libs/thread/src/win32/tss_pe.o \
103
+./boost/libs/thread/src/win32/tss_dll.o \
104
+./boost/libs/thread/src/win32/thread.o \
105
+./boost_aux/libs/nowide/src/iostream.o \
106
+./boost_aux/libs/nowide/src/cstdio.o \
107
+./boost_aux/libs/nowide/src/filebuf.o
108
+ARCH_CPPFLAGS=-fpermissive -DWINDOWS_NATIVE -DWIN32 -DBOOST_HAS_WINTHREADS -DBOOST_THREAD_BUILD_LIB
109
+ARCH_LIBS=-lws2_32 -lz
110
+RHDF5_LIBS=$(shell echo 'Rhdf5lib::pkgconfig("PKG_CXX_LIBS")'| "${R_HOME}/bin/R" --vanilla --slave)
111
+else
112
+ARCH_OBJS=./boost/libs/thread/src/pthread/once.o \
113
+./boost/libs/thread/src/pthread/thread.o
114
+RHDF5_LIBS=$(shell echo 'Rhdf5lib::pkgconfig("PKG_CXX_LIBS")'| "${R_HOME}/bin/R" --vanilla --slave)
115
+endif
116
+
117
+MZROBJECTS= RcppPwiz.o RcppPwizModule.o RcppIdent.o RcppIdentModule.o
118
+
119
+OBJECTS= $(MZROBJECTS) $(PWIZOBJECTS) $(ARCH_OBJS)
120
+
121
+## Generate dependency files
122
+#DEPFLAGS = -MT $@ -MMD -MP
123
+
124
+##
125
+## R complains about assert(), hence -D_NODEBUG
126
+##  http://www.gamedev.net/topic/555511-is-there-a-way-to-only-disable-boost-debug-checks/
127
+##
128
+
129
+PWIZ_CPPFLAGS=-I./boost_aux/ -I./boost/ -I. -D_LARGEFILE_SOURCE -DHAVE_PWIZ_MZML_LIB -D_NODEBUG
130
+PWIZ_LDFLAGS=-lpthread
131
+
132
+## Use the R_HOME indirection to support installations of multiple R version
133
+PKG_CPPFLAGS=$(PWIZ_CPPFLAGS) $(NC_CFLAGS)  $(ARCH_CPPFLAGS)
134
+
135
+PKG_LIBS=$(PWIZ_LDFLAGS) $(RHDF5_LIBS) $(NC_LIBS)  $(ARCH_LIBS)
136
+
137
+all: clean $(SHLIB)
138
+
139
+clean:
140
+	rm -f $(OBJECTS)
141
+
0 142
new file mode 100755
... ...
@@ -0,0 +1,74 @@
1
+//
2
+//  Copyright (c) 2012 Artyom Beilis (Tonkikh)
3
+//  Copyright (c) 2020 Alexander Grund
4
+//
5
+//  Distributed under the Boost Software License, Version 1.0. (See
6
+//  accompanying file LICENSE or copy at
7
+//  http://www.boost.org/LICENSE_1_0.txt)
8
+//
9
+
10
+#define BOOST_NOWIDE_SOURCE
11
+
12
+#ifdef _MSC_VER
13
+#define _CRT_SECURE_NO_WARNINGS
14
+#elif(defined(__MINGW32__) || defined(__CYGWIN__)) && defined(__STRICT_ANSI__)
15
+// Need the _w* functions which are extensions on MinGW/Cygwin
16
+#undef __STRICT_ANSI__
17
+#endif
18
+
19
+#include <boost/nowide/cstdio.hpp>
20
+#include <boost/nowide/stackstring.hpp>
21
+
22
+namespace boost {
23
+namespace nowide {
24
+    namespace detail {
25
+        FILE* wfopen(const wchar_t* filename, const wchar_t* mode)
26
+        {
27
+#ifdef BOOST_WINDOWS
28
+            return ::_wfopen(filename, mode);
29
+#else
30
+            const stackstring name(filename);
31
+            const short_stackstring smode2(mode);
32
+            return std::fopen(name.get(), smode2.get());
33
+#endif
34
+        }
35
+    } // namespace detail
36
+
37
+#ifdef BOOST_WINDOWS
38
+    ///
39
+    /// \brief Same as freopen but file_name and mode are UTF-8 strings
40
+    ///
41
+    FILE* freopen(const char* file_name, const char* mode, FILE* stream)
42
+    {
43
+        const wstackstring wname(file_name);
44
+        const wshort_stackstring wmode(mode);
45
+        return _wfreopen(wname.get(), wmode.get(), stream);
46
+    }
47
+    ///
48
+    /// \brief Same as fopen but file_name and mode are UTF-8 strings
49
+    ///
50
+    FILE* fopen(const char* file_name, const char* mode)
51
+    {
52
+        const wstackstring wname(file_name);
53
+        const wshort_stackstring wmode(mode);
54
+        return _wfopen(wname.get(), wmode.get());
55
+    }
56
+    ///
57
+    /// \brief Same as rename but old_name and new_name are UTF-8 strings
58
+    ///
59
+    int rename(const char* old_name, const char* new_name)
60
+    {
61
+        const wstackstring wold(old_name), wnew(new_name);
62
+        return _wrename(wold.get(), wnew.get());
63
+    }
64
+    ///
65
+    /// \brief Same as rename but name is UTF-8 string
66
+    ///
67
+    int remove(const char* name)
68
+    {
69
+        const wstackstring wname(name);
70
+        return _wremove(wname.get());
71
+    }
72
+#endif
73
+} // namespace nowide
74
+} // namespace boost
0 75
new file mode 100755
... ...
@@ -0,0 +1,80 @@
1
+//
2
+//  Copyright (c) 2020 Alexander Grund
3
+//
4
+//  Distributed under the Boost Software License, Version 1.0. (See
5
+//  accompanying file LICENSE or copy at
6
+//  http://www.boost.org/LICENSE_1_0.txt)
7
+//
8
+
9
+#define BOOST_NOWIDE_SOURCE
10
+
11
+#ifdef BOOST_NOWIDE_NO_LFS
12
+#define BOOST_NOWIDE_FTELL ::ftell
13
+#define BOOST_NOWIDE_FSEEK ::fseek
14
+#define BOOST_NOWIDE_OFF_T long
15
+#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
16
+#define BOOST_NOWIDE_FTELL _ftelli64
17
+#define BOOST_NOWIDE_FSEEK _fseeki64
18
+#define BOOST_NOWIDE_OFF_T int64_t
19
+#else
20
+// IMPORTANT: Have these defines BEFORE any #includes
21
+//            and make sure changes by those macros don't leak into the public interface
22
+// Make LFS functions available
23
+#define _LARGEFILE_SOURCE
24
+// Make off_t 64 bits if the macro isn't set
25
+#ifndef _FILE_OFFSET_BITS
26
+#define _FILE_OFFSET_BITS 64
27
+#endif
28
+
29
+#define BOOST_NOWIDE_FTELL ftello
30
+#define BOOST_NOWIDE_FSEEK fseeko
31
+#define BOOST_NOWIDE_OFF_T off_t
32
+#endif
33
+
34
+#include <boost/nowide/filebuf.hpp>
35
+#include <cassert>
36
+#include <cstdint>
37
+#include <limits>
38
+#include <stdio.h>
39
+#include <type_traits>
40
+
41
+namespace boost {
42
+namespace nowide {
43
+    namespace detail {
44
+
45
+        template<typename T, typename U>
46
+        constexpr bool is_in_range(U value)
47
+        {
48
+            static_assert(std::is_signed<T>::value == std::is_signed<U>::value,
49
+                          "Mixed sign comparison can lead to problems below");
50
+            // coverity[result_independent_of_operands]
51
+            return value >= std::numeric_limits<T>::min() && value <= std::numeric_limits<T>::max();
52
+        }
53
+
54
+        template<typename T, typename U>
55
+        T cast_if_valid_or_minus_one(U value)
56
+        {
57
+            return is_in_range<T>(value) ? static_cast<T>(value) : T(-1);
58
+        }
59
+
60
+        std::streampos ftell(FILE* file)
61
+        {
62
+            const auto pos = BOOST_NOWIDE_FTELL(file);
63
+            // Note that this is used in seekoff for which the standard states:
64
+            // On success, it returns the new absolute position the internal position pointer points to after the call,
65
+            // if representable [...] [or] the function returns pos_type(off_type(-1)). Hence we do a range check first,
66
+            // then cast or return failure instead of silently truncating
67
+            return cast_if_valid_or_minus_one<std::streamoff>(pos);
68
+        }
69
+
70
+        int fseek(FILE* file, std::streamoff offset, int origin)
71
+        {
72
+            // Similar to above: If the value of offset can't fit inside target type
73
+            // don't silently truncate but fail right away
74
+            if(!is_in_range<BOOST_NOWIDE_OFF_T>(offset))
75
+                return -1;
76
+            return BOOST_NOWIDE_FSEEK(file, static_cast<BOOST_NOWIDE_OFF_T>(offset), origin);
77
+        }
78
+    } // namespace detail
79
+} // namespace nowide
80
+} // namespace boost