Skip to content

Commit 81726a3

Browse files
committed
fpga-as: updated usage message and fixed non-returning error
1 parent ff8ab9a commit 81726a3

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

fpga/assembler.cc

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <sys/types.h>
22

33
#include <array>
4+
#include <cerrno>
45
#include <cstdint>
56
#include <cstdio>
67
#include <cstdlib>
@@ -21,7 +22,6 @@
2122
#include "absl/status/status.h"
2223
#include "absl/strings/match.h"
2324
#include "absl/strings/numbers.h"
24-
#include "absl/strings/str_cat.h"
2525
#include "absl/strings/str_format.h"
2626
#include "absl/strings/str_split.h"
2727
#include "fpga/database-parsers.h"
@@ -301,13 +301,12 @@ If not present, it must be provided via PRJXRAY_DB_PATH.)");
301301
ABSL_FLAG(std::string, part, "", R"(FPGA part name, e.g. "xc7a35tcsg324-1".)");
302302

303303
static inline std::string Usage(std::string_view name) {
304-
return absl::StrCat("usage: ", name,
305-
" [options] < input.fasm > output.frm\n"
306-
R"(
307-
fpga parses a sequence of fasm lines and assembles them
308-
into a set of frames to be mapped into bitstream.
309-
Output is written to stdout.
310-
)");
304+
return absl::StrFormat(R"(usage: %s [options] < input.fasm > output.bit
305+
306+
This tool parses a sequence of fasm lines and assemble them
307+
into a set of frames then mapped into bitstream.
308+
Output is written to stdout.)",
309+
name);
311310
}
312311

313312
static std::string StatusToErrorMessage(std::string_view message,
@@ -380,6 +379,7 @@ int main(int argc, char *argv[]) {
380379
const auto args_count = args.size();
381380
if (args_count > 2) {
382381
std::cerr << absl::ProgramUsageMessage() << '\n';
382+
return 1;
383383
}
384384
const absl::StatusOr<std::string> prjxray_db_path_result =
385385
GetOptFlagOrFromEnv(FLAGS_prjxray_db_path, "PRJXRAY_DB_PATH");
@@ -422,6 +422,11 @@ int main(int argc, char *argv[]) {
422422
const std::string_view arg(args[1]);
423423
if (arg != "-") {
424424
input_stream = std::fopen(args[1], "r");
425+
if (input_stream == nullptr) {
426+
std::cerr << absl::ErrnoToStatus(errno, "cannot open fasm file")
427+
<< "\n";
428+
return 1;
429+
}
425430
}
426431
}
427432
fpga::Frames frames;

0 commit comments

Comments
 (0)