diff --git a/src/libponyc/codegen/genexe.c b/src/libponyc/codegen/genexe.c index a8f811d1ae..ab908e70ed 100644 --- a/src/libponyc/codegen/genexe.c +++ b/src/libponyc/codegen/genexe.c @@ -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->bin_name != NULL) && (strlen(c->opt->bin_name) > 0)) + c->filename = c->opt->bin_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; } diff --git a/src/libponyc/pass/pass.h b/src/libponyc/pass/pass.h index e450107cd1..ca4e487612 100644 --- a/src/libponyc/pass/pass.h +++ b/src/libponyc/pass/pass.h @@ -238,6 +238,7 @@ typedef struct pass_opt_t magic_package_t* magic_packages; const char* output; + const char* bin_name; char* link_arch; char* linker; diff --git a/src/ponyc/main.c b/src/ponyc/main.c index cec1fffbe9..3b43ea03ab 100644 --- a/src/ponyc/main.c +++ b/src/ponyc/main.c @@ -28,6 +28,7 @@ enum OPT_STRIP, OPT_PATHS, OPT_OUTPUT, + OPT_BIN_NAME, OPT_LIBRARY, OPT_RUNTIMEBC, OPT_PIC, @@ -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}, + {"bin-name", 'b', OPT_ARG_REQUIRED, OPT_BIN_NAME}, {"library", 'l', OPT_ARG_NONE, OPT_LIBRARY}, {"runtimebc", '\0', OPT_ARG_NONE, OPT_RUNTIMEBC}, {"pic", '\0', OPT_ARG_NONE, OPT_PIC}, @@ -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" + " --bin-name, -b Name of executable binary.\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" @@ -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_BIN_NAME: opt.bin_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;