Skip to content

Commit

Permalink
Merge branch refactor-depot-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
aisouard authored Mar 20, 2017
2 parents 987a23f + 5744e63 commit 6aab703
Show file tree
Hide file tree
Showing 23 changed files with 559 additions and 328 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..

script:
- make package
- make -j 4 package

deploy:
provider: releases
Expand Down
105 changes: 104 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,113 @@ cmake_policy(SET CMP0057 NEW)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/CMakeModules)

find_package(Git REQUIRED)

include(FindLibraries)
include(Version)
include(Options)
include(TargetOsAndCpu)

add_subdirectory(Targets)
if (HAS_OWN_DEPOT_TOOLS)
find_package(DepotTools REQUIRED)
endif (HAS_OWN_DEPOT_TOOLS)

if (NOT WIN32)
find_package(PythonInterp 2.7 REQUIRED)
endif (NOT WIN32)

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)

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

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
${_WEBRTC_CMAKE_ARGS}
)

if (MSVC OR XCODE)
set(_CONFIG $<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>$<$<CONFIG:RelWithDebInfo>:Release>$<$<CONFIG:MinSizeRel>: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

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/${_CONFIG}
-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)
47 changes: 47 additions & 0 deletions CMakeModules/DepotTools.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
if (HAS_OWN_DEPOT_TOOLS)
return()
endif (HAS_OWN_DEPOT_TOOLS)

include(LibWebRTCExecute)

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-revision-commit-date
STATUS "Retrieving date for commit ${WEBRTC_REVISION}"
ERROR "Unable to find webrtc commit date at ${WEBRTC_REVISION}"
)
elseif (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 ${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)
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)
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}"
)
34 changes: 34 additions & 0 deletions CMakeModules/Environment.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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}")
endif (WIN32)

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 "/" "\\\\" _CHROMIUM_PYTHONPATH "${_CHROMIUM_PYTHONPATH}")
string(REGEX REPLACE ";" "\\\\\\\;" _WEBRTC_PATH "${_WEBRTC_PATH}")
else (WIN32)
string(REGEX REPLACE ";" ":" _WEBRTC_PATH "${_WEBRTC_PATH}")
endif (WIN32)

set(_ENV
PATH="${_WEBRTC_PATH}"
PYTHONPATH="${_CHROMIUM_PYTHONPATH}"
DEPOT_TOOLS_WIN_TOOLCHAIN=0
DEPOT_TOOLS_UPDATE=0
CHROME_HEADLESS=1)

set(PREFIX_EXECUTE ${CMAKE_COMMAND} -E env "${_ENV}")
13 changes: 7 additions & 6 deletions CMakeModules/FindDepotTools.cmake
Original file line number Diff line number Diff line change
@@ -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.")
10 changes: 0 additions & 10 deletions CMakeModules/FindLibraries.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
22 changes: 22 additions & 0 deletions CMakeModules/GClient.cmake
Original file line number Diff line number Diff line change
@@ -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")
25 changes: 0 additions & 25 deletions CMakeModules/GClientConfig.cmake

This file was deleted.

30 changes: 30 additions & 0 deletions CMakeModules/Gn.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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=$<$<CONFIG:Debug>:true>$<$<CONFIG:Release>:false>$<$<CONFIG:RelWithDebInfo>:false>$<$<CONFIG:MinSizeRel>:false>)
set(_NINJA_BUILD_DIR out/$<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>$<$<CONFIG:RelWithDebInfo>:Release>$<$<CONFIG:MinSizeRel>: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)
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)

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}\")
15 changes: 11 additions & 4 deletions CMakeModules/LibWebRTCCommand.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
if(LIBWEBRTC_COMMAND_INCLUDED)
return()
endif(LIBWEBRTC_COMMAND_INCLUDED)
set(LIBWEBRTC_COMMAND_INCLUDED true)

include(CMakeParseArguments)
include(Prefix)
include(Environment)

function(libwebrtc_command)
set(ONE_VALUE_ARGS NAME COMMENT DEPENDS WORKING_DIRECTORY)
set(MULTI_VALUE_ARGS 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)
Expand All @@ -19,5 +24,7 @@ function(libwebrtc_command)

add_custom_target(${COMMAND_NAME} ALL DEPENDS ${STAMP_FILE})

add_dependencies(${COMMAND_NAME} ${COMMAND_DEPENDS})
if (COMMAND_DEPENDS)
add_dependencies(${COMMAND_NAME} ${COMMAND_DEPENDS})
endif (COMMAND_DEPENDS)
endfunction()
Loading

0 comments on commit 6aab703

Please sign in to comment.