Automatically select appropriate libsoup version
This commit is contained in:
parent
809c1579e4
commit
6e37f3fe3f
|
@ -20,6 +20,7 @@ function(find_packages result)
|
||||||
find_package(${pkg} ${pkg_version} REQUIRED)
|
find_package(${pkg} ${pkg_version} REQUIRED)
|
||||||
list(APPEND _res ${${pkg}_PKG_CONFIG_NAME})
|
list(APPEND _res ${${pkg}_PKG_CONFIG_NAME})
|
||||||
list(APPEND _res_libs ${${pkg}_LIBRARIES})
|
list(APPEND _res_libs ${${pkg}_LIBRARIES})
|
||||||
|
set(${pkg}_VERSION "${${pkg}_VERSION}" PARENT_SCOPE)
|
||||||
endforeach(pkg)
|
endforeach(pkg)
|
||||||
foreach(pkg ${ARGS_OPTIONAL})
|
foreach(pkg ${ARGS_OPTIONAL})
|
||||||
string(REPLACE ">=" ";" pkg_ ${pkg})
|
string(REPLACE ">=" ";" pkg_ ${pkg})
|
||||||
|
@ -38,6 +39,7 @@ function(find_packages result)
|
||||||
if(${pkg}_FOUND)
|
if(${pkg}_FOUND)
|
||||||
list(APPEND _res ${${pkg}_PKG_CONFIG_NAME})
|
list(APPEND _res ${${pkg}_PKG_CONFIG_NAME})
|
||||||
list(APPEND _res_libs ${${pkg}_LIBRARIES})
|
list(APPEND _res_libs ${${pkg}_LIBRARIES})
|
||||||
|
set(${pkg}_VERSION "${${pkg}_VERSION}" PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
endforeach(pkg)
|
endforeach(pkg)
|
||||||
set(${result} "${_res}" PARENT_SCOPE)
|
set(${result} "${_res}" PARENT_SCOPE)
|
||||||
|
|
33
cmake/SoupVersion.cmake
Normal file
33
cmake/SoupVersion.cmake
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
find_package(Nice QUIET)
|
||||||
|
if (Nice_FOUND AND NOT SOUP_VERSION AND NOT USE_SOUP3)
|
||||||
|
file(GET_RUNTIME_DEPENDENCIES
|
||||||
|
RESOLVED_DEPENDENCIES_VAR Nice_DEPENDENCIES
|
||||||
|
UNRESOLVED_DEPENDENCIES_VAR Nice_UNRESOLVED_DEPENDENCIES
|
||||||
|
LIBRARIES ${Nice_LIBRARY}
|
||||||
|
PRE_INCLUDE_REGEXES "soup|gupnp"
|
||||||
|
PRE_EXCLUDE_REGEXES "."
|
||||||
|
)
|
||||||
|
foreach (lib ${Nice_DEPENDENCIES})
|
||||||
|
if (lib MATCHES ".*/libsoup-3.*")
|
||||||
|
set(SOUP_VERSION 3)
|
||||||
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
foreach (lib ${Nice_DEPENDENCIES})
|
||||||
|
if (lib MATCHES ".*/libsoup-2.*")
|
||||||
|
set(SOUP_VERSION 2)
|
||||||
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
set(SOUP_VERSION ${SOUP_VERSION} CACHE STRING "Version of libsoup to use")
|
||||||
|
set_property(CACHE SOUP_VERSION PROPERTY STRINGS "2" "3")
|
||||||
|
message(STATUS "Using Soup${SOUP_VERSION} to provide Soup")
|
||||||
|
elseif (NOT SOUP_VERSION)
|
||||||
|
find_package(Soup2 QUIET)
|
||||||
|
find_package(Soup3 QUIET)
|
||||||
|
# Only use libsoup 3 if specifically requested or when libsoup 2 is not available
|
||||||
|
if (Soup3_FOUND AND NOT Soup2_FOUND OR USE_SOUP3)
|
||||||
|
set(SOUP_VERSION 3)
|
||||||
|
else ()
|
||||||
|
set(SOUP_VERSION 2)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
set(Soup "Soup${SOUP_VERSION}")
|
6
configure
vendored
6
configure
vendored
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
OPTS=`getopt -o "h" --long \
|
OPTS=`getopt -o "h" --long \
|
||||||
help,fetch-only,no-debug,disable-fast-vapi,with-tests,release,with-libsignal-in-tree,\
|
help,fetch-only,no-debug,disable-fast-vapi,with-tests,release,with-libsignal-in-tree,with-libsoup3,\
|
||||||
enable-plugin:,disable-plugin:,\
|
enable-plugin:,disable-plugin:,\
|
||||||
prefix:,program-prefix:,exec-prefix:,lib-suffix:,\
|
prefix:,program-prefix:,exec-prefix:,lib-suffix:,\
|
||||||
bindir:,libdir:,includedir:,datadir:,\
|
bindir:,libdir:,includedir:,datadir:,\
|
||||||
|
@ -22,6 +22,7 @@ DISABLE_FAST_VAPI=
|
||||||
LIB_SUFFIX=
|
LIB_SUFFIX=
|
||||||
NO_DEBUG=
|
NO_DEBUG=
|
||||||
FETCH_ONLY=
|
FETCH_ONLY=
|
||||||
|
USE_SOUP3=
|
||||||
|
|
||||||
EXEC_PREFIX=
|
EXEC_PREFIX=
|
||||||
BINDIR=
|
BINDIR=
|
||||||
|
@ -56,6 +57,7 @@ Configuration:
|
||||||
--release Configure to build an optimized release version
|
--release Configure to build an optimized release version
|
||||||
--with-libsignal-in-tree Build libsignal-protocol-c in tree and link it
|
--with-libsignal-in-tree Build libsignal-protocol-c in tree and link it
|
||||||
statically.
|
statically.
|
||||||
|
--with-libsoup3 Build with libsoup-3.0
|
||||||
--with-tests Also build tests.
|
--with-tests Also build tests.
|
||||||
|
|
||||||
Plugin configuration:
|
Plugin configuration:
|
||||||
|
@ -111,6 +113,7 @@ while true; do
|
||||||
--valac-flags ) VALAC_FLAGS="$2"; shift; shift ;;
|
--valac-flags ) VALAC_FLAGS="$2"; shift; shift ;;
|
||||||
--lib-suffix ) LIB_SUFFIX="$2"; shift; shift ;;
|
--lib-suffix ) LIB_SUFFIX="$2"; shift; shift ;;
|
||||||
--with-libsignal-in-tree ) BUILD_LIBSIGNAL_IN_TREE=yes; shift ;;
|
--with-libsignal-in-tree ) BUILD_LIBSIGNAL_IN_TREE=yes; shift ;;
|
||||||
|
--with-libsoup3 ) USE_SOUP3=yes; shift ;;
|
||||||
--disable-fast-vapi ) DISABLE_FAST_VAPI=yes; shift ;;
|
--disable-fast-vapi ) DISABLE_FAST_VAPI=yes; shift ;;
|
||||||
--no-debug ) NO_DEBUG=yes; shift ;;
|
--no-debug ) NO_DEBUG=yes; shift ;;
|
||||||
--fetch-only ) FETCH_ONLY=yes; shift ;;
|
--fetch-only ) FETCH_ONLY=yes; shift ;;
|
||||||
|
@ -256,6 +259,7 @@ cmake -G "$cmake_type" \
|
||||||
-DDISABLED_PLUGINS="$DISABLED_PLUGINS" \
|
-DDISABLED_PLUGINS="$DISABLED_PLUGINS" \
|
||||||
-DBUILD_TESTS="$BUILD_TESTS" \
|
-DBUILD_TESTS="$BUILD_TESTS" \
|
||||||
-DBUILD_LIBSIGNAL_IN_TREE="$BUILD_LIBSIGNAL_IN_TREE" \
|
-DBUILD_LIBSIGNAL_IN_TREE="$BUILD_LIBSIGNAL_IN_TREE" \
|
||||||
|
-DUSE_SOUP3="$USE_SOUP3" \
|
||||||
-DVALA_EXECUTABLE="$VALAC" \
|
-DVALA_EXECUTABLE="$VALAC" \
|
||||||
-DCMAKE_VALA_FLAGS="$VALACFLAGS" \
|
-DCMAKE_VALA_FLAGS="$VALACFLAGS" \
|
||||||
-DDISABLE_FAST_VAPI="$DISABLE_FAST_VAPI" \
|
-DDISABLE_FAST_VAPI="$DISABLE_FAST_VAPI" \
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
set(HTTP_FILES_DEFINITIONS)
|
include(SoupVersion)
|
||||||
if(USE_SOUP3)
|
|
||||||
set(Soup Soup3)
|
|
||||||
set(HTTP_FILES_DEFINITIONS ${HTTP_FILES_DEFINITIONS} SOUP_3)
|
|
||||||
else()
|
|
||||||
set(Soup Soup2)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_packages(HTTP_FILES_PACKAGES REQUIRED
|
find_packages(HTTP_FILES_PACKAGES REQUIRED
|
||||||
Gee
|
Gee
|
||||||
GLib
|
GLib
|
||||||
|
@ -15,6 +8,12 @@ find_packages(HTTP_FILES_PACKAGES REQUIRED
|
||||||
${Soup}
|
${Soup}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(HTTP_FILES_DEFINITIONS)
|
||||||
|
|
||||||
|
if(${Soup}_VERSION VERSION_GREATER_EQUAL "3.0")
|
||||||
|
set(HTTP_FILES_DEFINITIONS ${HTTP_FILES_DEFINITIONS} SOUP_3_0)
|
||||||
|
endif()
|
||||||
|
|
||||||
vala_precompile(HTTP_FILES_VALA_C
|
vala_precompile(HTTP_FILES_VALA_C
|
||||||
SOURCES
|
SOURCES
|
||||||
src/file_provider.vala
|
src/file_provider.vala
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class FileProvider : Dino.FileProvider, Object {
|
||||||
head_message.request_headers.append("Accept-Encoding", "identity");
|
head_message.request_headers.append("Accept-Encoding", "identity");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
#if SOUP_3
|
#if SOUP_3_0
|
||||||
yield session.send_async(head_message, GLib.Priority.LOW, null);
|
yield session.send_async(head_message, GLib.Priority.LOW, null);
|
||||||
#else
|
#else
|
||||||
yield session.send_async(head_message, null);
|
yield session.send_async(head_message, null);
|
||||||
|
@ -136,7 +136,7 @@ public class FileProvider : Dino.FileProvider, Object {
|
||||||
var get_message = new Soup.Message("GET", http_receive_data.url);
|
var get_message = new Soup.Message("GET", http_receive_data.url);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
#if SOUP_3
|
#if SOUP_3_0
|
||||||
InputStream stream = yield session.send_async(get_message, GLib.Priority.LOW, file_transfer.cancellable);
|
InputStream stream = yield session.send_async(get_message, GLib.Priority.LOW, file_transfer.cancellable);
|
||||||
#else
|
#else
|
||||||
InputStream stream = yield session.send_async(get_message, file_transfer.cancellable);
|
InputStream stream = yield session.send_async(get_message, file_transfer.cancellable);
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class HttpFileSender : FileSender, Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !SOUP_3
|
#if !SOUP_3_0
|
||||||
private static void transfer_more_bytes(InputStream stream, Soup.MessageBody body) {
|
private static void transfer_more_bytes(InputStream stream, Soup.MessageBody body) {
|
||||||
uint8[] bytes = new uint8[4096];
|
uint8[] bytes = new uint8[4096];
|
||||||
ssize_t read = stream.read(bytes);
|
ssize_t read = stream.read(bytes);
|
||||||
|
@ -93,7 +93,7 @@ public class HttpFileSender : FileSender, Object {
|
||||||
var session = new Soup.Session();
|
var session = new Soup.Session();
|
||||||
session.user_agent = @"Dino/$(Dino.get_short_version()) ";
|
session.user_agent = @"Dino/$(Dino.get_short_version()) ";
|
||||||
var put_message = new Soup.Message("PUT", file_send_data.url_up);
|
var put_message = new Soup.Message("PUT", file_send_data.url_up);
|
||||||
#if SOUP_3
|
#if SOUP_3_0
|
||||||
put_message.set_request_body(file_meta.mime_type, file_transfer.input_stream, (ssize_t) file_meta.size);
|
put_message.set_request_body(file_meta.mime_type, file_transfer.input_stream, (ssize_t) file_meta.size);
|
||||||
#else
|
#else
|
||||||
put_message.request_headers.set_content_type(file_meta.mime_type, null);
|
put_message.request_headers.set_content_type(file_meta.mime_type, null);
|
||||||
|
@ -106,7 +106,7 @@ public class HttpFileSender : FileSender, Object {
|
||||||
put_message.request_headers.append(entry.key, entry.value);
|
put_message.request_headers.append(entry.key, entry.value);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
#if SOUP_3
|
#if SOUP_3_0
|
||||||
yield session.send_async(put_message, GLib.Priority.LOW, file_transfer.cancellable);
|
yield session.send_async(put_message, GLib.Priority.LOW, file_transfer.cancellable);
|
||||||
#else
|
#else
|
||||||
yield session.send_async(put_message, file_transfer.cancellable);
|
yield session.send_async(put_message, file_transfer.cancellable);
|
||||||
|
|
Loading…
Reference in a new issue