Bare minimum changes to get Windows builds running again.
This commit is contained in:
parent
0aa4aeff41
commit
9d9d094e6a
5
build.sh
5
build.sh
|
@ -70,6 +70,7 @@ CC="${CC:-cc}"
|
|||
CFLAGS="${CFLAGS:--std=c89 -Wall -Wno-unknown-pragmas}"
|
||||
case "$(uname -s 2>/dev/null)" in
|
||||
MSYS_NT*|MINGW*) # MSYS2 on Windows
|
||||
FILE_LDFLAGS="-liberty"
|
||||
if [ $console = 1 ];
|
||||
then
|
||||
UXNEMU_LDFLAGS="-static $(sdl2-config --cflags --static-libs | sed -e 's/ -mwindows//g')"
|
||||
|
@ -98,8 +99,8 @@ fi
|
|||
|
||||
echo "Building.."
|
||||
${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm
|
||||
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu
|
||||
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli
|
||||
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} ${FILE_LDFLAGS} -o bin/uxnemu
|
||||
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c ${FILE_LDFLAGS} -o bin/uxncli
|
||||
|
||||
if [ $install = 1 ]
|
||||
then
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <libiberty/libiberty.h>
|
||||
#define realpath(s, dummy) lrealpath(s)
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
@ -84,14 +89,17 @@ file_read_dir(UxnFile *c, char *dest, Uint16 len)
|
|||
continue;
|
||||
if(strcmp(c->de->d_name, "..") == 0) {
|
||||
/* hide "sandbox/.." */
|
||||
char cwd[PATH_MAX] = {'\0'}, t[PATH_MAX] = {'\0'};
|
||||
char cwd[PATH_MAX] = {'\0'}, *t;
|
||||
/* Note there's [currently] no way of chdir()ing from uxn, so $PWD
|
||||
* is always the sandbox top level. */
|
||||
getcwd(cwd, sizeof(cwd));
|
||||
/* We already checked that c->current_filename exists so don't need a wrapper. */
|
||||
realpath(c->current_filename, t);
|
||||
if(strcmp(cwd, t) == 0)
|
||||
t = realpath(c->current_filename, NULL);
|
||||
if(strcmp(cwd, t) == 0) {
|
||||
free(t);
|
||||
continue;
|
||||
}
|
||||
free(t);
|
||||
}
|
||||
if(strlen(c->current_filename) + 1 + strlen(c->de->d_name) < sizeof(pathname))
|
||||
sprintf(pathname, "%s/%s", c->current_filename, c->de->d_name);
|
||||
|
@ -108,7 +116,7 @@ file_read_dir(UxnFile *c, char *dest, Uint16 len)
|
|||
static char *
|
||||
retry_realpath(const char *file_name)
|
||||
{
|
||||
char r[PATH_MAX] = {'\0'}, p[PATH_MAX] = {'\0'}, *x;
|
||||
char *r, p[PATH_MAX] = {'\0'}, *x;
|
||||
if(file_name == NULL) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
|
@ -123,7 +131,7 @@ retry_realpath(const char *file_name)
|
|||
strcat(p, "/"); /* TODO: use a macro instead of '/' for the path delimiter */
|
||||
}
|
||||
strcat(p, file_name);
|
||||
while(realpath(p, r) == NULL) {
|
||||
while((r = realpath(p, NULL)) == NULL) {
|
||||
if(errno != ENOENT)
|
||||
return NULL;
|
||||
x = strrchr(p, '/'); /* TODO: path delimiter macro */
|
||||
|
@ -134,6 +142,7 @@ retry_realpath(const char *file_name)
|
|||
}
|
||||
x = malloc(strlen(r) + 1);
|
||||
strcpy(x, r);
|
||||
free(r);
|
||||
return x;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue