vere: compat: link binary at $pier/.run.exe on windows

This commit is contained in:
Joe Bryan 2022-05-18 21:13:20 -04:00
parent baf690c85a
commit a9233493d3
3 changed files with 16 additions and 4 deletions

View File

@ -358,7 +358,9 @@ _main_getopt(c3_i argc, c3_c** argv)
// no args, argv[0] == $pier/.run
//
if ( (4 <= len_w) && (0 == strcmp(argv[0] + (len_w - 4), ".run")) ) {
if ( (U3_BIN_ALIAS_LEN <= len_w)
&& (0 == strcmp(argv[0] + (len_w - U3_BIN_ALIAS_LEN), U3_BIN_ALIAS)) )
{
u3_Host.dir_c = _main_repath(dirname(argv[0]));
}
// no args, invalid command

View File

@ -123,6 +123,16 @@
# endif
# endif
/** Binary alias.
**/
# ifdef U3_OS_mingw
# define U3_BIN_ALIAS ".run.exe"
# else
# define U3_BIN_ALIAS ".run"
# endif
# define U3_BIN_ALIAS_LEN (sizeof(U3_BIN_ALIAS) - 1)
/** Address space layout.
***
*** NB: 2^29 words == 2GB

View File

@ -1053,7 +1053,7 @@ _king_link_run(c3_c* bin_c)
c3_c* lin_c;
c3_i ret_i;
ret_i = asprintf(&lin_c, "%s/.run", u3_Host.dir_c); // XX ./.run.exe?
ret_i = asprintf(&lin_c, "%s/%s", u3_Host.dir_c, U3_BIN_ALIAS);
c3_assert( ret_i > 0 );
ret_i = unlink(lin_c);
@ -1144,7 +1144,7 @@ _king_get_vere(c3_c* pac_c, c3_c* ver_c, c3_c* arc_c, c3_t lin_t)
//
if ( lin_t ) {
if ( _king_link_run(bin_c) ) {
fprintf(stderr, "vere: link %s/.run failed\n", u3_Host.dir_c);
fprintf(stderr, "vere: link %s/%s failed\n", u3_Host.dir_c, U3_BIN_ALIAS);
c3_free(url_c);
c3_free(bin_c);
return -1;
@ -1188,7 +1188,7 @@ _king_link_vere(c3_c* pac_c, c3_c* ver_c, c3_c* arc_c, c3_t lin_t)
//
if ( lin_t ) {
if ( _king_link_run(bin_c) ) {
fprintf(stderr, "vere: link %s/.run failed\n", u3_Host.dir_c);
fprintf(stderr, "vere: link %s/%s failed\n", u3_Host.dir_c, U3_BIN_ALIAS);
c3_free(bin_c);
return -1;
}