Merge lp:~sam-sgrs/click/cmake-modules into lp:ubuntu/utopic/click

Proposed by Sam Segers
Status: Needs review
Proposed branch: lp:~sam-sgrs/click/cmake-modules
Merge into: lp:ubuntu/utopic/click
Diff against target: 300 lines (+250/-1)
7 files modified
Makefile.am (+1/-1)
cmake/CLICKDeployLibs.cmake (+138/-0)
cmake/CLICKInstallDirs.cmake (+55/-0)
cmake/Makefile.am (+3/-0)
cmake/ResolveLibs.cmake (+51/-0)
configure.ac (+1/-0)
debian/click-dev.install (+1/-0)
To merge this branch: bzr merge lp:~sam-sgrs/click/cmake-modules
Reviewer Review Type Date Requested Status
Colin Watson Needs Information
Review via email: mp+219587@code.launchpad.net

Description of the change

Cmake files for click packaging

CLICKDeployLibs - deploys libs that are not in the ubuntu touch manifest (or other manifest supplied)
CLICKInstallDirs - Like GNUInstallDirs but for Click
ResolveLibs - resolve libs absolute

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

Please propose click merges to lp:click, not lp:ubuntu/click.

I'm having a hard time understanding why this is needed. Please can you provide some background? We shouldn't be going anywhere near image manifests from cdimage.ubuntu.com for building click packages, and building packages must not require access to a specific site on the network.

This all seems to overlap heavily with "click chroot", the ubuntu-sdk-libs-dev package, and associated framework files.

review: Needs Information
Revision history for this message
Sam Segers (sam-sgrs) wrote :

Yes, maybe ubuntu-sdk-libs-dev would be better.

Unmerged revisions

45. By Sam Segers

Add CMake modules to be used in Click packaging

CLICKDeployLibs - Add libs to be included in the click package
CLICKDeployLibs - GNUInstallDirs but for click
ResolveLibs - Resolves Libs to be included in CLICKDeployLibs

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2014-03-06 16:38:35 +0000
3+++ Makefile.am 2014-05-14 19:52:17 +0000
4@@ -1,4 +1,4 @@
5-SUBDIRS = lib preload click conf debhelper init po schroot
6+SUBDIRS = lib preload click conf debhelper init po schroot cmake
7 if PACKAGEKIT
8 SUBDIRS += pk-plugin
9 endif
10
11=== added directory 'cmake'
12=== added file 'cmake/CLICKDeployLibs.cmake'
13--- cmake/CLICKDeployLibs.cmake 1970-01-01 00:00:00 +0000
14+++ cmake/CLICKDeployLibs.cmake 2014-05-14 19:52:17 +0000
15@@ -0,0 +1,138 @@
16+# - Help functions for including libs for click packages
17+# It makes use of the latest manifest file provided on the Ubuntu website
18+# http://cdimage.ubuntu.com/ubuntu-touch/daily-preinstalled/current/
19+# Following cmake files need to be included:
20+# ResolveLibs.cmake
21+# You can change the url for lookup with:
22+# MANIFEST_URL_PREFIX - defaults to http://cdimage.ubuntu.com/ubuntu-touch/daily-preinstalled/current/trusty-preinstalled-touch-
23+# MANIFEST_URL_SUFFIX - defaults to .manifest
24+# MANIFEST_USE_ARCH - defaults to true
25+#
26+# Other variables that are used:
27+# CLICK_DEPLOY_ONLY_LIBS - defaults to true
28+# CLICK_DEPLOY_STATIC_LIBS - defaults to false
29+# CLICK_DEPLOY_INCLUDE_NO_MANIFEST - Include the libs when no manifest was found,
30+# defaults to true
31+
32+
33+include(ResolveLibs)
34+
35+if(NOT DEFINED DPKG_BUILD_ARCH)
36+ execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
37+ OUTPUT_VARIABLE BUILD_ARCH_TEMP
38+ OUTPUT_STRIP_TRAILING_WHITESPACE
39+ )
40+ set(DPKG_BUILD_ARCH ${BUILD_ARCH_TEMP} CACHE PATH "Debian arch")
41+endif()
42+
43+if(NOT DEFINED MANIFEST_URL_PREFIX)
44+ set(MANIFEST_URL_PREFIX "http://cdimage.ubuntu.com/ubuntu-touch/daily-preinstalled/current/trusty-preinstalled-touch-")
45+endif()
46+
47+if(NOT DEFINED MANIFEST_URL_SUFFIX)
48+ set(MANIFEST_URL_SUFFIX ".manifest")
49+endif()
50+
51+if(NOT DEFINED MANIFEST_USE_ARCH)
52+ set(MANIFEST_USE_ARCH true)
53+endif()
54+
55+if(NOT DEFINED CLICK_DEPLOY_ONLY_LIBS)
56+ set(CLICK_DEPLOY_ONLY_LIBS true)
57+endif()
58+
59+if(NOT DEFINED CLICK_DEPLOY_STATIC_LIBS)
60+ set(CLICK_DEPLOY_STATIC_LIBS false)
61+endif()
62+
63+if(NOT DEFINED CLICK_DEPLOY_INCLUDE_NO_MANIFEST)
64+ set(CLICK_DEPLOY_INCLUDE_NO_MANIFEST true)
65+endif()
66+
67+set(MANIFEST_URL "${MANIFEST_URL_PREFIX}")
68+if(MANIFEST_USE_ARCH)
69+ set(MANIFEST_URL "${MANIFEST_URL}${DPKG_BUILD_ARCH}")
70+endif()
71+set(MANIFEST_URL "${MANIFEST_URL}${MANIFEST_URL_SUFFIX}")
72+
73+message(STATUS "MANIFEST_URL: ${MANIFEST_URL}")
74+execute_process(
75+ COMMAND curl -s "${MANIFEST_URL}"
76+ COMMAND cut -f 1
77+ OUTPUT_VARIABLE PACKAGES
78+ OUTPUT_STRIP_TRAILING_WHITESPACE
79+)
80+
81+if(${PACKAGES} MATCHES "^<" OR NOT PACKAGES) # It's a HTML page or nothing returned
82+ message(STATUS "Error retreiving manifest")
83+ set(PACKAGES "")
84+ set(PACKAGES_LIST "")
85+else()
86+ STRING(REGEX REPLACE "\n" ";" PACKAGES_LIST ${PACKAGES})
87+endif()
88+
89+function(deploy_lib lib)
90+ message(STATUS "Mark ${lib} for install")
91+ install(FILES ${lib}
92+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/)
93+endfunction()
94+
95+function(deploy_libs libs)
96+ message(STATUS "Deploy Libs")
97+ set(error false)
98+ if(NOT PACKAGES_LIST) # If manifest was not downloaded
99+ if(NOT ${CLICK_DEPLOY_INCLUDE_NO_MANIFEST})
100+ set(error true)
101+ message(STATUS " No manifest found")
102+ endif()
103+ endif()
104+ if(NOT error)
105+ foreach(lib ${ARGN})
106+ set(error false)
107+ message(STATUS " LIB: ${lib}")
108+ resolve_lib(${lib} resolved found_lib)
109+ if(found_lib)
110+ message(STATUS " RESOLVED: ${resolved}")
111+ if(NOT ${CLICK_DEPLOY_STATIC_LIBS})
112+ if(${resolved} MATCHES "^.*\\.a([0-9]|\\.)*$") # If it's a static lib
113+ set(error true)
114+ message(STATUS " Not deploying static libs")
115+ endif()
116+ endif(NOT ${CLICK_DEPLOY_STATIC_LIBS})
117+ if(${CLICK_DEPLOY_ONLY_LIBS})
118+ if(${resolved} MATCHES "^.*\\.(so|a)([0-9]|\\.)*$") # If it's a static or dynamic lib
119+ else()
120+ set(error true)
121+ message(STATUS " Only deploy libs")
122+ endif()
123+ endif(${CLICK_DEPLOY_ONLY_LIBS})
124+ endif(found_lib)
125+ if(found_lib AND NOT error)
126+ if(NOT PACKAGES_LIST)
127+ deploy_lib(${resolved})
128+ else(NOT PACKAGES_LIST)
129+ execute_process(
130+ COMMAND dpkg -S ${resolved}
131+ COMMAND sed "s/^\\(.*\\):.*$/\\1/"
132+ COMMAND sed "s/^\\(.*\\):${DPKG_BUILD_ARCH}\$/\\1/"
133+ OUTPUT_VARIABLE PACKAGE
134+ OUTPUT_STRIP_TRAILING_WHITESPACE)
135+ message(STATUS " PACKAGE: ${PACKAGE}")
136+ list(FIND PACKAGES_LIST ${PACKAGE} index) # Search for package in manifest list
137+ if(index EQUAL -1)
138+ list(FIND PACKAGES_LIST "${PACKAGE}:${DPKG_BUILD_ARCH}" index) # Search for package:architecture in manifest
139+ endif(index EQUAL -1)
140+ if(index EQUAL -1)
141+ deploy_lib(${resolved})
142+ else(index EQUAL -1)
143+ message(STATUS " In manifest")
144+ endif(index EQUAL -1)
145+ endif(NOT PACKAGES_LIST)
146+ else(found_lib AND NOT error)
147+ if(NOT error)
148+ message(STATUS " Lib not found")
149+ endif(NOT error)
150+ endif(found_lib AND NOT error)
151+ endforeach(lib ${ARGN})
152+ endif(NOT error)
153+endfunction()
154
155=== added file 'cmake/CLICKInstallDirs.cmake'
156--- cmake/CLICKInstallDirs.cmake 1970-01-01 00:00:00 +0000
157+++ cmake/CLICKInstallDirs.cmake 2014-05-14 19:52:17 +0000
158@@ -0,0 +1,55 @@
159+# - Define CLICK installation directories when CLICK_MODE set
160+# otherwise defaults to GNU default installation directories
161+# Provides install directory variables as defined for GNU software:
162+# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
163+# Inclusion of this module defines the following variables:
164+# CMAKE_INSTALL_<dir> - destination for files of a given type
165+# CMAKE_INSTALL_FULL_<dir> - corresponding absolute path
166+# where <dir> is one of:
167+# BINDIR - user executables (bin)
168+# SBINDIR - system admin executables (sbin)
169+# LIBEXECDIR - program executables (libexec)
170+# SYSCONFDIR - read-only single-machine data (etc)
171+# SHAREDSTATEDIR - modifiable architecture-independent data (com)
172+# LOCALSTATEDIR - modifiable single-machine data (var)
173+# LIBDIR - object code libraries (lib or lib64 or lib/<multiarch-tuple> on Debian)
174+# INCLUDEDIR - C header files (include)
175+# OLDINCLUDEDIR - C header files for non-gcc (/usr/include)
176+# DATAROOTDIR - read-only architecture-independent data root (share)
177+# DATADIR - read-only architecture-independent data (DATAROOTDIR)
178+# INFODIR - info documentation (DATAROOTDIR/info)
179+# LOCALEDIR - locale-dependent data (DATAROOTDIR/locale)
180+# MANDIR - man documentation (DATAROOTDIR/man)
181+# DOCDIR - documentation root (DATAROOTDIR/doc/PROJECT_NAME)
182+# Each CMAKE_INSTALL_<dir> value may be passed to the DESTINATION options of
183+# install() commands for the corresponding file type. If the includer does
184+# not define a value the above-shown default will be used and the value will
185+# appear in the cache for editing by the user.
186+# Each CMAKE_INSTALL_FULL_<dir> value contains an absolute path constructed
187+# from the corresponding destination by prepending (if necessary) the value
188+# of CMAKE_INSTALL_PREFIX.
189+
190+option(CLICK_MODE "Installs to a contained location" off)
191+if(CLICK_MODE)
192+ execute_process(COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
193+ OUTPUT_VARIABLE BUILD_ARCH_TEMP
194+ OUTPUT_STRIP_TRAILING_WHITESPACE
195+ )
196+ set(BUILD_ARCH_TRIPLET "${BUILD_ARCH_TEMP}" CACHE PATH "Debian multiarch triplet")
197+
198+ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
199+ set(CMAKE_INSTALL_PREFIX "" CACHE PATH "Click install prefix" FORCE)
200+ endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
201+
202+ set(CMAKE_INSTALL_BINDIR "${CMAKE_INSTALL_PREFIX}/lib/${BUILD_ARCH_TRIPLET}" CACHE PATH "user executables")
203+ set(CMAKE_INSTALL_SBINDIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "system admin executables")
204+ set(CMAKE_INSTALL_LIBEXECDIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "program executables")
205+ set(CMAKE_INSTALL_SYSCONFDIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "read-only single-machine data")
206+ set(CMAKE_INSTALL_SHAREDSTATEDIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "modifiable architecture-independent data")
207+ set(CMAKE_INSTALL_LOCALSTATEDIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "modifiable single-machine data")
208+ set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "object code libraries")
209+
210+ set(CMAKE_INSTALL_DATAROOTDIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "read-only architecture-independent data root")
211+endif(CLICK_MODE)
212+
213+include(GNUInstallDirs)
214
215=== added file 'cmake/Makefile.am'
216--- cmake/Makefile.am 1970-01-01 00:00:00 +0000
217+++ cmake/Makefile.am 2014-05-14 19:52:17 +0000
218@@ -0,0 +1,3 @@
219+cmakedir = $(datadir)/cmake-2.8/Modules
220+
221+cmake_DATA = CLICKDeployLibs.cmake CLICKInstallDirs.cmake ResolveLibs.cmake
222
223=== added file 'cmake/ResolveLibs.cmake'
224--- cmake/ResolveLibs.cmake 1970-01-01 00:00:00 +0000
225+++ cmake/ResolveLibs.cmake 2014-05-14 19:52:17 +0000
226@@ -0,0 +1,51 @@
227+# Resolve the library (or other files) path
228+# Resolved_lib is defined to the lib or the lib it links to
229+# It follows multiple links
230+# Linking files are not processed
231+
232+function(resolve_lib lib resolved_lib success)
233+ set(${success} true)
234+ if(${lib} MATCHES "^-l(.*)$")
235+ STRING(REGEX REPLACE "^-l" "" lib_name "${lib}")
236+ if(lib_name)
237+ find_library(temp_lib NAMES ${lib_name})
238+ if(temp_lib)
239+ set(lib ${temp_lib})
240+ else()
241+ set(${success} false PARENT_SCOPE)
242+ endif()
243+ else()
244+ set(${resolved_lib} ${lib} PARENT_SCOPE)
245+ set(${success} false PARENT_SCOPE)
246+ endif()
247+ endif()
248+ if(${success})
249+ get_filename_component(resolved ${lib}
250+ REALPATH)
251+ if(EXISTS ${resolved})
252+ if(NOT ${resolved} STREQUAL ${lib})
253+ resolve_lib(${resolved} resolved temp)
254+ endif()
255+ set(${resolved_lib} ${resolved} PARENT_SCOPE)
256+ set(${success} true PARENT_SCOPE)
257+ else()
258+ set(${resolved_lib} ${lib} PARENT_SCOPE)
259+ set(${success} false PARENT_SCOPE)
260+ endif()
261+ endif()
262+endfunction(resolve_lib)
263+
264+function(resolve_libs resolved_libs libs)
265+ foreach(lib ${ARGN})
266+ resolve_lib(${lib} resolved temp)
267+ list(APPEND ${resolved_libs} ${resolved})
268+ endforeach()
269+endfunction(resolve_libs)
270+
271+function(remove_unexisting result_list lib_list)
272+ foreach(lib ${ARGN})
273+ if(EXISTS ${lib})
274+ list(APPEND ${result_list})
275+ endif()
276+ endforeach()
277+endfunction(remove_unexisting)
278
279=== modified file 'configure.ac'
280--- configure.ac 2014-03-06 16:38:35 +0000
281+++ configure.ac 2014-05-14 19:52:17 +0000
282@@ -140,6 +140,7 @@
283 po/Makefile.in
284 preload/Makefile
285 schroot/Makefile
286+ cmake/Makefile
287 ])
288 AC_CONFIG_FILES([lib/click/valac-wrapper], [chmod +x lib/click/valac-wrapper])
289 AC_CONFIG_FILES([setup.py], [chmod +x setup.py])
290
291=== modified file 'debian/click-dev.install'
292--- debian/click-dev.install 2013-11-21 14:46:16 +0000
293+++ debian/click-dev.install 2014-05-14 19:52:17 +0000
294@@ -1,5 +1,6 @@
295 etc/schroot/click
296 usr/bin/dh_click
297 usr/share/debhelper
298+usr/share/cmake-2.8/Modules
299 usr/share/man/man1/dh_click.1
300 usr/share/perl5

Subscribers

People subscribed via source and target branches

to all changes: