diff --git a/ets2panda/aot/main.cpp b/ets2panda/aot/main.cpp index 420240cb0ee8c3f829f32ba08e3e68afa017d0f0..36daabba059094436418834d72a6bc1b9a95d88d 100644 --- a/ets2panda/aot/main.cpp +++ b/ets2panda/aot/main.cpp @@ -27,6 +27,7 @@ #include "util/perfMetrics.h" #include "libpandabase/os/stacktrace.h" #include "generated/diagnostic.h" +#include "generated/options.h" #include #include @@ -193,8 +194,7 @@ static int Run(Span args) es2panda::Compiler compiler(options->GetExtension(), options->GetThread(), std::move(pluginsOpt.value())); if (options->IsListPhases()) { - std::cerr << "Available phases:" << std::endl; - std::cerr << compiler.GetPhasesList(); + std::cerr << "Available phases:" << std::endl << compiler.GetPhasesList(); diagnosticEngine.FlushDiagnostic(); return 1; } @@ -213,6 +213,10 @@ static int Run(Span args) auto [buf, size] = options->CStrParserInputContents(); parserInput = std::string_view(buf, size); } + if (options->WasSetArktsconfig() && !options->ArkTSConfig()->IsOutDirDefault() && options->GetOutputFlag()) { + diagnosticEngine.LogDiagnostic(diagnostic::REWRITE_OUTPUT_IN_CLI, + ark::es2panda::util::DiagnosticMessageParams()); + } es2panda::SourceFile input(sourceFile, parserInput, options->IsModule(), options->GetOutput()); res = CompileFromSource(compiler, input, *options.get(), diagnosticEngine); } diff --git a/ets2panda/util/arktsconfig.cpp b/ets2panda/util/arktsconfig.cpp index c63bc91f971c9a515734b64896780acb05cab800..b670f2dfd65a6b00bd21229ba33de9a16e5b15be 100644 --- a/ets2panda/util/arktsconfig.cpp +++ b/ets2panda/util/arktsconfig.cpp @@ -368,6 +368,9 @@ bool ArkTsConfig::ParseCompilerOptions(std::string &arktsConfigDir, const JsonOb // Parse "baseUrl", "outDir", "rootDir", "cacheDir" baseUrl_ = MakeAbsolute(ValueOrEmptyString(compilerOptions, BASE_URL), arktsConfigDir); outDir_ = MakeAbsolute(ValueOrEmptyString(compilerOptions, OUT_DIR), arktsConfigDir); + if (ValueOrEmptyString(compilerOptions, OUT_DIR) == "") { + isOutDirDefault_ = true; + } rootDir_ = ValueOrEmptyString(compilerOptions, ROOT_DIR); if (!rootDir_.empty() && !Check(ark::os::file::File::IsDirectory(rootDir_), diagnostic::NOT_A_DIR, {"rootDir " + rootDir_})) { diff --git a/ets2panda/util/arktsconfig.h b/ets2panda/util/arktsconfig.h index eeb613ccb2c4339009805288befbdc7d23141a6d..5a9616b28fb8eb1891eccc63cd9b4afec0657953 100644 --- a/ets2panda/util/arktsconfig.h +++ b/ets2panda/util/arktsconfig.h @@ -134,6 +134,10 @@ public: void ResolveAllDependenciesInArkTsConfig(); + bool IsOutDirDefault() const + { + return isOutDirDefault_; + } const std::string &ConfigPath() const { return configPath_; @@ -219,6 +223,8 @@ private: std::map &dependenciesMap); bool isParsed_ = false; + bool isOutDirDefault_ = false; + std::string configPath_; std::string package_ {}; diff --git a/ets2panda/util/diagnostic/warning.yaml b/ets2panda/util/diagnostic/warning.yaml index 5d2579c02557ad6190fc322af03f9144d475dbd0..967ba6258c03d33476e114f56a80ed0a132955f3 100644 --- a/ets2panda/util/diagnostic/warning.yaml +++ b/ets2panda/util/diagnostic/warning.yaml @@ -105,6 +105,10 @@ warning: id: 6 message: "Replace the lambda function with a regular function." +- name: REWRITE_OUTPUT_IN_CLI + id: 31 + message: "Output presented in config, used from cli args" + - name: SETTER_LOOP id: 24 message: "Assigning new value to the property inside its setter may lead to an endless loop." diff --git a/ets2panda/util/options.cpp b/ets2panda/util/options.cpp index dbb5e1fbee52249f632b57df0dd2b8e7f290e9fa..e5642b964d4f7b551a187ddbb63ca4521fea7a83 100644 --- a/ets2panda/util/options.cpp +++ b/ets2panda/util/options.cpp @@ -208,6 +208,9 @@ bool Options::Parse(Span args) if (!CallPandArgParser(es2pandaArgs)) { return false; } + if (WasSetOutput()) { + outputFlag_ = true; + } if (IsVersion()) { std::cerr << GetVersion(); diff --git a/ets2panda/util/options.h b/ets2panda/util/options.h index 7b115a50f17c2c58da2552dda683c98b1d1d78f2..5b6b077c43c18f74f7ab75ed2365712ac4f29c49 100644 --- a/ets2panda/util/options.h +++ b/ets2panda/util/options.h @@ -170,6 +170,11 @@ public: return astVerifierEachPhase_ || astVerifierPhases_.find(std::string(phase)) != astVerifierPhases_.end(); } + bool GetOutputFlag() const + { + return outputFlag_; + } + private: template static bool CallPandArgParser(const std::vector &args, T &options, @@ -204,6 +209,7 @@ private: Logger::Level logLevel_ {Logger::Level::ERROR}; EvalMode evalMode_ = {EvalMode::NONE}; util::DiagnosticEngine &diagnosticEngine_; + bool outputFlag_ = false; }; } // namespace ark::es2panda::util