aboutsummaryrefslogtreecommitdiffstats
path: root/lv2includegen
diff options
context:
space:
mode:
Diffstat (limited to 'lv2includegen')
-rwxr-xr-xlv2includegen/lv2includegen.py44
1 files changed, 31 insertions, 13 deletions
diff --git a/lv2includegen/lv2includegen.py b/lv2includegen/lv2includegen.py
index a27f1cd..ffca0e8 100755
--- a/lv2includegen/lv2includegen.py
+++ b/lv2includegen/lv2includegen.py
@@ -1,8 +1,25 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-#
-# lv2includegen, a tool to generate directory trees for including
-# extension headers from source code.
+
+"""A program (and Python module) to generate a tree of symlinks to LV2
+extension bundles, where the path of the symlink corresponds to the URI of
+the extension. This allows including extension headers in code without using
+the bundle name. Including extension headers in this way is much better,
+since there is no dependency on the (meaningless and non-persistent) bundle
+name in the code using the header.
+
+For example, after running lv2includegen (and setting the compiler include
+path appropriately), LV2 headers could be included like so:
+
+#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
+#include "lv2/lv2plug.in/ns/ext/event/event.h"
+#include "lv2/example.org/foo/foo.h"
+
+Where the initial "lv2" is arbitrary; in this case lv2includegen's output
+directory was "lv2", and that directory's parent was added to the compiler
+include search path. It is a good idea to use such a prefix directory so
+domain names do not conflict with anything else in the include path.
+"""
__authors__ = 'David Robillard'
__license = 'GNU GPL v3 or later <http://www.gnu.org/licenses/gpl.html>'
@@ -21,7 +38,7 @@ rdf = RDF.NS('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
lv2 = RDF.NS('http://lv2plug.in/ns/lv2core#')
def lv2_path():
- "Return the LV2 search path (LV2_PATH)."
+ "Return the LV2 search path (LV2_PATH in the environment, or a default)."
if 'LV2_PATH' in os.environ:
return os.environ['LV2_PATH']
else:
@@ -29,15 +46,15 @@ def lv2_path():
print 'LV2_PATH unset, using default ' + ret
return ret
-def lv2_bundles(search_path):
- "Return a list of all LV2 bundles found in a search path."
+def bundles(search_path):
+ "Return a list of all LV2 bundles found in search_path."
dirs = search_path.split(os.pathsep)
bundles = []
for dir in dirs:
bundles += glob.glob(os.path.join(dir, '*.lv2'))
return bundles
-def usage():
+def __usage():
script = os.path.basename(sys.argv[0])
print """Usage:
%s OUTDIR
@@ -48,7 +65,7 @@ Example:
%s /usr/local/include/lv2
""" % (script, script)
-def mkdir_p(path):
+def __mkdir_p(path):
"Equivalent of UNIX mkdir -p"
try:
os.makedirs(path)
@@ -58,9 +75,10 @@ def mkdir_p(path):
else:
raise
-def lv2includegen(bundles):
- """Build a directory tree of symlinks to LV2 extension bundles
- for including header files using URI-like paths."""
+def gen(bundles, outdir):
+ """Build a directory tree under outdir containing symlinks to all LV2
+ extensions found in bundles, such that the symlink paths correspond to
+ the extension URIs."""
for bundle in bundles:
# Load manifest into model
manifest = RDF.Model()
@@ -75,7 +93,7 @@ def lv2includegen(bundles):
ext_dir = os.path.join(outdir, ext_path)
# Make parent directories
- mkdir_p(os.path.dirname(ext_dir))
+ __mkdir_p(os.path.dirname(ext_dir))
# Remove existing symlink if necessary
if os.access(ext_dir, os.F_OK):
@@ -97,4 +115,4 @@ if __name__ == "__main__":
outdir = args[0]
print "Building LV2 include tree at", outdir
- lv2includegen(lv2_bundles(lv2_path()))
+ gen(bundles(lv2_path()), outdir)
2' href='#n262'>262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412