gen_makefile: allow combining several .opts files

Neels Hofmeyr 6 years ago
parent 20e169f4b5
commit 450dac79c3

@ -8,13 +8,13 @@ more separate build trees in ./make-*.
Run ./ with a choice of projects (2G only or also 3G?)
and a choice of configure options, for example:
./ 3G+2G.deps all_enabled.opts
./ 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
If you make modifications in one of the source trees, this Makefile will pick

@ -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

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

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

@ -2,7 +2,7 @@
Generate a top-level makefile that builds the Osmocom 2G + 3G network components.
./ projects.deps [configuration.opts] [-o Makefile.output]
./ 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''')
help='''Config file containing project name and
./configure options''',
default=None, 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
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)
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):
@ -187,7 +214,7 @@ regen:
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]),
src_dir=os.path.relpath(args.src_dir, make_dir),

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

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