Merge lp:~zorba-coders/zorba/declare-uri-file into lp:zorba
- declare-uri-file
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Chris Hillery |
Approved revision: | 10640 |
Merged at revision: | 10639 |
Proposed branch: | lp:~zorba-coders/zorba/declare-uri-file |
Merge into: | lp:zorba |
Diff against target: |
256 lines (+106/-43) 6 files modified
cmake_modules/ZorbaModule.cmake (+69/-36) src/context/default_uri_mappers.cpp (+27/-7) test/rbkt/ExpQueryResults/zorba/fetch/fetch_random_file.xml.res (+1/-0) test/rbkt/Queries/zorba/fetch/fetch_random_file.xq (+4/-0) test/rbkt/modules/CMakeLists.txt (+4/-0) test/rbkt/modules/random-file.txt (+1/-0) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/declare-uri-file |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cezar Andrei | Approve | ||
Chris Hillery | Approve | ||
Review via email: mp+91049@code.launchpad.net |
Commit message
Added DECLARE_
Description of the change
Chris Hillery (ceejatec) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/declare-uri-file into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job declare-
The final status was:
28 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/declare-uri-file into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job declare-
The final status was:
40 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job declare-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 1 Approve, 1 Pending.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job declare-
All tests succeeded!
Preview Diff
1 | === modified file 'cmake_modules/ZorbaModule.cmake' |
2 | --- cmake_modules/ZorbaModule.cmake 2012-01-29 10:07:34 +0000 |
3 | +++ cmake_modules/ZorbaModule.cmake 2012-02-01 17:43:20 +0000 |
4 | @@ -66,7 +66,8 @@ |
5 | # |
6 | # Parameters: |
7 | # URI - URI to mangle |
8 | -# EXT - extension to ensure URI ends with |
9 | +# EXT - extension to ensure URI ends with (may be empty; if set, must |
10 | +# include leading "." |
11 | # DIR_VAR - variable to set with the directory part of the mangled path |
12 | # FILE_VAR - variable to set with the file part of the mangled path |
13 | MACRO (MANGLE_URI URI EXT DIR_VAR FILE_VAR) |
14 | @@ -89,13 +90,14 @@ |
15 | |
16 | # Convert final component into proper filename |
17 | IF (NOT final_comp) |
18 | - SET (${FILE_VAR} "index.${EXT}") |
19 | + SET (${FILE_VAR} "index${EXT}") |
20 | ELSE (NOT final_comp) |
21 | - IF ("${final_comp}" MATCHES "\\.${EXT}$") |
22 | + # \\ necessary to escape the leading . in EXT |
23 | + IF ("${final_comp}" MATCHES "\\${EXT}$") |
24 | SET (${FILE_VAR} "${final_comp}") |
25 | - ELSE ("${final_comp}" MATCHES "\\.${EXT}$") |
26 | - SET (${FILE_VAR} "${final_comp}.${EXT}") |
27 | - ENDIF ("${final_comp}" MATCHES "\\.${EXT}$") |
28 | + ELSE ("${final_comp}" MATCHES "\\${EXT}$") |
29 | + SET (${FILE_VAR} "${final_comp}${EXT}") |
30 | + ENDIF ("${final_comp}" MATCHES "\\${EXT}$") |
31 | ENDIF (NOT final_comp) |
32 | |
33 | # Stick the reversed authority back on the front of the path: done! |
34 | @@ -139,7 +141,7 @@ |
35 | GET_FILENAME_COMPONENT (module_name "${MODULE_FILE}" NAME) |
36 | |
37 | |
38 | - MANGLE_URI (${MODULE_URI} "xq" module_path module_filename) |
39 | + MANGLE_URI (${MODULE_URI} ".xq" module_path module_filename) |
40 | |
41 | # Compute a CMake-symbol-safe version of the target URI, for storing |
42 | # things in CMake properties. |
43 | @@ -355,7 +357,7 @@ |
44 | SET (SOURCE_FILE "${SCHEMA_FILE}") |
45 | ENDIF (NOT IS_ABSOLUTE "${SCHEMA_FILE}") |
46 | GET_FILENAME_COMPONENT (schema_name "${SCHEMA_FILE}" NAME) |
47 | - MANGLE_URI (${SCHEMA_URI} "xsd" schema_path schema_filename) |
48 | + MANGLE_URI (${SCHEMA_URI} ".xsd" schema_path schema_filename) |
49 | |
50 | # Add to schema manifest (except test schema). |
51 | IF (NOT SCHEMA_TEST_ONLY) |
52 | @@ -367,11 +369,44 @@ |
53 | |
54 | ENDMACRO (DECLARE_ZORBA_SCHEMA) |
55 | |
56 | +# Macro which declares a file to be loaded by URI. This sets up the |
57 | +# installation of the file into the URI_PATH folder so it will be |
58 | +# found at runtime. |
59 | +# |
60 | +# Args: URI - the URI of the file |
61 | +# FILE - path to file (if not absolute, will be resolved |
62 | +# relative to CMAKE_CURRENT_SOURCE_DIR) |
63 | +# TEST_ONLY - (optional) File is for testcases only and should not |
64 | +# be installed |
65 | +MACRO (DECLARE_ZORBA_URI_FILE) |
66 | + # QQQ Refactor - this macro is basically identical to DECLARE_ZORBA_SCHEMA |
67 | + PARSE_ARGUMENTS(URI_FILE "" "URI;FILE" "TEST_ONLY" ${ARGN}) |
68 | + IF (NOT URI_FILE_FILE) |
69 | + MESSAGE (FATAL_ERROR "'FILE' argument is required for ZORBA_DECLARE_URI_FILE()") |
70 | + ENDIF (NOT URI_FILE_FILE) |
71 | + IF (NOT URI_FILE_URI) |
72 | + MESSAGE (FATAL_ERROR "'URI' argument is required for ZORBA_DECLARE_URI_FILE()") |
73 | + ENDIF (NOT URI_FILE_URI) |
74 | + IF (NOT IS_ABSOLUTE "${URI_FILE_FILE}") |
75 | + SET (SOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${URI_FILE_FILE}") |
76 | + ELSE (NOT IS_ABSOLUTE "${URI_FILE_FILE}") |
77 | + SET (SOURCE_FILE "${URI_FILE_FILE}") |
78 | + ENDIF (NOT IS_ABSOLUTE "${URI_FILE_FILE}") |
79 | + GET_FILENAME_COMPONENT (uri_file_name "${URI_FILE_FILE}" NAME) |
80 | + # Don't enforce any extension on general files |
81 | + MANGLE_URI (${URI_FILE_URI} "" uri_file_path uri_file_filename) |
82 | + |
83 | + ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${uri_file_path}/${uri_file_filename}" |
84 | + "" "" "${URI_FILE_TEST_ONLY}") |
85 | + |
86 | +ENDMACRO (DECLARE_ZORBA_URI_FILE) |
87 | + |
88 | # Utility macro for setting up a build rule to copy a file to a |
89 | # particular (possibly versioned) file in a shared directory if such a file has |
90 | # not already been output. |
91 | # FILE_TYPE: Either "URI" or "LIB"; will be used to determine which shared |
92 | -# directory to place output in (URI_PATH or LIB_PATH). |
93 | +# directory to place output in (URI_PATH or LIB_PATH). Also, "URI" files |
94 | +# will have an INSTALL() directive to put them in the install image. |
95 | # INPUT_FILE: Absolute path to file to copy. |
96 | # OUTPUT_FILE: Relative path to output file (relative to URI_PATH). |
97 | # VERSION_ARG: Version; may be "" for non-versioned files. |
98 | @@ -425,39 +460,37 @@ |
99 | SET_PROPERTY (GLOBAL APPEND PROPERTY ZORBA_URI_FILES |
100 | "${INPUT_FILE}" "${_output_file}" "${DEPEND_TARGET}" "${_is_core}") |
101 | |
102 | - # For .xq and .xsd files, also set up an INSTALL rule (if not TEST_ONLY). |
103 | - IF (NOT ${TEST_ONLY} EQUAL 1) |
104 | - IF (${_output_ext} STREQUAL ".xq" OR ${_output_ext} STREQUAL ".xsd") |
105 | + # Also set up an INSTALL rule (unless TEST_ONLY or LIB). |
106 | + IF ( (NOT "${FILE_TYPE}" STREQUAL "LIB") AND (NOT ${TEST_ONLY} EQUAL 1) ) |
107 | |
108 | - IF(NOT _is_core) |
109 | - STRING(REPLACE "-" "_" component_name ${PROJECT_NAME}) |
110 | - INSTALL (FILES "${INPUT_FILE}" |
111 | - DESTINATION "${ZORBA_NONCORE_URI_DIR}/${_output_path}" |
112 | - RENAME "${_output_filename}" |
113 | - COMPONENT "${component_name}") |
114 | + IF(NOT _is_core) |
115 | + STRING(REPLACE "-" "_" component_name ${PROJECT_NAME}) |
116 | + INSTALL (FILES "${INPUT_FILE}" |
117 | + DESTINATION "${ZORBA_NONCORE_URI_DIR}/${_output_path}" |
118 | + RENAME "${_output_filename}" |
119 | + COMPONENT "${component_name}") |
120 | |
121 | - IF (NOT ${component_name}_cpack) |
122 | - SET (${component_name}_cpack 1) |
123 | + IF (NOT ${component_name}_cpack) |
124 | + SET (${component_name}_cpack 1) |
125 | |
126 | - STRING(TOUPPER ${component_name} component_name2) |
127 | - FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake "SET(CPACK_COMPONENT_${component_name2}_GROUP \"external_modules\")\n") |
128 | - |
129 | - STRING(REPLACE "zorba_" "" component_display_name ${component_name}) |
130 | - STRING(REPLACE "_" " " component_display_name ${component_display_name}) |
131 | - FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake "SET(CPACK_COMPONENT_${component_name2}_DISPLAY_NAME \"${component_display_name}\")\n") |
132 | - |
133 | - FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake "SET(CPACK_COMPONENT_${component_name2}_DESCRIPTION \"Install the functionalities of the ${component_display_name}.\")\n") |
134 | - FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake "SET(CPACK_COMPONENT_${component_name2}_INSTALL_TYPES Full)\n") |
135 | - ENDIF (NOT ${component_name}_cpack) |
136 | - |
137 | - ELSE(NOT _is_core) |
138 | - INSTALL (FILES "${INPUT_FILE}" |
139 | + STRING(TOUPPER ${component_name} component_name2) |
140 | + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake "SET(CPACK_COMPONENT_${component_name2}_GROUP \"external_modules\")\n") |
141 | + |
142 | + STRING(REPLACE "zorba_" "" component_display_name ${component_name}) |
143 | + STRING(REPLACE "_" " " component_display_name ${component_display_name}) |
144 | + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake "SET(CPACK_COMPONENT_${component_name2}_DISPLAY_NAME \"${component_display_name}\")\n") |
145 | + |
146 | + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake "SET(CPACK_COMPONENT_${component_name2}_DESCRIPTION \"Install the functionalities of the ${component_display_name}.\")\n") |
147 | + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake "SET(CPACK_COMPONENT_${component_name2}_INSTALL_TYPES Full)\n") |
148 | + ENDIF (NOT ${component_name}_cpack) |
149 | + |
150 | + ELSE(NOT _is_core) |
151 | + INSTALL (FILES "${INPUT_FILE}" |
152 | DESTINATION "${ZORBA_CORE_URI_DIR}/${_output_path}" |
153 | RENAME "${_output_filename}") |
154 | - ENDIF(NOT _is_core) |
155 | + ENDIF(NOT _is_core) |
156 | |
157 | - ENDIF (${_output_ext} STREQUAL ".xq" OR ${_output_ext} STREQUAL ".xsd") |
158 | - ENDIF (NOT ${TEST_ONLY} EQUAL 1) |
159 | + ENDIF ( (NOT "${FILE_TYPE}" STREQUAL "LIB") AND (NOT ${TEST_ONLY} EQUAL 1) ) |
160 | ENDIF (file_found EQUAL -1) |
161 | ENDMACRO (ADD_COPY_RULE) |
162 | |
163 | |
164 | === modified file 'src/context/default_uri_mappers.cpp' |
165 | --- src/context/default_uri_mappers.cpp 2011-11-08 03:11:02 +0000 |
166 | +++ src/context/default_uri_mappers.cpp 2012-02-01 17:43:20 +0000 |
167 | @@ -38,19 +38,35 @@ |
168 | (zstring const& aUri, EntityData const* aEntityData, |
169 | static_context const& aSctx, std::vector<zstring>& oUris) |
170 | { |
171 | - // File-izing is only for schemas and modules. |
172 | + // File-izing isn't for collections. Also, Thesauri use fake URIs that can |
173 | + // choke our URI class, so skip them. |
174 | EntityData::Kind lKind = aEntityData->getKind(); |
175 | - if (lKind != EntityData::SCHEMA && lKind != EntityData::MODULE) { |
176 | + if (lKind == EntityData::COLLECTION |
177 | +#ifndef ZORBA_NO_FULL_TEXT |
178 | + || lKind == EntityData::THESAURUS |
179 | +#endif |
180 | + ) { |
181 | return; |
182 | } |
183 | |
184 | - // Append extension / filename as necessary |
185 | - zstring lExtension(lKind == EntityData::SCHEMA ? ".xsd": ".xq"); |
186 | + // Append extension / filename as necessary. |
187 | + zstring lExtension; |
188 | + switch (lKind) { |
189 | + case EntityData::SCHEMA: |
190 | + lExtension = ".xsd"; |
191 | + break; |
192 | + case EntityData::MODULE: |
193 | + lExtension = ".xq"; |
194 | + break; |
195 | + default: |
196 | + lExtension = ""; |
197 | + break; |
198 | + } |
199 | URI lUri(aUri); |
200 | zstring lPath = lUri.get_encoded_path(); |
201 | bool lChanged = false; |
202 | if (ascii::ends_with(lPath, "/")) { |
203 | - // If URI ends with /, append "index.xsd" or "index.xq". |
204 | + // If URI ends with /, append "index.<extension>". |
205 | lPath.append("index"); |
206 | lPath.append(lExtension); |
207 | lChanged = true; |
208 | @@ -128,9 +144,13 @@ |
209 | (zstring const& aUri, EntityData const* aEntityData, |
210 | static_context const& aSctx, std::vector<zstring>& oUris) |
211 | { |
212 | - // Automatic resolution is (currently?) only for schemas and modules |
213 | + // Filesystem resolution doesn't make sense for collections |
214 | EntityData::Kind lKind = aEntityData->getKind(); |
215 | - if (lKind != EntityData::SCHEMA && lKind != EntityData::MODULE) { |
216 | + if (lKind == EntityData::COLLECTION |
217 | +#ifndef ZORBA_NO_FULL_TEXT |
218 | + || lKind == EntityData::THESAURUS |
219 | +#endif |
220 | + ) { |
221 | return; |
222 | } |
223 | // Automatic resolution is for NON-file: URIs |
224 | |
225 | === added file 'test/rbkt/ExpQueryResults/zorba/fetch/fetch_random_file.xml.res' |
226 | --- test/rbkt/ExpQueryResults/zorba/fetch/fetch_random_file.xml.res 1970-01-01 00:00:00 +0000 |
227 | +++ test/rbkt/ExpQueryResults/zorba/fetch/fetch_random_file.xml.res 2012-02-01 17:43:20 +0000 |
228 | @@ -0,0 +1,1 @@ |
229 | +This is a random file that I would like to load by URI. |
230 | |
231 | === added file 'test/rbkt/Queries/zorba/fetch/fetch_random_file.xq' |
232 | --- test/rbkt/Queries/zorba/fetch/fetch_random_file.xq 1970-01-01 00:00:00 +0000 |
233 | +++ test/rbkt/Queries/zorba/fetch/fetch_random_file.xq 2012-02-01 17:43:20 +0000 |
234 | @@ -0,0 +1,4 @@ |
235 | +(: Fetch a random file from the filesystem :) |
236 | +import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch#2.0"; |
237 | + |
238 | +fetch:content("http://www.zorba-xquery.com/random-file", "SOME_CONTENT") |
239 | |
240 | === modified file 'test/rbkt/modules/CMakeLists.txt' |
241 | --- test/rbkt/modules/CMakeLists.txt 2012-01-11 17:30:25 +0000 |
242 | +++ test/rbkt/modules/CMakeLists.txt 2012-02-01 17:43:20 +0000 |
243 | @@ -54,3 +54,7 @@ |
244 | -e "manifest:=${CMAKE_BINARY_DIR}/ZorbaManifest.xml" |
245 | --module-path "${CMAKE_BINARY_DIR}/TEST_URI_PATH") |
246 | ENDIF (NOT ZORBA_NO_XMLSCHEMA) |
247 | + |
248 | +# This is as good a place as any to test this feature |
249 | +DECLARE_ZORBA_URI_FILE(FILE "random-file.txt" |
250 | + URI "http://www.zorba-xquery.com/random-file" TEST_ONLY) |
251 | |
252 | === added file 'test/rbkt/modules/random-file.txt' |
253 | --- test/rbkt/modules/random-file.txt 1970-01-01 00:00:00 +0000 |
254 | +++ test/rbkt/modules/random-file.txt 2012-02-01 17:43:20 +0000 |
255 | @@ -0,0 +1,1 @@ |
256 | +This is a random file that I would like to load by URI. |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ declare- uri-file- 2012-02- 01T11-39- 55.537Z/ log.html
Log at: http://