Skip to content

Commit b06f71d

Browse files
winlinvipwenjiegit
authored andcommitted
For ossrs#2532: Windows: Support CYGWIN64 for SRS (ossrs#3255)
1. Support cygwin by '--cygwin64=on' 2. Detect cygwin automatically. 3. Disalbe sanitizer, srt and srtp with openssl. 4. Disable multiple threads, use single threads. 5. Support utest for cygwin64. 6. Query features for windows by API. 7. Disable stat APIs for cygwin. 8. Use ST select event driver. Co-authored-by: wenjie.zhao <[email protected]>
1 parent 5d0730b commit b06f71d

15 files changed

+121
-310
lines changed

trunk/auto/auto_headers.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ if [[ $SRS_CROSS_BUILD == YES ]]; then
198198
else
199199
srs_undefine_macro "SRS_CROSSBUILD" $SRS_AUTO_HEADERS_H
200200
fi
201+
if [[ $SRS_CYGWIN64 == YES ]]; then
202+
srs_define_macro "SRS_CYGWIN64" $SRS_AUTO_HEADERS_H
203+
else
204+
srs_undefine_macro "SRS_CYGWIN64" $SRS_AUTO_HEADERS_H
205+
fi
201206
if [[ $SRS_OSX == YES ]]; then
202207
srs_define_macro "SRS_OSX" $SRS_AUTO_HEADERS_H
203208
else

trunk/auto/depends.sh

Lines changed: 19 additions & 286 deletions
Original file line numberDiff line numberDiff line change
@@ -14,286 +14,7 @@
1414
#####################################################################################
1515
# Check OS and CPU architectures.
1616
#####################################################################################
17-
function require_sudoer() {
18-
sudo echo "" >/dev/null 2>&1
19-
20-
ret=$?; if [[ 0 -ne $ret ]]; then
21-
echo "\"$1\" require sudoer failed. ret=$ret";
22-
exit $ret;
23-
fi
24-
}
25-
26-
#####################################################################################
27-
# for Ubuntu, auto install tools by apt-get
28-
#####################################################################################
29-
function Ubuntu_prepare() {
30-
if [[ $OS_IS_UBUNTU != YES ]]; then return 0; fi
31-
echo "Installing tools for Ubuntu."
32-
33-
gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
34-
echo "Installing gcc."
35-
require_sudoer "sudo apt-get install -y --force-yes gcc"
36-
sudo apt-get install -y --force-yes gcc; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
37-
echo "The gcc is installed."
38-
fi
39-
40-
g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
41-
echo "Installing g++."
42-
require_sudoer "sudo apt-get install -y --force-yes g++"
43-
sudo apt-get install -y --force-yes g++; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
44-
echo "The g++ is installed."
45-
fi
46-
47-
make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
48-
echo "Installing make."
49-
require_sudoer "sudo apt-get install -y --force-yes make"
50-
sudo apt-get install -y --force-yes make; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
51-
echo "The make is installed."
52-
fi
53-
54-
patch --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
55-
echo "Installing patch."
56-
require_sudoer "sudo apt-get install -y --force-yes patch"
57-
sudo apt-get install -y --force-yes patch; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
58-
echo "The patch is installed."
59-
fi
60-
61-
unzip --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
62-
echo "Installing unzip."
63-
require_sudoer "sudo apt-get install -y --force-yes unzip"
64-
sudo apt-get install -y --force-yes unzip; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
65-
echo "The unzip is installed."
66-
fi
67-
68-
if [[ $SRS_VALGRIND == YES ]]; then
69-
valgrind --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
70-
echo "Installing valgrind."
71-
require_sudoer "sudo apt-get install -y --force-yes valgrind"
72-
sudo apt-get install -y --force-yes valgrind; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
73-
echo "The valgrind is installed."
74-
fi
75-
fi
76-
77-
if [[ $SRS_VALGRIND == YES ]]; then
78-
if [[ ! -f /usr/include/valgrind/valgrind.h ]]; then
79-
echo "Installing valgrind-dev."
80-
require_sudoer "sudo apt-get install -y --force-yes valgrind-dbg"
81-
sudo apt-get install -y --force-yes valgrind-dev; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
82-
echo "The valgrind-dev is installed."
83-
fi
84-
fi
85-
86-
if [[ $SRS_SRT == YES ]]; then
87-
echo "SRT enable, install depend tools"
88-
tclsh <<< "exit" >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
89-
echo "Installing tcl."
90-
require_sudoer "sudo apt-get install -y --force-yes tcl"
91-
sudo apt-get install -y --force-yes tcl; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
92-
echo "The tcl is installed."
93-
fi
94-
95-
cmake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
96-
echo "Installing cmake."
97-
require_sudoer "sudo apt-get install -y --force-yes cmake"
98-
sudo apt-get install -y --force-yes cmake; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
99-
echo "The cmake is installed."
100-
fi
101-
fi
102-
103-
pkg-config --version >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
104-
echo "Installing pkg-config."
105-
require_sudoer "sudo apt-get install -y --force-yes pkg-config"
106-
sudo apt-get install -y --force-yes pkg-config; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
107-
echo "The pkg-config is installed."
108-
fi
109-
110-
echo "Tools for Ubuntu are installed."
111-
return 0
112-
}
113-
# donot prepare tools, for srs-librtmp depends only gcc and g++.
114-
Ubuntu_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Install tools for ubuntu failed, ret=$ret"; exit $ret; fi
115-
116-
#####################################################################################
117-
# for Centos, auto install tools by yum
118-
#####################################################################################
119-
function Centos_prepare() {
120-
if [[ $OS_IS_CENTOS != YES ]]; then return 0; fi
121-
echo "Installing tools for Centos."
122-
123-
gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
124-
echo "Installing gcc."
125-
require_sudoer "sudo yum install -y gcc"
126-
sudo yum install -y gcc; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
127-
echo "The gcc is installed."
128-
fi
129-
130-
g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
131-
echo "Installing gcc-c++."
132-
require_sudoer "sudo yum install -y gcc-c++"
133-
sudo yum install -y gcc-c++; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
134-
echo "The gcc-c++ is installed."
135-
fi
136-
137-
make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
138-
echo "Installing make."
139-
require_sudoer "sudo yum install -y make"
140-
sudo yum install -y make; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
141-
echo "The make is installed."
142-
fi
143-
144-
patch --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
145-
echo "Installing patch."
146-
require_sudoer "sudo yum install -y patch"
147-
sudo yum install -y patch; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
148-
echo "The patch is installed."
149-
fi
150-
151-
unzip --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
152-
echo "Installing unzip."
153-
require_sudoer "sudo yum install -y unzip"
154-
sudo yum install -y unzip; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
155-
echo "The unzip is installed."
156-
fi
157-
158-
if [[ $SRS_VALGRIND == YES ]]; then
159-
valgrind --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
160-
echo "Installing valgrind."
161-
require_sudoer "sudo yum install -y valgrind"
162-
sudo yum install -y valgrind; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
163-
echo "The valgrind is installed."
164-
fi
165-
fi
166-
167-
if [[ $SRS_VALGRIND == YES ]]; then
168-
if [[ ! -f /usr/include/valgrind/valgrind.h ]]; then
169-
echo "Installing valgrind-devel."
170-
require_sudoer "sudo yum install -y valgrind-devel"
171-
sudo yum install -y valgrind-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
172-
echo "The valgrind-devel is installed."
173-
fi
174-
fi
175-
176-
if [[ $SRS_SRT == YES ]]; then
177-
echo "SRT enable, install depend tools"
178-
tclsh <<< "exit" >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
179-
echo "Installing tcl."
180-
require_sudoer "sudo yum install -y tcl"
181-
sudo yum install -y tcl; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
182-
echo "The tcl is installed."
183-
fi
184-
185-
cmake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
186-
echo "Installing cmake."
187-
require_sudoer "sudo yum install -y cmake"
188-
sudo yum install -y cmake; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
189-
echo "The cmake is installed."
190-
fi
191-
fi
192-
193-
pkg-config --version --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
194-
echo "Please install pkg-config"; exit -1;
195-
fi
196-
197-
echo "Tools for Centos are installed."
198-
return 0
199-
}
200-
# donot prepare tools, for srs-librtmp depends only gcc and g++.
201-
Centos_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Install tools for CentOS failed, ret=$ret"; exit $ret; fi
202-
203-
#####################################################################################
204-
# For OSX, auto install tools by brew
205-
#####################################################################################
206-
function OSX_prepare() {
207-
if [[ $OS_IS_OSX != YES ]]; then
208-
if [[ $SRS_OSX == YES ]]; then echo "OSX check failed, actual is `uname -s`"; exit 1; fi
209-
return 0
210-
fi
211-
212-
# cross build for arm, install the cross build tool chain.
213-
if [[ $SRS_CROSS_BUILD == YES ]]; then
214-
echo "The embeded(arm/mips) is invalid for OSX"
215-
return 1
216-
fi
217-
218-
# Requires the osx when darwin detected
219-
if [[ $OS_IS_OSX == YES && $SRS_OSX != YES ]]; then
220-
echo "OSX detected, please use: ./configure --osx"
221-
exit 1
222-
fi
223-
224-
echo "OSX detected, install tools if needed"
225-
226-
brew --version >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
227-
echo "Please install brew at https://brew.sh/"
228-
exit $ret
229-
fi
230-
231-
gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
232-
echo "install gcc"
233-
echo "brew install gcc"
234-
brew install gcc; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
235-
echo "install gcc success"
236-
fi
237-
238-
g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
239-
echo "install gcc-c++"
240-
echo "brew install gcc-c++"
241-
brew install gcc-c++; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
242-
echo "install gcc-c++ success"
243-
fi
244-
245-
make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
246-
echo "install make"
247-
echo "brew install make"
248-
brew install make; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
249-
echo "install make success"
250-
fi
251-
252-
patch --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
253-
echo "install patch"
254-
echo "brew install patch"
255-
brew install patch; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
256-
echo "install patch success"
257-
fi
258-
259-
unzip --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
260-
echo "install unzip"
261-
echo "brew install unzip"
262-
brew install unzip; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
263-
echo "install unzip success"
264-
fi
265-
266-
pkg-config --version >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
267-
echo "Please install pkg-config"; exit -1;
268-
fi
269-
270-
if [[ $SRS_SRT == YES ]]; then
271-
echo "SRT enable, install depend tools"
272-
tclsh <<< "exit" >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
273-
echo "Installing tcl."
274-
echo "brew install tcl."
275-
brew install tcl; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
276-
echo "install tcl success"
277-
fi
278-
279-
cmake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
280-
echo "Installing cmake."
281-
echo "brew install cmake."
282-
brew install cmake; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
283-
echo "install cmake success"
284-
fi
285-
fi
286-
287-
echo "OSX install tools success"
288-
return 0
289-
}
290-
# donot prepare tools, for srs-librtmp depends only gcc and g++.
291-
OSX_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "OSX prepare failed, ret=$ret"; exit $ret; fi
292-
293-
#####################################################################################
294-
# Check OS and CPU architectures.
295-
#####################################################################################
296-
if [[ $OS_IS_UBUNTU != YES && $OS_IS_CENTOS != YES && $OS_IS_OSX != YES && $SRS_CROSS_BUILD != YES ]]; then
17+
if [[ $OS_IS_UBUNTU != YES && $OS_IS_CENTOS != YES && $OS_IS_OSX != YES && $SRS_CROSS_BUILD != YES && $SRS_CYGWIN64 != YES ]]; then
29718
echo "Your OS `uname -s` is not supported."
29819
exit 1
29920
fi
@@ -385,6 +106,10 @@ fi
385106
if [[ $SRS_OSX == YES ]]; then
386107
_ST_MAKE=darwin-debug && _ST_OBJ="DARWIN_`uname -r`_DBG"
387108
fi
109+
# for windows/cygwin
110+
if [[ $SRS_CYGWIN64 = YES ]]; then
111+
_ST_MAKE=cygwin64-debug && _ST_OBJ="CYGWIN64_`uname -s`_DBG"
112+
fi
388113
# For Ubuntu, the epoll detection might be fail.
389114
if [[ $OS_IS_UBUNTU == YES ]]; then
390115
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_HAVE_EPOLL"
@@ -660,8 +385,16 @@ if [[ $SRS_RTC == YES ]] && [[ $SRS_SSL_3_0 == NO ]]; then
660385
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srtp2 \
661386
${SRS_OBJS}/srtp2 &&
662387
cp -rf ${SRS_WORKDIR}/3rdparty/libsrtp-2-fit ${SRS_OBJS}/${SRS_PLATFORM}/ &&
663-
patch -p0 ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/crypto/math/datatypes.c ${SRS_WORKDIR}/3rdparty/patches/srtp/gcc10-01.patch &&
664-
patch -p0 ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/config.guess ${SRS_WORKDIR}/3rdparty/patches/srtp/config.guess-02.patch &&
388+
# For cygwin64, the patch is not available, so use sed instead.
389+
if [[ $SRS_CYGWIN64 == YES ]]; then
390+
sed -i 's/char bit_string/static char bit_string/g' ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/crypto/math/datatypes.c
391+
else
392+
patch -p0 ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/crypto/math/datatypes.c ${SRS_WORKDIR}/3rdparty/patches/srtp/gcc10-01.patch
393+
fi &&
394+
# Patch the cpu arch guessing for RISCV.
395+
if [[ $OS_IS_RISCV == YES ]]; then
396+
patch -p0 ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/config.guess ${SRS_WORKDIR}/3rdparty/patches/srtp/config.guess-02.patch
397+
fi &&
665398
(
666399
cd ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit &&
667400
$SRTP_CONFIGURE ${SRTP_OPTIONS} --prefix=${SRS_DEPENDS_LIBS}/${SRS_PLATFORM}/3rdpatry/srtp2
@@ -878,16 +611,16 @@ if [[ $SRS_SRT == YES ]]; then
878611
else
879612
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --enable-shared=0"
880613
fi
614+
# For windows build, over cygwin
615+
if [[ $SRS_CYGWIN64 == YES ]]; then
616+
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --cygwin-use-posix"
617+
fi
881618
# For cross-build.
882619
if [[ $SRS_CROSS_BUILD == YES ]]; then
883620
TOOL_GCC_REALPATH=$(realpath $(which $SRS_TOOL_CC))
884621
SRT_COMPILER_PREFIX=$(echo $TOOL_GCC_REALPATH |sed 's/-gcc.*$/-/')
885622
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --with-compiler-prefix=$SRT_COMPILER_PREFIX"
886623
fi
887-
# For windows build, over cygwin
888-
if [[ $SRS_CYGWIN64 == YES ]]; then
889-
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --cygwin-use-posix"
890-
fi
891624

892625
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srt/lib/libsrt.a ]]; then
893626
rm -rf ${SRS_OBJS}/srt && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srt ${SRS_OBJS}/ &&

0 commit comments

Comments
 (0)