Skip to content

Commit 7085925

Browse files
committed
Bugfixing and executable script added
1 parent 2d16be0 commit 7085925

File tree

6 files changed

+112
-94
lines changed

6 files changed

+112
-94
lines changed

MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include *.txt
2+
recursive-include lbuild *.xsd

lbuild/module.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __getitem__(self, key):
3636
if module == "":
3737
module = self.module.name
3838

39-
key = "%s:%s:s" % (repo, module, option)
39+
key = "%s:%s:%s" % (repo, module, option)
4040
return self.module_options[key].value
4141
else:
4242
raise exception.BlobException("Option name '%s' must contain exactly one (or two) colon " \

lbuild/parser.py

+16-64
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88
# governing this code.
99

1010
import os
11-
import sys
12-
import argparse
1311
import pkgutil
14-
import logging.config
12+
import logging
1513
from lxml import etree
1614

17-
1815
import lbuild.module
1916
import lbuild.environment
2017

@@ -192,7 +189,8 @@ def merge_repository_options(self, config_options):
192189
# module option
193190
pass
194191
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)
196194

197195
# Check that all option values are set
198196
for option in repo_options_by_full_name.values():
@@ -335,7 +333,8 @@ def merge_module_options(self, build_modules, config_options):
335333
if not found:
336334
raise exception.BlobException("Option '%s' not found!" % config_name)
337335
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)
339338

340339
options = {}
341340
# Check that all option values are set
@@ -354,61 +353,14 @@ def build_modules(self, outpath, build_modules, repo_options, module_options):
354353
options = lbuild.module.Options(module.repository, module, repo_options, module_options)
355354
env = lbuild.environment.Environment(options, module.path, outpath)
356355
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)

scripts/blob

-20
This file was deleted.

scripts/lbuild

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2015, Fabian Greif
5+
# All Rights Reserved.
6+
#
7+
# The file is part of the lbuild project and is released under the
8+
# 2-clause BSD license. See the file `LICENSE.txt` for the full license
9+
# governing this code.
10+
11+
import os
12+
import sys
13+
import argparse
14+
import logging
15+
import logging.config
16+
17+
rootpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
18+
sys.path.append(rootpath)
19+
20+
import lbuild.parser
21+
22+
def configure_logger(verbosity):
23+
logging.config.dictConfig({
24+
'version': 1,
25+
'disable_existing_loggers': False,
26+
'formatters': {
27+
'full': {
28+
#'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
29+
'format': '[%(levelname)s] %(name)s: %(message)s'
30+
},
31+
'simple': {
32+
'format': '%(message)s'
33+
},
34+
},
35+
'handlers': {
36+
'default': {
37+
'class':'logging.StreamHandler',
38+
'formatter': 'full',
39+
},
40+
},
41+
'loggers': {
42+
'': {
43+
'handlers': ['default'],
44+
'level': 'DEBUG' if verbosity > 1 else ('INFO' if verbosity == 1 else 'WARNING'),
45+
'propagate': True
46+
}
47+
}
48+
})
49+
50+
if __name__ == '__main__':
51+
parser = argparse.ArgumentParser(description='Build libraries from source code repositories')
52+
parser.add_argument('-r', '--repository',
53+
dest='repositories',
54+
required=True,
55+
action='append',
56+
help='Folder in which modules are located')
57+
parser.add_argument('-c', '--configuration',
58+
dest='config',
59+
required=True,
60+
help='Project/library configuration file')
61+
parser.add_argument('-o', '--outpath',
62+
dest='outpath',
63+
default='.',
64+
help='Path in which the library will be generated')
65+
parser.add_argument('-v', '--verbose',
66+
action='count',
67+
default = 0,
68+
dest='verbose')
69+
70+
args = parser.parse_args()
71+
72+
configure_logger(args.verbose)
73+
74+
try:
75+
parser = lbuild.parser.Parser()
76+
for repofile in args.repositories:
77+
parser.parse_repository(repofile)
78+
79+
parser.configure_and_build_library(args.config, args.outpath)
80+
except lbuild.exception.BlobException as e:
81+
sys.stderr.write('%s\n' % e)
82+
sys.exit(1)

setup.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,26 @@
1212
setup(
1313
name = "lbuild",
1414
version = "0.1",
15-
packages = find_packages(exclude=["test", "example"]),
16-
scripts = ['lbuild'],
17-
18-
# Project uses reStructuredText, so ensure that the docutils get
19-
# installed or upgraded on the target machine
20-
install_requires = ['lxml', 'jinja2'],
15+
scripts = ['scripts/lbuild'],
2116

22-
test_requires = ['testfixtures'],
17+
packages = find_packages(exclude=["test"]),
18+
19+
include_package_data = True,
20+
21+
# Make sure all files are unzipped during installation
22+
#zip_safe = False,
23+
24+
install_requires = ['lxml', 'jinja2'],
2325

24-
# other stuff here
2526
extras_require = {
2627
"test": ['testfixtures'],
2728
},
2829

2930
# Metadata
3031
author = "Fabian Greif",
3132
author_email = "[email protected]",
32-
description = "Library builder to create a compilable library from a set of template files for different target environments",
33+
description = "Library builder to create a compilable library from " \
34+
"a set of template files for different target environments",
3335
license = "BSD",
3436
keywords = "library builder generator",
3537
url = "https://github.com/dergraaf/library-builder",

0 commit comments

Comments
 (0)