Skip to content

Commit

Permalink
New way of downloading web-client deps!
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Hieta authored and LongChair committed Feb 7, 2018
1 parent 1af8667 commit 773ad42
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 68 deletions.
8 changes: 1 addition & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ endif()

project(PlexMediaPlayer CXX C)

if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
else()
message(WARNING "Could not find conanbuildinfo.cmake - could be a problem! Make sure to run conan install first")
endif()

# we want this to be able to run clang-tidy
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "" FORCE)

Expand Down Expand Up @@ -56,6 +50,7 @@ set_policy(CMP0026 OLD)

include(utils)
include(CompilerFlags)
include(WebClient)
include(DependencyConfiguration)
include(QtConfiguration)
include(VersionConfiguration)
Expand All @@ -65,7 +60,6 @@ include(InputConfiguration)
include(FindBreakpad)
include(BreakpadSymbols)
include(ClangTidy)
include(WebClientConan)

add_definitions(-DQS_LOG_LINE_NUMBERS -DQS_LOG_SEPARATE_THREAD)

Expand Down
53 changes: 36 additions & 17 deletions CMakeModules/FetchDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,16 @@ function(get_content_of_url)
endfunction(get_content_of_url)

function(download_deps DD_NAME)
set(ARGS DIRECTORY BUILD_NUMBER ARTIFACTNAME VARIANT DEPHASH_VAR ARCHSTR DYLIB_SCRIPT_PATH TOKEN)
cmake_parse_arguments(DD "" "${ARGS}" "" ${ARGN})
set(ARGS DIRECTORY BUILD_NUMBER
ARTIFACTNAME
VARIANT
DEPHASH_VAR
ARCHSTR
DYLIB_SCRIPT_PATH
BASE_URL
TOKEN)

cmake_parse_arguments(DD "NO_HASH_FILE" "${ARGS}" "" ${ARGN})

if(NOT DEFINED DD_VARIANT)
set(DD_VARIANT "release")
Expand All @@ -92,7 +100,10 @@ function(download_deps DD_NAME)
set(DD_TOKEN plex-dependencies)
endif()

set(BASE_URL "https://nightlies.plex.tv/directdl/${DD_TOKEN}/${DD_NAME}/${DD_BUILD_NUMBER}")
if(NOT DEFINED DD_BASE_URL)
set(DD_BASE_URL "https://nightlies.plex.tv/directdl/${DD_TOKEN}/${DD_NAME}/${DD_BUILD_NUMBER}")
endif()

set(DEP_DIR ${DEPENDENCY_UNTAR_DIR}/${DD_ARCHSTR}-${DD_NAME}/${DD_BUILD_NUMBER})

get_cmake_property(cacheVars CACHE_VARIABLES)
Expand All @@ -103,26 +114,34 @@ function(download_deps DD_NAME)
endif()
endforeach()

set(HASH_FILENAME ${DD_NAME}-${DD_BUILD_NUMBER}-hash.txt)
get_content_of_url(URL ${BASE_URL}/hash.txt CONTENT_VAR DEP_HASH FILENAME ${HASH_FILENAME} ${DD_ALWAYS_DOWNLOAD})
if(NOT DD_NO_HASH_FILE)
set(HASH_FILENAME ${DD_NAME}-${DD_BUILD_NUMBER}-hash.txt)
get_content_of_url(URL ${DD_BASE_URL}/hash.txt CONTENT_VAR DEP_HASH FILENAME ${HASH_FILENAME} ${DD_ALWAYS_DOWNLOAD})

if(NOT DEP_HASH)
message(FATAL_ERROR "Failed to get hash for dependencies. Abort abort abort...")
endif()
if(NOT DEP_HASH)
message(FATAL_ERROR "Failed to get hash for dependencies. Abort abort abort...")
endif()

message(STATUS "Dependency hash is: ${DEP_HASH}")
if(DD_DEPHASH_VAR)
set(${DD_DEPHASH_VAR} ${DEP_HASH} PARENT_SCOPE)
endif()
message(STATUS "Dependency hash is: ${DEP_HASH}")
if(DD_DEPHASH_VAR)
set(${DD_DEPHASH_VAR} ${DEP_HASH} PARENT_SCOPE)
endif()

set(DEP_DIRNAME "${DD_ARTIFACTNAME}-${DD_ARCHSTR}-${DD_VARIANT}-${DEP_HASH}")
set(DEP_FILENAME ${DEP_DIRNAME}.tbz2)
set(DEP_DIRNAME "${DD_ARTIFACTNAME}-${DD_ARCHSTR}-${DD_VARIANT}-${DEP_HASH}")
set(DEP_FILENAME ${DEP_DIRNAME}.tbz2)
set(${DD_DEP_HASH} ${DEP_HASH} PARENT_SCOPE)
set(DEP_URL "${DD_BASE_URL}/${DEP_FILENAME}")
set(CONTENT_HASH_URL ${DEP_URL}.sha.txt)
else()
set(DEP_DIRNAME "${DD_ARTIFACTNAME}-${DD_VARIANT}")
set(DEP_FILENAME "${DEP_DIRNAME}.tar.xz")
set(DEP_URL "${DD_BASE_URL}/${DEP_FILENAME}")
set(CONTENT_HASH_URL ${DEP_URL}.sha1)
endif()

set(${DD_DIRECTORY} ${DEP_DIR}/${DEP_DIRNAME} PARENT_SCOPE)
set(${DD_DEP_HASH} ${DEP_HASH} PARENT_SCOPE)

set(DEP_URL "${BASE_URL}/${DEP_FILENAME}")
get_content_of_url(URL ${DEP_URL}.sha.txt CONTENT_VAR CONTENT_HASH)
get_content_of_url(URL ${CONTENT_HASH_URL} CONTENT_VAR CONTENT_HASH)

string(SUBSTRING "${CONTENT_HASH}" 0 40 CONTENT_HASH)

Expand Down
33 changes: 33 additions & 0 deletions CMakeModules/WebClient.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
include(FetchDependencies)

option(WEB_CLIENT_TV_OLD "" OFF)
option(WEB_CLIENT_DISABLE_DESKTOP "" OFF)

set(WEB_CLIENT_BUILD_NUMBER 20)
set(DESKTOP_VERSION 3.34.1-b51c37a)
set(TVOLD_VERSION 3.13.3-5401c32)
set(TV_VERSION 3.33.4-81b752aa)

if(WEB_CLIENT_TV_OLD)
set(TV_VERSION ${TVOLD_VERSION})
endif()

if(NOT WEB_CLIENT_DISABLE_DESKTOP)
download_deps("web-client-desktop"
BUILD_NUMBER ${WEB_CLIENT_BUILD_NUMBER}
VARIANT ${DESKTOP_VERSION}
NO_HASH_FILE
ARCHSTR "universal"
BASE_URL "https://artifacts.plex.tv/web-client-pmp/${WEB_CLIENT_BUILD_NUMBER}"
DIRECTORY WEB_DESKTOP_DIR
)
endif()

download_deps("web-client-tv"
BUILD_NUMBER ${WEB_CLIENT_BUILD_NUMBER}
VARIANT ${TV_VERSION}
NO_HASH_FILE
ARCHSTR "universal"
BASE_URL "https://artifacts.plex.tv/web-client-pmp/${WEB_CLIENT_BUILD_NUMBER}"
DIRECTORY WEB_TV_DIR
)
Empty file removed CMakeModules/WebClientConan.cmake
Empty file.
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ If you're happy just building from the command line then run CMake for the ninja
* ``brew install ninja``
* Install mpv and other dependencies with homebrew:
* ``brew install mpv --with-shared --HEAD``
* Install conan (dependency fetcher)
* ``brew install conan``
* Add the `plex` repository to conan: ``conan remote add plex https://conan.plex.tv``
* ``mkdir build ; cd build``
* ``conan install ..``
* ``cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=output ..``

Build (ninja):
Expand Down Expand Up @@ -76,14 +72,6 @@ With this, libmpv should have been installed to ``/usr/local/``. It does not con

You can also attempt to skip the installation step, and change the paths in the PMP build step to the build directory, but this is more complicated.

### Install conan (dependency fetcher)

Usually you can install conan by running: ``pip install -U conan``.

Now add the `plex` repository to conan ``conan remote add plex https://conan.plex.tv``

You can try that it works by running ``conan search -r plex *@*/public`` that should list web-client packages.

### Building plex-media-player

Assuming that everything else has installed correctly, building Plex Media Player should now be fairly straightforward:
Expand All @@ -93,7 +81,6 @@ Assuming that everything else has installed correctly, building Plex Media Playe
* ``cd plex-media-player``
* ``mkdir build``
* ``cd build``
* ``conan install ..``
* ``cmake -DCMAKE_BUILD_TYPE=Debug -DQTROOT=/opt/Qt5.6.1/5.6/gcc_64/ -DCMAKE_INSTALL_PREFIX=/usr/local/ ..``
* ``make -j4``
* ``sudo make install``
Expand All @@ -118,4 +105,3 @@ Sometimes, PMP will pick up SDL 1.x libraries. This is not supported and will le
Plex Media Player is licensed under GPL v2. See the ``LICENSE`` file.
Licenses of dependencies are summarized under ``resources/misc/licenses.txt``.
This file can also be printed at runtime when using the ``--licenses`` option.

14 changes: 0 additions & 14 deletions conanfile.py

This file was deleted.

4 changes: 0 additions & 4 deletions scripts/build-windows.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
cd %BUILD_DIR% || exit /b

if exist ../conanfile.py (
conan install ..
)

%CMAKE_DIR%\cmake -DDEPENDENCY_TOKEN=%DEP_SECRET% -DCRASHDUMP_SECRET=%CD_SECRET% -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=output -DDEPENDENCY_UNTAR_DIR=c:\jenkins\pmp-deps .. -G Ninja -DCODE_SIGN=ON -DENABLE_CODECS=on || exit /b

ninja || exit /b
Expand Down
26 changes: 14 additions & 12 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,23 @@ if(APPLE)
set(RESOURCE_ROOT Resources)
endif()

if(NOT DEFINED CONAN_WEB-CLIENT-TV2_ROOT)
message(FATAL_ERROR "Could not find the web-client! Run conan!")
endif()

add_resources(TARGET ${MAIN_TARGET} SOURCES ${CONAN_WEB-CLIENT-TV2_ROOT}/tv DEST ${RESOURCE_ROOT}/web-client/tv)
if(DEFINED CONAN_WEB-CLIENT-DESKTOP_ROOT)
add_resources(TARGET ${MAIN_TARGET} SOURCES ${CONAN_WEB-CLIENT-DESKTOP_ROOT}/desktop DEST ${RESOURCE_ROOT}/web-client/desktop)
add_resources(TARGET ${MAIN_TARGET} SOURCES ${WEB_TV_DIR} DEST ${RESOURCE_ROOT}/web-client/tv)
if(NOT WEB_CLIENT_DISABLE_DESKTOP)
add_resources(TARGET ${MAIN_TARGET} SOURCES ${WEB_DESKTOP_DIR} DEST ${RESOURCE_ROOT}/web-client/desktop)
endif()

if(NOT APPLE)
install(FILES ${QTROOT}/resources/qtwebengine_devtools_resources.pak DESTINATION resources)
install(DIRECTORY ${CONAN_WEB-CLIENT-TV2_ROOT}/tv DESTINATION ${INSTALL_RESOURCE_DIR}/web-client)
if(DEFINED CONAN_WEB-CLIENT-DESKTOP_ROOT)
install(DIRECTORY ${CONAN_WEB-CLIENT-DESKTOP_ROOT}/desktop DESTINATION ${INSTALL_RESOURCE_DIR}/web-client)
endif()
set(rsrc_locations
${QTROOT}/resources
/usr/share/qt/resources
)
foreach(loc ${rsrc_locations})
if(EXISTS ${loc}/qtwebengine_devtools_resources.pak)
install(FILES ${loc}/qtwebengine_devtools_resources.pak DESTINATION resources)
endif()
endforeach()
install(DIRECTORY ${WEB_TV_DIR}/ DESTINATION ${INSTALL_RESOURCE_DIR}/web-client/tv)
install(DIRECTORY ${WEB_DESKTOP_DIR}/ DESTINATION ${INSTALL_RESOURCE_DIR}/web-client/desktop)
endif()

if(XCODE)
Expand Down

0 comments on commit 773ad42

Please sign in to comment.