kiwix-build/kiwixbuild/_global.py
Matthieu Gautier 041826d0e8 Move from target logic to steps logic.
This is the big change !!!!

Instead of handling target as primary object and prepare/build targets,
we are handling build steps.

A build step may be a source (preparation) or a build (of the source).
Actualy, a step is a tuple (context, Builder or Source).

The context define the context of the step. It can be :
- 'source', for a Source step
- 'neutral' or the name of a platform for Build step.

Target becomes a "Class only" class.
2018-05-31 11:25:59 +02:00

38 lines
867 B
Python

from collections import OrderedDict as _OrderedDict
_neutralEnv = None
_target_steps = _OrderedDict()
_plt_steps = _OrderedDict()
def set_neutralEnv(env):
global _neutralEnv
_neutralEnv = env
def neutralEnv(what):
return getattr(_neutralEnv, what)
def add_target_step(key, what):
_target_steps[key] = what
def get_target_step(key, default_context=None):
try:
context, target = key
except ValueError:
context, target = default_context, key
return _target_steps[(context, target)]
def target_steps():
return _target_steps
def add_plt_step(key, what):
_plt_steps[key] = what
def get_plt_step(key, default_context=None):
try:
context, target = key
except ValueError:
context, target = default_context, key
return _plt_steps[(context, target)]
def plt_steps():
return _plt_steps