From b96a03c22e331e8879341721a0b29f0954c1c883 Mon Sep 17 00:00:00 2001 From: daizihan Date: Tue, 8 Jul 2025 14:34:13 +0800 Subject: [PATCH] Remove extension options Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICKR20?from=project-issue Signed-off-by: daizihan --- ets2panda/CMakeLists.txt | 1 + ets2panda/cmake/extensionOption.cmake | 19 +++++++++++++++++++ ets2panda/util/diagnostic/fatal.yaml | 2 +- ets2panda/util/options.cpp | 7 +++++++ ets2panda/util/options.yaml | 3 ++- 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 ets2panda/cmake/extensionOption.cmake diff --git a/ets2panda/CMakeLists.txt b/ets2panda/CMakeLists.txt index 73d465ae36..8cab1b5e22 100644 --- a/ets2panda/CMakeLists.txt +++ b/ets2panda/CMakeLists.txt @@ -14,6 +14,7 @@ cmake_minimum_required (VERSION 3.5.0) include(cmake/coverage.cmake) +include(cmake/extensionOption.cmake) project (es2panda) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/ets2panda/cmake/extensionOption.cmake b/ets2panda/cmake/extensionOption.cmake new file mode 100644 index 0000000000..d81624b902 --- /dev/null +++ b/ets2panda/cmake/extensionOption.cmake @@ -0,0 +1,19 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# 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. + +option(ENABLE_ES2PANDA_OTHER_EXTENSION "Enable TS/AS/JS extension for es2panda" false) + +if(ENABLE_ES2PANDA_OTHER_EXTENSION) + add_definitions(-DES2PANDA_WITH_OTHER_EXTENSION=1) + message(STATUS "TS/AS/JS extension for es2panda is enabled") +endif(ENABLE_ES2PANDA_OTHER_EXTENSION) diff --git a/ets2panda/util/diagnostic/fatal.yaml b/ets2panda/util/diagnostic/fatal.yaml index be12c9338f..0f46c39c63 100644 --- a/ets2panda/util/diagnostic/fatal.yaml +++ b/ets2panda/util/diagnostic/fatal.yaml @@ -108,7 +108,7 @@ fatal: - name: UNKNOWN_EXT id: 10 message: "Unknown extension of sourcefile, set the '--extension' option or change the file extension (available options: - js, ts, as, ets)" + ets)" - name: UNRESOLVED_MODULE id: 14 diff --git a/ets2panda/util/options.cpp b/ets2panda/util/options.cpp index e2818c61a2..10c47b51d8 100644 --- a/ets2panda/util/options.cpp +++ b/ets2panda/util/options.cpp @@ -371,6 +371,13 @@ bool Options::DetermineExtension() } return true; } +#ifndef ES2PANDA_WITH_OTHER_EXTENSION + case ScriptExtension::AS: + case ScriptExtension::TS: { + diagnosticEngine_.LogDiagnostic(diagnostic::UNKNOWN_EXT, util::DiagnosticMessageParams {}); + return false; + } +#endif default: return true; } diff --git a/ets2panda/util/options.yaml b/ets2panda/util/options.yaml index 5aef15cb8f..96bb96a46c 100644 --- a/ets2panda/util/options.yaml +++ b/ets2panda/util/options.yaml @@ -37,7 +37,8 @@ options: - ts - as - ets - possible_values: *ScriptExtension + possible_values: + - ets - name: module type: bool -- Gitee