|
1 | 1 | #include <sys/types.h> |
2 | 2 |
|
3 | 3 | #include <array> |
| 4 | +#include <cerrno> |
4 | 5 | #include <cstdint> |
5 | 6 | #include <cstdio> |
6 | 7 | #include <cstdlib> |
|
21 | 22 | #include "absl/status/status.h" |
22 | 23 | #include "absl/strings/match.h" |
23 | 24 | #include "absl/strings/numbers.h" |
24 | | -#include "absl/strings/str_cat.h" |
25 | 25 | #include "absl/strings/str_format.h" |
26 | 26 | #include "absl/strings/str_split.h" |
27 | 27 | #include "fpga/database-parsers.h" |
@@ -301,13 +301,12 @@ If not present, it must be provided via PRJXRAY_DB_PATH.)"); |
301 | 301 | ABSL_FLAG(std::string, part, "", R"(FPGA part name, e.g. "xc7a35tcsg324-1".)"); |
302 | 302 |
|
303 | 303 | 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); |
311 | 310 | } |
312 | 311 |
|
313 | 312 | static std::string StatusToErrorMessage(std::string_view message, |
@@ -380,6 +379,7 @@ int main(int argc, char *argv[]) { |
380 | 379 | const auto args_count = args.size(); |
381 | 380 | if (args_count > 2) { |
382 | 381 | std::cerr << absl::ProgramUsageMessage() << '\n'; |
| 382 | + return 1; |
383 | 383 | } |
384 | 384 | const absl::StatusOr<std::string> prjxray_db_path_result = |
385 | 385 | GetOptFlagOrFromEnv(FLAGS_prjxray_db_path, "PRJXRAY_DB_PATH"); |
@@ -422,6 +422,11 @@ int main(int argc, char *argv[]) { |
422 | 422 | const std::string_view arg(args[1]); |
423 | 423 | if (arg != "-") { |
424 | 424 | 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 | + } |
425 | 430 | } |
426 | 431 | } |
427 | 432 | fpga::Frames frames; |
|
0 commit comments