From 99e0a2e577c468df6fd06cd9151b240a5f3d63a5 Mon Sep 17 00:00:00 2001 From: Leonardo Romor Date: Thu, 3 Apr 2025 23:20:48 +0200 Subject: [PATCH 1/2] fpga-as: updated usage message and fixed non-returning error --- fpga/assembler.cc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/fpga/assembler.cc b/fpga/assembler.cc index 5913c1f..204ce38 100644 --- a/fpga/assembler.cc +++ b/fpga/assembler.cc @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -21,7 +22,6 @@ #include "absl/status/status.h" #include "absl/strings/match.h" #include "absl/strings/numbers.h" -#include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/str_split.h" #include "fpga/database-parsers.h" @@ -301,13 +301,12 @@ If not present, it must be provided via PRJXRAY_DB_PATH.)"); ABSL_FLAG(std::string, part, "", R"(FPGA part name, e.g. "xc7a35tcsg324-1".)"); static inline std::string Usage(std::string_view name) { - return absl::StrCat("usage: ", name, - " [options] < input.fasm > output.frm\n" - R"( -fpga parses a sequence of fasm lines and assembles them -into a set of frames to be mapped into bitstream. -Output is written to stdout. -)"); + return absl::StrFormat(R"(usage: %s [options] < input.fasm > output.bit + +This tool parses a sequence of fasm lines and assemble them +into a set of frames then mapped into bitstream. +Output is written to stdout.)", + name); } static std::string StatusToErrorMessage(std::string_view message, @@ -380,6 +379,7 @@ int main(int argc, char *argv[]) { const auto args_count = args.size(); if (args_count > 2) { std::cerr << absl::ProgramUsageMessage() << '\n'; + return 1; } const absl::StatusOr prjxray_db_path_result = GetOptFlagOrFromEnv(FLAGS_prjxray_db_path, "PRJXRAY_DB_PATH"); @@ -422,6 +422,11 @@ int main(int argc, char *argv[]) { const std::string_view arg(args[1]); if (arg != "-") { input_stream = std::fopen(args[1], "r"); + if (input_stream == nullptr) { + std::cerr << absl::ErrnoToStatus(errno, "cannot open fasm file") + << "\n"; + return 1; + } } } fpga::Frames frames; From e51a10245679ae10f9f7135ba75b57c7fa4941f0 Mon Sep 17 00:00:00 2001 From: Leonardo Romor Date: Fri, 4 Apr 2025 18:08:00 +0200 Subject: [PATCH 2/2] Update fpga/assembler.cc Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- fpga/assembler.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpga/assembler.cc b/fpga/assembler.cc index 204ce38..c429e9f 100644 --- a/fpga/assembler.cc +++ b/fpga/assembler.cc @@ -303,7 +303,7 @@ ABSL_FLAG(std::string, part, "", R"(FPGA part name, e.g. "xc7a35tcsg324-1".)"); static inline std::string Usage(std::string_view name) { return absl::StrFormat(R"(usage: %s [options] < input.fasm > output.bit -This tool parses a sequence of fasm lines and assemble them +This tool parses a sequence of fasm lines and assembles them into a set of frames then mapped into bitstream. Output is written to stdout.)", name);