@@ -55,6 +55,29 @@ PACKAGE_VERSION := $(or \
55
55
PACKAGE_CHANNEL := cloe/develop
56
56
PACKAGE_FQN := ${PACKAGE_NAME}/${PACKAGE_VERSION}@${PACKAGE_CHANNEL}
57
57
58
+ # It is an order of magnitude faster to parse ~/.conan/editable_packages.json
59
+ # ourselves than to get conan to do it for us. This should only take us 20ms,
60
+ # while conan needs 250ms. Also, this will tell us if the package is editable,
61
+ # or the path to the current conanfile.py is marked as editable. This helps
62
+ # inform the user when they make a package editable, but then check out another
63
+ # state of the tree with a different version.
64
+ SOURCE_CONANFILE_REALPATH := $(realpath ${SOURCE_CONANFILE})
65
+ define JQ_PACKAGE_EDITABLE
66
+ if has(\"${PACKAGE_FQN}\") then
67
+ if .[\"${PACKAGE_FQN}\"].path == \"${SOURCE_CONANFILE_REALPATH}\" then
68
+ \"editable\"
69
+ else
70
+ \"editable-elsewhere\"
71
+ end
72
+ else
73
+ if ([.[].path] | any(. == \"${SOURCE_CONANFILE_REALPATH}\")) then
74
+ \"editable-other-name\"
75
+ else
76
+ \"not-editable\"
77
+ end
78
+ end
79
+ endef
80
+
58
81
# Normally, you should set this in your profile, but if you just want to build
59
82
# the package in debug mode once, you can do it this way, although it will
60
83
# only apply to local builds.
92
115
93
116
# INFORMATIONAL TARGETS -------------------------------------------------------
94
117
.DEFAULT : help
95
- .SILENT : help status parse-info info-name info-version info-channel info-fqn info
96
- .PHONY : help status parse-info info-name info-version info-channel info-fqn info
97
- help :: parse-info
118
+ .SILENT : help status parse-info parse-editable info-name info-version info-channel info-fqn info
119
+ .PHONY : help status parse-info parse-editable info-name info-version info-channel info-fqn info
120
+ help :: parse-info parse-editable
98
121
echo " Usage: make <target>"
99
122
echo
100
123
echo " The following targets define common operations with this package in"
@@ -136,6 +159,7 @@ help:: parse-info
136
159
echo " PACKAGE_VERSION: ${PACKAGE_VERSION} "
137
160
echo " PACKAGE_CHANNEL: ${PACKAGE_CHANNEL} "
138
161
echo " PACKAGE_FQN: ${PACKAGE_FQN} "
162
+ echo " PACKAGE_EDITABLE:${PACKAGE_EDITABLE} "
139
163
echo " PACKAGE_ID: ${PACKAGE_ID} "
140
164
echo " PACKAGE_DIR: ${PACKAGE_DIR} "
141
165
echo " PACKAGE_DATE: ${PACKAGE_DATE} "
@@ -149,28 +173,30 @@ parse-info: ${BUILD_LOCKFILE}
149
173
# target needs one of these variables, they should depend on this target
150
174
# to ensure that these variables are set.
151
175
#
152
- $(eval PACKAGE_INFO := $(shell conan info ${ALL_OPTIONS} "${PACKAGE_FQN}" --package-filter "${PACKAGE_FQN}" --paths | sed -r 's/$$/\\n/') )
176
+ $(eval PACKAGE_INFO := $(shell conan info ${ALL_OPTIONS} "${PACKAGE_FQN}" --package-filter "${PACKAGE_FQN}" --paths 2>/dev/null | sed -r 's/$$/\\n/') )
153
177
$(eval PACKAGE_ID := $(shell echo -e "${PACKAGE_INFO}" | sed -rn 's/^ * ID: * (.* ) $$/\1/p') )
154
178
$(eval PACKAGE_DIR := $(shell echo -e "${PACKAGE_INFO}" | sed -rn 's/^ * package_folder: * (.* ) $$/\1/p') )
155
179
$(eval PACKAGE_DATE := $(shell echo -e "${PACKAGE_INFO}" | sed -rn 's/^ * Creation date: * (.* ) $$/\1/p') )
156
180
157
- status : parse-info
181
+ parse-editable :
182
+ $(eval PACKAGE_EDITABLE := $(shell [ -e ~/.conan/editable_packages.json ] && jq -r "${JQ_PACKAGE_EDITABLE}" ~/.conan/editable_packages.json || echo "not-editable") )
183
+
184
+ status : parse-info parse-editable
158
185
# Show the *approximate* status of each package in the cloe workspace.
159
186
#
160
187
# This lets you know whether a package is in editable mode or not,
161
188
# and will also let you know if any of the files in the package
162
189
# directory has been modified more recently than the package in the
163
190
# Conan cache.
164
191
#
165
- _editable=$$(conan editable list | grep "${PACKAGE_FQN}" ) ; \
166
- if [ -z " $$ {_editable}" ]; then \
192
+ if [ " ${PACKAGE_EDITABLE} " != " not-editable" ] ; then \
193
+ echo " ${PACKAGE_EDITABLE} : ${PACKAGE_FQN} " ; \
194
+ else \
167
195
if [ -n " ${PACKAGE_DATE} " ] && [ -z " $$ (find -type f -newermt " ${PACKAGE_DATE} " )" ]; then \
168
196
echo " ok : ${PACKAGE_FQN} " ; \
169
197
else \
170
198
echo " outdated : ${PACKAGE_FQN} " ; \
171
199
fi \
172
- else \
173
- echo " editable : ${PACKAGE_FQN} " ; \
174
200
fi
175
201
176
202
info-name :
@@ -218,13 +244,13 @@ uneditable:
218
244
# CONAN TARGETS ---------------------------------------------------------------
219
245
.PHONY : export package package-all package-missing package-outdated purge list
220
246
221
- export :
247
+ export : parse-editable
222
248
# Export sources to Conan cache.
223
249
#
224
250
# This does not build this package but provides the sources and the
225
251
# build recipe to Conan for on-demand building.
226
252
#
227
- conan export . ${PACKAGE_FQN}
253
+ if [ " ${PACKAGE_EDITABLE} " = " not-editable " ] || [ " ${PACKAGE_EDITABLE} " = " editable-other-name " ] ; then conan export . ${PACKAGE_FQN} ; fi
228
254
229
255
download :
230
256
# Try to download the package to Conan cache.
0 commit comments