jolt 0.9.355__py3-none-any.whl → 0.9.371__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
jolt/plugins/conan.py CHANGED
@@ -3,6 +3,7 @@ from os import path
3
3
 
4
4
  from jolt import Task
5
5
  from jolt import influence
6
+ from jolt import utils
6
7
  from jolt.error import raise_task_error_if
7
8
 
8
9
 
@@ -239,3 +240,240 @@ class Conan(Task):
239
240
  artifact.cxxinfo.cflags.append(dep["cflags"])
240
241
  artifact.cxxinfo.cxxflags.append(dep["cxxflags"])
241
242
  artifact.cxxinfo.ldflags.append(dep["exelinkflags"])
243
+
244
+
245
+ @influence.attribute("conanfile")
246
+ @influence.attribute("generators")
247
+ @influence.attribute("incremental")
248
+ @influence.attribute("options")
249
+ @influence.attribute("packages")
250
+ class Conan2(Task):
251
+ """
252
+ Conan package installer task.
253
+
254
+ This task base class can be used to fetch, build and publish Conan packages
255
+ as Jolt artifacts. All package metadata is transfered from the Conan package
256
+ manifest to the Jolt artifact so that no manual configuration of include
257
+ paths, library paths, macros, etc is required.
258
+
259
+ An existing installation of Conan is required. Please visit https://conan.io/
260
+ for installation instructions and documentation.
261
+
262
+ A minimal task to download and publish the Boost C++ libraries can look like this:
263
+
264
+ .. code-block:: python
265
+
266
+ from jolt.plugins.conan import Conan
267
+
268
+ class Boost(Conan):
269
+ packages = ["boost/1.74.0"]
270
+
271
+ Boost may then be used from Ninja tasks by declaring a requirement:
272
+
273
+ .. code-block:: python
274
+
275
+ from jolt.plugins.ninja import CXXExecutable
276
+
277
+ class BoostApplication(CXXExecutable):
278
+ requires = ["boost"]
279
+ sources = ["main.cpp"]
280
+
281
+ The task supports using an existing conanfile.txt, but it is not required.
282
+ Packages are installed into and collected from Jolt build directories. The
283
+ user's regular Conan cache will not be affected.
284
+
285
+ """
286
+
287
+ abstract = True
288
+
289
+ conanfile = None
290
+ """
291
+ An existing conanfile.txt file to use.
292
+
293
+ Instead of generating the conanfile.txt file on-demand, an external
294
+ file may be used. If this attribute is set, the ``generators``, ``options``
295
+ and ``packages`` attributes must not be set.
296
+
297
+ See Conan documentation for further details.
298
+ """
299
+
300
+ packages = []
301
+ """
302
+ A list of Conan package references to collect and publish.
303
+
304
+ The reference format is ``PkgName/<version>@user/channel``. See Conan
305
+ documentation for further details.
306
+
307
+ Any {keyword} arguments, or macros, found in the strings are automatically
308
+ expanded to the value of the associated task's parameters and properties.
309
+
310
+ Example:
311
+
312
+ .. code-block:: python
313
+
314
+ sdl_version = Parameter("2.0.12")
315
+
316
+ packages = [
317
+ "boost/1.74.0",
318
+ "sdl2/{sdl_version}@bincrafters/stable",
319
+ ]
320
+
321
+ """
322
+
323
+ options = []
324
+ """
325
+ A list of Conan package options to apply
326
+
327
+ The option format is ``PkgName:Option=Value``. See Conan
328
+ documentation for further details.
329
+
330
+ Any {keyword} arguments, or macros, found in the strings are automatically
331
+ expanded to the value of the associated task's parameters and properties.
332
+
333
+ Example:
334
+
335
+ .. code-block:: python
336
+
337
+ options = [
338
+ "boost:shared=True",
339
+ "zlib:shared=True",
340
+ ]
341
+
342
+ """
343
+
344
+ settings = []
345
+ """
346
+ A list of Conan settings to apply
347
+
348
+ The settings format is ``Option=Value``. See Conan
349
+ documentation for further details.
350
+
351
+ Any {keyword} arguments, or macros, found in the strings are automatically
352
+ expanded to the value of the associated task's parameters and properties.
353
+
354
+ Example:
355
+
356
+ .. code-block:: python
357
+
358
+ settings = [
359
+ "compiler.libcxx=libstdc++11",
360
+ ]
361
+
362
+ """
363
+
364
+ remotes = {}
365
+ """
366
+ A dictionary with Conan remotes to use when fetching packages.
367
+
368
+ The dictionary key is the name of remote and its value is the URL.
369
+
370
+ Example:
371
+
372
+ .. code-block:: python
373
+
374
+ remotes = {
375
+ "bincrafters": "https://api.bintray.com/conan/bincrafters/public-conan"
376
+ }
377
+
378
+ """
379
+
380
+ incremental = True
381
+ """
382
+ Keep installed packages in the Conan cache between Jolt invokations.
383
+
384
+ If incremental build is disabled, the Jolt Conan cache is removed
385
+ before execution begins.
386
+ """
387
+
388
+ def __init__(self, *args, **kwargs):
389
+ super().__init__(*args, **kwargs)
390
+ if self.conanfile:
391
+ self.influence.append(influence.FileInfluence(self.conanfile))
392
+
393
+ def _options(self):
394
+ return [] + self.options
395
+
396
+ def _settings(self):
397
+ return [] + self.settings
398
+
399
+ def _packages(self):
400
+ return [] + self.packages
401
+
402
+ def _remotes(self):
403
+ return self.remotes
404
+
405
+ def run(self, deps, tools):
406
+ raise_task_error_if(
407
+ not tools.which("conan"), self,
408
+ "Conan: Conan is not installed in the PATH")
409
+ raise_task_error_if(
410
+ self.conanfile and (self._packages() or self._options()), self,
411
+ "Conan: 'conanfile' attribute cannot be used with other attributes")
412
+
413
+ conanfile = tools.expand_path(self.conanfile) if self.conanfile else None
414
+
415
+ with tools.cwd(tools.builddir()):
416
+ if conanfile is None or not path.exists(conanfile):
417
+ conanfile = "conanfile.txt"
418
+ self.info("Creating conanfile.txt")
419
+ self.tools.write_file(conanfile, "[requires]\n")
420
+ for pkg in self._packages():
421
+ self.tools.append_file(conanfile, pkg + "\n")
422
+
423
+ with tools.environ(CONAN_USER_HOME=tools.builddir("conan", incremental=self.incremental)):
424
+ for remote, url in self._remotes().items():
425
+ self.info("Registering remote '{}'", remote)
426
+ tools.run("conan remote add -f {} {}", remote, url, output_on_error=True)
427
+
428
+ self.info("Installing packages into the Conan cache")
429
+ options = " ".join(["-o " + opt for opt in self._options()])
430
+ settings = " ".join(["-s " + opt for opt in self._settings()])
431
+ output = tools.run("conan install --build=missing --output-folder . -u --format=json {} {} {}", options, settings, conanfile, output_stdout=False)
432
+
433
+ self.info("Parsing manifest")
434
+ self._manifest = json.loads(output)
435
+
436
+ for dep in self._manifest["graph"]["nodes"].values():
437
+ if dep["package_folder"]:
438
+ self.info("Collecting '{}' files from: {}", dep["name"], dep["package_folder"])
439
+ tools.copy(dep["package_folder"], dep["name"])
440
+
441
+ def publish(self, artifact, tools):
442
+ self.info("Publishing package files")
443
+ with tools.cwd(tools.builddir()):
444
+ artifact.collect("*")
445
+
446
+ self.info("Publishing metadata")
447
+ for dep in self._manifest["graph"]["nodes"].values():
448
+ if not dep["package_folder"]:
449
+ continue
450
+
451
+ for node in dep["cpp_info"]:
452
+ for incpath in dep["cpp_info"][node]["includedirs"]:
453
+ artifact.cxxinfo.incpaths.append(path.join(dep["name"], path.relpath(incpath, dep["package_folder"])))
454
+ for libpath in dep["cpp_info"][node]["libdirs"]:
455
+ artifact.cxxinfo.libpaths.append(path.join(dep["name"], path.relpath(libpath, dep["package_folder"])))
456
+ for binpath in dep["cpp_info"][node]["bindirs"]:
457
+ artifact.environ.PATH.append(path.join(dep["name"], path.relpath(binpath, dep["package_folder"])))
458
+ if dep["cpp_info"][node]["libs"]:
459
+ artifact.cxxinfo.libraries.extend(dep["cpp_info"][node]["libs"])
460
+ if dep["cpp_info"][node]["system_libs"]:
461
+ artifact.cxxinfo.libraries.extend(dep["cpp_info"][node]["system_libs"])
462
+ if dep["cpp_info"][node]["defines"]:
463
+ artifact.cxxinfo.macros.extend(dep["cpp_info"][node]["defines"])
464
+ if dep["cpp_info"][node]["cflags"]:
465
+ artifact.cxxinfo.cflags.extend(dep["cpp_info"][node]["cflags"])
466
+ if dep["cpp_info"][node]["cxxflags"]:
467
+ artifact.cxxinfo.cxxflags.extend(dep["cpp_info"][node]["cxxflags"])
468
+ if dep["cpp_info"][node]["exelinkflags"]:
469
+ artifact.cxxinfo.ldflags.extend(dep["cpp_info"][node]["exelinkflags"])
470
+
471
+ # Make list of unique values
472
+ artifact.cxxinfo.incpaths = utils.unique_list(artifact.cxxinfo.incpaths)
473
+ artifact.cxxinfo.libpaths = utils.unique_list(artifact.cxxinfo.libpaths)
474
+ artifact.cxxinfo.libraries = utils.unique_list(artifact.cxxinfo.libraries)
475
+ artifact.cxxinfo.macros = utils.unique_list(artifact.cxxinfo.macros)
476
+ artifact.cxxinfo.cflags = utils.unique_list(artifact.cxxinfo.cflags)
477
+ artifact.cxxinfo.cxxflags = utils.unique_list(artifact.cxxinfo.cxxflags)
478
+ artifact.cxxinfo.ldflags = utils.unique_list(artifact.cxxinfo.ldflags)
479
+ artifact.environ.PATH = path.pathsep.join(utils.unique_list(str(artifact.environ.PATH).split(path.pathsep)))
jolt/plugins/docker.py CHANGED
@@ -254,7 +254,7 @@ class DockerContainer(Resource):
254
254
  def _image(self):
255
255
  registry = TaskRegistry.get()
256
256
  tool = tools.Tools(self)
257
- if registry.get_task_class(tool.expand(self.image)):
257
+ if registry.has_task(tool.expand(self.image)):
258
258
  return [self.image]
259
259
  return []
260
260
 
jolt/plugins/environ.py CHANGED
@@ -55,6 +55,17 @@ class PathEnvironmentVariable(EnvironmentVariable):
55
55
 
56
56
 
57
57
  class EnvironmentVariableSet(ArtifactAttributeSet):
58
+ """ A set of environment variables for an artifact.
59
+
60
+ Example:
61
+
62
+ .. code-block:: python
63
+
64
+ artifact.environ.FOO = "bar"
65
+ artifact.environ.PATH.append("bin")
66
+
67
+ """
68
+
58
69
  def __init__(self, artifact):
59
70
  super(EnvironmentVariableSet, self).__init__()
60
71
  super(ArtifactAttributeSet, self).__setattr__("_artifact", artifact)
jolt/plugins/gdb.py CHANGED
@@ -70,19 +70,18 @@ def gdb(ctx, task, default, machine_interface, no_binary, gdb_args):
70
70
  if machine_interface:
71
71
  log.enable_gdb()
72
72
 
73
- manifest = ctx.obj["manifest"]
74
73
  options = JoltOptions(default=default)
75
74
  acache = cache.ArtifactCache.get(options)
76
75
  TaskHookRegistry.get(options)
77
76
  executors = scheduler.ExecutorRegistry.get(options)
78
77
  registry = TaskRegistry.get()
79
78
  strategy = scheduler.DownloadStrategy(executors, acache)
80
- queue = scheduler.TaskQueue(strategy, acache, {})
79
+ queue = scheduler.TaskQueue()
81
80
 
82
81
  for params in default:
83
82
  registry.set_default_parameters(params)
84
83
 
85
- gb = graph.GraphBuilder(registry, acache, manifest, options, progress=True)
84
+ gb = graph.GraphBuilder(registry, acache, options, progress=True)
86
85
  dag = gb.build([task])
87
86
 
88
87
  try:
@@ -92,9 +91,10 @@ def gdb(ctx, task, default, machine_interface, no_binary, gdb_args):
92
91
 
93
92
  while leafs:
94
93
  task = leafs.pop()
95
- queue.submit(task)
94
+ executor = strategy.create_executor({}, task)
95
+ queue.submit(executor)
96
96
 
97
- task, error = queue.wait()
97
+ task, _ = queue.wait()
98
98
 
99
99
  # Materialize workspace resources so that
100
100
  # source code is available to the debugger.
@@ -113,6 +113,7 @@ def gdb(ctx, task, default, machine_interface, no_binary, gdb_args):
113
113
  log.warning("Interrupted by user")
114
114
  try:
115
115
  queue.abort()
116
+ executors.shutdown()
116
117
  sys.exit(1)
117
118
  except KeyboardInterrupt:
118
119
  print()