[win32] add make-addon-depends.bat and cmake-based addon-depends system
authormontellese <montellese@xbmc.org>
Wed, 4 Jun 2014 21:36:27 +0000 (23:36 +0200)
committerJonathan Marshall <jmarshall@xbmc.org>
Thu, 10 Jul 2014 07:18:04 +0000 (19:18 +1200)
16 files changed:
.gitignore
project/cmake/addons/depends/win32/CMakeLists.txt [new file with mode: 0644]
project/cmake/addons/depends/win32/Find7Zip.cmake [new file with mode: 0644]
project/cmake/addons/depends/win32/README [new file with mode: 0644]
project/cmake/addons/depends/win32/extract-7z.cmake [new file with mode: 0644]
project/cmake/addons/depends/win32/extract-direct.cmake [new file with mode: 0644]
project/cmake/addons/depends/win32/install.cmake [new file with mode: 0644]
project/cmake/addons/depends/win32/prebuilt/README [new file with mode: 0644]
project/cmake/addons/depends/win32/prebuilt/flac/flac.txt [new file with mode: 0644]
project/cmake/addons/depends/win32/prebuilt/flac/install.txt [new file with mode: 0644]
project/cmake/addons/depends/win32/prebuilt/lame.txt [new file with mode: 0644]
project/cmake/addons/depends/win32/prebuilt/ogg/install.txt [new file with mode: 0644]
project/cmake/addons/depends/win32/prebuilt/ogg/ogg.txt [new file with mode: 0644]
project/cmake/addons/depends/win32/prebuilt/vorbis/install.txt [new file with mode: 0644]
project/cmake/addons/depends/win32/prebuilt/vorbis/vorbis.txt [new file with mode: 0644]
tools/buildsteps/win32/make-addon-depends.bat [new file with mode: 0644]

index dcbc921..1a39ec6 100644 (file)
@@ -341,6 +341,8 @@ lib/cpluff/stamp-h1
 # /project/cmake
 /project/cmake/xbmc-config.cmake
 /project/cmake/addons/build
+/project/cmake/addons/depends/win32/build
+/project/cmake/addons/output
 
 # /project/Win32BuildSetup/
 /project/Win32BuildSetup/XBMC.log
diff --git a/project/cmake/addons/depends/win32/CMakeLists.txt b/project/cmake/addons/depends/win32/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d8a55eb
--- /dev/null
@@ -0,0 +1,65 @@
+project(xbmc-addons-depends-win32)
+
+cmake_minimum_required(VERSION 2.8)
+
+list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
+
+if(NOT CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE Release)
+endif()
+
+include(ExternalProject)
+
+if(NOT CMAKE_INSTALL_PREFIX)
+  set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/depends)
+endif()
+list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
+
+function(add_internal id url inputfile)
+  externalproject_add(${id}
+                      URL ${url}
+                      PREFIX build/${id}
+                      CONFIGURE_COMMAND ""
+                      BUILD_COMMAND ""
+                      INSTALL_COMMAND ${CMAKE_COMMAND}
+                                      -DINPUTDIR=${CMAKE_BINARY_DIR}/build/${id}/src/${id}
+                                      -DINPUTFILE=${inputfile}
+                                      -DDESTDIR=${CMAKE_INSTALL_PREFIX}
+                                      -P ${PROJECT_SOURCE_DIR}/install.cmake)
+endfunction()
+
+function(add_7zip id url inputfile)
+  externalproject_add(${id}
+                      PREFIX build/${id}
+                      DOWNLOAD_COMMAND ${CMAKE_COMMAND}
+                                       -D7ZIP_EXECUTABLE=${7ZIP_EXECUTABLE}
+                                       -DURL=${url}
+                                       -DDEST=${CMAKE_BINARY_DIR}/build/${id}/src/${id}
+                                       -DDESTDIR=${CMAKE_BINARY_DIR}/build/${id}/src/${id}-build
+                                       -P ${PROJECT_SOURCE_DIR}/extract-7z.cmake
+                      CONFIGURE_COMMAND ""
+                      BUILD_COMMAND ""
+                      INSTALL_COMMAND ${CMAKE_COMMAND}
+                                      -DINPUTDIR=${CMAKE_BINARY_DIR}/build/${id}/src/${id}-build/
+                                      -DINPUTFILE=${inputfile}
+                                      -DDESTDIR=${CMAKE_INSTALL_PREFIX}
+                                      -P ${PROJECT_SOURCE_DIR}/install.cmake)
+endfunction()
+
+#find_package(7Zip REQUIRED)
+
+file(GLOB_RECURSE download_input_files prebuilt/*.txt)
+foreach(file ${download_input_files})
+  if(NOT file MATCHES install.txt)
+    file(STRINGS ${file} def)
+    get_filename_component(dir ${file} PATH)
+    string(REPLACE " " ";" def ${def})
+    list(GET def 0 id)
+    list(GET def 1 url)
+    #    if(url MATCHES .7z OR url MATCHES .lzma)
+    #      add_7zip(${id} ${url} ${dir}/install.txt)
+    #    else()
+      add_internal(${id} ${url} ${dir}/install.txt)
+      #    endif()
+  endif()
+endforeach()
diff --git a/project/cmake/addons/depends/win32/Find7Zip.cmake b/project/cmake/addons/depends/win32/Find7Zip.cmake
new file mode 100644 (file)
index 0000000..82b0902
--- /dev/null
@@ -0,0 +1,7 @@
+find_program(7ZIP_EXECUTABLE NAMES 7z.exe
+             HINTS PATHS "c:/Program Files/7-Zip")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(7Zip DEFAULT_MSG 7ZIP_EXECUTABLE)
+
+mark_as_advanced(7ZIP_EXECUTABLE)
diff --git a/project/cmake/addons/depends/win32/README b/project/cmake/addons/depends/win32/README
new file mode 100644 (file)
index 0000000..1021a18
--- /dev/null
@@ -0,0 +1,19 @@
+XBMC WIN32 ADDON DEPENDENCIES
+=============================
+This directory contains the cmake-based buildsystem for dependencies (currently
+only prebuilt) used by one or multiple addons. The buildsystem looks into the
+"prebuilt" sub-directory, downloads all the specified dependencies, extracts
+them and places them into the "depends" sub-directory.
+
+To trigger the cmake-based buildsystem the following command must be executed
+with <path> being the path to this directory (absolute or relative, allowing for
+in-source and out-of-source builds).
+
+  cmake <path> -G <generator>
+
+cmake supports multiple generators, see
+http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators for a list.
+For win32 builds one of the "Visual Studio XX" or the "NMake Makefiles"
+generators is preferred. For the "NMake Makefiles" generator to work the above
+command must be called from an environment prepared for VC++ builds (see
+http://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx).
diff --git a/project/cmake/addons/depends/win32/extract-7z.cmake b/project/cmake/addons/depends/win32/extract-7z.cmake
new file mode 100644 (file)
index 0000000..95a2672
--- /dev/null
@@ -0,0 +1,10 @@
+get_filename_component(file ${URL} NAME)
+file(DOWNLOAD ${URL} ${DEST}/${file})
+execute_process(COMMAND ${7ZIP_EXECUTABLE} -y x ${DEST}/${file}
+                WORKING_DIRECTORY ${DESTDIR})
+if(${file} MATCHES .tar)
+  string(REPLACE ".7z" "" tarball ${file})
+  string(REPLACE ".lzma" "" tarball ${file})
+  execute_process(COMMAND ${7ZIP_EXECUTABLE} -y x ${DESTDIR}/${tarball}
+                  WORKING_DIRECTORY ${DESTDIR})
+endif()
diff --git a/project/cmake/addons/depends/win32/extract-direct.cmake b/project/cmake/addons/depends/win32/extract-direct.cmake
new file mode 100644 (file)
index 0000000..13cb74f
--- /dev/null
@@ -0,0 +1,2 @@
+get_filename_component(file ${URL} NAME)
+file(DOWNLOAD ${URL} ${DEST}/${file})
diff --git a/project/cmake/addons/depends/win32/install.cmake b/project/cmake/addons/depends/win32/install.cmake
new file mode 100644 (file)
index 0000000..9a3adbb
--- /dev/null
@@ -0,0 +1,24 @@
+if(EXISTS "${INPUTFILE}")
+  # if there's an input file we use it to determine which files to copy where
+  file(STRINGS ${INPUTFILE} FILES)
+  string(REPLACE "\n" ";" FILES "${FILES}")
+  foreach(file ${FILES})
+    string(REPLACE " " ";" file "${file}")
+    list(GET file 0 dir)
+    list(GET file 1 dest)
+    list(LENGTH file deflength)
+    if(deflength GREATER 2)
+      list(GET file 2 copy)
+    endif()
+    file(GLOB files ${INPUTDIR}/${dir})
+    foreach(instfile ${files})
+      file(COPY ${instfile} DESTINATION ${DESTDIR}/${dest})
+      if(copy)
+        file(COPY ${instfile} DESTINATION ${DESTDIR}/${copy})
+      endif()
+    endforeach()
+  endforeach()
+else()
+  # otherwise we assume that the content of the extracted archive is already well-formed and can just be copied
+  file(COPY ${INPUTDIR}/${dir} DESTINATION ${DESTDIR})
+endif()
\ No newline at end of file
diff --git a/project/cmake/addons/depends/win32/prebuilt/README b/project/cmake/addons/depends/win32/prebuilt/README
new file mode 100644 (file)
index 0000000..11a05a5
--- /dev/null
@@ -0,0 +1,21 @@
+XBMC WIN32 PREBUILT ADDON DEPENDENCIES
+======================================
+This directory contains a file or sub-directory for every prebuilt dependency
+used by one of the addons being built. There are two different modes supported.
+Both include a file named <library-id>.txt which must follow the defined format
+  <library-id> <download-url>
+
+If the archive, which the <download-url> points at, contains
+ * only the necessary files and in the proper directory structure (i.e. an
+   "include" and a "lib" directory) then the file must be put into this
+   directory and nothing else is needed.
+ * unnecessary files and/or does not follow the defined directory structure
+   (i.e. an "include" and a "lib" directory) then the file must be put into a
+   sub-directory named <library-id>. Furthermore an additional file called
+   "install.txt" must be placed in that sub-directory. install.txt contains a
+   line for every path/directory/file with a destination where it must be copied
+   to. It must follow the defined format
+     <source> <destination> [<copy-destination>]
+   where <source> must be an existing file, directory or a path containing
+   wildcards, <destination> and the optional <copy-destination> must be existing
+   directories.
diff --git a/project/cmake/addons/depends/win32/prebuilt/flac/flac.txt b/project/cmake/addons/depends/win32/prebuilt/flac/flac.txt
new file mode 100644 (file)
index 0000000..098f08f
--- /dev/null
@@ -0,0 +1 @@
+flac http://mirrors.xbmc.org/build-deps/win32/flac-1.2.1-devel-win.zip
diff --git a/project/cmake/addons/depends/win32/prebuilt/flac/install.txt b/project/cmake/addons/depends/win32/prebuilt/flac/install.txt
new file mode 100644 (file)
index 0000000..8a6437e
--- /dev/null
@@ -0,0 +1,2 @@
+include/FLAC/* include/FLAC
+lib/libFLAC_static.lib lib
diff --git a/project/cmake/addons/depends/win32/prebuilt/lame.txt b/project/cmake/addons/depends/win32/prebuilt/lame.txt
new file mode 100644 (file)
index 0000000..6fc7acf
--- /dev/null
@@ -0,0 +1 @@
+lame http://mirrors.xbmc.org/build-deps/win32/libmp3lame-3.99.5-static-win32-2.zip
\ No newline at end of file
diff --git a/project/cmake/addons/depends/win32/prebuilt/ogg/install.txt b/project/cmake/addons/depends/win32/prebuilt/ogg/install.txt
new file mode 100644 (file)
index 0000000..a5f8852
--- /dev/null
@@ -0,0 +1,2 @@
+include/ogg/* include/ogg
+lib/* lib
diff --git a/project/cmake/addons/depends/win32/prebuilt/ogg/ogg.txt b/project/cmake/addons/depends/win32/prebuilt/ogg/ogg.txt
new file mode 100644 (file)
index 0000000..801b13b
--- /dev/null
@@ -0,0 +1 @@
+ogg http://mirrors.xbmc.org/build-deps/win32/libogg-vc100-1.2.0-lib.tar.bz2
diff --git a/project/cmake/addons/depends/win32/prebuilt/vorbis/install.txt b/project/cmake/addons/depends/win32/prebuilt/vorbis/install.txt
new file mode 100644 (file)
index 0000000..3021f12
--- /dev/null
@@ -0,0 +1,2 @@
+include/vorbis/* include/vorbis
+lib/* lib
diff --git a/project/cmake/addons/depends/win32/prebuilt/vorbis/vorbis.txt b/project/cmake/addons/depends/win32/prebuilt/vorbis/vorbis.txt
new file mode 100644 (file)
index 0000000..23e56e2
--- /dev/null
@@ -0,0 +1 @@
+vorbis http://mirrors.xbmc.org/build-deps/win32/libvorbis-vc100-1.3.1-lib.tar.bz2
diff --git a/tools/buildsteps/win32/make-addon-depends.bat b/tools/buildsteps/win32/make-addon-depends.bat
new file mode 100644 (file)
index 0000000..c9a3c0b
--- /dev/null
@@ -0,0 +1,77 @@
+@ECHO OFF
+
+SETLOCAL
+
+SET EXITCODE=0
+
+rem set Visual C++ build environment
+call "%VS120COMNTOOLS%..\..\VC\bin\vcvars32.bat"
+
+SET WORKDIR=%WORKSPACE%
+
+IF "%WORKDIR%"=="" (
+  SET WORKDIR=%CD%\..\..\..
+)
+
+rem setup some paths that we need later
+SET CUR_PATH=%CD%
+
+SET BASE_PATH=%WORKDIR%\project\cmake\
+SET ADDONS_PATH=%BASE_PATH%\addons
+SET ADDONS_OUTPUT_PATH=%ADDONS_PATH%\output
+SET ADDON_DEPENDS_PATH=%ADDONS_PATH%\depends\win32
+SET ADDON_DEPENDS_BUILD_PATH=%ADDON_DEPENDS_PATH%\build
+
+SET ERRORFILE=%BASE_PATH%\make-addon-depends.error
+
+rem remove the output directory if it exists
+IF EXIST "%ADDONS_OUTPUT_PATH%" (
+       RMDIR "%ADDONS_OUTPUT_PATH%" /S /Q > NUL
+)
+
+rem create the output directory
+MKDIR "%ADDONS_OUTPUT_PATH%"
+
+rem go into the addon depends directory
+CD %ADDON_DEPENDS_PATH%
+
+rem remove the build directory if it exists
+IF EXIST "%ADDON_DEPENDS_BUILD_PATH%" (
+       RMDIR "%ADDON_DEPENDS_BUILD_PATH%" /S /Q > NUL
+)
+
+rem create the build directory
+MKDIR "%ADDON_DEPENDS_BUILD_PATH%"
+
+rem go into the build directory
+CD "%ADDON_DEPENDS_BUILD_PATH%"
+
+rem execute cmake to generate makefiles processable by nmake
+cmake "%ADDON_DEPENDS_PATH%" -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%ADDONS_OUTPUT_PATH%
+IF ERRORLEVEL 1 (
+       ECHO cmake error level: %ERRORLEVEL% > %ERRORFILE%
+       GOTO ERROR
+)
+
+rem execute nmake to build the addon depends
+nmake
+IF ERRORLEVEL 1 (
+       ECHO nmake error level: %ERRORLEVEL% > %ERRORFILE%
+       GOTO ERROR
+)
+
+rem everything was fine
+GOTO END
+
+:ERROR
+rem something went wrong
+ECHO Failed to build addon dependencies
+ECHO See %ERRORFILE% for more details
+SET EXITCODE=1
+
+:END
+rem go back to the original directory
+cd %CUR_PATH%
+
+rem exit the script with the defined exitcode
+EXIT /B %EXITCODE%