← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~verzegnassi-stefano/ubuntu-docviewer-app/cmake-click-cache-option into lp:ubuntu-docviewer-app

 

Stefano Verzegnassi has proposed merging lp:~verzegnassi-stefano/ubuntu-docviewer-app/cmake-click-cache-option into lp:ubuntu-docviewer-app.

Commit message:
Allow to disable .click dependencies caching through a CMake option

Requested reviews:
  Ubuntu Document Viewer Developers (ubuntu-docviewer-dev)
Related bugs:
  Bug #1547059 in Ubuntu Document Viewer App: "needs no-cache option during cmake build"
  https://bugs.launchpad.net/ubuntu-docviewer-app/+bug/1547059

For more details, see:
https://code.launchpad.net/~verzegnassi-stefano/ubuntu-docviewer-app/cmake-click-cache-option/+merge/287187

Allow to disable .click dependencies caching through a CMake option
-- 
Your team Ubuntu Document Viewer Developers is requested to review the proposed merge of lp:~verzegnassi-stefano/ubuntu-docviewer-app/cmake-click-cache-option into lp:ubuntu-docviewer-app.
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2016-02-05 22:57:24 +0000
+++ CMakeLists.txt	2016-02-25 15:13:53 +0000
@@ -14,6 +14,7 @@
 
 option(INSTALL_TESTS    "Install the tests on make install" on)
 option(CLICK_MODE       "Installs to a contained location" on)
+option(NO_CACHE         "Disable caching of click dependencies (CLICK_MODE only)" off)
 
 set(APP_NAME            ubuntu-docviewer-app)
 set(DESKTOP_FILE        "${PROJECT_NAME}.desktop")

=== modified file 'cmake/modules/Click.cmake'
--- cmake/modules/Click.cmake	2016-01-17 20:15:53 +0000
+++ cmake/modules/Click.cmake	2016-02-25 15:13:53 +0000
@@ -19,22 +19,33 @@
 
   MESSAGE("Grabbing upstream libs to ${UPSTREAM_LIBS_DIR}") 
 
-  get_filename_component(BLD_CONFIGURATION_NAME ${CMAKE_BINARY_DIR} NAME)
-  set(UPSTREAM_CACHE $ENV{HOME}/dev/upstream-libs-docviewer/${BLD_CONFIGURATION_NAME})
-  MESSAGE("Upstream libs cache path: ${UPSTREAM_CACHE}")  
-
-  if(EXISTS "${UPSTREAM_CACHE}")
-    MESSAGE("Upstream libs cache exists.") 
-    file(COPY ${UPSTREAM_CACHE}/upstream-libs/ DESTINATION ${UPSTREAM_LIBS_DIR} PATTERN * )
-  else()
-    MESSAGE("Cache miss, downloading from network.") 
+  if(NO_CACHE)
+    # It has been specified not to cache .click dependencies on the machine.
+    # This is meant to be used for automatic builds (e.g. Jenkins Bot).
     execute_process(
       COMMAND mkdir ${UPSTREAM_LIBS_DIR}
       COMMAND ${GET_CLICK_DEPS_TOOL} -d ${DEPS_MANIFEST} -c ${CUSTOM_SCRIPT} ${CLICK_ARCH} ${UPSTREAM_LIBS_DIR}
     )
-    # Cache for next usage.
-    file(COPY ${UPSTREAM_LIBS_DIR} DESTINATION ${UPSTREAM_CACHE} )
-  endif()
+  else(NO_CACHE)
+    # Cache the .click dependencies for next usage. (Default)
+    # Useful on developer machine.
+    get_filename_component(BLD_CONFIGURATION_NAME ${CMAKE_BINARY_DIR} NAME)
+    set(UPSTREAM_CACHE $ENV{HOME}/dev/upstream-libs-docviewer/${BLD_CONFIGURATION_NAME})
+    MESSAGE("Upstream libs cache path: ${UPSTREAM_CACHE}")
+
+    if(EXISTS "${UPSTREAM_CACHE}")
+      MESSAGE("Upstream libs cache exists.")
+      file(COPY ${UPSTREAM_CACHE}/upstream-libs/ DESTINATION ${UPSTREAM_LIBS_DIR} PATTERN * )
+    else()
+      MESSAGE("Cache miss, downloading from network.")
+      execute_process(
+        COMMAND mkdir ${UPSTREAM_LIBS_DIR}
+        COMMAND ${GET_CLICK_DEPS_TOOL} -d ${DEPS_MANIFEST} -c ${CUSTOM_SCRIPT} ${CLICK_ARCH} ${UPSTREAM_LIBS_DIR}
+      )
+      # Cache for next usage.
+      file(COPY ${UPSTREAM_LIBS_DIR} DESTINATION ${UPSTREAM_CACHE} )
+    endif() #EXISTS "${UPSTREAM_CACHE}"
+  endif() #NO_CACHE
 
   MESSAGE("Installing upstream libs from ${UPSTREAM_LIBS_DIR}/usr/lib/${ARCH_TRIPLET}/ to ${DATA_DIR}lib/${ARCH_TRIPLET}")
   file(GLOB_RECURSE UPSTREAM_LIBS "${UPSTREAM_LIBS_DIR}/usr/lib/${ARCH_TRIPLET}/*")


Follow ups