From 470e444791109e744ee6f0cd630838aba354fbe7 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 12 Mar 2017 12:16:19 +0100 Subject: [PATCH 01/27] Find git and depot_tools in the main file --- CMakeLists.txt | 9 +++++++++ CMakeModules/FindLibraries.cmake | 10 ---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd51901..1235a67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,15 @@ cmake_policy(SET CMP0057 NEW) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeModules) +find_package(Git REQUIRED) +find_package(DepotTools REQUIRED) + +if (WIN32) + set(PYTHON_EXECUTABLE ${DEPOTTOOLS_PATH}/python.bat) +else (WIN32) + find_package(PythonInterp REQUIRED) +endif (WIN32) + include(FindLibraries) include(Version) include(Options) diff --git a/CMakeModules/FindLibraries.cmake b/CMakeModules/FindLibraries.cmake index 8a29977..20e15ba 100644 --- a/CMakeModules/FindLibraries.cmake +++ b/CMakeModules/FindLibraries.cmake @@ -1,15 +1,5 @@ # # Find required packages - -find_package(Git REQUIRED) -find_package(DepotTools REQUIRED) - -if (WIN32) - set(PYTHON_EXECUTABLE ${DEPOTTOOLS_PATH}/python.bat) -else (WIN32) - find_package(PythonInterp REQUIRED) -endif (WIN32) - list(APPEND LIBWEBRTC_LIBRARIES webrtc) if (UNIX AND NOT APPLE) From 638022675f26922a19756165fb6c4ed596d9cead Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 12 Mar 2017 12:29:01 +0100 Subject: [PATCH 02/27] Look for depot_tools only when DEPOT_TOOLS_PATH is set --- CMakeLists.txt | 13 +++++++------ CMakeModules/FindDepotTools.cmake | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1235a67..00c466c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,13 +9,14 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeModules) find_package(Git REQUIRED) -find_package(DepotTools REQUIRED) -if (WIN32) - set(PYTHON_EXECUTABLE ${DEPOTTOOLS_PATH}/python.bat) -else (WIN32) - find_package(PythonInterp REQUIRED) -endif (WIN32) +if (DEPOT_TOOLS_PATH) + find_package(DepotTools REQUIRED) +endif (DEPOT_TOOLS_PATH) + +if (NOT WIN32) + find_package(PythonInterp 2.7 REQUIRED) +endif (NOT WIN32) include(FindLibraries) include(Version) diff --git a/CMakeModules/FindDepotTools.cmake b/CMakeModules/FindDepotTools.cmake index b714748..c23d4eb 100644 --- a/CMakeModules/FindDepotTools.cmake +++ b/CMakeModules/FindDepotTools.cmake @@ -1,16 +1,17 @@ find_program(GCLIENT_EXECUTABLE NAMES gclient gclient.bat - PATHS ${CMAKE_CURRENT_SOURCE_DIR}/depot_tools) + DOC "Path to gclient executable" + HINTS ${DEPOT_TOOLS_PATH} ENV DEPOT_TOOLS_PATH) -find_path(DEPOTTOOLS_PATH +find_path(DEPOT_TOOLS_PATH NAMES gclient gclient.py gclient.bat - gn gn.py gn.bat ninja ninja.exe ninja-linux32 ninja-linux64 ninja-mac download_from_google_storage download_from_google_storage.bat download_from_google_storage.py - HINTS ${CMAKE_CURRENT_SOURCE_DIR}/depot_tools) + DOC "Path to depot_tools directory" + HINTS ${DEPOT_TOOLS_PATH} ENV DEPOT_TOOLS_PATH) include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(DepotTools - REQUIRED_VARS GCLIENT_EXECUTABLE - FAIL_MESSAGE "Could not find the gclient executable.") + REQUIRED_VARS GCLIENT_EXECUTABLE DEPOT_TOOLS_PATH + FAIL_MESSAGE "Could not find depot_tools.") From b565920acb47ae31a9e1385382730c90f241d405 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 12 Mar 2017 12:38:19 +0100 Subject: [PATCH 03/27] Do not manage depot_tools as a submodule anymore --- .gitmodules | 3 --- README.md | 14 ++++++++------ depot_tools | 1 - 3 files changed, 8 insertions(+), 10 deletions(-) delete mode 100644 .gitmodules delete mode 160000 depot_tools diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e2c4ddd..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "depot_tools"] - path = depot_tools - url = https://chromium.googlesource.com/chromium/tools/depot_tools.git diff --git a/README.md b/README.md index 701570f..4c9bef1 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ supported platforms and architectures. ### Debian & Ubuntu -Install the required development packages +Install the required development packages: ``` # apt-get install build-essential libglib2.0-dev libgtk2.0-dev libxtst-dev \ @@ -96,15 +96,12 @@ Install the required development packages ## Compiling -Clone the repository, initialize the submodules if `depot_tools` is not -installed on your system or not defined inside your `PATH` environment variable. -Create an output directory, browse inside it, then run CMake. +Clone the repository, create an output directory, browse inside it, +then run CMake. ``` $ git clone https://github.com/aisouard/libwebrtc.git $ cd libwebrtc -$ git submodule init -$ git submodule update $ mkdir out $ cd out $ cmake .. @@ -172,6 +169,11 @@ perform cross-compiling. Defaults to OFF, will define the `component_build` gn argument to `true` if enabled. This option will build a shared library instead of a static one. +- **DEPOT_TOOLS_PATH** + + Set this variable to your own `depot_tools` directory. This will prevent + CMake from fetching the one matching with the desired WebRTC revision. + - **NINJA_ARGS** Arguments to pass while executing the `ninja` command. For instance, you can diff --git a/depot_tools b/depot_tools deleted file mode 160000 index 33e88a4..0000000 --- a/depot_tools +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 33e88a4e19aa1eb306fe66431e8b0621773eb66c From a750ea484d99d8e580020bc31edc83ff215d06ee Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Fri, 17 Mar 2017 18:40:07 +0100 Subject: [PATCH 04/27] Add DEPOT_TOOLS_PATH variable --- CMakeModules/Options.cmake | 1 + CMakeModules/Prefix.cmake | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeModules/Options.cmake b/CMakeModules/Options.cmake index bfe5d15..65c3e7d 100644 --- a/CMakeModules/Options.cmake +++ b/CMakeModules/Options.cmake @@ -1,6 +1,7 @@ # # Options, flags option(BUILD_TESTS "Build test binaries" OFF) +set(DEPOT_TOOLS_PATH "" CACHE STRING "Path to your own depot_tools directory") set(NINJA_ARGS "" CACHE STRING "Ninja arguments to pass before compiling WebRTC") set(GN_EXTRA_ARGS "" CACHE STRING "Extra gn gen arguments to pass before generating build files") option(BUILD_SHARED_LIB "Build WebRTC as a shared library" OFF) diff --git a/CMakeModules/Prefix.cmake b/CMakeModules/Prefix.cmake index d721c70..3d3dcd8 100644 --- a/CMakeModules/Prefix.cmake +++ b/CMakeModules/Prefix.cmake @@ -1,7 +1,11 @@ # # Generate environment variables # -set(WEBRTC_PATH ${CMAKE_SOURCE_DIR}/depot_tools) +if (DEPOT_TOOLS_PATH) + set(WEBRTC_PATH ${DEPOT_TOOLS_PATH}) +else (DEPOT_TOOLS_PATH) + set(WEBRTC_PATH ${CMAKE_BINARY_DIR}/depot_tools) +endif (DEPOT_TOOLS_PATH) if (WIN32) get_filename_component(DEPOT_TOOLS_PYTHON_PATH From 7ad84637f4b0b57e5f9255e76e9c1d48884134b9 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Fri, 17 Mar 2017 18:52:54 +0100 Subject: [PATCH 05/27] Add include guards --- CMakeModules/FindDepotTools.cmake | 5 +++++ CMakeModules/FindLibraries.cmake | 5 +++++ CMakeModules/GClientConfig.cmake | 7 ++++++- CMakeModules/Install.cmake | 5 +++++ CMakeModules/LibWebRTCCommand.cmake | 5 +++++ CMakeModules/Options.cmake | 5 +++++ CMakeModules/Package.cmake | 5 +++++ CMakeModules/Prefix.cmake | 5 +++++ CMakeModules/TargetOsAndCpu.cmake | 7 ++++++- CMakeModules/Version.cmake | 5 +++++ 10 files changed, 52 insertions(+), 2 deletions(-) diff --git a/CMakeModules/FindDepotTools.cmake b/CMakeModules/FindDepotTools.cmake index c23d4eb..6b2c258 100644 --- a/CMakeModules/FindDepotTools.cmake +++ b/CMakeModules/FindDepotTools.cmake @@ -1,3 +1,8 @@ +if(FIND_DEPOT_TOOLS_INCLUDED) + return() +endif(FIND_DEPOT_TOOLS_INCLUDED) +set(FIND_DEPOT_TOOLS_INCLUDED true) + find_program(GCLIENT_EXECUTABLE NAMES gclient gclient.bat DOC "Path to gclient executable" diff --git a/CMakeModules/FindLibraries.cmake b/CMakeModules/FindLibraries.cmake index 20e15ba..761aa9b 100644 --- a/CMakeModules/FindLibraries.cmake +++ b/CMakeModules/FindLibraries.cmake @@ -1,3 +1,8 @@ +if(FIND_LIBRARIES_INCLUDED) + return() +endif(FIND_LIBRARIES_INCLUDED) +set(FIND_LIBRARIES_INCLUDED true) + # # Find required packages list(APPEND LIBWEBRTC_LIBRARIES webrtc) diff --git a/CMakeModules/GClientConfig.cmake b/CMakeModules/GClientConfig.cmake index 818abac..1d5d458 100644 --- a/CMakeModules/GClientConfig.cmake +++ b/CMakeModules/GClientConfig.cmake @@ -1,3 +1,8 @@ +if(GCLIENT_CONFIG_INCLUDED) + return() +endif(GCLIENT_CONFIG_INCLUDED) +set(GCLIENT_CONFIG_INCLUDED true) + # # Retrieve WebRTC source code # @@ -22,4 +27,4 @@ elseif (TARGET_OS STREQUAL "mac") file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"mac\"]") elseif (TARGET_OS STREQUAL "win") file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"win\"]") -endif (TARGET_OS STREQUAL "android") \ No newline at end of file +endif (TARGET_OS STREQUAL "android") diff --git a/CMakeModules/Install.cmake b/CMakeModules/Install.cmake index ca077c5..8924fcc 100644 --- a/CMakeModules/Install.cmake +++ b/CMakeModules/Install.cmake @@ -1,3 +1,8 @@ +if(INSTALL_INCLUDED) + return() +endif(INSTALL_INCLUDED) +set(INSTALL_INCLUDED true) + # # Install library file(GLOB_RECURSE _LIBRARY_FILES diff --git a/CMakeModules/LibWebRTCCommand.cmake b/CMakeModules/LibWebRTCCommand.cmake index 48c73e4..b7f7e1f 100644 --- a/CMakeModules/LibWebRTCCommand.cmake +++ b/CMakeModules/LibWebRTCCommand.cmake @@ -1,3 +1,8 @@ +if(LIBWEBRTC_COMMAND_INCLUDED) + return() +endif(LIBWEBRTC_COMMAND_INCLUDED) +set(LIBWEBRTC_COMMAND_INCLUDED true) + include(CMakeParseArguments) include(Prefix) diff --git a/CMakeModules/Options.cmake b/CMakeModules/Options.cmake index 65c3e7d..219bc3b 100644 --- a/CMakeModules/Options.cmake +++ b/CMakeModules/Options.cmake @@ -1,3 +1,8 @@ +if(OPTIONS_INCLUDED) + return() +endif(OPTIONS_INCLUDED) +set(OPTIONS_INCLUDED true) + # # Options, flags option(BUILD_TESTS "Build test binaries" OFF) diff --git a/CMakeModules/Package.cmake b/CMakeModules/Package.cmake index 949e6e4..7b949c3 100644 --- a/CMakeModules/Package.cmake +++ b/CMakeModules/Package.cmake @@ -1,3 +1,8 @@ +if(PACKAGE_INCLUDED) + return() +endif(PACKAGE_INCLUDED) +set(PACKAGE_INCLUDED true) + # # Create package set(CPACK_PACKAGE_FILE_NAME "libwebrtc-${LIBWEBRTC_VERSION}-${TARGET_OS}-${TARGET_CPU}") diff --git a/CMakeModules/Prefix.cmake b/CMakeModules/Prefix.cmake index 3d3dcd8..f1b766b 100644 --- a/CMakeModules/Prefix.cmake +++ b/CMakeModules/Prefix.cmake @@ -1,3 +1,8 @@ +if(PREFIX_INCLUDED) + return() +endif(PREFIX_INCLUDED) +set(PREFIX_INCLUDED true) + # # Generate environment variables # diff --git a/CMakeModules/TargetOsAndCpu.cmake b/CMakeModules/TargetOsAndCpu.cmake index bedcffc..20bd4d9 100644 --- a/CMakeModules/TargetOsAndCpu.cmake +++ b/CMakeModules/TargetOsAndCpu.cmake @@ -1,3 +1,8 @@ +if(TARGET_OS_AND_CPU_INCLUDED) + return() +endif(TARGET_OS_AND_CPU_INCLUDED) +set(TARGET_OS_AND_CPU_INCLUDED true) + include(CheckSymbolExists) # @@ -82,4 +87,4 @@ elseif (WIN32) set(LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG "/MTd") set(LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE "/MT") list(APPEND LIBWEBRTC_DEFINITIONS WEBRTC_WIN NOMINMAX _CRT_SECURE_NO_WARNINGS) -endif(UNIX) \ No newline at end of file +endif(UNIX) diff --git a/CMakeModules/Version.cmake b/CMakeModules/Version.cmake index 8840f42..d0706ff 100644 --- a/CMakeModules/Version.cmake +++ b/CMakeModules/Version.cmake @@ -1,3 +1,8 @@ +if(VERSION_INCLUDED) + return() +endif(VERSION_INCLUDED) +set(VERSION_INCLUDED true) + # # Set the project's version From e60dbd57f6e2f45249606166546a17b4dd80e378 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Fri, 17 Mar 2017 23:26:47 +0100 Subject: [PATCH 06/27] Find all libraries first, set HAS_OWN_DEPOT_TOOLS variable --- CMakeLists.txt | 14 +++++++------- CMakeModules/FindDepotTools.cmake | 5 ----- CMakeModules/Options.cmake | 4 ++++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00c466c..0088fa6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,18 +10,18 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} find_package(Git REQUIRED) -if (DEPOT_TOOLS_PATH) +include(FindLibraries) +include(Version) +include(Options) +include(TargetOsAndCpu) + +if (HAS_OWN_DEPOT_TOOLS) find_package(DepotTools REQUIRED) -endif (DEPOT_TOOLS_PATH) +endif (HAS_OWN_DEPOT_TOOLS) if (NOT WIN32) find_package(PythonInterp 2.7 REQUIRED) endif (NOT WIN32) -include(FindLibraries) -include(Version) -include(Options) -include(TargetOsAndCpu) - add_subdirectory(Targets) export(PACKAGE LibWebRTC) diff --git a/CMakeModules/FindDepotTools.cmake b/CMakeModules/FindDepotTools.cmake index 6b2c258..c23d4eb 100644 --- a/CMakeModules/FindDepotTools.cmake +++ b/CMakeModules/FindDepotTools.cmake @@ -1,8 +1,3 @@ -if(FIND_DEPOT_TOOLS_INCLUDED) - return() -endif(FIND_DEPOT_TOOLS_INCLUDED) -set(FIND_DEPOT_TOOLS_INCLUDED true) - find_program(GCLIENT_EXECUTABLE NAMES gclient gclient.bat DOC "Path to gclient executable" diff --git a/CMakeModules/Options.cmake b/CMakeModules/Options.cmake index 219bc3b..1833223 100644 --- a/CMakeModules/Options.cmake +++ b/CMakeModules/Options.cmake @@ -13,6 +13,10 @@ option(BUILD_SHARED_LIB "Build WebRTC as a shared library" OFF) set(WEBRTC_REVISION "" CACHE STRING "WebRTC commit hash to checkout") set(WEBRTC_BRANCH_HEAD "${LIBWEBRTC_WEBRTC_HEAD}" CACHE STRING "WebRTC branch head to checkout") +if (DEPOT_TOOLS_PATH) + set(HAS_OWN_DEPOT_TOOLS 1) +endif (DEPOT_TOOLS_PATH) + if(BUILD_SHARED_LIB) set(LIBRARY_TYPE SHARED) else() From 93438caf7610f53633dfed6bb640c9f07cac9abf Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sat, 18 Mar 2017 12:48:03 +0100 Subject: [PATCH 07/27] README: Add Acknowledgements --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 4c9bef1..9ec2344 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,16 @@ modifications are working on the three major OS (Windows, macOS and Linux). Don't forget to put your name and e-mail address inside the `AUTHORS` file! You can also reach me on [Twitter][twitter] for further discussion. +## Acknowledgements + +Many thanks to Dr. Alex Gouaillard for being an excellent mentor for this +project. + +Everything started from his +« [Automating libwebrtc build with CMake][webrtc-dr-alex-cmake] » blog article, +which was a great source of inspiration for me to create the easiest way to link +the WebRTC library in any native project. + ## License Apache License 2.0 © [Axel Isouard][author] @@ -232,4 +242,5 @@ Apache License 2.0 © [Axel Isouard][author] [w10sdk]:https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk [wdk10]:https://go.microsoft.com/fwlink/p/?LinkId=526733 [twitter]:https://twitter.com/aisouard +[webrtc-dr-alex-cmake]:http://webrtcbydralex.com/index.php/2015/07/22/automating-libwebrtc-build-with-cmake [author]:https://axel.isouard.fr From e3a4e5d64efe8c122352d89724b5af818cbbdc34 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sat, 18 Mar 2017 12:48:30 +0100 Subject: [PATCH 08/27] README: Add CMake syntax highlighting --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9ec2344..24527aa 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repository contains a collection of CMake scripts to help you embed Google's native WebRTC implementation inside your project as simple as this: -``` +```cmake cmake_minimum_required(VERSION 3.3) project(sample) @@ -132,7 +132,7 @@ All you have to do is include the package, then embed the "use file" that will automatically find the required libraries, define the proper compiling flags and include directories. -``` +```cmake find_package(LibWebRTC REQUIRED) include(${LIBWEBRTC_USE_FILE}) From 5a602922c0c41c913cc3375948fa3d95e4b3a718 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sat, 18 Mar 2017 16:00:31 +0100 Subject: [PATCH 09/27] Remove include guards --- CMakeModules/FindLibraries.cmake | 5 ----- CMakeModules/Install.cmake | 5 ----- CMakeModules/Options.cmake | 5 ----- CMakeModules/Package.cmake | 5 ----- CMakeModules/TargetOsAndCpu.cmake | 5 ----- CMakeModules/Version.cmake | 8 -------- 6 files changed, 33 deletions(-) diff --git a/CMakeModules/FindLibraries.cmake b/CMakeModules/FindLibraries.cmake index 761aa9b..20e15ba 100644 --- a/CMakeModules/FindLibraries.cmake +++ b/CMakeModules/FindLibraries.cmake @@ -1,8 +1,3 @@ -if(FIND_LIBRARIES_INCLUDED) - return() -endif(FIND_LIBRARIES_INCLUDED) -set(FIND_LIBRARIES_INCLUDED true) - # # Find required packages list(APPEND LIBWEBRTC_LIBRARIES webrtc) diff --git a/CMakeModules/Install.cmake b/CMakeModules/Install.cmake index 8924fcc..ca077c5 100644 --- a/CMakeModules/Install.cmake +++ b/CMakeModules/Install.cmake @@ -1,8 +1,3 @@ -if(INSTALL_INCLUDED) - return() -endif(INSTALL_INCLUDED) -set(INSTALL_INCLUDED true) - # # Install library file(GLOB_RECURSE _LIBRARY_FILES diff --git a/CMakeModules/Options.cmake b/CMakeModules/Options.cmake index 1833223..665aac7 100644 --- a/CMakeModules/Options.cmake +++ b/CMakeModules/Options.cmake @@ -1,8 +1,3 @@ -if(OPTIONS_INCLUDED) - return() -endif(OPTIONS_INCLUDED) -set(OPTIONS_INCLUDED true) - # # Options, flags option(BUILD_TESTS "Build test binaries" OFF) diff --git a/CMakeModules/Package.cmake b/CMakeModules/Package.cmake index 7b949c3..949e6e4 100644 --- a/CMakeModules/Package.cmake +++ b/CMakeModules/Package.cmake @@ -1,8 +1,3 @@ -if(PACKAGE_INCLUDED) - return() -endif(PACKAGE_INCLUDED) -set(PACKAGE_INCLUDED true) - # # Create package set(CPACK_PACKAGE_FILE_NAME "libwebrtc-${LIBWEBRTC_VERSION}-${TARGET_OS}-${TARGET_CPU}") diff --git a/CMakeModules/TargetOsAndCpu.cmake b/CMakeModules/TargetOsAndCpu.cmake index 20bd4d9..d1f7e3b 100644 --- a/CMakeModules/TargetOsAndCpu.cmake +++ b/CMakeModules/TargetOsAndCpu.cmake @@ -1,8 +1,3 @@ -if(TARGET_OS_AND_CPU_INCLUDED) - return() -endif(TARGET_OS_AND_CPU_INCLUDED) -set(TARGET_OS_AND_CPU_INCLUDED true) - include(CheckSymbolExists) # diff --git a/CMakeModules/Version.cmake b/CMakeModules/Version.cmake index d0706ff..2c1fec9 100644 --- a/CMakeModules/Version.cmake +++ b/CMakeModules/Version.cmake @@ -1,11 +1,3 @@ -if(VERSION_INCLUDED) - return() -endif(VERSION_INCLUDED) -set(VERSION_INCLUDED true) - -# -# Set the project's version - set(LIBWEBRTC_MAJOR_VERSION 0) set(LIBWEBRTC_MINOR_VERSION 0) set(LIBWEBRTC_PATCH_VERSION 1) From b59291f0932a708a396127a2d6a1abba1d82d1b6 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sat, 18 Mar 2017 16:13:36 +0100 Subject: [PATCH 10/27] Manage depot_tools, replace modules, remove Targets folder, fixes #33 --- CMakeLists.txt | 79 ++++++- CMakeModules/DepotTools.cmake | 75 +++++++ .../{Prefix.cmake => Environment.cmake} | 78 +++---- CMakeModules/GClient.cmake | 22 ++ CMakeModules/GClientConfig.cmake | 30 --- CMakeModules/Gn.cmake | 35 +++ CMakeModules/LibWebRTCCommand.cmake | 28 --- Targets/CMakeLists.txt | 205 ------------------ depot_tools/CMakeLists.txt | 27 +++ .../libwebrtc => libwebrtc}/CMakeLists.txt | 0 webrtc/CMakeLists.txt.in | 110 ++++++++++ 11 files changed, 381 insertions(+), 308 deletions(-) create mode 100644 CMakeModules/DepotTools.cmake rename CMakeModules/{Prefix.cmake => Environment.cmake} (50%) create mode 100644 CMakeModules/GClient.cmake delete mode 100644 CMakeModules/GClientConfig.cmake create mode 100644 CMakeModules/Gn.cmake delete mode 100644 CMakeModules/LibWebRTCCommand.cmake delete mode 100644 Targets/CMakeLists.txt create mode 100644 depot_tools/CMakeLists.txt rename {Targets/libwebrtc => libwebrtc}/CMakeLists.txt (100%) create mode 100644 webrtc/CMakeLists.txt.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 0088fa6..64f00c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,5 +23,82 @@ if (NOT WIN32) find_package(PythonInterp 2.7 REQUIRED) endif (NOT WIN32) -add_subdirectory(Targets) +include(ExternalProject) + +if (NOT HAS_OWN_DEPOT_TOOLS) + if (WIN32) + set(GCLIENT_EXECUTABLE ${CMAKE_BINARY_DIR}/depot_tools/src/depot-tools/gclient.bat) + else (WIN32) + set(GCLIENT_EXECUTABLE ${CMAKE_BINARY_DIR}/depot_tools/src/depot-tools/gclient) + endif (WIN32) + + ExternalProject_Add( + depot-tools + + GIT_REPOSITORY https://chromium.googlesource.com/chromium/tools/depot_tools + + PREFIX ${CMAKE_BINARY_DIR}/depot_tools + + CONFIGURE_COMMAND "" + UPDATE_COMMAND "" + PATCH_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) + + set(_NEXT_DEPENDS depot-tools) + set(DEPOT_TOOLS_PATH ${CMAKE_BINARY_DIR}/depot_tools/src/depot-tools) +endif (NOT HAS_OWN_DEPOT_TOOLS) + +ExternalProject_Add( + webrtc-src + + DEPENDS ${_NEXT_DEPENDS} + GIT_REPOSITORY https://chromium.googlesource.com/external/webrtc + + PREFIX ${CMAKE_BINARY_DIR}/webrtc + BINARY_DIR ${CMAKE_BINARY_DIR}/webrtc/build + DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/webrtc/src + SOURCE_DIR ${CMAKE_BINARY_DIR}/webrtc/src + STAMP_DIR ${CMAKE_BINARY_DIR}/webrtc/stamp + TMP_DIR ${CMAKE_BINARY_DIR}/webrtc/tmp + + PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/webrtc/CMakeLists.txt.in ${CMAKE_BINARY_DIR}/webrtc/src/CMakeLists.txt + UPDATE_COMMAND "" + INSTALL_COMMAND "" + + CMAKE_ARGS + -DDEPOT_TOOLS_PATH:PATH=${DEPOT_TOOLS_PATH} + -DGCLIENT_EXECUTABLE:PATH=${GCLIENT_EXECUTABLE} + -DHAS_OWN_DEPOT_TOOLS:PATH=${HAS_OWN_DEPOT_TOOLS} + -DCMAKE_MODULE_PATH:PATH=${CMAKE_MODULE_PATH} + -DTARGET_CPU=${TARGET_CPU} + -DTARGET_OS=${TARGET_OS} + -DWEBRTC_BRANCH_HEAD=${WEBRTC_BRANCH_HEAD} + -DWEBRTC_PARENT_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc + -DWEBRTC_REVISION=${WEBRTC_REVISION} + -DWEBRTC_ROOT_DIR:PATH=${CMAKE_BINARY_DIR} +) + +ExternalProject_Add( + libwebrtc + DEPENDS webrtc-src + + INSTALL_DIR ${CMAKE_BINARY_DIR} + SOURCE_DIR ${CMAKE_SOURCE_DIR}/libwebrtc + BINARY_DIR ${CMAKE_BINARY_DIR}/libwebrtc + + CMAKE_ARGS + -DLIBRARY_TYPE:STRING=${LIBRARY_TYPE} + -DTARGET_OS:STRING=${TARGET_OS} + -DWEBRTC_OUTPUT_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src/out/Default + -DWEBRTC_SOURCE_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src/webrtc + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DINSTALL_CMAKE_DIR:PATH=${CMAKE_BINARY_DIR}/lib/cmake/LibWebRTC +) + +include(Install) +include(Package) + export(PACKAGE LibWebRTC) diff --git a/CMakeModules/DepotTools.cmake b/CMakeModules/DepotTools.cmake new file mode 100644 index 0000000..94a60d0 --- /dev/null +++ b/CMakeModules/DepotTools.cmake @@ -0,0 +1,75 @@ +if (HAS_OWN_DEPOT_TOOLS) + return() +endif (HAS_OWN_DEPOT_TOOLS) + +if (WEBRTC_REVISION) + message(STATUS "Retrieving date for commit ${WEBRTC_REVISION}") + execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%ci ${WEBRTC_REVISION} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE _WEBRTC_COMMIT_DATE) + + if (NOT _WEBRTC_COMMIT_DATE) + message(FATAL_ERROR "-- Unable to find webrtc commit date at ${WEBRTC_REVISION}") + endif (NOT _WEBRTC_COMMIT_DATE) +elseif (WEBRTC_BRANCH_HEAD) + message(STATUS "Retrieving branch-heads refspecs") + execute_process(COMMAND ${GIT_EXECUTABLE} config remote.origin.fetch +refs/branch-heads/*:refs/remotes/branch-heads/* ^\\+refs/branch-heads/\\*:.*$ + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE _ADD_REMOTE_RESULT) + + if (NOT _ADD_REMOTE_RESULT EQUAL 0) + message(FATAL_ERROR "-- Unable to add branch-heads refspec") + endif (NOT _ADD_REMOTE_RESULT EQUAL 0) + + message(STATUS "Fetching ${WEBRTC_BRANCH_HEAD}") + execute_process(COMMAND ${GIT_EXECUTABLE} fetch origin ${WEBRTC_BRANCH_HEAD} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE _WEBRTC_FETCH_RESULT) + + if (NOT _WEBRTC_FETCH_RESULT EQUAL 0) + message(FATAL_ERROR "-- Unable to fetch ${WEBRTC_BRANCH_HEAD}") + endif (NOT _WEBRTC_FETCH_RESULT EQUAL 0) + + message(STATUS "Checking out ${WEBRTC_BRANCH_HEAD}") + execute_process(COMMAND ${GIT_EXECUTABLE} checkout FETCH_HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE _WEBRTC_CHECKOUT_RESULT) + + if (NOT _WEBRTC_CHECKOUT_RESULT EQUAL 0) + message(FATAL_ERROR "-- Unable to checkout ${WEBRTC_BRANCH_HEAD}") + endif (NOT _WEBRTC_CHECKOUT_RESULT EQUAL 0) + + message(STATUS "Retrieving date for commit ${WEBRTC_BRANCH_HEAD}") + execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%ci + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE _WEBRTC_COMMIT_DATE + RESULT_VARIABLE _WEBRTC_COMMIT_DATE_RESULT) + + if (NOT _WEBRTC_COMMIT_DATE_RESULT EQUAL 0) + message(FATAL_ERROR "-- Unable to retrieve the commit date") + endif (NOT _WEBRTC_COMMIT_DATE_RESULT EQUAL 0) +else (WEBRTC_REVISION) + message(FATAL_ERROR "-- Both WEBRTC_REVISION and WEBRTC_BRANCH_HEAD variables are undefined") +endif (WEBRTC_REVISION) + +string(STRIP ${_WEBRTC_COMMIT_DATE} _WEBRTC_COMMIT_DATE) +message(STATUS "Retrieving depot_tools commit before ${_WEBRTC_COMMIT_DATE}") + +execute_process(COMMAND ${GIT_EXECUTABLE} rev-list -n 1 --before=\"${_WEBRTC_COMMIT_DATE}\" master + WORKING_DIRECTORY ${DEPOT_TOOLS_PATH} + OUTPUT_VARIABLE _DEPOT_TOOLS_COMMIT) + +if (NOT _DEPOT_TOOLS_COMMIT) + message(FATAL_ERROR "-- Unable to find depot_tools commit before ${_WEBRTC_COMMIT_DATE}") +endif (NOT _DEPOT_TOOLS_COMMIT) + +string(STRIP ${_DEPOT_TOOLS_COMMIT} _DEPOT_TOOLS_COMMIT) +message(STATUS "Checking out depot_tools to commit ${_DEPOT_TOOLS_COMMIT}") + +execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${_DEPOT_TOOLS_COMMIT} + WORKING_DIRECTORY ${DEPOT_TOOLS_PATH} + RESULT_VARIABLE _DEPOT_TOOLS_CHECKED_OUT) + +if (NOT _DEPOT_TOOLS_CHECKED_OUT EQUAL 0) + message(FATAL_ERROR "-- Unable to checkout depot_tools to commit ${_DEPOT_TOOLS_COMMIT}") +endif (NOT _DEPOT_TOOLS_CHECKED_OUT EQUAL 0) diff --git a/CMakeModules/Prefix.cmake b/CMakeModules/Environment.cmake similarity index 50% rename from CMakeModules/Prefix.cmake rename to CMakeModules/Environment.cmake index f1b766b..a665f31 100644 --- a/CMakeModules/Prefix.cmake +++ b/CMakeModules/Environment.cmake @@ -1,58 +1,48 @@ -if(PREFIX_INCLUDED) - return() -endif(PREFIX_INCLUDED) -set(PREFIX_INCLUDED true) - -# -# Generate environment variables -# -if (DEPOT_TOOLS_PATH) - set(WEBRTC_PATH ${DEPOT_TOOLS_PATH}) -else (DEPOT_TOOLS_PATH) - set(WEBRTC_PATH ${CMAKE_BINARY_DIR}/depot_tools) -endif (DEPOT_TOOLS_PATH) +set(_WEBRTC_PATH ${DEPOT_TOOLS_PATH}) +set(_DEPOT_TOOLS_ENV PATH=${_WEBRTC_PATH}) if (WIN32) get_filename_component(DEPOT_TOOLS_PYTHON_PATH - "${WEBRTC_PATH}/python276_bin" + "${_WEBRTC_PATH}/python276_bin" REALPATH) - list(APPEND WEBRTC_PATH ${DEPOT_TOOLS_PYTHON_PATH}) + list(APPEND _WEBRTC_PATH ${DEPOT_TOOLS_PYTHON_PATH}) endif (WIN32) -list(APPEND WEBRTC_PATH $ENV{PATH}) +list(APPEND _WEBRTC_PATH $ENV{PATH}) if (WIN32) - string(REGEX REPLACE "/" "\\\\" WEBRTC_PATH "${WEBRTC_PATH}") - string(REGEX REPLACE ";" "\\\;" WEBRTC_PATH "${WEBRTC_PATH}") + string(REGEX REPLACE "/" "\\\\" _WEBRTC_PATH "${_WEBRTC_PATH}") + string(REGEX REPLACE ";" "\\\;" _WEBRTC_PATH "${_WEBRTC_PATH}") else (WIN32) - string(REGEX REPLACE ";" ":" WEBRTC_PATH "${WEBRTC_PATH}") + string(REGEX REPLACE ";" ":" _WEBRTC_PATH "${_WEBRTC_PATH}") endif (WIN32) -get_filename_component(CHROMIUM_PYTHONPATH - "${CMAKE_BINARY_DIR}/src/build" +get_filename_component(_CHROMIUM_PYTHONPATH + "${CMAKE_SOURCE_DIR}/build" REALPATH) -if (WIN32) - set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.bat) - set(PREFIX_COMMAND set) - set(PREFIX_HEADER "@ECHO OFF") - set(PREFIX_EVAL "%*") - set(PREFIX_EXECUTE cmd /c ${PREFIX_FILENAME}) - set(PREFIX_NEWLINE \r\n) -else (WIN32) - set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.sh) - set(PREFIX_COMMAND export) - set(PREFIX_HEADER "") - set(PREFIX_EVAL eval\ $@) - set(PREFIX_EXECUTE /bin/sh ${PREFIX_FILENAME}) - set(PREFIX_NEWLINE \n) -endif (WIN32) +if (WIN32) + set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.bat) + set(PREFIX_COMMAND set) + set(PREFIX_HEADER "@ECHO OFF") + set(PREFIX_EVAL "%*") + set(PREFIX_EXECUTE cmd /c ${PREFIX_FILENAME}) + set(PREFIX_NEWLINE \r\n) +else (WIN32) + set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.sh) + set(PREFIX_COMMAND export) + set(PREFIX_HEADER "") + set(PREFIX_EVAL eval\ $@) + set(PREFIX_EXECUTE /bin/sh ${PREFIX_FILENAME}) + set(PREFIX_NEWLINE \n) +endif (WIN32) + +file(WRITE ${PREFIX_FILENAME} "${PREFIX_HEADER} +${PREFIX_COMMAND} PATH=${_WEBRTC_PATH} +${PREFIX_COMMAND} PYTHONPATH=${_CHROMIUM_PYTHONPATH} +${PREFIX_COMMAND} DEPOT_TOOLS_WIN_TOOLCHAIN=0 +${PREFIX_COMMAND} DEPOT_TOOLS_UPDATE=0 +${PREFIX_COMMAND} CHROME_HEADLESS=1 +${PREFIX_EVAL} +") -file(WRITE ${PREFIX_FILENAME} "${PREFIX_HEADER} -${PREFIX_COMMAND} PATH=${WEBRTC_PATH} -${PREFIX_COMMAND} PYTHONPATH=${CHROMIUM_PYTHONPATH} -${PREFIX_COMMAND} DEPOT_TOOLS_WIN_TOOLCHAIN=0 -${PREFIX_COMMAND} DEPOT_TOOLS_UPDATE=0 -${PREFIX_COMMAND} CHROME_HEADLESS=1 -${PREFIX_EVAL} -") diff --git a/CMakeModules/GClient.cmake b/CMakeModules/GClient.cmake new file mode 100644 index 0000000..a42671a --- /dev/null +++ b/CMakeModules/GClient.cmake @@ -0,0 +1,22 @@ +file(WRITE ${WEBRTC_PARENT_DIR}/.gclient "solutions = [ + { + \"url\": \"https://chromium.googlesource.com/external/webrtc.git\", + \"managed\": False, + \"name\": \"src\", + \"deps_file\": \"DEPS\", + \"custom_deps\": {}, + }, +] +") + +if (TARGET_OS STREQUAL "android") + file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"android\", \"unix\"]") +elseif (TARGET_OS STREQUAL "ios") + file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"ios\", \"mac\"]") +elseif (TARGET_OS STREQUAL "linux") + file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"unix\"]") +elseif (TARGET_OS STREQUAL "mac") + file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"mac\"]") +elseif (TARGET_OS STREQUAL "win") + file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"win\"]") +endif (TARGET_OS STREQUAL "android") diff --git a/CMakeModules/GClientConfig.cmake b/CMakeModules/GClientConfig.cmake deleted file mode 100644 index 1d5d458..0000000 --- a/CMakeModules/GClientConfig.cmake +++ /dev/null @@ -1,30 +0,0 @@ -if(GCLIENT_CONFIG_INCLUDED) - return() -endif(GCLIENT_CONFIG_INCLUDED) -set(GCLIENT_CONFIG_INCLUDED true) - -# -# Retrieve WebRTC source code -# -file(WRITE ${CMAKE_BINARY_DIR}/.gclient "solutions = [ - { - \"url\": \"https://chromium.googlesource.com/external/webrtc.git\", - \"managed\": False, - \"name\": \"src\", - \"deps_file\": \"DEPS\", - \"custom_deps\": {}, - }, -] -") - -if (TARGET_OS STREQUAL "android") - file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"android\", \"unix\"]") -elseif (TARGET_OS STREQUAL "ios") - file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"ios\", \"mac\"]") -elseif (TARGET_OS STREQUAL "linux") - file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"unix\"]") -elseif (TARGET_OS STREQUAL "mac") - file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"mac\"]") -elseif (TARGET_OS STREQUAL "win") - file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"win\"]") -endif (TARGET_OS STREQUAL "android") diff --git a/CMakeModules/Gn.cmake b/CMakeModules/Gn.cmake new file mode 100644 index 0000000..cf52c5b --- /dev/null +++ b/CMakeModules/Gn.cmake @@ -0,0 +1,35 @@ +set(_GEN_ARGS "use_gold=false target_cpu=\\\"${TARGET_CPU}\\\" target_os=\\\"${TARGET_OS}\\\"") + +if (MSVC OR XCODE) + set(_GEN_ARGS "${_GEN_ARGS} is_debug=false") +elseif (CMAKE_BUILD_TYPE MATCHES Debug) + set(_GEN_ARGS "${_GEN_ARGS} is_debug=true") +else (MSVC OR XCODE) + set(_GEN_ARGS "${_GEN_ARGS} is_debug=false") +endif (MSVC OR XCODE) + +if (BUILD_TESTS) + set(_GEN_ARGS "${_GEN_ARGS} rtc_include_tests=true") +else (BUILD_TESTS) + set(_GEN_ARGS "${_GEN_ARGS} rtc_include_tests=false") +endif (BUILD_TESTS) + +if (GN_EXTRA_ARGS) + set(_GEN_ARGS "${_GEN_ARGS} ${GN_EXTRA_ARGS}") +endif (GN_EXTRA_ARGS) + +set(_GN_OUT_DIR out/Default) +set(_GEN_COMMAND_LINE gn gen ${_GN_OUT_DIR} --args=\"${_GEN_ARGS}\") + +if (WIN32) + set(_SCRIPT_SUFFIX .bat) +elseif (UNIX) + set(_SCRIPT_SUFFIX .sh) + set(_GEN_COMMAND sh) +endif (WIN32) + +string(REPLACE ";" " " _GEN_COMMAND_STR "${_GEN_COMMAND_LINE}") +set(_GN_SCRIPT_FILENAME ${WEBRTC_PARENT_DIR}/gn-gen${_SCRIPT_SUFFIX}) +file(WRITE ${_GN_SCRIPT_FILENAME} ${_GEN_COMMAND_STR}) + +set(_GEN_COMMAND ${_GEN_COMMAND} ${_GN_SCRIPT_FILENAME}) diff --git a/CMakeModules/LibWebRTCCommand.cmake b/CMakeModules/LibWebRTCCommand.cmake deleted file mode 100644 index b7f7e1f..0000000 --- a/CMakeModules/LibWebRTCCommand.cmake +++ /dev/null @@ -1,28 +0,0 @@ -if(LIBWEBRTC_COMMAND_INCLUDED) - return() -endif(LIBWEBRTC_COMMAND_INCLUDED) -set(LIBWEBRTC_COMMAND_INCLUDED true) - -include(CMakeParseArguments) -include(Prefix) - -function(libwebrtc_command) - set(ONE_VALUE_ARGS NAME COMMENT DEPENDS WORKING_DIRECTORY) - set(MULTI_VALUE_ARGS COMMAND) - cmake_parse_arguments(COMMAND "" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN} ) - - set(CMF_DIR ${CMAKE_BINARY_DIR}/CMakeFiles) - set(STAMP_FILE "${CMF_DIR}/${COMMAND_NAME}-complete") - - add_custom_command( - OUTPUT ${STAMP_FILE} - COMMENT ${COMMAND_COMMENT} - COMMAND ${PREFIX_EXECUTE} ${COMMAND_COMMAND} - COMMAND ${CMAKE_COMMAND} -E touch ${STAMP_FILE} - WORKING_DIRECTORY ${COMMAND_WORKING_DIRECTORY} - ) - - add_custom_target(${COMMAND_NAME} ALL DEPENDS ${STAMP_FILE}) - - add_dependencies(${COMMAND_NAME} ${COMMAND_DEPENDS}) -endfunction() diff --git a/Targets/CMakeLists.txt b/Targets/CMakeLists.txt deleted file mode 100644 index dc71cee..0000000 --- a/Targets/CMakeLists.txt +++ /dev/null @@ -1,205 +0,0 @@ -include(ExternalProject) -include(LibWebRTCCommand) -include(GClientConfig) - -set(_DOWNLOAD_COMMAND ${GCLIENT_EXECUTABLE} sync --with_branch_heads --nohooks) -if (WEBRTC_REVISION) - set(_DOWNLOAD_COMMAND ${_DOWNLOAD_COMMAND} --revision ${WEBRTC_REVISION}) -endif (WEBRTC_REVISION) - -ExternalProject_Add( - webrtc-src - PREFIX ${CMAKE_BINARY_DIR} - BINARY_DIR ${CMAKE_BINARY_DIR} - SOURCE_DIR ${CMAKE_BINARY_DIR} - DOWNLOAD_DIR ${CMAKE_BINARY_DIR} - - DOWNLOAD_COMMAND ${PREFIX_EXECUTE} ${_DOWNLOAD_COMMAND} - BUILD_COMMAND "" - INSTALL_COMMAND "" -) - -set(_NEXT_DEPENDS webrtc-src) -if (NOT WEBRTC_REVISION) - libwebrtc_command( - NAME webrtc-fetch-refs - COMMAND ${GIT_EXECUTABLE} fetch origin ${WEBRTC_BRANCH_HEAD} - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src" - COMMENT "Fetching branch heads" - DEPENDS webrtc-src - ) - - libwebrtc_command( - NAME webrtc-checkout-fetch-head - COMMAND ${GIT_EXECUTABLE} checkout FETCH_HEAD - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src" - COMMENT "Checking out fetch head" - DEPENDS webrtc-fetch-refs - ) - - set(_NEXT_DEPENDS webrtc-checkout-fetch-head) -endif (NOT WEBRTC_REVISION) - -libwebrtc_command( - NAME webrtc-update-clang - COMMAND ${PYTHON_EXECUTABLE} src/tools/clang/scripts/update.py - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - COMMENT "Updating clang" - DEPENDS ${_NEXT_DEPENDS} -) - -set(_NEXT_DEPENDS webrtc-update-clang) -if (UNIX AND NOT APPLE) - libwebrtc_command( - NAME webrtc-install-sysroot - COMMAND ${CMAKE_BINARY_DIR}/src/build/linux/sysroot_scripts/install-sysroot.py --running-as-hook - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - COMMENT "Installing Linux sysroots" - DEPENDS ${_NEXT_DEPENDS} - ) - set(_NEXT_DEPENDS webrtc-install-sysroot) - - set(_PLATFORM linux*) - set(_FOLDER linux64) -elseif (APPLE) - set(_PLATFORM darwin) - set(_FOLDER mac) -elseif (WIN32) - libwebrtc_command( - NAME webrtc-vs-toolchain - COMMAND ${PYTHON_EXECUTABLE} src/build/vs_toolchain.py update - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - COMMENT "Updating Visual Studio toolchain" - DEPENDS ${_NEXT_DEPENDS} - ) - set(_NEXT_DEPENDS webrtc-vs-toolchain) - - set(_PLATFORM win32) - set(_FOLDER win) - set(_SUFFIX .exe) -endif (UNIX AND NOT APPLE) - -libwebrtc_command( - NAME webrtc-fetch-gn - COMMAND download_from_google_storage --no_resume --platform=${_PLATFORM} --no_auth --bucket chromium-gn -s src/buildtools/${_FOLDER}/gn${_SUFFIX}.sha1 - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - COMMENT "Fetching gn binary" - DEPENDS ${_NEXT_DEPENDS} -) - -libwebrtc_command( - NAME webrtc-fetch-clang-format - COMMAND download_from_google_storage --no_resume --platform=${_PLATFORM} --no_auth --bucket chromium-clang-format -s src/buildtools/${_FOLDER}/clang-format${_SUFFIX}.sha1 - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - COMMENT "Fetching clang-format binary" - DEPENDS webrtc-fetch-gn -) - -# -# Android dependencies -set(_NEXT_DEPENDS webrtc-fetch-clang-format) -if (TARGET_OS STREQUAL "android") - libwebrtc_command( - NAME webrtc-android-fetch-play-services - COMMAND ${PYTHON_EXECUTABLE} src/build/android/play_services/update.py download - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - COMMENT "Fetching Google Play Services" - DEPENDS webrtc-fetch-clang-format - ) - - libwebrtc_command( - NAME webrtc-android-update-lastchange - COMMAND ${PYTHON_EXECUTABLE} src/build/util/lastchange.py -o src/build/util/LASTCHANGE - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - COMMENT "Updating src/build/util/LASTCHANGE" - DEPENDS webrtc-android-fetch-play-services - ) - - set(_NEXT_DEPENDS webrtc-android-update-lastchange) - foreach(_DEPENDENCY_NAME android-support-test-runner espresso guava hamcrest javax-inject) - string(REPLACE "-" "_" _DEPENDENCY_FOLDER ${_DEPENDENCY_NAME}) - - libwebrtc_command( - NAME webrtc-android-fetch-${_DEPENDENCY_NAME} - COMMAND ${PYTHON_EXECUTABLE} src/build/android/update_deps/update_third_party_deps.py download -b chromium-${_DEPENDENCY_NAME} -l third_party/${_DEPENDENCY_FOLDER} - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - COMMENT "Fetching Android dependency: ${_DEPENDENCY_NAME}" - DEPENDS ${_NEXT_DEPENDS} - ) - - set(_NEXT_DEPENDS webrtc-android-fetch-${_DEPENDENCY_NAME}) - endforeach(_DEPENDENCY_NAME) -endif (TARGET_OS STREQUAL "android") - -# -# Generate build files -set(_GEN_ARGS use_gold=false target_cpu=\\"${TARGET_CPU}\\" target_os=\\"${TARGET_OS}\\") - -if (MSVC OR XCODE) - set(_GEN_ARGS ${_GEN_ARGS} is_debug=$<$:true>$<$:false>) -elseif (CMAKE_BUILD_TYPE MATCHES Debug) - set(_GEN_ARGS ${_GEN_ARGS} is_debug=true) -else (MSVC OR XCODE) - set(_GEN_ARGS ${_GEN_ARGS} is_debug=false) -endif (MSVC OR XCODE) - -if (BUILD_TESTS) - set(_GEN_ARGS ${_GEN_ARGS} rtc_include_tests=true) -else (BUILD_TESTS) - set(_GEN_ARGS ${_GEN_ARGS} rtc_include_tests=false) -endif (BUILD_TESTS) - -if (LIBRARY_TYPE STREQUAL STATIC) - set(_GEN_ARGS ${_GEN_ARGS} is_component_build=false) -else (LIBRARY_TYPE STREQUAL STATIC) - set(_GEN_ARGS ${_GEN_ARGS} is_component_build=true) -endif (LIBRARY_TYPE STREQUAL STATIC) - -set(_GEN_ARGS ${_GEN_ARGS} ${GN_EXTRA_ARGS}) - -if (WIN32) - set(_GEN_COMMAND gn gen out/Default --args="${_GEN_ARGS}") -elseif (UNIX) - set(_GEN_COMMAND gn gen out/Default --args='"${_GEN_ARGS}"') -endif (WIN32) - -libwebrtc_command( - NAME webrtc-generate - COMMAND ${_GEN_COMMAND} - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src" - COMMENT "Generating build files" - DEPENDS ${_NEXT_DEPENDS} -) - -# -# Run ninja -libwebrtc_command( - NAME webrtc-build - COMMAND ninja ${NINJA_ARGS} -C out/Default - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src" - COMMENT "Building WebRTC" - DEPENDS webrtc-generate -) - -# -# Link the library -ExternalProject_Add( - libwebrtc - DEPENDS webrtc-build - - INSTALL_DIR ${CMAKE_BINARY_DIR} - SOURCE_DIR ${CMAKE_SOURCE_DIR}/Targets/libwebrtc - BINARY_DIR ${CMAKE_BINARY_DIR}/libwebrtc - - CMAKE_ARGS - -DLIBRARY_TYPE:STRING=${LIBRARY_TYPE} - -DTARGET_OS:STRING=${TARGET_OS} - -DWEBRTC_OUTPUT_DIR:PATH=${CMAKE_BINARY_DIR}/src/out/Default - -DWEBRTC_SOURCE_DIR:PATH=${CMAKE_BINARY_DIR}/src/webrtc - -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DINSTALL_CMAKE_DIR:PATH=${CMAKE_BINARY_DIR}/lib/cmake/LibWebRTC -) - -include(Install) -include(Package) diff --git a/depot_tools/CMakeLists.txt b/depot_tools/CMakeLists.txt new file mode 100644 index 0000000..7ea078a --- /dev/null +++ b/depot_tools/CMakeLists.txt @@ -0,0 +1,27 @@ +if (DEPOT_TOOLS_PATH) + return() +endif (DEPOT_TOOLS_PATH) + +include(ExternalProject) + +if (WIN32) + set(GCLIENT_EXECUTABLE ${CMAKE_BINARY_DIR}/depot_tools/gclient.bat) +else (WIN32) + set(GCLIENT_EXECUTABLE ${CMAKE_BINARY_DIR}/depot_tools/gclient) +endif (WIN32) + +ExternalProject_Add( + depot-tools + + GIT_REPOSITORY https://chromium.googlesource.com/chromium/tools/depot_tools + + PREFIX ${CMAKE_BINARY_DIR}/depot_tools + + CONFIGURE_COMMAND "" + UPDATE_COMMAND "" + PATCH_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" +) + +set(_NEXT_DEPENDS depot-tools) diff --git a/Targets/libwebrtc/CMakeLists.txt b/libwebrtc/CMakeLists.txt similarity index 100% rename from Targets/libwebrtc/CMakeLists.txt rename to libwebrtc/CMakeLists.txt diff --git a/webrtc/CMakeLists.txt.in b/webrtc/CMakeLists.txt.in new file mode 100644 index 0000000..d1d229e --- /dev/null +++ b/webrtc/CMakeLists.txt.in @@ -0,0 +1,110 @@ +cmake_minimum_required(VERSION 3.3) +project(webrtc) + +find_package(Git REQUIRED) +if (WIN32) + set(PYTHON_EXECUTABLE ${DEPOT_TOOLS_PATH}/python.bat) +else (WIN32) + find_package(PythonInterp 2.7 REQUIRED) +endif (WIN32) + +include(DepotTools) +include(GClient) +include(Environment) + +message(STATUS "Synchronizing webrtc") +set(_SYNC_COMMAND ${GCLIENT_EXECUTABLE} sync --nohooks) +execute_process(COMMAND ${PREFIX_EXECUTE} ${_SYNC_COMMAND} + WORKING_DIRECTORY ${WEBRTC_PARENT_DIR} + RESULT_VARIABLE _SYNCHRONIZED_WEBRTC) + +if (NOT _SYNCHRONIZED_WEBRTC EQUAL 0) + message(FATAL_ERROR "Unable to synchronize webrtc ${PREFIX_EXECUTE} ${_SYNC_COMMAND}") +endif (NOT _SYNCHRONIZED_WEBRTC EQUAL 0) + +message(STATUS "Updating clang") +set(_UPDATE_CLANG_COMMAND ${PYTHON_EXECUTABLE} src/tools/clang/scripts/update.py) +execute_process(COMMAND ${PREFIX_EXECUTE} ${_UPDATE_CLANG_COMMAND} + WORKING_DIRECTORY ${WEBRTC_PARENT_DIR} + RESULT_VARIABLE _CLANG_UPDATED) + +if (NOT _CLANG_UPDATED EQUAL 0) + message(FATAL_ERROR "Unable to update clang") +endif (NOT _CLANG_UPDATED EQUAL 0) + +if (UNIX AND NOT APPLE) + message(STATUS "Retrieving sysroot") + set(_SYSROOT_COMMAND ${PYTHON_EXECUTABLE} ${WEBRTC_PARENT_DIR}/src/build/linux/sysroot_scripts/install-sysroot.py --running-as-hook) + execute_process(COMMAND ${PREFIX_EXECUTE} ${_SYSROOT_COMMAND} + WORKING_DIRECTORY ${WEBRTC_PARENT_DIR} + RESULT_VARIABLE _SYSROOT_RETRIEVED) + + if (NOT _SYSROOT_RETRIEVED EQUAL 0) + message(FATAL_ERROR "Unable to retrieve the sysroot") + endif (NOT _SYSROOT_RETRIEVED EQUAL 0) + + set(_PLATFORM linux*) + set(_FOLDER linux64) +elseif (APPLE) + set(_PLATFORM darwin) + set(_FOLDER mac) +elseif (WIN32) + message(STATUS "Retrieving Visual Studio toolchain") + set(_TOOLCHAIN_COMMAND ${PYTHON_EXECUTABLE} src/build/vs_toolchain.py update) + execute_process(COMMAND ${PREFIX_EXECUTE} ${_TOOLCHAIN_COMMAND} + WORKING_DIRECTORY ${WEBRTC_PARENT_DIR} + RESULT_VARIABLE _VS_TOOLCHAIN_RETRIEVED) + + if (NOT _VS_TOOLCHAIN_RETRIEVED EQUAL 0) + message(FATAL_ERROR "Unable to retrieve Visual Studio toolchain") + endif (NOT _VS_TOOLCHAIN_RETRIEVED EQUAL 0) + + set(_PLATFORM win32) + set(_FOLDER win) + set(_SUFFIX .exe) +endif (UNIX AND NOT APPLE) + +message(STATUS "Fetching gn${_SUFFIX} for ${_PLATFORM}") +set(_GN_COMMAND download_from_google_storage --no_resume --platform=${_PLATFORM} + --no_auth --bucket chromium-gn + -s src/buildtools/${_FOLDER}/gn${_SUFFIX}.sha1) +execute_process(COMMAND ${PREFIX_EXECUTE} ${_GN_COMMAND} + WORKING_DIRECTORY ${WEBRTC_PARENT_DIR} + RESULT_VARIABLE _GN_RETRIEVED) + +if (NOT _GN_RETRIEVED EQUAL 0) + message(FATAL_ERROR "Unable to retrieve clang-format${_SUFFIX}") +endif (NOT _GN_RETRIEVED EQUAL 0) + +message(STATUS "Fetching clang-format${_SUFFIX} for ${_PLATFORM}") +set(_CLANG_FORMAT_COMMAND download_from_google_storage --no_resume + --platform=${_PLATFORM} --no_auth --bucket chromium-clang-format + -s src/buildtools/${_FOLDER}/clang-format${_SUFFIX}.sha1) +execute_process(COMMAND ${PREFIX_EXECUTE} ${_CLANG_FORMAT_COMMAND} + WORKING_DIRECTORY ${WEBRTC_PARENT_DIR} + RESULT_VARIABLE _CLANG_FORMAT_RETRIEVED) + +if (NOT _CLANG_FORMAT_RETRIEVED EQUAL 0) + message(FATAL_ERROR "Unable to retrieve clang-format${_SUFFIX}") +endif (NOT _CLANG_FORMAT_RETRIEVED EQUAL 0) + +include(Gn) + +message(STATUS "Generating build files: ${_GEN_COMMAND}") +execute_process(COMMAND ${PREFIX_EXECUTE} ${_GEN_COMMAND} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE _BUILD_GENERATED) + +if (NOT _BUILD_GENERATED EQUAL 0) + message(FATAL_ERROR "Unable to execute ${_GEN_COMMAND}") +endif (NOT _BUILD_GENERATED EQUAL 0) + +message(STATUS "Running ninja") +set(_NINJA_COMMAND ninja ${NINJA_ARGS} -C out/Default) +execute_process(COMMAND ${PREFIX_EXECUTE} ${_NINJA_COMMAND} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE _NINJA_DONE) + +if (NOT _NINJA_DONE EQUAL 0) + message(FATAL_ERROR "Unable to build webrtc") +endif (NOT _NINJA_DONE EQUAL 0) From b294fac6276e80ff6b8cfcbc90b761a3ffe09c60 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 08:29:30 +0100 Subject: [PATCH 11/27] Remove unused PREFIX_NEWLINE variable --- CMakeModules/Environment.cmake | 46 ++++++++++++++++------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/CMakeModules/Environment.cmake b/CMakeModules/Environment.cmake index a665f31..069d4f8 100644 --- a/CMakeModules/Environment.cmake +++ b/CMakeModules/Environment.cmake @@ -21,28 +21,26 @@ get_filename_component(_CHROMIUM_PYTHONPATH "${CMAKE_SOURCE_DIR}/build" REALPATH) -if (WIN32) - set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.bat) - set(PREFIX_COMMAND set) - set(PREFIX_HEADER "@ECHO OFF") - set(PREFIX_EVAL "%*") - set(PREFIX_EXECUTE cmd /c ${PREFIX_FILENAME}) - set(PREFIX_NEWLINE \r\n) -else (WIN32) - set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.sh) - set(PREFIX_COMMAND export) - set(PREFIX_HEADER "") - set(PREFIX_EVAL eval\ $@) - set(PREFIX_EXECUTE /bin/sh ${PREFIX_FILENAME}) - set(PREFIX_NEWLINE \n) -endif (WIN32) - -file(WRITE ${PREFIX_FILENAME} "${PREFIX_HEADER} -${PREFIX_COMMAND} PATH=${_WEBRTC_PATH} -${PREFIX_COMMAND} PYTHONPATH=${_CHROMIUM_PYTHONPATH} -${PREFIX_COMMAND} DEPOT_TOOLS_WIN_TOOLCHAIN=0 -${PREFIX_COMMAND} DEPOT_TOOLS_UPDATE=0 -${PREFIX_COMMAND} CHROME_HEADLESS=1 -${PREFIX_EVAL} -") +if (WIN32) + set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.bat) + set(PREFIX_COMMAND set) + set(PREFIX_HEADER "@ECHO OFF") + set(PREFIX_EVAL "%*") + set(PREFIX_EXECUTE cmd /c ${PREFIX_FILENAME}) +else (WIN32) + set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.sh) + set(PREFIX_COMMAND export) + set(PREFIX_HEADER "") + set(PREFIX_EVAL eval\ $@) + set(PREFIX_EXECUTE /bin/sh ${PREFIX_FILENAME}) +endif (WIN32) + +file(WRITE ${PREFIX_FILENAME} "${PREFIX_HEADER} +${PREFIX_COMMAND} PATH=${_WEBRTC_PATH} +${PREFIX_COMMAND} PYTHONPATH=${_CHROMIUM_PYTHONPATH} +${PREFIX_COMMAND} DEPOT_TOOLS_WIN_TOOLCHAIN=0 +${PREFIX_COMMAND} DEPOT_TOOLS_UPDATE=0 +${PREFIX_COMMAND} CHROME_HEADLESS=1 +${PREFIX_EVAL} +") From bbdd74ce9a4b4cc28da93a0ff99830ae8f9796b1 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 10:17:26 +0100 Subject: [PATCH 12/27] Add libwebrtc_execute function, use it in DepotTools.cmake --- CMakeModules/DepotTools.cmake | 18 +++++----- CMakeModules/LibWebRTCExecute.cmake | 51 +++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 CMakeModules/LibWebRTCExecute.cmake diff --git a/CMakeModules/DepotTools.cmake b/CMakeModules/DepotTools.cmake index 94a60d0..7ecb5d3 100644 --- a/CMakeModules/DepotTools.cmake +++ b/CMakeModules/DepotTools.cmake @@ -2,15 +2,17 @@ if (HAS_OWN_DEPOT_TOOLS) return() endif (HAS_OWN_DEPOT_TOOLS) -if (WEBRTC_REVISION) - message(STATUS "Retrieving date for commit ${WEBRTC_REVISION}") - execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%ci ${WEBRTC_REVISION} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE _WEBRTC_COMMIT_DATE) +include(LibWebRTCExecute) - if (NOT _WEBRTC_COMMIT_DATE) - message(FATAL_ERROR "-- Unable to find webrtc commit date at ${WEBRTC_REVISION}") - endif (NOT _WEBRTC_COMMIT_DATE) +if (WEBRTC_REVISION) + libwebrtc_execute( + COMMAND ${GIT_EXECUTABLE} log -1 --format=%ci ${WEBRTC_REVISION} + OUTPUT_VARIABLE _WEBRTC_COMMIT_DATE + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + STAMPFILE webrtc-commit-date + STATUS "Retrieving date for commit ${WEBRTC_REVISION}" + ERROR "Unable to find webrtc commit date at ${WEBRTC_REVISION}" + ) elseif (WEBRTC_BRANCH_HEAD) message(STATUS "Retrieving branch-heads refspecs") execute_process(COMMAND ${GIT_EXECUTABLE} config remote.origin.fetch +refs/branch-heads/*:refs/remotes/branch-heads/* ^\\+refs/branch-heads/\\*:.*$ diff --git a/CMakeModules/LibWebRTCExecute.cmake b/CMakeModules/LibWebRTCExecute.cmake new file mode 100644 index 0000000..e5c93f7 --- /dev/null +++ b/CMakeModules/LibWebRTCExecute.cmake @@ -0,0 +1,51 @@ +if (LIBWEBRTC_EXECUTE_INCLUDED) + return() +endif (LIBWEBRTC_EXECUTE_INCLUDED) +set(LIBWEBRTC_EXECUTE_INCLUDED true) + +include(CMakeParseArguments) +include(Environment) + +function (libwebrtc_execute) + set(ONE_VALUE_ARGS OUTPUT_VARIABLE WORKING_DIRECTORY STAMPFILE STATUS ERROR) + set(MULTI_VALUE_ARGS COMMAND) + cmake_parse_arguments(COMMAND "" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN}) + + set(CMF_DIR ${CMAKE_BINARY_DIR}/CMakeFiles) + + if (COMMAND_STAMPFILE) + set(STAMP_FILE "${CMF_DIR}/${COMMAND_STAMPFILE}") + + if (EXISTS ${STAMP_FILE}) + if (COMMAND_OUTPUT_VARIABLE) + file(READ ${STAMP_FILE} _OUTPUT) + + if (_OUTPUT) + set(${COMMAND_OUTPUT_VARIABLE} ${_OUTPUT} PARENT_SCOPE) + endif (_OUTPUT) + endif (COMMAND_OUTPUT_VARIABLE) + + return() + endif (EXISTS ${STAMP_FILE}) + endif (COMMAND_STAMPFILE) + + if (COMMAND_STATUS) + message(STATUS ${COMMAND_STATUS}) + endif (COMMAND_STATUS) + + execute_process(COMMAND ${COMMAND_COMMAND} + WORKING_DIRECTORY ${COMMAND_WORKING_DIRECTORY} + OUTPUT_VARIABLE _OUTPUT) + + if (NOT _OUTPUT) + message(FATAL_ERROR "-- " ${COMMAND_ERROR}) + endif (NOT _OUTPUT) + + if (COMMAND_STAMP_FILE) + file(WRITE ${STAMP_FILE} ${_OUTPUT}) + endif (COMMAND_STAMP_FILE) + + if (COMMAND_OUTPUT_VARIABLE) + set(${COMMAND_OUTPUT_VARIABLE} ${_OUTPUT} PARENT_SCOPE) + endif (COMMAND_OUTPUT_VARIABLE) +endfunction () From 17ef828ce251acc06f7793a6161056af0b7e1363 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 10:20:45 +0100 Subject: [PATCH 13/27] Use libwebrtc_command instead of execute_process --- CMakeModules/LibWebRTCCommand.cmake | 30 +++++++ webrtc/CMakeLists.txt.in | 130 +++++++++++++--------------- 2 files changed, 90 insertions(+), 70 deletions(-) create mode 100644 CMakeModules/LibWebRTCCommand.cmake diff --git a/CMakeModules/LibWebRTCCommand.cmake b/CMakeModules/LibWebRTCCommand.cmake new file mode 100644 index 0000000..253b4e6 --- /dev/null +++ b/CMakeModules/LibWebRTCCommand.cmake @@ -0,0 +1,30 @@ +if(LIBWEBRTC_COMMAND_INCLUDED) + return() +endif(LIBWEBRTC_COMMAND_INCLUDED) +set(LIBWEBRTC_COMMAND_INCLUDED true) + +include(CMakeParseArguments) +include(Environment) + +function(libwebrtc_command) + set(ONE_VALUE_ARGS NAME COMMENT WORKING_DIRECTORY) + set(MULTI_VALUE_ARGS COMMAND DEPENDS) + cmake_parse_arguments(COMMAND "" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN} ) + + set(CMF_DIR ${CMAKE_BINARY_DIR}/CMakeFiles) + set(STAMP_FILE "${CMF_DIR}/${COMMAND_NAME}-complete") + + add_custom_command( + OUTPUT ${STAMP_FILE} + COMMENT ${COMMAND_COMMENT} + COMMAND ${PREFIX_EXECUTE} ${COMMAND_COMMAND} + COMMAND ${CMAKE_COMMAND} -E touch ${STAMP_FILE} + WORKING_DIRECTORY ${COMMAND_WORKING_DIRECTORY} + ) + + add_custom_target(${COMMAND_NAME} ALL DEPENDS ${STAMP_FILE}) + + if (COMMAND_DEPENDS) + add_dependencies(${COMMAND_NAME} ${COMMAND_DEPENDS}) + endif (COMMAND_DEPENDS) +endfunction() diff --git a/webrtc/CMakeLists.txt.in b/webrtc/CMakeLists.txt.in index d1d229e..09e6bd6 100644 --- a/webrtc/CMakeLists.txt.in +++ b/webrtc/CMakeLists.txt.in @@ -11,37 +11,31 @@ endif (WIN32) include(DepotTools) include(GClient) include(Environment) - -message(STATUS "Synchronizing webrtc") -set(_SYNC_COMMAND ${GCLIENT_EXECUTABLE} sync --nohooks) -execute_process(COMMAND ${PREFIX_EXECUTE} ${_SYNC_COMMAND} - WORKING_DIRECTORY ${WEBRTC_PARENT_DIR} - RESULT_VARIABLE _SYNCHRONIZED_WEBRTC) - -if (NOT _SYNCHRONIZED_WEBRTC EQUAL 0) - message(FATAL_ERROR "Unable to synchronize webrtc ${PREFIX_EXECUTE} ${_SYNC_COMMAND}") -endif (NOT _SYNCHRONIZED_WEBRTC EQUAL 0) - -message(STATUS "Updating clang") -set(_UPDATE_CLANG_COMMAND ${PYTHON_EXECUTABLE} src/tools/clang/scripts/update.py) -execute_process(COMMAND ${PREFIX_EXECUTE} ${_UPDATE_CLANG_COMMAND} - WORKING_DIRECTORY ${WEBRTC_PARENT_DIR} - RESULT_VARIABLE _CLANG_UPDATED) - -if (NOT _CLANG_UPDATED EQUAL 0) - message(FATAL_ERROR "Unable to update clang") -endif (NOT _CLANG_UPDATED EQUAL 0) +include(LibWebRTCCommand) + +libwebrtc_command( + NAME webrtc-sync + COMMAND ${GCLIENT_EXECUTABLE} sync --nohooks + WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}" + COMMENT "Synchronizing WebRTC" +) + +libwebrtc_command( + NAME webrtc-clang + COMMAND ${PYTHON_EXECUTABLE} src/tools/clang/scripts/update.py + WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}" + COMMENT "Updating clang" + DEPENDS webrtc-sync +) if (UNIX AND NOT APPLE) - message(STATUS "Retrieving sysroot") - set(_SYSROOT_COMMAND ${PYTHON_EXECUTABLE} ${WEBRTC_PARENT_DIR}/src/build/linux/sysroot_scripts/install-sysroot.py --running-as-hook) - execute_process(COMMAND ${PREFIX_EXECUTE} ${_SYSROOT_COMMAND} - WORKING_DIRECTORY ${WEBRTC_PARENT_DIR} - RESULT_VARIABLE _SYSROOT_RETRIEVED) - - if (NOT _SYSROOT_RETRIEVED EQUAL 0) - message(FATAL_ERROR "Unable to retrieve the sysroot") - endif (NOT _SYSROOT_RETRIEVED EQUAL 0) + libwebrtc_command( + NAME webrtc-toolchain + COMMAND ${PYTHON_EXECUTABLE} ${WEBRTC_PARENT_DIR}/src/build/linux/sysroot_scripts/install-sysroot.py --running-as-hook + WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}" + COMMENT "Retrieving sysroot" + DEPENDS webrtc-sync + ) set(_PLATFORM linux*) set(_FOLDER linux64) @@ -49,62 +43,58 @@ elseif (APPLE) set(_PLATFORM darwin) set(_FOLDER mac) elseif (WIN32) - message(STATUS "Retrieving Visual Studio toolchain") - set(_TOOLCHAIN_COMMAND ${PYTHON_EXECUTABLE} src/build/vs_toolchain.py update) - execute_process(COMMAND ${PREFIX_EXECUTE} ${_TOOLCHAIN_COMMAND} - WORKING_DIRECTORY ${WEBRTC_PARENT_DIR} - RESULT_VARIABLE _VS_TOOLCHAIN_RETRIEVED) - - if (NOT _VS_TOOLCHAIN_RETRIEVED EQUAL 0) - message(FATAL_ERROR "Unable to retrieve Visual Studio toolchain") - endif (NOT _VS_TOOLCHAIN_RETRIEVED EQUAL 0) + libwebrtc_command( + NAME webrtc-toolchain + COMMAND ${PYTHON_EXECUTABLE} src/build/vs_toolchain.py update + WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}" + COMMENT "Retrieving Visual Studio toolchain" + DEPENDS webrtc-sync + ) set(_PLATFORM win32) set(_FOLDER win) set(_SUFFIX .exe) endif (UNIX AND NOT APPLE) -message(STATUS "Fetching gn${_SUFFIX} for ${_PLATFORM}") set(_GN_COMMAND download_from_google_storage --no_resume --platform=${_PLATFORM} --no_auth --bucket chromium-gn -s src/buildtools/${_FOLDER}/gn${_SUFFIX}.sha1) -execute_process(COMMAND ${PREFIX_EXECUTE} ${_GN_COMMAND} - WORKING_DIRECTORY ${WEBRTC_PARENT_DIR} - RESULT_VARIABLE _GN_RETRIEVED) -if (NOT _GN_RETRIEVED EQUAL 0) - message(FATAL_ERROR "Unable to retrieve clang-format${_SUFFIX}") -endif (NOT _GN_RETRIEVED EQUAL 0) +libwebrtc_command( + NAME webrtc-gn + COMMAND ${_GN_COMMAND} + WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}" + COMMENT "Fetching gn${_SUFFIX} for ${_PLATFORM}" + DEPENDS webrtc-sync +) -message(STATUS "Fetching clang-format${_SUFFIX} for ${_PLATFORM}") set(_CLANG_FORMAT_COMMAND download_from_google_storage --no_resume --platform=${_PLATFORM} --no_auth --bucket chromium-clang-format -s src/buildtools/${_FOLDER}/clang-format${_SUFFIX}.sha1) -execute_process(COMMAND ${PREFIX_EXECUTE} ${_CLANG_FORMAT_COMMAND} - WORKING_DIRECTORY ${WEBRTC_PARENT_DIR} - RESULT_VARIABLE _CLANG_FORMAT_RETRIEVED) -if (NOT _CLANG_FORMAT_RETRIEVED EQUAL 0) - message(FATAL_ERROR "Unable to retrieve clang-format${_SUFFIX}") -endif (NOT _CLANG_FORMAT_RETRIEVED EQUAL 0) +libwebrtc_command( + NAME webrtc-clang-format + COMMAND ${_CLANG_FORMAT_COMMAND} + WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}" + COMMENT "Fetching clang-format${_SUFFIX} for ${_PLATFORM}" + DEPENDS webrtc-sync +) include(Gn) -message(STATUS "Generating build files: ${_GEN_COMMAND}") -execute_process(COMMAND ${PREFIX_EXECUTE} ${_GEN_COMMAND} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - RESULT_VARIABLE _BUILD_GENERATED) - -if (NOT _BUILD_GENERATED EQUAL 0) - message(FATAL_ERROR "Unable to execute ${_GEN_COMMAND}") -endif (NOT _BUILD_GENERATED EQUAL 0) - -message(STATUS "Running ninja") -set(_NINJA_COMMAND ninja ${NINJA_ARGS} -C out/Default) -execute_process(COMMAND ${PREFIX_EXECUTE} ${_NINJA_COMMAND} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - RESULT_VARIABLE _NINJA_DONE) - -if (NOT _NINJA_DONE EQUAL 0) - message(FATAL_ERROR "Unable to build webrtc") -endif (NOT _NINJA_DONE EQUAL 0) +libwebrtc_command( + NAME webrtc-generate + COMMAND ${_GEN_COMMAND} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + COMMENT "Generating build files" + DEPENDS webrtc-clang webrtc-toolchain webrtc-gn webrtc-clang-format +) + +set(_NINJA_COMMAND ninja ${NINJA_ARGS} -C out/Default pc) +libwebrtc_command( + NAME webrtc-build + COMMAND ${_NINJA_COMMAND} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + COMMENT "Running ninja" + DEPENDS webrtc-generate +) From 8970f2368b030f1fc1a441fc455bedda8e4e143d Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 10:23:09 +0100 Subject: [PATCH 14/27] README: Add more instructions for specific commits and depot_tools management --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 24527aa..88972c0 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,8 @@ supported platforms and architectures. macOS ✔ - - + - + - Windows @@ -146,6 +146,35 @@ linker flags by specifying `LibWebRTC` as the package name. $ pkg-config --cflags --libs LibWebRTC ``` +## Fetching a specific revision + +The latest working release will be fetched by default, unless you decide to +retrieve a specific commit by setting it's hash into the **WEBRTC_REVISION** +CMake variable, or another branch head ref into the **WEBRTC_BRANCH_HEAD** +variable. + +``` +$ cmake -DWEBRTC_REVISION=be22d51 .. +$ cmake -DWEBRTC_BRANCH_HEAD=refs/branch-heads/57 .. +``` + +If both variables are set, it will focus on fetching the commit defined inside +**WEBRTC_REVISION**. + +## Managing depot_tools + +CMake will retrieve the latest revision of the `depot_tools` repository. It will +get the WebRTC repository's commit date, then check-out `depot_tools` to the +commit having the closest date to WebRTC's, in order to ensure a high +compatibility with `gclient` and other tools. + +It is possible to prevent this behavior by specifying the location to your own +`depot_tools` repository by defining the **DEPOT_TOOLS_PATH** variable. + +``` +$ cmake -DDEPOT_TOOLS_PATH=/opt/depot_tools .. +``` + ## Configuration The library will be compiled and usable on the same host's platform and @@ -174,6 +203,10 @@ perform cross-compiling. Set this variable to your own `depot_tools` directory. This will prevent CMake from fetching the one matching with the desired WebRTC revision. +- **GN_EXTRA_ARGS** + + Add extra arguments to the `gn gen --args` parameter. + - **NINJA_ARGS** Arguments to pass while executing the `ninja` command. For instance, you can @@ -206,6 +239,15 @@ perform cross-compiling. - `arm64` - `mipsel` +- **WEBRTC_BRANCH_HEAD** + + Set the branch head ref to retrieve, it is set to the latest working one. + This variable is ignored if **WEBRTC_REVISION** is set. + +- **WEBRTC_REVISION** + + Set a specific commit hash to check-out. + ## Contributing Feel free to open an issue if you wish a bug to be fixed, to discuss a new From c10f3458f0be1dc749e2cd95ebed9bafaa1da54c Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 10:25:22 +0100 Subject: [PATCH 15/27] Enable parallel build for CI, remove -j 4 flag everywhere, fixes #34 --- .travis.yml | 4 ++-- README.md | 6 +----- appveyor.yml | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3d95d10..c660413 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,10 +43,10 @@ install: - git submodule update - mkdir out - cd out -- cmake -DNINJA_ARGS="-j 4" -DGN_EXTRA_ARGS="clang_use_chrome_plugins=false" .. +- cmake -DGN_EXTRA_ARGS="clang_use_chrome_plugins=false" .. script: -- make package +- make -j 4 package deploy: provider: releases diff --git a/README.md b/README.md index 88972c0..2836881 100644 --- a/README.md +++ b/README.md @@ -209,11 +209,7 @@ perform cross-compiling. - **NINJA_ARGS** - Arguments to pass while executing the `ninja` command. For instance, you can - define the number of cores you would like to use, in order to speed-up the - build process: - - `cmake -DNINJA_ARGS="-j 4" ..` + Arguments to pass while executing the `ninja` command. - **TARGET_OS** diff --git a/appveyor.yml b/appveyor.yml index c80a9e2..df06dc7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,7 +13,7 @@ build: before_build: - cd c:\projects\libwebrtc - git submodule update --init --recursive - - cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=c:\projects\libwebrtc -DNINJA_ARGS="-j 2" . + - cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=c:\projects\libwebrtc . artifacts: - path: libwebrtc-0.0.1-rc.4-win32-x64.7z From daf8535a2d5500654f05e9afcee47273f5361ed9 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 10:30:50 +0100 Subject: [PATCH 16/27] Set the target dependencies in a list --- webrtc/CMakeLists.txt.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webrtc/CMakeLists.txt.in b/webrtc/CMakeLists.txt.in index 09e6bd6..fef47bf 100644 --- a/webrtc/CMakeLists.txt.in +++ b/webrtc/CMakeLists.txt.in @@ -27,6 +27,7 @@ libwebrtc_command( COMMENT "Updating clang" DEPENDS webrtc-sync ) +set(_DEPENDENCIES webrtc-clang) if (UNIX AND NOT APPLE) libwebrtc_command( @@ -36,6 +37,7 @@ if (UNIX AND NOT APPLE) COMMENT "Retrieving sysroot" DEPENDS webrtc-sync ) + set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-toolchain) set(_PLATFORM linux*) set(_FOLDER linux64) @@ -50,6 +52,7 @@ elseif (WIN32) COMMENT "Retrieving Visual Studio toolchain" DEPENDS webrtc-sync ) + set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-toolchain) set(_PLATFORM win32) set(_FOLDER win) @@ -67,6 +70,7 @@ libwebrtc_command( COMMENT "Fetching gn${_SUFFIX} for ${_PLATFORM}" DEPENDS webrtc-sync ) +set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-gn) set(_CLANG_FORMAT_COMMAND download_from_google_storage --no_resume --platform=${_PLATFORM} --no_auth --bucket chromium-clang-format @@ -79,6 +83,7 @@ libwebrtc_command( COMMENT "Fetching clang-format${_SUFFIX} for ${_PLATFORM}" DEPENDS webrtc-sync ) +set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-clang-format) include(Gn) @@ -87,7 +92,7 @@ libwebrtc_command( COMMAND ${_GEN_COMMAND} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" COMMENT "Generating build files" - DEPENDS webrtc-clang webrtc-toolchain webrtc-gn webrtc-clang-format + DEPENDS webrtc-clang ${_DEPENDENCIES} ) set(_NINJA_COMMAND ninja ${NINJA_ARGS} -C out/Default pc) From ea5d4643aa5ef1daac7f821ab5f1ed305a4d577e Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 11:56:21 +0100 Subject: [PATCH 17/27] Gn.cmake: Set is_debug depending on the IDE --- CMakeModules/Gn.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeModules/Gn.cmake b/CMakeModules/Gn.cmake index cf52c5b..aa92c93 100644 --- a/CMakeModules/Gn.cmake +++ b/CMakeModules/Gn.cmake @@ -1,7 +1,7 @@ set(_GEN_ARGS "use_gold=false target_cpu=\\\"${TARGET_CPU}\\\" target_os=\\\"${TARGET_OS}\\\"") if (MSVC OR XCODE) - set(_GEN_ARGS "${_GEN_ARGS} is_debug=false") + set(_GEN_ARGS ${_GEN_ARGS} is_debug=$<$:true>$<$:false>$<$:false>$<$:false>) elseif (CMAKE_BUILD_TYPE MATCHES Debug) set(_GEN_ARGS "${_GEN_ARGS} is_debug=true") else (MSVC OR XCODE) From 5d3887b918874cf8679d4c713acf3bc7cab1e1fd Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 04:30:25 -0700 Subject: [PATCH 18/27] No prefix file for gn command anymore, set the right directory for IDE config --- CMakeLists.txt | 10 +++++++++- CMakeModules/Gn.cmake | 19 ++++--------------- webrtc/CMakeLists.txt.in | 2 +- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64f00c1..350d0a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,14 @@ ExternalProject_Add( -DWEBRTC_ROOT_DIR:PATH=${CMAKE_BINARY_DIR} ) +if (MSVC OR XCODE) + set(_CONFIG $<$:Debug>$<$:Release>$<$:Release>$<$:Release>) +elseif (CMAKE_BUILD_TYPE MATCHES Debug) + set(_CONFIG Debug) +else (MSVC OR XCODE) + set(_CONFIG Release) +endif (MSVC OR XCODE) + ExternalProject_Add( libwebrtc DEPENDS webrtc-src @@ -91,7 +99,7 @@ ExternalProject_Add( CMAKE_ARGS -DLIBRARY_TYPE:STRING=${LIBRARY_TYPE} -DTARGET_OS:STRING=${TARGET_OS} - -DWEBRTC_OUTPUT_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src/out/Default + -DWEBRTC_OUTPUT_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src/out/$<$:Debug>$<$:Release>$<$:Release>$<$:Release> -DWEBRTC_SOURCE_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src/webrtc -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} diff --git a/CMakeModules/Gn.cmake b/CMakeModules/Gn.cmake index aa92c93..dfbe09e 100644 --- a/CMakeModules/Gn.cmake +++ b/CMakeModules/Gn.cmake @@ -2,10 +2,13 @@ set(_GEN_ARGS "use_gold=false target_cpu=\\\"${TARGET_CPU}\\\" target_os=\\\"${T if (MSVC OR XCODE) set(_GEN_ARGS ${_GEN_ARGS} is_debug=$<$:true>$<$:false>$<$:false>$<$:false>) + set(_NINJA_BUILD_DIR out/$<$:Debug>$<$:Release>$<$:Release>$<$:Release>) elseif (CMAKE_BUILD_TYPE MATCHES Debug) set(_GEN_ARGS "${_GEN_ARGS} is_debug=true") + set(_NINJA_BUILD_DIR out/Debug) else (MSVC OR XCODE) set(_GEN_ARGS "${_GEN_ARGS} is_debug=false") + set(_NINJA_BUILD_DIR out/Release) endif (MSVC OR XCODE) if (BUILD_TESTS) @@ -18,18 +21,4 @@ if (GN_EXTRA_ARGS) set(_GEN_ARGS "${_GEN_ARGS} ${GN_EXTRA_ARGS}") endif (GN_EXTRA_ARGS) -set(_GN_OUT_DIR out/Default) -set(_GEN_COMMAND_LINE gn gen ${_GN_OUT_DIR} --args=\"${_GEN_ARGS}\") - -if (WIN32) - set(_SCRIPT_SUFFIX .bat) -elseif (UNIX) - set(_SCRIPT_SUFFIX .sh) - set(_GEN_COMMAND sh) -endif (WIN32) - -string(REPLACE ";" " " _GEN_COMMAND_STR "${_GEN_COMMAND_LINE}") -set(_GN_SCRIPT_FILENAME ${WEBRTC_PARENT_DIR}/gn-gen${_SCRIPT_SUFFIX}) -file(WRITE ${_GN_SCRIPT_FILENAME} ${_GEN_COMMAND_STR}) - -set(_GEN_COMMAND ${_GEN_COMMAND} ${_GN_SCRIPT_FILENAME}) +set(_GEN_COMMAND gn gen ${_NINJA_BUILD_DIR} --args=\"${_GEN_ARGS}\") diff --git a/webrtc/CMakeLists.txt.in b/webrtc/CMakeLists.txt.in index fef47bf..8b22d93 100644 --- a/webrtc/CMakeLists.txt.in +++ b/webrtc/CMakeLists.txt.in @@ -95,7 +95,7 @@ libwebrtc_command( DEPENDS webrtc-clang ${_DEPENDENCIES} ) -set(_NINJA_COMMAND ninja ${NINJA_ARGS} -C out/Default pc) +set(_NINJA_COMMAND ninja ${NINJA_ARGS} -C ${_NINJA_BUILD_DIR} pc) libwebrtc_command( NAME webrtc-build COMMAND ${_NINJA_COMMAND} From c8a3e8eb8ab03168cf579c9bd9428a7ffa4356c1 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 14:14:55 +0100 Subject: [PATCH 19/27] Remove prefix files, use cmake -E env --- CMakeModules/Environment.cmake | 29 +++++++---------------------- CMakeModules/Gn.cmake | 12 ++++++------ 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/CMakeModules/Environment.cmake b/CMakeModules/Environment.cmake index 069d4f8..b565049 100644 --- a/CMakeModules/Environment.cmake +++ b/CMakeModules/Environment.cmake @@ -21,26 +21,11 @@ get_filename_component(_CHROMIUM_PYTHONPATH "${CMAKE_SOURCE_DIR}/build" REALPATH) -if (WIN32) - set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.bat) - set(PREFIX_COMMAND set) - set(PREFIX_HEADER "@ECHO OFF") - set(PREFIX_EVAL "%*") - set(PREFIX_EXECUTE cmd /c ${PREFIX_FILENAME}) -else (WIN32) - set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.sh) - set(PREFIX_COMMAND export) - set(PREFIX_HEADER "") - set(PREFIX_EVAL eval\ $@) - set(PREFIX_EXECUTE /bin/sh ${PREFIX_FILENAME}) -endif (WIN32) - -file(WRITE ${PREFIX_FILENAME} "${PREFIX_HEADER} -${PREFIX_COMMAND} PATH=${_WEBRTC_PATH} -${PREFIX_COMMAND} PYTHONPATH=${_CHROMIUM_PYTHONPATH} -${PREFIX_COMMAND} DEPOT_TOOLS_WIN_TOOLCHAIN=0 -${PREFIX_COMMAND} DEPOT_TOOLS_UPDATE=0 -${PREFIX_COMMAND} CHROME_HEADLESS=1 -${PREFIX_EVAL} -") +set(_WEBRTC_ENV + PATH=\"${_WEBRTC_PATH}\" + PYTHONPATH=\"${_CHROMIUM_PYTHONPATH}\" + DEPOT_TOOLS_WIN_TOOLCHAIN=0 + DEPOT_TOOLS_UPDATE=0 + CHROME_HEADLESS=1) +set(PREFIX_EXECUTE cmake -E env ${_WEBRTC_ENV} ${PREFIX_FILENAME}) diff --git a/CMakeModules/Gn.cmake b/CMakeModules/Gn.cmake index dfbe09e..73aab6e 100644 --- a/CMakeModules/Gn.cmake +++ b/CMakeModules/Gn.cmake @@ -1,24 +1,24 @@ -set(_GEN_ARGS "use_gold=false target_cpu=\\\"${TARGET_CPU}\\\" target_os=\\\"${TARGET_OS}\\\"") +set(_GEN_ARGS use_gold=false target_cpu=\\"${TARGET_CPU}\\" target_os=\\"${TARGET_OS}\\") if (MSVC OR XCODE) set(_GEN_ARGS ${_GEN_ARGS} is_debug=$<$:true>$<$:false>$<$:false>$<$:false>) set(_NINJA_BUILD_DIR out/$<$:Debug>$<$:Release>$<$:Release>$<$:Release>) elseif (CMAKE_BUILD_TYPE MATCHES Debug) - set(_GEN_ARGS "${_GEN_ARGS} is_debug=true") + set(_GEN_ARGS ${_GEN_ARGS} is_debug=true) set(_NINJA_BUILD_DIR out/Debug) else (MSVC OR XCODE) - set(_GEN_ARGS "${_GEN_ARGS} is_debug=false") + set(_GEN_ARGS ${_GEN_ARGS} is_debug=false) set(_NINJA_BUILD_DIR out/Release) endif (MSVC OR XCODE) if (BUILD_TESTS) - set(_GEN_ARGS "${_GEN_ARGS} rtc_include_tests=true") + set(_GEN_ARGS ${_GEN_ARGS} rtc_include_tests=true) else (BUILD_TESTS) - set(_GEN_ARGS "${_GEN_ARGS} rtc_include_tests=false") + set(_GEN_ARGS ${_GEN_ARGS} rtc_include_tests=false) endif (BUILD_TESTS) if (GN_EXTRA_ARGS) - set(_GEN_ARGS "${_GEN_ARGS} ${GN_EXTRA_ARGS}") + set(_GEN_ARGS ${_GEN_ARGS} ${GN_EXTRA_ARGS}) endif (GN_EXTRA_ARGS) set(_GEN_COMMAND gn gen ${_NINJA_BUILD_DIR} --args=\"${_GEN_ARGS}\") From 7950fa7e8a279263ed82916eee5948f8ff77e1cf Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 09:17:53 -0700 Subject: [PATCH 20/27] Fix the environment variables forever, add .bat suffix for win32 --- CMakeModules/Environment.cmake | 31 +++++++++++++++++-------------- CMakeModules/Gn.cmake | 8 +++++++- webrtc/CMakeLists.txt.in | 5 +++-- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/CMakeModules/Environment.cmake b/CMakeModules/Environment.cmake index b565049..ee4b849 100644 --- a/CMakeModules/Environment.cmake +++ b/CMakeModules/Environment.cmake @@ -1,31 +1,34 @@ -set(_WEBRTC_PATH ${DEPOT_TOOLS_PATH}) -set(_DEPOT_TOOLS_ENV PATH=${_WEBRTC_PATH}) +if (ENVIRONMENT_INCLUDED) + return() +endif (ENVIRONMENT_INCLUDED) +set(ENVIRONMENT_INCLUDED true) if (WIN32) get_filename_component(DEPOT_TOOLS_PYTHON_PATH "${_WEBRTC_PATH}/python276_bin" REALPATH) - list(APPEND _WEBRTC_PATH ${DEPOT_TOOLS_PYTHON_PATH}) + list(APPEND _WEBRTC_PATH "${DEPOT_TOOLS_PYTHON_PATH}") endif (WIN32) -list(APPEND _WEBRTC_PATH $ENV{PATH}) +list(APPEND _WEBRTC_PATH ${DEPOT_TOOLS_PATH} $ENV{PATH}) + +get_filename_component(_CHROMIUM_PYTHONPATH + "${CMAKE_SOURCE_DIR}/build" + REALPATH) if (WIN32) string(REGEX REPLACE "/" "\\\\" _WEBRTC_PATH "${_WEBRTC_PATH}") - string(REGEX REPLACE ";" "\\\;" _WEBRTC_PATH "${_WEBRTC_PATH}") + string(REGEX REPLACE "/" "\\\\" _CHROMIUM_PYTHONPATH "${_CHROMIUM_PYTHONPATH}") + string(REGEX REPLACE ";" "\\\\\\\;" _WEBRTC_PATH "${_WEBRTC_PATH}") else (WIN32) string(REGEX REPLACE ";" ":" _WEBRTC_PATH "${_WEBRTC_PATH}") endif (WIN32) -get_filename_component(_CHROMIUM_PYTHONPATH - "${CMAKE_SOURCE_DIR}/build" - REALPATH) - -set(_WEBRTC_ENV - PATH=\"${_WEBRTC_PATH}\" - PYTHONPATH=\"${_CHROMIUM_PYTHONPATH}\" - DEPOT_TOOLS_WIN_TOOLCHAIN=0 +set(_ENV + PATH="${_WEBRTC_PATH}" + PYTHONPATH="${_CHROMIUM_PYTHONPATH}" + DEPOT_TOOLS_WIN_TOOLCHAIN=0 DEPOT_TOOLS_UPDATE=0 CHROME_HEADLESS=1) -set(PREFIX_EXECUTE cmake -E env ${_WEBRTC_ENV} ${PREFIX_FILENAME}) +set(PREFIX_EXECUTE ${CMAKE_COMMAND} -E env "${_ENV}") diff --git a/CMakeModules/Gn.cmake b/CMakeModules/Gn.cmake index 73aab6e..5df8d2f 100644 --- a/CMakeModules/Gn.cmake +++ b/CMakeModules/Gn.cmake @@ -21,4 +21,10 @@ if (GN_EXTRA_ARGS) set(_GEN_ARGS ${_GEN_ARGS} ${GN_EXTRA_ARGS}) endif (GN_EXTRA_ARGS) -set(_GEN_COMMAND gn gen ${_NINJA_BUILD_DIR} --args=\"${_GEN_ARGS}\") +if (WIN32) + set(_GN_EXECUTABLE gn.bat) +else (WIN32) + set(_GN_EXECUTABLE gn) +endif (WIN32) + +set(_GEN_COMMAND ${_GN_EXECUTABLE} gen ${_NINJA_BUILD_DIR} --args=\"${_GEN_ARGS}\") diff --git a/webrtc/CMakeLists.txt.in b/webrtc/CMakeLists.txt.in index 8b22d93..e52b98a 100644 --- a/webrtc/CMakeLists.txt.in +++ b/webrtc/CMakeLists.txt.in @@ -57,9 +57,10 @@ elseif (WIN32) set(_PLATFORM win32) set(_FOLDER win) set(_SUFFIX .exe) + set(_SCRIPT_SUFFIX .bat) endif (UNIX AND NOT APPLE) -set(_GN_COMMAND download_from_google_storage --no_resume --platform=${_PLATFORM} +set(_GN_COMMAND download_from_google_storage${_SCRIPT_SUFFIX} --no_resume --platform=${_PLATFORM} --no_auth --bucket chromium-gn -s src/buildtools/${_FOLDER}/gn${_SUFFIX}.sha1) @@ -72,7 +73,7 @@ libwebrtc_command( ) set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-gn) -set(_CLANG_FORMAT_COMMAND download_from_google_storage --no_resume +set(_CLANG_FORMAT_COMMAND download_from_google_storage${_SCRIPT_SUFFIX} --no_resume --platform=${_PLATFORM} --no_auth --bucket chromium-clang-format -s src/buildtools/${_FOLDER}/clang-format${_SUFFIX}.sha1) From 7311f13bfa4e92f37073eb438ac615ddc532047a Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 18:35:24 +0100 Subject: [PATCH 21/27] Use the correct variable for the stamp file --- CMakeModules/LibWebRTCExecute.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeModules/LibWebRTCExecute.cmake b/CMakeModules/LibWebRTCExecute.cmake index e5c93f7..9cfe243 100644 --- a/CMakeModules/LibWebRTCExecute.cmake +++ b/CMakeModules/LibWebRTCExecute.cmake @@ -41,7 +41,7 @@ function (libwebrtc_execute) message(FATAL_ERROR "-- " ${COMMAND_ERROR}) endif (NOT _OUTPUT) - if (COMMAND_STAMP_FILE) + if (COMMAND_STAMPFILE) file(WRITE ${STAMP_FILE} ${_OUTPUT}) endif (COMMAND_STAMP_FILE) From 16578cdd5c716d7b0b5a537162e0d8f79eca66e9 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 18:36:07 +0100 Subject: [PATCH 22/27] Use the right variable for the lib output directory --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 350d0a3..4fb8d99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,7 +99,7 @@ ExternalProject_Add( CMAKE_ARGS -DLIBRARY_TYPE:STRING=${LIBRARY_TYPE} -DTARGET_OS:STRING=${TARGET_OS} - -DWEBRTC_OUTPUT_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src/out/$<$:Debug>$<$:Release>$<$:Release>$<$:Release> + -DWEBRTC_OUTPUT_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src/out/${_CONFIG} -DWEBRTC_SOURCE_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src/webrtc -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} From 64690d1a3017d37f2be36d8fea72d4da88fa8a19 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 18:55:36 +0100 Subject: [PATCH 23/27] Define WEBRTC_BRANCH_HEAD and WEBRTC_REVISION when required --- CMakeLists.txt | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fb8d99..5f9f0a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,23 @@ if (NOT HAS_OWN_DEPOT_TOOLS) set(DEPOT_TOOLS_PATH ${CMAKE_BINARY_DIR}/depot_tools/src/depot-tools) endif (NOT HAS_OWN_DEPOT_TOOLS) +set(_WEBRTC_CMAKE_ARGS + -DDEPOT_TOOLS_PATH:PATH=${DEPOT_TOOLS_PATH} + -DGCLIENT_EXECUTABLE:PATH=${GCLIENT_EXECUTABLE} + -DHAS_OWN_DEPOT_TOOLS:PATH=${HAS_OWN_DEPOT_TOOLS} + -DCMAKE_MODULE_PATH:PATH=${CMAKE_MODULE_PATH} + -DTARGET_CPU=${TARGET_CPU} + -DTARGET_OS=${TARGET_OS} + -DWEBRTC_PARENT_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc) + +if (WEBRTC_BRANCH_HEAD) + set(_WEBRTC_CMAKE_ARGS ${_WEBRTC_CMAKE_ARGS} -DWEBRTC_BRANCH_HEAD=${WEBRTC_BRANCH_HEAD}) +endif (WEBRTC_BRANCH_HEAD) + +if (WEBRTC_REVISION) + set(_WEBRTC_CMAKE_ARGS ${_WEBRTC_CMAKE_ARGS} -DWEBRTC_REVISION=${WEBRTC_REVISION}) +endif (WEBRTC_REVISION) + ExternalProject_Add( webrtc-src @@ -68,16 +85,7 @@ ExternalProject_Add( INSTALL_COMMAND "" CMAKE_ARGS - -DDEPOT_TOOLS_PATH:PATH=${DEPOT_TOOLS_PATH} - -DGCLIENT_EXECUTABLE:PATH=${GCLIENT_EXECUTABLE} - -DHAS_OWN_DEPOT_TOOLS:PATH=${HAS_OWN_DEPOT_TOOLS} - -DCMAKE_MODULE_PATH:PATH=${CMAKE_MODULE_PATH} - -DTARGET_CPU=${TARGET_CPU} - -DTARGET_OS=${TARGET_OS} - -DWEBRTC_BRANCH_HEAD=${WEBRTC_BRANCH_HEAD} - -DWEBRTC_PARENT_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc - -DWEBRTC_REVISION=${WEBRTC_REVISION} - -DWEBRTC_ROOT_DIR:PATH=${CMAKE_BINARY_DIR} + ${_WEBRTC_CMAKE_ARGS} ) if (MSVC OR XCODE) From c21220c58c2373f9101ee7cc658045b137f30e31 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 18:56:08 +0100 Subject: [PATCH 24/27] Replace all `execute_process` calls with `libwebrtc_execute` --- CMakeModules/DepotTools.cmake | 101 ++++++++++++++-------------- CMakeModules/LibWebRTCExecute.cmake | 9 +-- 2 files changed, 54 insertions(+), 56 deletions(-) diff --git a/CMakeModules/DepotTools.cmake b/CMakeModules/DepotTools.cmake index 7ecb5d3..238b650 100644 --- a/CMakeModules/DepotTools.cmake +++ b/CMakeModules/DepotTools.cmake @@ -9,69 +9,66 @@ if (WEBRTC_REVISION) COMMAND ${GIT_EXECUTABLE} log -1 --format=%ci ${WEBRTC_REVISION} OUTPUT_VARIABLE _WEBRTC_COMMIT_DATE WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - STAMPFILE webrtc-commit-date + STAMPFILE webrtc-revision-commit-date STATUS "Retrieving date for commit ${WEBRTC_REVISION}" ERROR "Unable to find webrtc commit date at ${WEBRTC_REVISION}" ) elseif (WEBRTC_BRANCH_HEAD) - message(STATUS "Retrieving branch-heads refspecs") - execute_process(COMMAND ${GIT_EXECUTABLE} config remote.origin.fetch +refs/branch-heads/*:refs/remotes/branch-heads/* ^\\+refs/branch-heads/\\*:.*$ - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - RESULT_VARIABLE _ADD_REMOTE_RESULT) - - if (NOT _ADD_REMOTE_RESULT EQUAL 0) - message(FATAL_ERROR "-- Unable to add branch-heads refspec") - endif (NOT _ADD_REMOTE_RESULT EQUAL 0) - - message(STATUS "Fetching ${WEBRTC_BRANCH_HEAD}") - execute_process(COMMAND ${GIT_EXECUTABLE} fetch origin ${WEBRTC_BRANCH_HEAD} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - RESULT_VARIABLE _WEBRTC_FETCH_RESULT) - - if (NOT _WEBRTC_FETCH_RESULT EQUAL 0) - message(FATAL_ERROR "-- Unable to fetch ${WEBRTC_BRANCH_HEAD}") - endif (NOT _WEBRTC_FETCH_RESULT EQUAL 0) - - message(STATUS "Checking out ${WEBRTC_BRANCH_HEAD}") - execute_process(COMMAND ${GIT_EXECUTABLE} checkout FETCH_HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - RESULT_VARIABLE _WEBRTC_CHECKOUT_RESULT) + libwebrtc_execute( + COMMAND ${GIT_EXECUTABLE} config remote.origin.fetch +refs/branch-heads/*:refs/remotes/branch-heads/* ^\\+refs/branch-heads/\\*:.*$ + OUTPUT_VARIABLE _WEBRTC_CONFIG_FETCH + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + STAMPFILE webrtc-config-fetch + STATUS "Setting up branch-heads refspecs" + ERROR "Unable to add branch-heads refspec to the git config" + ) - if (NOT _WEBRTC_CHECKOUT_RESULT EQUAL 0) - message(FATAL_ERROR "-- Unable to checkout ${WEBRTC_BRANCH_HEAD}") - endif (NOT _WEBRTC_CHECKOUT_RESULT EQUAL 0) + libwebrtc_execute( + COMMAND ${GIT_EXECUTABLE} fetch origin ${WEBRTC_BRANCH_HEAD} + OUTPUT_VARIABLE _WEBRTC_FETCH + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + STAMPFILE webrtc-fetch-branch-heads + STATUS "Fetching ${WEBRTC_BRANCH_HEAD}" + ERROR "Unable to fetch ${WEBRTC_BRANCH_HEAD}" + ) - message(STATUS "Retrieving date for commit ${WEBRTC_BRANCH_HEAD}") - execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%ci - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE _WEBRTC_COMMIT_DATE - RESULT_VARIABLE _WEBRTC_COMMIT_DATE_RESULT) + libwebrtc_execute( + COMMAND ${GIT_EXECUTABLE} checkout FETCH_HEAD + OUTPUT_VARIABLE _WEBRTC_CHECKOUT + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + STAMPFILE webrtc-checkout-branch-head + STATUS "Checking out ${WEBRTC_BRANCH_HEAD}" + ERROR "Unable to checkout ${WEBRTC_BRANCH_HEAD}" + ) - if (NOT _WEBRTC_COMMIT_DATE_RESULT EQUAL 0) - message(FATAL_ERROR "-- Unable to retrieve the commit date") - endif (NOT _WEBRTC_COMMIT_DATE_RESULT EQUAL 0) + libwebrtc_execute( + COMMAND ${GIT_EXECUTABLE} log -1 --format=%ci + OUTPUT_VARIABLE _WEBRTC_COMMIT_DATE + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + STAMPFILE webrtc-branch-head-commit-date + STATUS "Retrieving date for commit ${WEBRTC_BRANCH_HEAD}" + ERROR "Unable to retrieve the commit date for ${WEBRTC_BRANCH_HEAD}" + ) else (WEBRTC_REVISION) message(FATAL_ERROR "-- Both WEBRTC_REVISION and WEBRTC_BRANCH_HEAD variables are undefined") endif (WEBRTC_REVISION) string(STRIP ${_WEBRTC_COMMIT_DATE} _WEBRTC_COMMIT_DATE) -message(STATUS "Retrieving depot_tools commit before ${_WEBRTC_COMMIT_DATE}") - -execute_process(COMMAND ${GIT_EXECUTABLE} rev-list -n 1 --before=\"${_WEBRTC_COMMIT_DATE}\" master - WORKING_DIRECTORY ${DEPOT_TOOLS_PATH} - OUTPUT_VARIABLE _DEPOT_TOOLS_COMMIT) - -if (NOT _DEPOT_TOOLS_COMMIT) - message(FATAL_ERROR "-- Unable to find depot_tools commit before ${_WEBRTC_COMMIT_DATE}") -endif (NOT _DEPOT_TOOLS_COMMIT) +libwebrtc_execute( + COMMAND ${GIT_EXECUTABLE} rev-list -n 1 --before=\"${_WEBRTC_COMMIT_DATE}\" master + OUTPUT_VARIABLE _DEPOT_TOOLS_COMMIT + WORKING_DIRECTORY ${DEPOT_TOOLS_PATH} + STAMPFILE webrtc-depot-tools-date + STATUS "Retrieving depot_tools commit before ${_WEBRTC_COMMIT_DATE}" + ERROR "Unable to find depot_tools commit before ${_WEBRTC_COMMIT_DATE}" +) string(STRIP ${_DEPOT_TOOLS_COMMIT} _DEPOT_TOOLS_COMMIT) -message(STATUS "Checking out depot_tools to commit ${_DEPOT_TOOLS_COMMIT}") - -execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${_DEPOT_TOOLS_COMMIT} - WORKING_DIRECTORY ${DEPOT_TOOLS_PATH} - RESULT_VARIABLE _DEPOT_TOOLS_CHECKED_OUT) - -if (NOT _DEPOT_TOOLS_CHECKED_OUT EQUAL 0) - message(FATAL_ERROR "-- Unable to checkout depot_tools to commit ${_DEPOT_TOOLS_COMMIT}") -endif (NOT _DEPOT_TOOLS_CHECKED_OUT EQUAL 0) +libwebrtc_execute( + COMMAND ${GIT_EXECUTABLE} checkout ${_DEPOT_TOOLS_COMMIT} + OUTPUT_VARIABLE _DEPOT_TOOLS_CHECKED_OUT + WORKING_DIRECTORY ${DEPOT_TOOLS_PATH} + STAMPFILE webrtc-depot-tools-checkout + STATUS "Checking out depot_tools to commit ${_DEPOT_TOOLS_COMMIT}" + ERROR "Unable to checkout depot_tools to commit ${_DEPOT_TOOLS_COMMIT}" +) diff --git a/CMakeModules/LibWebRTCExecute.cmake b/CMakeModules/LibWebRTCExecute.cmake index 9cfe243..149e830 100644 --- a/CMakeModules/LibWebRTCExecute.cmake +++ b/CMakeModules/LibWebRTCExecute.cmake @@ -35,15 +35,16 @@ function (libwebrtc_execute) execute_process(COMMAND ${COMMAND_COMMAND} WORKING_DIRECTORY ${COMMAND_WORKING_DIRECTORY} - OUTPUT_VARIABLE _OUTPUT) + OUTPUT_VARIABLE _OUTPUT + RESULT_VARIABLE _RESULT) - if (NOT _OUTPUT) + if (NOT _RESULT EQUAL 0) message(FATAL_ERROR "-- " ${COMMAND_ERROR}) - endif (NOT _OUTPUT) + endif (NOT _RESULT EQUAL 0) if (COMMAND_STAMPFILE) file(WRITE ${STAMP_FILE} ${_OUTPUT}) - endif (COMMAND_STAMP_FILE) + endif (COMMAND_STAMPFILE) if (COMMAND_OUTPUT_VARIABLE) set(${COMMAND_OUTPUT_VARIABLE} ${_OUTPUT} PARENT_SCOPE) From 418e54b4016434df1392a825f76e20b72f615ff3 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 19:52:34 +0100 Subject: [PATCH 25/27] Execute checkout commands inside the main CMake file --- CMakeModules/DepotTools.cmake | 29 +------------------------ webrtc/CMakeLists.txt.in | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/CMakeModules/DepotTools.cmake b/CMakeModules/DepotTools.cmake index 238b650..90a8254 100644 --- a/CMakeModules/DepotTools.cmake +++ b/CMakeModules/DepotTools.cmake @@ -14,39 +14,12 @@ if (WEBRTC_REVISION) ERROR "Unable to find webrtc commit date at ${WEBRTC_REVISION}" ) elseif (WEBRTC_BRANCH_HEAD) - libwebrtc_execute( - COMMAND ${GIT_EXECUTABLE} config remote.origin.fetch +refs/branch-heads/*:refs/remotes/branch-heads/* ^\\+refs/branch-heads/\\*:.*$ - OUTPUT_VARIABLE _WEBRTC_CONFIG_FETCH - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - STAMPFILE webrtc-config-fetch - STATUS "Setting up branch-heads refspecs" - ERROR "Unable to add branch-heads refspec to the git config" - ) - - libwebrtc_execute( - COMMAND ${GIT_EXECUTABLE} fetch origin ${WEBRTC_BRANCH_HEAD} - OUTPUT_VARIABLE _WEBRTC_FETCH - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - STAMPFILE webrtc-fetch-branch-heads - STATUS "Fetching ${WEBRTC_BRANCH_HEAD}" - ERROR "Unable to fetch ${WEBRTC_BRANCH_HEAD}" - ) - - libwebrtc_execute( - COMMAND ${GIT_EXECUTABLE} checkout FETCH_HEAD - OUTPUT_VARIABLE _WEBRTC_CHECKOUT - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - STAMPFILE webrtc-checkout-branch-head - STATUS "Checking out ${WEBRTC_BRANCH_HEAD}" - ERROR "Unable to checkout ${WEBRTC_BRANCH_HEAD}" - ) - libwebrtc_execute( COMMAND ${GIT_EXECUTABLE} log -1 --format=%ci OUTPUT_VARIABLE _WEBRTC_COMMIT_DATE WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} STAMPFILE webrtc-branch-head-commit-date - STATUS "Retrieving date for commit ${WEBRTC_BRANCH_HEAD}" + STATUS "Retrieving date for ${WEBRTC_BRANCH_HEAD}" ERROR "Unable to retrieve the commit date for ${WEBRTC_BRANCH_HEAD}" ) else (WEBRTC_REVISION) diff --git a/webrtc/CMakeLists.txt.in b/webrtc/CMakeLists.txt.in index e52b98a..4a7d07a 100644 --- a/webrtc/CMakeLists.txt.in +++ b/webrtc/CMakeLists.txt.in @@ -8,6 +8,46 @@ else (WIN32) find_package(PythonInterp 2.7 REQUIRED) endif (WIN32) +include(LibWebRTCExecute) + +if (WEBRTC_REVISION) + libwebrtc_execute( + COMMAND ${GIT_EXECUTABLE} checkout ${WEBRTC_REVISION} + OUTPUT_VARIABLE _WEBRTC_CHECKOUT + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + STAMPFILE webrtc-checkout-commit + STATUS "Checking out webrtc to commit ${WEBRTC_REVISION}" + ERROR "Unable to checkout webrtc to commit ${WEBRTC_REVISION}" + ) +elseif (WEBRTC_BRANCH_HEAD) + libwebrtc_execute( + COMMAND ${GIT_EXECUTABLE} config remote.origin.fetch +refs/branch-heads/*:refs/remotes/branch-heads/* ^\\+refs/branch-heads/\\*:.*$ + OUTPUT_VARIABLE _WEBRTC_CONFIG_FETCH + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + STAMPFILE webrtc-config-fetch + STATUS "Setting up branch-heads refspecs" + ERROR "Unable to add branch-heads refspec to the git config" + ) + + libwebrtc_execute( + COMMAND ${GIT_EXECUTABLE} fetch origin ${WEBRTC_BRANCH_HEAD} + OUTPUT_VARIABLE _WEBRTC_FETCH + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + STAMPFILE webrtc-fetch-branch-heads + STATUS "Fetching ${WEBRTC_BRANCH_HEAD}" + ERROR "Unable to fetch ${WEBRTC_BRANCH_HEAD}" + ) + + libwebrtc_execute( + COMMAND ${GIT_EXECUTABLE} checkout FETCH_HEAD + OUTPUT_VARIABLE _WEBRTC_CHECKOUT + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + STAMPFILE webrtc-checkout-branch-head + STATUS "Checking out ${WEBRTC_BRANCH_HEAD}" + ERROR "Unable to checkout ${WEBRTC_BRANCH_HEAD}" + ) +endif (WEBRTC_REVISION) + include(DepotTools) include(GClient) include(Environment) From 58f2d70a74914a3e9231c9f8c498550c67ccd178 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 20:06:21 +0100 Subject: [PATCH 26/27] No longer need for clang_use_chrome_plugins=false, disable tests on appveyor --- .travis.yml | 2 +- appveyor.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c660413..7a1b61f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ install: - git submodule update - mkdir out - cd out -- cmake -DGN_EXTRA_ARGS="clang_use_chrome_plugins=false" .. +- cmake .. script: - make -j 4 package diff --git a/appveyor.yml b/appveyor.yml index df06dc7..d4d6ea2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,3 +18,5 @@ before_build: artifacts: - path: libwebrtc-0.0.1-rc.4-win32-x64.7z name: libwebrtc-0.0.1-rc.4-win32-x64.7z + +test: off From 5744e63abe126c4208d01ea2d9b1517aff950ad1 Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Sun, 19 Mar 2017 20:22:30 +0100 Subject: [PATCH 27/27] Rename artifact for Appveyor --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d4d6ea2..c9681d6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,7 +16,7 @@ before_build: - cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=c:\projects\libwebrtc . artifacts: - - path: libwebrtc-0.0.1-rc.4-win32-x64.7z - name: libwebrtc-0.0.1-rc.4-win32-x64.7z + - path: libwebrtc-0.0.1-rc.4-win-x64.zip + name: libwebrtc-0.0.1-rc.4-win-x64.zip test: off