Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/ketopt #42

Merged
merged 9 commits into from
Nov 25, 2024
Merged

Feat/ketopt #42

merged 9 commits into from
Nov 25, 2024

Conversation

jaromil
Copy link
Member

@jaromil jaromil commented Nov 19, 2024

change option arguments to accept more commandline switches also multiple times

  ketopt_t opt = KETOPT_INIT;
  int i, c;
  while ((c = ketopt(&opt, argc, argv, 1, "vD:L:l:C:I:", NULL)) >= 0) {
    if (c == 'v') {
      _err("Running version: %s\n",VERSION);
      tcc_delete(TCC);
      exit(0); // print version and exit
    } else if (c == 'D') { // define
      _err("define: %s",opt.arg);
      tcc_define_symbol(TCC, opt.arg, NULL); // TODO: sym=var
    } else if (c == 'L') { // library path
      _err("lib path: %s",opt.arg);
      tcc_add_library_path(TCC,tmpdir);
    } else if (c == 'l') { // library link
      _err("lib: %s",opt.arg);
      tcc_add_library(TCC, opt.arg);
    } else if (c == 'C') { // library link
      _err("cflags: %s",opt.arg);
      tcc_set_options(TCC, opt.arg);
    } else if (c == 'I') { // library link
      tcc_add_include_path(TCC,opt.arg);
    }
    else if (c == '?') _err("unknown opt: -%c\n", opt.opt? opt.opt : ':');
    else if (c == ':') _err("missing arg: -%c\n", opt.opt? opt.opt : ':');
  }

ketopt allows to have calls at every parsed option so they can append

@jaromil jaromil marked this pull request as ready for review November 25, 2024 13:53
@jaromil jaromil merged commit 2a5e425 into main Nov 25, 2024
12 checks passed
@jaromil jaromil deleted the feat/ketopt branch November 25, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant