gen_makefile: allow combining several .opts files

changes/28/3728/1
Neels Hofmeyr 2017-08-22 19:27:08 +02:00
parent 20e169f4b5
commit 450dac79c3
7 changed files with 44 additions and 12 deletions

4
README
View File

@ -8,13 +8,13 @@ more separate build trees in ./make-*.
Run ./gen_makefile.py with a choice of projects (2G only or also 3G?)
and a choice of configure options, for example:
./gen_makefile.py 3G+2G.deps all_enabled.opts
./gen_makefile.py 3G+2G.deps default.opts iu.opts
This generates a new dir containing a Makefile. When you run make in it, this
will clone the source trees (if not present yet) and build all of them in the
right order:
cd make-3G+2G.deps-all_enabled.opts/
cd make-3G+2G-default+iu
make
If you make modifications in one of the source trees, this Makefile will pick

View File

@ -1,4 +0,0 @@
osmo-mgw --enable-mgcp-transcoding
osmo-msc --enable-smpp --enable-iu --enable-mgcp-transcoding --enable-external-tests
osmo-bsc --enable-osmo-bsc --enable-nat --enable-mgcp-transcoding --enable-external-tests
osmo-sgsn --enable-iu --enable-external-tests

2
default.opts Normal file
View File

@ -0,0 +1,2 @@
osmo-msc --enable-smpp
osmo-bsc --enable-osmo-bsc --enable-nat

3
external-tests.opts Normal file
View File

@ -0,0 +1,3 @@
osmo-msc --enable-external-tests
osmo-bsc --enable-external-tests
osmo-sgsn --enable-external-tests

View File

@ -2,7 +2,7 @@
'''
Generate a top-level makefile that builds the Osmocom 2G + 3G network components.
./gen_makefile.py projects.deps [configuration.opts] [-o Makefile.output]
./gen_makefile.py projects.deps [configure.opts [more.opts]] [-o Makefile.output]
Configured by text files:
@ -37,10 +37,10 @@ parser.add_argument('projects_and_deps_file',
help='''Config file containing projects to build and
dependencies between those''')
parser.add_argument('configure_opts_file',
parser.add_argument('configure_opts_files',
help='''Config file containing project name and
./configure options''',
default=None, nargs='?')
nargs='*')
parser.add_argument('-m', '--make-dir', dest='make_dir',
help='''Place Makefile in this dir (default: create
@ -69,6 +69,27 @@ parser.add_argument('-j', '--jobs', dest='jobs', default='9',
args = parser.parse_args()
class listdict(dict):
'a dict of lists { "a": [1, 2, 3], "b": [1, 2] }'
def add(self, name, item):
l = self.get(name)
if not l:
l = []
self[name] = l
l.append(item)
def extend(self, name, l):
for v in l:
self.add(name, v)
def add_dict(self, d):
for k,v in d.items():
self.add(k, v)
def extend_dict(self, d):
for k,v in d.items():
l = self.extend(k, v)
def read_projects_deps(path):
'Read deps config and return tuples of (project_name, which-other-to-build-first).'
@ -156,11 +177,17 @@ def gen_make(proj, deps, configure_opts, jobs, make_dir, src_dir, build_dir, url
projects_deps = read_projects_deps(args.projects_and_deps_file)
configure_opts = read_configure_opts(args.configure_opts_file)
configure_opts = listdict()
configure_opts_files = sorted(args.configure_opts_files or [])
for configure_opts_file in configure_opts_files:
r = read_configure_opts(configure_opts_file)
configure_opts.extend_dict(read_configure_opts(configure_opts_file))
make_dir = args.make_dir
if not make_dir:
make_dir = 'make-%s-%s' % (args.projects_and_deps_file, args.configure_opts_file)
deps_name = args.projects_and_deps_file.replace('.deps', '')
opts_names = '+'.join([f.replace('.opts', '') for f in configure_opts_files])
make_dir = 'make-%s-%s' % (deps_name, opts_names)
if not os.path.isdir(make_dir):
os.makedirs(make_dir)
@ -187,7 +214,7 @@ regen:
'''.format(
script=os.path.relpath(sys.argv[0], make_dir),
projects_and_deps=os.path.relpath(args.projects_and_deps_file, make_dir),
configure_opts=os.path.relpath(args.configure_opts_file, make_dir),
configure_opts=' '.join([os.path.relpath(f, make_dir) for f in configure_opts_files]),
make_dir='.',
makefile=args.output,
src_dir=os.path.relpath(args.src_dir, make_dir),

2
iu.opts Normal file
View File

@ -0,0 +1,2 @@
osmo-msc --enable-iu
osmo-sgsn --enable-iu

2
transcoding.opts Normal file
View File

@ -0,0 +1,2 @@
osmo-mgw --enable-mgcp-transcoding
osmo-msc --enable-mgcp-transcoding