You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
4 years ago
|
#!/usr/bin/env python
|
||
|
# encoding: utf-8
|
||
|
# Copyright (c) 2019 mittorn
|
||
|
|
||
|
'''
|
||
|
Reconfigure
|
||
|
|
||
|
Store/load configuration user input
|
||
|
|
||
|
Usage:
|
||
|
def options(opt):
|
||
|
opt.load('reconfigure')
|
||
|
|
||
|
def configure(conf):
|
||
|
conf.load('reconfigure')
|
||
|
|
||
|
./waf configure --reconfigure
|
||
|
'''
|
||
|
|
||
|
from waflib import Configure, Logs, Options, Utils, ConfigSet
|
||
|
import os
|
||
|
import optparse
|
||
|
|
||
|
def options(opt):
|
||
|
opt.add_option('--rebuild-cache', dest='rebuild_cache', default=False, action='store_true', help='load previous configuration')
|
||
|
opt.add_option('--reconfigure', dest='reconfigure', default=False, action='store_true', help='load and update configuration')
|
||
|
|
||
|
def configure(conf):
|
||
|
store_path = os.path.join(conf.bldnode.abspath(), 'configuration.py')
|
||
|
store_data = ConfigSet.ConfigSet()
|
||
|
options = vars(conf.options)
|
||
|
environ = conf.environ
|
||
|
if conf.options.reconfigure or conf.options.rebuild_cache:
|
||
|
store_data.load(store_path)
|
||
|
if conf.options.reconfigure:
|
||
|
for o in options:
|
||
|
if options[o]: store_data['OPTIONS'][o] = options[o]
|
||
|
store_data['ENVIRON'].update(environ)
|
||
|
store_data.store(store_path)
|
||
|
conf.environ = store_data['ENVIRON']
|
||
|
conf.options = optparse.Values(store_data['OPTIONS'])
|
||
|
else:
|
||
|
store_data['OPTIONS'] = vars(conf.options)
|
||
|
store_data['ENVIRON'] = conf.environ
|
||
|
store_data.store(store_path)
|