init: remove Parser singleton and related cleanup
* Remove the Parser singleton (Hooray!)
* Rename parser.* to tokenizer.* as this is actually a tokenizer
* Rename init_parser.* to parser.* as this is a generic parser
* Move contents of init_parser_test.cpp to service_test.cpp as this
actually is a test of the parsing in MakeExecOneshotService() and
nothing related to (init_)parser.cpp
Test: boot bullhead
Test: bool sailfish
Test: init unit tests
Change-Id: I4fe39e6483f58ebd3ce5ee715a45dbba0acf5d91
diff --git a/init/builtins.cpp b/init/builtins.cpp
index dfd7b73..dec6f40 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -57,7 +57,7 @@
#include "action.h"
#include "bootchart.h"
#include "init.h"
-#include "init_parser.h"
+#include "parser.h"
#include "property_service.h"
#include "reboot.h"
#include "service.h"
@@ -388,21 +388,15 @@
* start_index: index of the first path in the args list
*/
static void import_late(const std::vector<std::string>& args, size_t start_index, size_t end_index) {
- Parser& parser = Parser::GetInstance();
+ auto& action_manager = ActionManager::GetInstance();
+ auto& service_manager = ServiceManager::GetInstance();
+ Parser parser = CreateParser(action_manager, service_manager);
if (end_index <= start_index) {
// Fallbacks for partitions on which early mount isn't enabled.
- if (!parser.is_system_etc_init_loaded()) {
- parser.ParseConfig("/system/etc/init");
- parser.set_is_system_etc_init_loaded(true);
+ for (const auto& path : late_import_paths) {
+ parser.ParseConfig(path);
}
- if (!parser.is_vendor_etc_init_loaded()) {
- parser.ParseConfig("/vendor/etc/init");
- parser.set_is_vendor_etc_init_loaded(true);
- }
- if (!parser.is_odm_etc_init_loaded()) {
- parser.ParseConfig("/odm/etc/init");
- parser.set_is_odm_etc_init_loaded(true);
- }
+ late_import_paths.clear();
} else {
for (size_t i = start_index; i < end_index; ++i) {
parser.ParseConfig(args[i]);