| 630 | "pipeline libbuild <code_file> <lib_file>\n"; |
| 631 | |
| 632 | static void |
| 633 | cmd_pipeline_libbuild(char **tokens, |
| 634 | uint32_t n_tokens, |
| 635 | char *out, |
| 636 | size_t out_size, |
| 637 | void *obj __rte_unused) |
| 638 | { |
| 639 | char *code_file, *lib_file, *obj_file = NULL, *log_file = NULL; |
| 640 | char *install_dir, *cwd = NULL, *buffer = NULL; |
| 641 | size_t length; |
| 642 | int status = 0; |
| 643 | |
| 644 | if (n_tokens != 4) { |
| 645 | snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); |
| 646 | goto free; |
| 647 | } |
| 648 | |
| 649 | install_dir = getenv("RTE_INSTALL_DIR"); |
| 650 | if (!install_dir) { |
| 651 | cwd = malloc(MAX_LINE_SIZE); |
| 652 | if (!cwd) { |
| 653 | snprintf(out, out_size, MSG_OUT_OF_MEMORY); |
| 654 | goto free; |
| 655 | } |
| 656 | |
| 657 | install_dir = getcwd(cwd, MAX_LINE_SIZE); |
| 658 | if (!install_dir) { |
| 659 | snprintf(out, out_size, "Error: Path too long.\n"); |
| 660 | goto free; |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | snprintf(out, out_size, "Using DPDK source code from \"%s\".\n", install_dir); |
| 665 | out_size -= strlen(out); |
| 666 | out += strlen(out); |
| 667 | |
| 668 | code_file = tokens[2]; |
| 669 | length = strnlen(code_file, MAX_LINE_SIZE); |
| 670 | if ((length < 3) || |
| 671 | (code_file[length - 2] != '.') || |
| 672 | (code_file[length - 1] != 'c')) { |
| 673 | snprintf(out, out_size, MSG_ARG_INVALID, "code_file"); |
| 674 | goto free; |
| 675 | } |
| 676 | |
| 677 | lib_file = tokens[3]; |
| 678 | length = strnlen(lib_file, MAX_LINE_SIZE); |
| 679 | if ((length < 4) || |
| 680 | (lib_file[length - 3] != '.') || |
| 681 | (lib_file[length - 2] != 's') || |
| 682 | (lib_file[length - 1] != 'o')) { |
| 683 | snprintf(out, out_size, MSG_ARG_INVALID, "lib_file"); |
| 684 | goto free; |
| 685 | } |
| 686 | |
| 687 | obj_file = malloc(length); |
| 688 | log_file = malloc(length + 2); |
| 689 | if (!obj_file || !log_file) { |