xref: /openbsd-src/usr.bin/make/enginechoice.c (revision c9fc29cfc69a20b8ffa3404f847e4bf84cf4130a)
1*c9fc29cfSespie /*	$OpenBSD: enginechoice.c,v 1.4 2023/09/04 11:35:11 espie Exp $ */
21314328aSespie /*
31314328aSespie  * Copyright (c) 2020 Marc Espie.
41314328aSespie  *
51314328aSespie  * Redistribution and use in source and binary forms, with or without
61314328aSespie  * modification, are permitted provided that the following conditions
71314328aSespie  * are met:
81314328aSespie  * 1. Redistributions of source code must retain the above copyright
91314328aSespie  *    notice, this list of conditions and the following disclaimer.
101314328aSespie  * 2. Redistributions in binary form must reproduce the above copyright
111314328aSespie  *    notice, this list of conditions and the following disclaimer in the
121314328aSespie  *    documentation and/or other materials provided with the distribution.
131314328aSespie  *
141314328aSespie  * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
151314328aSespie  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
161314328aSespie  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
171314328aSespie  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OPENBSD
181314328aSespie  * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
191314328aSespie  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
201314328aSespie  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
211314328aSespie  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
221314328aSespie  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
231314328aSespie  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
241314328aSespie  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
251314328aSespie  */
26ec86491dSespie #include "defines.h"
27ec86491dSespie #include "compat.h"
28ec86491dSespie #include "make.h"
2910d58120Sespie #include "enginechoice.h"
30ec86491dSespie 
31ec86491dSespie struct engine {
32ec86491dSespie 	void (*run_list)(Lst, bool *, bool *);
33ec86491dSespie 	void (*node_updated)(GNode *);
34ec86491dSespie 	void (*init)(void);
35ec86491dSespie }
36ec86491dSespie 	compat_engine = { Compat_Run, Compat_Update, Compat_Init },
37ec86491dSespie 	parallel_engine = { Make_Run, Make_Update, Make_Init },
38ec86491dSespie 	*engine;
39ec86491dSespie 
40ec86491dSespie void
choose_engine(bool compat)41ec86491dSespie choose_engine(bool compat)
42ec86491dSespie {
43ec86491dSespie 	engine = compat ? &compat_engine: &parallel_engine;
44ec86491dSespie 	engine->init();
45ec86491dSespie }
46ec86491dSespie 
47ec86491dSespie void
engine_run_list(Lst l,bool * has_errors,bool * out_of_date)48ec86491dSespie engine_run_list(Lst l, bool *has_errors, bool *out_of_date)
49ec86491dSespie {
50ec86491dSespie 	engine->run_list(l, has_errors, out_of_date);
51ec86491dSespie }
52ec86491dSespie 
53ec86491dSespie void
engine_node_updated(GNode * gn)54ec86491dSespie engine_node_updated(GNode *gn)
55ec86491dSespie {
56ec86491dSespie 	engine->node_updated(gn);
57ec86491dSespie }
58