Skip to content

Commit 00f3a68

Browse files
sdroegesuperdump
authored andcommitted
owr: Conditionally build a static binary or not
Make the default no, so that a normal configure will work as expected and builds a version that works out of the box with the system dependencies. EricssonResearch#6
1 parent 679dacb commit 00f3a68

File tree

5 files changed

+55
-9
lines changed

5 files changed

+55
-9
lines changed

bridge/owr_bridge.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#endif
3131
#include "owr_bridge.h"
3232

33-
#include "Owr-0.1.gir.h"
3433
#include "client/domutils.js.h"
3534
#include "client/sdp.js.h"
3635
#include "client/webrtc.js.h"
@@ -42,13 +41,17 @@
4241
#include "worker/bridgeserver.js.h"
4342
#include "worker/peerhandler.js.h"
4443

44+
#ifdef OWR_STATIC
45+
#include "Owr-0.1.gir.h"
4546
#include <gir/GIRepository-2.0.gir.h>
4647
#include <gir/GLib-2.0.gir.h>
4748
#include <gir/GObject-2.0.gir.h>
4849
#include <gir/Gio-2.0.gir.h>
4950

5051
#include <girepository.h>
5152
#include <girparser.h>
53+
#endif
54+
5255
#include <glib/gstdio.h>
5356
#include <seed.h>
5457

@@ -58,6 +61,7 @@
5861
#include <TargetConditionals.h>
5962
#endif
6063

64+
#ifdef OWR_STATIC
6165
GLogLevelFlags logged_levels;
6266
static void no_log_handler() { }
6367

@@ -274,6 +278,7 @@ static void load_typelibs()
274278
for (i = 0; gir_checksums[i]; i++)
275279
g_free(gir_checksums[i]);
276280
}
281+
#endif
277282

278283
static SeedException evaluate_script(SeedContext context, gchar *script, guint script_len,
279284
gchar *script_name)
@@ -376,7 +381,10 @@ static gpointer run(GAsyncQueue *msg_queue)
376381
client_script_lengths[3] = webrtc_js__len;
377382
client_script_lengths[4] = 0;
378383

384+
#ifdef OWR_STATIC
379385
load_typelibs();
386+
#endif
387+
380388
owr_init_with_main_context(g_main_context_default());
381389
engine = seed_init(&argc, &argv);
382390
seed_engine_set_search_path(engine, "");

build.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,36 +74,36 @@ build(){
7474

7575
export CFLAGS="$PLATFORM_CFLAGS -I${src_dir}/openwebrtc-deps-${target}/include -I${src_dir}/framework"
7676
if [[ $target_triple == "arm-apple-darwin10" ]]; then
77-
local configure_flags="--enable-static --disable-shared --disable-introspection"
77+
local configure_flags="--enable-static --enable-owr-static --disable-shared --disable-introspection"
7878
local platform_ldflags="${home}/openwebrtc-deps-armv7-ios/lib/my_environ.o ${home}/openwebrtc-deps-${target}/lib/my_stat.o "
7979
local seed_platform_libs="-framework JavaScriptCore"
8080
export PLATFORM_GLIB_LIBS="-lffi -lresolv -liconv -lintl "
8181
export PLATFORM_GSTREAMER_LIBS="-lgstosxaudio -lgstapplemedia -framework AssetsLibrary -framework CoreMedia -framework CoreVideo -framework AVFoundation -framework Foundation -framework OpenGLES -framework CoreAudio -framework AudioToolbox"
8282
export PLATFORM_OWR_GST_PLUGINS_LIBS="-lgstercolorspace"
8383
export PLATFORM_CXX_LIBS="-lc++"
8484
elif [[ $target_triple == "i386-apple-darwin10" ]]; then
85-
local configure_flags="--enable-static --disable-shared --disable-introspection"
85+
local configure_flags="--enable-static --enable-owr-static --disable-shared --disable-introspection"
8686
local seed_platform_libs="-framework JavaScriptCore"
8787
export PLATFORM_GLIB_LIBS="-lffi -lresolv -liconv -lintl "
8888
export PLATFORM_GSTREAMER_LIBS="-framework CoreMedia -framework CoreVideo -framework AVFoundation -framework Foundation -framework OpenGLES -lgstosxaudio -lgstapplemedia -framework AssetsLibrary -framework CoreAudio -framework AudioToolbox"
8989
export PLATFORM_CXX_LIBS="-lc++"
9090
elif [[ $target_triple == "arm-linux-androideabi" ]]; then
9191
local platform_ldflags="-llog -Wl,--allow-multiple-definition "
92-
local configure_flags="--disable-static --enable-shared --disable-introspection"
92+
local configure_flags="--disable-static --enable-owr-static --enable-shared --disable-introspection"
9393
local seed_platform_libs="-ljavascriptcoregtk-3.0 -licui18n -licuuc -licudata"
9494
export PLATFORM_GLIB_LIBS="-lffi -liconv -lintl "
9595
export PLATFORM_GSTREAMER_LIBS="-lgstopensles -lOpenSLES -lGLESv2 -lEGL"
9696
export PLATFORM_OWR_GST_PLUGINS_LIBS="-lgstandroidvideosrc -lgstercolorspace"
9797
export PLATFORM_CXX_LIBS="-L$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a -lgnustl_static -lstdc++"
9898
elif [[ $target_triple == "x86_64-apple-darwin" ]]; then
99-
local configure_flags="--enable-static --enable-shared --enable-gtk-doc"
99+
local configure_flags="--enable-static --enable-owr-static --enable-shared --enable-gtk-doc"
100100
local seed_platform_libs="-framework JavaScriptCore"
101101
export PLATFORM_GLIB_LIBS="-lffi -lresolv -liconv -lintl -framework Carbon"
102102
export PLATFORM_GSTREAMER_LIBS="-lgstvideoconvert -lgstapplemedia -lgstosxaudio"
103103
export PLATFORM_GSTREAMER_LIBS="$PLATFORM_GSTREAMER_LIBS -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework CoreMedia -framework CoreVideo -framework QTKit -framework AVFoundation -framework Foundation -framework VideoToolbox -framework AppKit -framework OpenGL"
104104
export PLATFORM_CXX_LIBS="-lc++"
105105
elif [[ $target_triple == "x86_64-unknown-linux" ]] ; then
106-
local configure_flags="--enable-static --enable-shared --enable-gtk-doc"
106+
local configure_flags="--enable-static --enable-owr-static --enable-shared --enable-gtk-doc"
107107
local seed_platform_libs="-ljavascriptcoregtk-3.0 -licui18n -licuuc -licudata"
108108
export PLATFORM_GLIB_LIBS="-lpthread -lffi -lrt -ldl -lresolv"
109109
export PLATFORM_GSTREAMER_LIBS="-lgstvideoconvert -lgstpulse -lpulse-mainloop-glib -lpulse -lgstvideo4linux2 -lv4l2 -lX11 -lXv -lgstallocators-1.0 -lGLU -lGL"

configure.ac

+18
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@ if test "x$enable_debug" = xyes; then
5757
fi
5858
AM_CONDITIONAL(OWR_DEBUG, test x$enable_debug = xyes)
5959

60+
dnl build static or not
61+
AC_MSG_CHECKING([whether to build static owr or not])
62+
AC_ARG_ENABLE(owr-static,
63+
AC_HELP_STRING(
64+
[--enable-owr-static],
65+
[Enable static owr @<:@default=no@:>@]),
66+
[case "${enableval}" in
67+
yes) enable_owr_static=yes ;;
68+
no) enable_owr_static=no ;;
69+
*) AC_MSG_ERROR(bad value ${enableval} for --enable-owr-static) ;;
70+
esac],[enable_owr_static=no])
71+
AC_MSG_RESULT([$enable_owr_static])
72+
if test "x$enable_owr_static" = xyes; then
73+
AC_DEFINE(OWR_STATIC, 1,
74+
[Define if building static])
75+
fi
76+
AM_CONDITIONAL(OWR_STATIC, test x$enable_owr_static = xyes)
77+
6078
AC_OUTPUT([
6179
Makefile
6280
bridge/Makefile

owr/Makefile.am

+14-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ lib_LTLIBRARIES = libopenwebrtc.la
1717

1818
libopenwebrtc_la_SOURCES = \
1919
owr.c \
20-
owr_require_symbols.c \
2120
owr_types.c \
2221
owr_media_source.c \
2322
owr_utils.c
@@ -35,10 +34,15 @@ libopenwebrtc_la_DEPENDENCIES = \
3534
$(top_builddir)/local/libopenwebrtc_local.la \
3635
$(top_builddir)/transport/libopenwebrtc_transport.la
3736

38-
libopenwebrtc_la_LDFLAGS = -export-dynamic -export-symbols $(top_srcdir)/libopenwebrtc.exp -version-info 3601
37+
libopenwebrtc_la_LDFLAGS = -export-dynamic -version-info 3601
3938

39+
if OWR_STATIC
40+
libopenwebrtc_la_LDFLAGS += -export-symbols $(top_srcdir)/libopenwebrtc.exp
41+
libopenwebrtc_la_SOURCES += \
42+
owr_require_symbols.c
4043
owr_require_symbols.c:
4144
python ${srcdir}/symbols_to_source.py $(top_srcdir)/libopenwebrtc.exp $@
45+
endif
4246

4347
includedir = $(prefix)/include/owr
4448
include_HEADERS = \
@@ -61,7 +65,11 @@ EXTRA_DIST = \
6165
-include $(INTROSPECTION_MAKEFILE)
6266
INTROSPECTION_GIRS =
6367
INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --warn-all
64-
INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) --shared-library=""
68+
69+
INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
70+
if OWR_STATIC
71+
INTROSPECTION_COMPILER_ARGS += --shared-library=""
72+
endif
6573

6674
if HAVE_INTROSPECTION
6775
introspection_sources = $(libopenwebrtc_la_SOURCES)
@@ -74,6 +82,9 @@ Owr_0_1_gir_CFLAGS = \
7482
-I$(top_srcdir)/transport \
7583
-I$(top_srcdir)/local
7684
Owr_0_1_gir_LIBS = libopenwebrtc.la
85+
if !OWR_STATIC
86+
Owr_0_1_gir_LIBS += gstreamer-1.0 gstvideo-1.0 gstapp-1.0
87+
endif
7788
Owr_0_1_gir_FILES = \
7889
owr.h \
7990
owr.c \

owr/owr.c

+9
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@
4343
#include "owr_utils.h"
4444

4545
#include <gst/gst.h>
46+
47+
#ifdef OWR_STATIC
4648
#include <gstnice.h>
49+
#endif
4750

4851
#ifdef __APPLE__
4952
#include <TargetConditionals.h>
@@ -64,6 +67,7 @@ static guint bus_watch_id = -1;
6467
static gpointer owr_run(gpointer data);
6568
static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer user_data);
6669

70+
#ifdef OWR_STATIC
6771
GST_PLUGIN_STATIC_DECLARE(alaw);
6872
GST_PLUGIN_STATIC_DECLARE(app);
6973
GST_PLUGIN_STATIC_DECLARE(audioconvert);
@@ -105,6 +109,7 @@ GST_PLUGIN_STATIC_DECLARE(video4linux2);
105109
#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR)
106110
GST_PLUGIN_STATIC_DECLARE(ercolorspace);
107111
#endif
112+
#endif
108113

109114
#ifdef __ANDROID__
110115
static void g_print_android_handler(const gchar *message)
@@ -176,12 +181,15 @@ void owr_init()
176181
gst_debug_add_log_function((GstLogFunction)gst_log_android_handler, NULL, NULL);
177182
#endif
178183

184+
#ifdef OWR_STATIC
179185
/* Hack to make sure that all symbols that we need are included in the resulting library/binary */
180186
_owr_require_symbols();
187+
#endif
181188

182189
gst_init(NULL, NULL);
183190
owr_initialized = TRUE;
184191

192+
#ifdef OWR_STATIC
185193
GST_PLUGIN_STATIC_REGISTER(alaw);
186194
GST_PLUGIN_STATIC_REGISTER(app);
187195
GST_PLUGIN_STATIC_REGISTER(audioconvert);
@@ -225,6 +233,7 @@ void owr_init()
225233

226234
gst_element_register(NULL, "nicesrc", GST_RANK_NONE, GST_TYPE_NICE_SRC);
227235
gst_element_register(NULL, "nicesink", GST_RANK_NONE, GST_TYPE_NICE_SINK);
236+
#endif
228237

229238
owr_main_context_is_external = !!owr_main_context;
230239

0 commit comments

Comments
 (0)