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