From 6e4a9ae51acca00134d7771b53571b4d6bc185b3 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 3 Oct 2017 14:49:32 -0700 Subject: edify: Remove edify_parser. It used to be containing some unit tests for basic edify syntax, which has been moved into recovery_component_test (commit d770d2e7afd8a909156447c2b79d8739228279d7). The edify_parser host tool supports edify built-in functions only, but doesn't recognize the ones defined in updater. This makes it much less useful to do any real analyzing work. Test: mmma bootable/recovery Change-Id: I3c12f5402d2d6698e0ef5ac6c2e7804c0fbba78a --- edify/Android.mk | 20 ------------- edify/edify_parser.cpp | 79 -------------------------------------------------- 2 files changed, 99 deletions(-) delete mode 100644 edify/edify_parser.cpp diff --git a/edify/Android.mk b/edify/Android.mk index baf4dd21d..cec65f42a 100644 --- a/edify/Android.mk +++ b/edify/Android.mk @@ -19,26 +19,6 @@ edify_src_files := \ parser.yy \ expr.cpp -# -# Build the host-side command line tool (host executable) -# -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - $(edify_src_files) \ - edify_parser.cpp - -LOCAL_CFLAGS := -Wall -Werror -LOCAL_CPPFLAGS := -g -O0 -LOCAL_MODULE := edify_parser -LOCAL_YACCFLAGS := -v -LOCAL_CPPFLAGS += -Wno-unused-parameter -LOCAL_CPPFLAGS += -Wno-deprecated-register -LOCAL_C_INCLUDES += $(LOCAL_PATH)/.. -LOCAL_STATIC_LIBRARIES += libbase - -include $(BUILD_HOST_EXECUTABLE) - # # Build the device-side library (static library) # diff --git a/edify/edify_parser.cpp b/edify/edify_parser.cpp deleted file mode 100644 index f1b56284c..000000000 --- a/edify/edify_parser.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * This is a host-side tool for validating a given edify script file. - * - * We used to have edify test cases here, which have been moved to - * tests/component/edify_test.cpp. - * - * Caveat: It doesn't recognize functions defined through updater, which - * makes the tool less useful. We should either extend the tool or remove it. - */ - -#include -#include - -#include -#include - -#include - -#include "expr.h" - -static void ExprDump(int depth, const std::unique_ptr& n, const std::string& script) { - printf("%*s", depth*2, ""); - printf("%s %p (%d-%d) \"%s\"\n", - n->name.c_str(), n->fn, n->start, n->end, - script.substr(n->start, n->end - n->start).c_str()); - for (size_t i = 0; i < n->argv.size(); ++i) { - ExprDump(depth+1, n->argv[i], script); - } -} - -int main(int argc, char** argv) { - RegisterBuiltins(); - - if (argc != 2) { - printf("Usage: %s \n", argv[0]); - return 1; - } - - std::string buffer; - if (!android::base::ReadFileToString(argv[1], &buffer)) { - printf("%s: failed to read %s: %s\n", argv[0], argv[1], strerror(errno)); - return 1; - } - - std::unique_ptr root; - int error_count = 0; - int error = parse_string(buffer.data(), &root, &error_count); - printf("parse returned %d; %d errors encountered\n", error, error_count); - if (error == 0 || error_count > 0) { - - ExprDump(0, root, buffer); - - State state(buffer, nullptr); - std::string result; - if (!Evaluate(&state, root, &result)) { - printf("result was NULL, message is: %s\n", - (state.errmsg.empty() ? "(NULL)" : state.errmsg.c_str())); - } else { - printf("result is [%s]\n", result.c_str()); - } - } - return 0; -} -- cgit v1.2.3