Commit 734898cd authored by Andreas Dedner's avatar Andreas Dedner

improve setting different builddir in setup script

parent 188ef977
......@@ -34,18 +34,21 @@ def toBuildDir(builddir, moddir, module):
def main(argv):
try:
opts, args = getopt.getopt(argv,"ho",["opts="])
opts, args = getopt.getopt(argv,"ho",["opts=","builddir="])
except getopt.GetoptError:
print('usage: setup-dunepy.py [-o config.opts | --opts=config.opts] [install]')
print('usage: setup-dunepy.py [-o config.opts | --opts=config.opts | --builddir] [install]')
sys.exit(2)
optsfile = None
builddir = None
for opt, arg in opts:
if opt == '-h':
print('usage: setup-dunepy.py [-o config.opts | --opts=config.opts] [install]')
sys.exit(2)
elif opt in ("-o", "--opts"):
optsfile = arg
elif opt in ("--builddir"):
builddir = arg
if len(args) > 0:
execute = args[0]
else:
......@@ -61,15 +64,24 @@ def main(argv):
if key.startswith('-D'):
key = key[2:]
definitions[key] = value
command = ['bash', '-c', 'source ' + optsfile + ' && echo "$BUILDDIR"']
proc = subprocess.Popen(command, stdout = subprocess.PIPE)
stdout, _ = proc.communicate()
builddir = buffer_to_str(stdout).strip()
if not builddir:
builddir = 'build-cmake'
if builddir is None:
# get the build dir (check for BUILDDIR, DUNE_BUILDDIR in opts file
# and then DUNE_BUILDDIR in environment variable
command = ['bash', '-c', 'source ' + optsfile + ' && echo "$BUILDDIR"']
proc = subprocess.Popen(command, stdout = subprocess.PIPE)
stdout, _ = proc.communicate()
builddir = buffer_to_str(stdout).strip()
if not builddir:
command = ['bash', '-c', 'source ' + optsfile + ' && echo "$DUNE_BUILDDIR"']
proc = subprocess.Popen(command, stdout = subprocess.PIPE)
stdout, _ = proc.communicate()
builddir = buffer_to_str(stdout).strip()
if not builddir:
builddir = os.environ.get('DUNE_BUILDDIR', 'build-cmake')
else:
definitions = None
builddir = 'build-cmake'
if builddir is None:
builddir = os.environ.get('DUNE_BUILDDIR', 'build-cmake')
dunepy = get_dune_py_dir()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment