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

Support setting the binary executable name with --bin-name. #2430

Merged
merged 2 commits into from
Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/libponyc/codegen/genexe.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,17 @@ bool genexe(compile_t* c, ast_t* program)
// The first package is the main package. It has to have a Main actor.
const char* main_actor = c->str_Main;
const char* env_class = c->str_Env;
const char* package_name = c->filename;

if((c->opt->exe_name != NULL) && (strlen(c->opt->exe_name) > 0))
c->filename = c->opt->exe_name;

ast_t* package = ast_child(program);
ast_t* main_def = ast_get(package, main_actor, NULL);

if(main_def == NULL)
{
errorf(errors, NULL, "no Main actor found in package '%s'", c->filename);
errorf(errors, NULL, "no Main actor found in package '%s'", package_name);
return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/libponyc/pass/pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ typedef struct pass_opt_t
magic_package_t* magic_packages;

const char* output;
const char* exe_name;
char* link_arch;
char* linker;

Expand Down
5 changes: 5 additions & 0 deletions src/ponyc/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum
OPT_STRIP,
OPT_PATHS,
OPT_OUTPUT,
OPT_EXE_NAME,
OPT_LIBRARY,
OPT_RUNTIMEBC,
OPT_PIC,
Expand Down Expand Up @@ -71,6 +72,7 @@ static opt_arg_t args[] =
{"strip", 's', OPT_ARG_NONE, OPT_STRIP},
{"path", 'p', OPT_ARG_REQUIRED, OPT_PATHS},
{"output", 'o', OPT_ARG_REQUIRED, OPT_OUTPUT},
{"exe-name", 'e', OPT_ARG_REQUIRED, OPT_EXE_NAME},
{"library", 'l', OPT_ARG_NONE, OPT_LIBRARY},
{"runtimebc", '\0', OPT_ARG_NONE, OPT_RUNTIMEBC},
{"pic", '\0', OPT_ARG_NONE, OPT_PIC},
Expand Down Expand Up @@ -124,6 +126,8 @@ static void usage()
" =path Used to find packages and libraries.\n"
" --output, -o Write output to this directory.\n"
" =path Defaults to the current directory.\n"
" --exe-name, -e Name of executable.\n"
" =name Defaults to name of the directory.\n"
" --library, -l Generate a C-API compatible static library.\n"
" --runtimebc Compile with the LLVM bitcode file for the runtime.\n"
" --pic Compile using position independent code.\n"
Expand Down Expand Up @@ -306,6 +310,7 @@ int main(int argc, char* argv[])
case OPT_STRIP: opt.strip_debug = true; break;
case OPT_PATHS: package_add_paths(s.arg_val, &opt); break;
case OPT_OUTPUT: opt.output = s.arg_val; break;
case OPT_EXE_NAME: opt.exe_name = s.arg_val; break;
case OPT_LIBRARY: opt.library = true; break;
case OPT_RUNTIMEBC: opt.runtimebc = true; break;
case OPT_PIC: opt.pic = true; break;
Expand Down