8
8
# governing this code.
9
9
10
10
import os
11
- import sys
12
- import argparse
13
11
import pkgutil
14
- import logging . config
12
+ import logging
15
13
from lxml import etree
16
14
17
-
18
15
import lbuild .module
19
16
import lbuild .environment
20
17
@@ -192,7 +189,8 @@ def merge_repository_options(self, config_options):
192
189
# module option
193
190
pass
194
191
else :
195
- raise exception .BlobException ("Invalid option '%s'" % config_name )
192
+ raise exception .BlobException ("Invalid option format '%s'. Option must contain one " \
193
+ "(repository option) or two (module option) colons." % config_name )
196
194
197
195
# Check that all option values are set
198
196
for option in repo_options_by_full_name .values ():
@@ -335,7 +333,8 @@ def merge_module_options(self, build_modules, config_options):
335
333
if not found :
336
334
raise exception .BlobException ("Option '%s' not found!" % config_name )
337
335
else :
338
- raise exception .BlobException ("Invalid option '%s'" % config_name )
336
+ raise exception .BlobException ("Invalid option format '%s'. Option must contain one " \
337
+ "(repository option) or two (module option) colons." % config_name )
339
338
340
339
options = {}
341
340
# Check that all option values are set
@@ -354,61 +353,14 @@ def build_modules(self, outpath, build_modules, repo_options, module_options):
354
353
options = lbuild .module .Options (module .repository , module , repo_options , module_options )
355
354
env = lbuild .environment .Environment (options , module .path , outpath )
356
355
module .functions ["build" ](env )
357
-
358
- def configure_logger (verbosity ):
359
- logging .config .dictConfig ({
360
- 'version' : 1 ,
361
- 'disable_existing_loggers' : False ,
362
- 'formatters' : {
363
- 'full' : {
364
- #'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
365
- 'format' : '[%(levelname)s] %(name)s: %(message)s'
366
- },
367
- 'simple' : {
368
- 'format' : '%(message)s'
369
- },
370
- },
371
- 'handlers' : {
372
- 'default' : {
373
- 'class' :'logging.StreamHandler' ,
374
- 'formatter' : 'full' ,
375
- },
376
- },
377
- 'loggers' : {
378
- '' : {
379
- 'handlers' : ['default' ],
380
- 'level' : 'DEBUG' if verbosity > 1 else ('INFO' if verbosity == 1 else 'WARNING' ),
381
- 'propagate' : True
382
- }
383
- }
384
- })
385
-
386
- def main ():
387
- parser = argparse .ArgumentParser (description = 'Build libraries from source code repositories' )
388
- parser .add_argument ('-r' , '--repository' ,
389
- dest = 'repositories' ,
390
- required = True ,
391
- action = 'append' ,
392
- help = 'Folder in which modules are located' )
393
- parser .add_argument ('-p' , '--project' ,
394
- dest = 'project' ,
395
- required = True ,
396
- help = 'Project/library configuration file' )
397
- parser .add_argument ('-o' , '--__outpath' ,
398
- dest = '__outpath' ,
399
- default = '.' ,
400
- help = 'Output path to which the library will be generated' )
401
- parser .add_argument ('-v' , '--verbose' ,
402
- action = 'count' ,
403
- default = 0 ,
404
- dest = 'verbose' )
405
-
406
- args = parser .parse_args ()
407
-
408
- configure_logger (args .verbose )
409
-
410
- try :
411
- pass
412
- except exception .BlobException as e :
413
- sys .stderr .write ('%s\n ' % e )
414
- sys .exit (1 )
356
+
357
+ def configure_and_build_library (self , configfile , outpath ):
358
+ selected_modules , config_options = self .parse_configuration (configfile )
359
+
360
+ repo_options = self .merge_repository_options (config_options )
361
+ modules = self .prepare_modules (repo_options )
362
+
363
+ build_modules = self .resolve_dependencies (modules , selected_modules )
364
+ module_options = self .merge_module_options (build_modules , config_options )
365
+
366
+ self .build_modules (outpath , build_modules , repo_options , module_options )
0 commit comments