diff --git a/projects/webrtc/build b/projects/webrtc/build index bd42a73..5151c75 100644 --- a/projects/webrtc/build +++ b/projects/webrtc/build @@ -2,6 +2,18 @@ set -e [% c("var/set_default_env") -%] [% c("var/setarch") -%] +[% IF c("var/windows") -%] + # This gcc is used only to compile the bootstrap gn. + mkdir -p /var/tmp/dist + tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/gcc') %] + hgccdir=/var/tmp/dist/gcc + export PATH=$hgccdir/bin:$PATH + [% IF c("var/windows-i686") -%] + export LD_LIBRARY_PATH=$hgccdir/lib + [% ELSE -%] + export LD_LIBRARY_PATH=$hgccdir/lib64 + [% END -%] +[% END -%] distdir=/var/tmp/dist/[% project %] [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %] @@ -40,8 +52,11 @@ cd $builddir [% IF c("var/osx") -%] patch -p1 < $rootdir/webrtc-mac.patch [% END -%] +[% IF c("var/windows") -%] + patch -p1 < $rootdir/webrtc-windows.patch +[% END -%] -[% IF c("var/linux") -%] +[% IF c("var/linux") || c("var/windows") -%] # First, build a copy of GN, rather than use the prebuilt copy in buildtools/linux64. cd tools/gn # __STDC_FORMAT_MACROS is needed for a definition of PRIxPTR from inttypes.h. @@ -75,7 +90,31 @@ print("xcode_build=\"7.3\"") print("xcode_version=\"0730\"") EOF [% END -%] +[% IF c("var/windows") -%] + win_sdk_version=[% pc('win_sdk', 'version') %] + vs_files=third_party/depot_tools/win_toolchain/vs_files + mkdir -p $vs_files + # Extract the Windows SDK into a case-insensitive ciopfs mount, where + # build/vs_toolchain.py expects to find it. + tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/ciopfs') %] + mkdir -p $vs_files.ciopfs + /var/tmp/dist/ciopfs/bin/ciopfs -o use_ino $vs_files.ciopfs $vs_files + mkdir -p $vs_files/$win_sdk_version + unzip -q -d $vs_files/$win_sdk_version $rootdir/[% c('input_files_by_name/win_sdk') %] + # Override the desired Windows SDK hash with the one we have. + sed -i -e '/^def _GetDesiredVsToolchainHashes/,/^\($\|[^ ]\)/ {s/return \[.*/return ["'$win_sdk_version'"]/}' build/vs_toolchain.py + + # This command generates the build/win_toolchain.json file. + build/vs_toolchain.py update --force + + # For some reason, the necessary INCLUDE environment variable, which defines + # the header search path, isn't set automatically. Construct one out of the + # contents of SetEnv.{x86,x64}.json. Compare to + # https://github.com/nico/hack/blob/3add7d1a010ac8e2bbc431c9953ecfa243cb975d/res/distrib.py#L48-L53 + # I didn't find it necessary to set LIB. + export INCLUDE="$(jq -r '["'$(realpath $vs_files/$win_sdk_version/win_sdk/bin)'/" + (.env.INCLUDE[]|join("/"))]|join(";")' $vs_files/$win_sdk_version/win_sdk/bin/SetEnv.[% IF c("var/linux-i686") %]x86[% ELSE %]x64[% END %].json)" +[% END -%] [% IF c("var/linux") -%] export CC=gcc @@ -131,9 +170,18 @@ GN_ARGS+=" use_custom_libcxx=false use_custom_libcxx_for_host=false" rm -rf third_party/llvm-build rm -rf third_party/binutils [% END -%] +[% IF c("var/windows") -%] + # Note, starting GN_ARGS over empty. + GN_ARGS="" + GN_ARGS+=" target_os=\"win\" target_cpu=\"[% IF c("var/windows-i686") %]x86[% ELSE %]x64[% END %]\"" +[% END -%] rm -rf out/Release "$GN" gen out/Release --args="$GN_ARGS" ninja -C out/Release webrtc field_trial metrics_default pc_test_utils +[% IF c("var/linux") -%] +"$AR" crs libwebrtc-magic.a $(find out/Release/obj -name '*.o' | sort) +[% END -%] +[% IF c("var/osx") -%] # The cctools ar doesn't have the 'D' deterministic option of GNU ar, but the # ZERO_AR_DATE environment variable similarly sets timestamps within the # archive to zero. @@ -144,7 +192,11 @@ ninja -C out/Release webrtc field_trial metrics_default pc_test_utils # like that, not necessarily of the target architecture, and anyway are not # needed. # https://bugs.torproject.org/22832 -[% IF c("var/osx") %]ZERO_AR_DATE=1 [% END %]"$AR" crs libwebrtc-magic.a $(find out/Release/obj -name '*.o' | sort) +ZERO_AR_DATE=1 "$AR" crs libwebrtc-magic.a $(find out/Release/obj -name '*.o' | sort) +[% END -%] +[% IF c("var/windows") -%] +cp out/Release/obj/webrtc.lib libwebrtc-magic.a +[% END -%] mkdir -p $distdir cd $distdir @@ -152,11 +204,13 @@ mkdir -p include lib cp -f $builddir/libwebrtc-magic.a [% c("var/webrtc/lib_path") %] INCLUDE_DIR="$PWD/include" cd $builddir -for h in $(find . -type f -name '*.h'); +(IFS= # Disable word splitting by read. +find . -type f -name '*.h' -print0 | while read -r -d "" h do mkdir -p "$INCLUDE_DIR/$(dirname $h)" cp -f "$h" "$INCLUDE_DIR/$h" done +) cd /var/tmp/dist [% c('tar', { diff --git a/projects/webrtc/config b/projects/webrtc/config index af337e2..5f0fc4d 100644 --- a/projects/webrtc/config +++ b/projects/webrtc/config @@ -18,10 +18,22 @@ input_files: - project: binutils name: binutils enable: '[% c("var/linux") %]' + # windows needs a recent gcc only to compile the bootstrap gn. + - project: gcc + name: gcc + enable: '[% c("var/windows") %]' + - project: win_sdk + name: win_sdk + enable: '[% c("var/windows") %]' + - project: ciopfs + name: ciopfs + enable: '[% c("var/windows") %]' - filename: webrtc-linux.patch enable: '[% c("var/linux") %]' - filename: webrtc-mac.patch enable: '[% c("var/osx") %]' + - filename: webrtc-windows.patch + enable: '[% c("var/windows") %]' targets: linux: @@ -54,6 +66,22 @@ targets: - libgtk2.0-dev - pkg-config - python-biplist + windows: + var: + arch_deps: + - pkg-config + - libattr1 + - libfuse2 + - libglib2.0-0 + - jq + windows-i686: + var: + webrtc: + lib_path: lib/libwebrtc-windows-386-magic.lib + windows-x86_64: + var: + webrtc: + lib_path: lib/libwebrtc-windows-amd64-magic.lib steps: fetch_sources: diff --git a/projects/webrtc/webrtc-windows.patch b/projects/webrtc/webrtc-windows.patch new file mode 100644 index 0000000..0136194 --- /dev/null +++ b/projects/webrtc/webrtc-windows.patch @@ -0,0 +1,194 @@ +From 796d7655435fc9038017d2946c0331508ddf0071 Mon Sep 17 00:00:00 2001 +From: David Fifield +Date: Wed, 28 Mar 2018 13:20:44 -0700 +Subject: [PATCH 1/3] Comment out _CopyDebugger and _CopyRuntime in + build/vs_toolchain.py. + +This function looks for a file dbghelp.dll that is not present in the +SDK installed by Visual Studio Community: +Exception: dbghelp.dll not found in ".../win_sdk/Debuggers/x64/dbghelp.dll" +You must install the "Debugging Tools for Windows" feature from the Windows 10 SDK. + +The Visual Studio installer doesn't have a "Debugging Tools for Windows" +option. The standalone SDK installer from +https://developer.microsoft.com/en-us/windows/downloads/sdk-archive +does; however just commenting out this call seems to make it +unnecessary. +--- + vs_toolchain.py | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +diff --git a/build/vs_toolchain.py b/build/vs_toolchain.py +index 7a258ed1d..b8e031a03 100755 +--- a/build/vs_toolchain.py ++++ b/build/vs_toolchain.py +@@ -305,15 +305,15 @@ def CopyDlls(target_dir, configuration, target_cpu): + if not vs_runtime_dll_dirs: + return + +- x64_runtime, x86_runtime = vs_runtime_dll_dirs +- runtime_dir = x64_runtime if target_cpu == 'x64' else x86_runtime +- _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=False) +- if configuration == 'Debug': +- _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True) +- else: +- _CopyPGORuntime(target_dir, target_cpu) +- +- _CopyDebugger(target_dir, target_cpu) ++ # x64_runtime, x86_runtime = vs_runtime_dll_dirs ++ # runtime_dir = x64_runtime if target_cpu == 'x64' else x86_runtime ++ # _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=False) ++ # if configuration == 'Debug': ++ # _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True) ++ # else: ++ # _CopyPGORuntime(target_dir, target_cpu) ++ ++ # _CopyDebugger(target_dir, target_cpu) + + + def _CopyDebugger(target_dir, target_cpu): +-- +2.11.0 + + +From 0462bedf5126537bfc6d246c630c158b617810d7 Mon Sep 17 00:00:00 2001 +From: David Fifield +Date: Wed, 28 Mar 2018 18:48:27 -0700 +Subject: [PATCH 2/3] Set vc_bin_dir to a dummy value. + +This doesn't seem to be needed (it would contain e.g. cl.exe, which we +don't use), but it needs to be set to appease the build scripts. +--- + toolchain/win/setup_toolchain.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/build/toolchain/win/setup_toolchain.py b/build/toolchain/win/setup_toolchain.py +index a1d2ea4b2..c98f013ff 100644 +--- a/build/toolchain/win/setup_toolchain.py ++++ b/build/toolchain/win/setup_toolchain.py +@@ -209,6 +209,7 @@ def main(): + with open('environment.winrt_' + cpu, 'wb') as f: + f.write(env_block) + ++ vc_bin_dir = "NONEXISTENT_VC_BIN_DIR" + assert vc_bin_dir + print 'vc_bin_dir = ' + gn_helpers.ToGNString(vc_bin_dir) + assert include_I +-- +2.11.0 + +From fe050ea847d1797adfe64ab702c2aae6bb37bae9 Mon Sep 17 00:00:00 2001 +From: David Fifield +Date: Wed, 28 Mar 2018 20:49:21 -0700 +Subject: [PATCH 3/3] Disable the video_capture module. + +It depends on winsdk_samples code, which requires some SDK files that we +don't have. E.g., + +In file included from ../../third_party/winsdk_samples/Samples/multimedia/directshow/baseclasses/amextra.cpp:10: +In file included from ../../third_party/winsdk_samples/Samples/multimedia/directshow/baseclasses/streams.h:185: +../../third_party/winsdk_samples/Samples/multimedia/directshow/baseclasses/refclock.h(83,37): error: unknown type name 'CAMSchedule' + __inout_opt CAMSchedule * pSched = 0 ); + ^ +--- + BUILD.gn | 8 ++++---- + common_video/BUILD.gn | 2 +- + media/BUILD.gn | 6 +++--- + modules/BUILD.gn | 2 +- + 4 files changed, 9 insertions(+), 9 deletions(-) + +diff --git a/BUILD.gn b/BUILD.gn +index e59064452..bcbfd5107 100644 +--- a/BUILD.gn ++++ b/BUILD.gn +@@ -277,7 +277,7 @@ if (!build_with_chromium) { + "logging", + "media", + "modules", +- "modules/video_capture:video_capture_internal_impl", ++ # "modules/video_capture:video_capture_internal_impl", + "ortc", + "p2p", + "pc", +@@ -318,7 +318,7 @@ if (!build_with_chromium) { + "modules/audio_processing:audio_processing_tests", + "modules/remote_bitrate_estimator:bwe_simulations_tests", + "modules/rtp_rtcp:test_packet_masks_metrics", +- "modules/video_capture:video_capture_internal_impl", ++ # "modules/video_capture:video_capture_internal_impl", + "ortc:ortc_unittests", + "pc:peerconnection_unittests", + "pc:rtc_pc_unittests", +@@ -336,7 +336,7 @@ if (!build_with_chromium) { + "sdk/android:libjingle_peerconnection_android_unittest", + ] + } else { +- deps += [ "modules/video_capture:video_capture_tests" ] ++ # deps += [ "modules/video_capture:video_capture_tests" ] + } + if (rtc_enable_protobuf) { + deps += [ +@@ -450,7 +450,7 @@ if (rtc_include_tests) { + # TODO(eladalon): call_tests aren't actually video-specific, so we + # should move them to a more appropriate test suite. + "call:call_tests", +- "modules/video_capture", ++ # "modules/video_capture", + "rtc_base:rtc_base_tests_utils", + "test:test_common", + "test:test_main", +diff --git a/common_video/BUILD.gn b/common_video/BUILD.gn +index 669fa7a54..1dcc7ce85 100644 +--- a/common_video/BUILD.gn ++++ b/common_video/BUILD.gn +@@ -117,7 +117,7 @@ if (rtc_include_tests) { + deps = [ + ":common_video", + "../api:video_frame_api_i420", +- "../modules/video_capture:video_capture", ++ # "../modules/video_capture:video_capture", + "../rtc_base:rtc_base", + "../rtc_base:rtc_base_approved", + "../system_wrappers:system_wrappers", +diff --git a/media/BUILD.gn b/media/BUILD.gn +index f59cbb63e..613bc5d71 100644 +--- a/media/BUILD.gn ++++ b/media/BUILD.gn +@@ -227,10 +227,10 @@ rtc_static_library("rtc_audio_video") { + + public_configs = [] + if (build_with_chromium) { +- deps += [ "../modules/video_capture:video_capture" ] ++ # deps += [ "../modules/video_capture:video_capture" ] + } else { + public_configs += [ ":rtc_media_defines_config" ] +- deps += [ "../modules/video_capture:video_capture_internal_impl" ] ++ # deps += [ "../modules/video_capture:video_capture_internal_impl" ] + } + if (rtc_enable_protobuf) { + deps += [ "../modules/audio_processing/aec_dump:aec_dump_impl" ] +@@ -255,7 +255,7 @@ rtc_static_library("rtc_audio_video") { + "../modules/audio_mixer:audio_mixer_impl", + "../modules/audio_processing:audio_processing", + "../modules/audio_processing/aec_dump", +- "../modules/video_capture:video_capture_module", ++ # "../modules/video_capture:video_capture_module", + "../modules/video_coding", + "../modules/video_coding:webrtc_h264", + "../modules/video_coding:webrtc_vp8", +diff --git a/modules/BUILD.gn b/modules/BUILD.gn +index 465f32d3c..4918bc8b8 100644 +--- a/modules/BUILD.gn ++++ b/modules/BUILD.gn +@@ -255,7 +255,7 @@ if (rtc_include_tests) { + "remote_bitrate_estimator:remote_bitrate_estimator_unittests", + "rtp_rtcp:rtp_rtcp_unittests", + "utility:utility_unittests", +- "video_capture", ++ # "video_capture", + "video_coding:video_coding_unittests", + "video_processing:video_processing_unittests", + ] +-- +2.11.0 +