Browse Source

waf: implement 'reconfigure' module

pull/2/head
mittorn 6 years ago
parent
commit
f1638b09c5
  1. 47
      scripts/waflib/reconfigure.py
  2. 3
      wscript

47
scripts/waflib/reconfigure.py

@ -0,0 +1,47 @@
#!/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
STORE_PATH = 'build/configuration.py'
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_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)

3
wscript

@ -66,8 +66,11 @@ def options(opt):
opt.load('xcompile compiler_cxx compiler_c sdl2') opt.load('xcompile compiler_cxx compiler_c sdl2')
if sys.platform == 'win32': if sys.platform == 'win32':
opt.load('msvc msdev msvs') opt.load('msvc msdev msvs')
opt.load('reconfigure')
def configure(conf): def configure(conf):
conf.load('reconfigure')
conf.start_msg('Build type') conf.start_msg('Build type')
if conf.options.BUILD_TYPE == None: if conf.options.BUILD_TYPE == None:
conf.end_msg('not set', color='RED') conf.end_msg('not set', color='RED')

Loading…
Cancel
Save