diff options
Diffstat (limited to 'tools/rtc.py')
-rw-r--r-- | tools/rtc.py | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/tools/rtc.py b/tools/rtc.py index a487b08..6882bb4 100644 --- a/tools/rtc.py +++ b/tools/rtc.py @@ -1,8 +1,8 @@ import os -def rtc_cmake_config(env): - config = { +def build_library(env, ssl): + rtc_config = { "CMAKE_BUILD_TYPE": "RelWithDebInfo" if env["debug_symbols"] else "Release", "USE_NICE": 0, "NO_WEBSOCKET": 1, @@ -15,21 +15,31 @@ def rtc_cmake_config(env): "OPENSSL_CRYPTO_LIBRARY": env["SSL_CRYPTO_LIBRARY"], "OPENSSL_ROOT_DIR": env["SSL_INSTALL"], } - return config - - -def build_library(env, ssl): + is_msvc = env.get("is_msvc", False) + lib_ext = ".lib" if is_msvc else ".a" + lib_prefix = "" if is_msvc else "lib" + rtc_libs = [ + "{}datachannel-static{}".format(lib_prefix, lib_ext), + "deps/libjuice/{}juice-static{}".format(lib_prefix, lib_ext), + "deps/libsrtp/{}srtp2{}".format(lib_prefix, lib_ext), + "deps/usrsctp/usrsctplib/{}usrsctp{}".format(lib_prefix, lib_ext), + ] + # Build libdatachannel + rtc = env.CMakeBuild( + "#bin/thirdparty/libdatachannel/", + "#thirdparty/libdatachannel", + cmake_options=rtc_config, + cmake_outputs=rtc_libs, + cmake_targets=["datachannel-static"], + dependencies=ssl, + ) + + # Configure env. if env["platform"] == "windows": env.PrependUnique(LIBS=["iphlpapi", "bcrypt"]) + env.Prepend(LIBS=list(filter(lambda f: str(f).endswith(lib_ext), rtc))) + env.Append(CPPPATH=["#thirdparty/libdatachannel/include"]) - env.Prepend(LIBS=env["RTC_LIBS"]) - - rtc_env = env.Clone() - rtc_targets = [env.Dir(env["RTC_BUILD"])] + env["RTC_LIBS"] - rtc_sources = [env.Dir(env["RTC_SOURCE"])] + ssl - rtc_env.Append(CMAKECONFFLAGS=["-D%s=%s" % it for it in rtc_cmake_config(env).items()]) - rtc_env.Append(CMAKEBUILDFLAGS=["-t", "datachannel-static"]) - rtc = rtc_env.CMake(rtc_targets, rtc_sources) return rtc @@ -38,23 +48,4 @@ def exists(env): def generate(env): - env["RTC_SOURCE"] = env.Dir("#thirdparty/libdatachannel").abspath - env["RTC_BUILD"] = env.Dir("#bin/thirdparty/libdatachannel/{}/{}".format(env["platform"], env["arch"])).abspath - env["RTC_INCLUDE"] = env["RTC_SOURCE"] + "/include" - lib_ext = ".a" - lib_prefix = "lib" - if env.get("is_msvc", False): - lib_ext = ".lib" - lib_prefix = "" - env["RTC_LIBS"] = [ - env.File(env["RTC_BUILD"] + "/" + lib) - for lib in [ - "{}datachannel-static{}".format(lib_prefix, lib_ext), - "deps/libjuice/{}juice-static{}".format(lib_prefix, lib_ext), - "deps/libsrtp/{}srtp2{}".format(lib_prefix, lib_ext), - "deps/usrsctp/usrsctplib/{}usrsctp{}".format(lib_prefix, lib_ext), - ] - ] env.AddMethod(build_library, "BuildLibDataChannel") - env.Append(LIBPATH=[env["RTC_BUILD"]]) - env.Append(CPPPATH=[env["RTC_INCLUDE"]]) |