Skip to content

Commit

Permalink
Haiku: Add visible error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lonemadmax committed Nov 20, 2020
1 parent 3fb2ef6 commit 6b59808
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 3 deletions.
13 changes: 11 additions & 2 deletions Makefile.src.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ CONFIG_CACHE_SOURCE = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_SOURCE!!
CONFIG_CACHE_VERSION = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_VERSION!!

OBJS_C := !!OBJS_C!!
OBJS_CXX := !!OBJS_CXX!!
OBJS_S := !!OBJS_S!!
OBJS := $(OBJS_C) $(OBJS_S)
OBJS := $(OBJS_C) $(OBJS_CXX) $(OBJS_S)
SRCS := !!SRCS!!

# All C-files depend on those 3 files
Expand Down Expand Up @@ -79,7 +80,7 @@ RES := $(shell if [ "`cat $(CONFIG_CACHE_VERSION) 2>/dev/null`" != "$(REV) $(MOD
ifndef MAKEDEPEND
# The slow, but always correct, dep-check
DEP_MASK := %.d
DEPS := $(OBJS_C:%.o=%.d)
DEPS := $(OBJS_C:%.o=%.d) $(OBJS_CXX:%.o=%.d)

# Only include the deps if we are compiling everything
ifeq ($(filter %.o clean mrproper, $(MAKECMDGOALS)),)
Expand All @@ -98,6 +99,10 @@ $(OBJS_C:%.o=%.d): %.d: $(SRC_DIR)/%.c $(FILE_DEP)
$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.c=%.c)'
$(Q)$(CC_HOST) $(CFLAGS) -MM $< | sed 's@^$(@F:%.d=%.o):@$@ $(@:%.d=%.o):@' > $@

$(OBJS_CXX:%.o=%.d): %.d: $(SRC_DIR)/%.cpp $(FILE_DEP)
$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CC_HOST) $(CFLAGS) -MM $< | sed 's@^$(@F:%.d=%.o):@$@ $(@:%.d=%.o):@' > $@

else
# The much faster, but can be wrong, dep-check
DEP_MASK :=
Expand Down Expand Up @@ -178,6 +183,10 @@ $(OBJS_C): %.o: $(SRC_DIR)/%.c $(DEP_MASK) $(FILE_DEP)
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.c=%.c)'
$(Q)$(CC_HOST) $(CFLAGS) -c -o $@ $<

$(OBJS_CXX): %.o: $(SRC_DIR)/%.cpp $(DEP_MASK) $(FILE_DEP)
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CC_HOST) $(CFLAGS) -c -o $@ $<

$(OBJS_S): %.o: $(SRC_DIR)/%.s
$(E) '$(STAGE) Assembling $(<:$(SRC_DIR)/%.s=%.s)'
$(Q)$(AS_HOST) $(ASFLAGS) -o $@ $<
Expand Down
4 changes: 4 additions & 0 deletions config.lib
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,9 @@ make_cflags_and_ldflags() {

if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ]; then
LIBS="$LIBS -lmidi -lbe"
if [ "$os" = "HAIKU" ]; then
LIBS="$LIBS -lstdc++"
fi
fi

# Most targets act like UNIX, just with some additions
Expand Down Expand Up @@ -1924,6 +1927,7 @@ make_sed() {
s@[email protected]@g;
s@[email protected]@g;
s@[email protected]@g;
s@!!OBJS_CXX!!@$OBJS_CXX@g;
s@!!OBJS_C!!@$OBJS_C@g;
s@!!OBJS_S!!@$OBJS_S@g;
s@!!SRCS!!@$SRCS@g;
Expand Down
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ AWKCOMMAND='
SRCS="`< $ROOT_DIR/source.list tr '\r' '\n' | $awk \"$AWKCOMMAND\" | $PIPE_SORT`"

OBJS_C="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.c$/ { gsub(\".c$\", \".o\", $0); print $0; }'`"
OBJS_CXX="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.cpp$/ { gsub(\".cpp$\", \".o\", $0); print $0; }'`"
OBJS_S="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.s$/ { gsub(\".s$\", \".o\", $0); print $0; }'`"
SRCS="` echo \"$SRCS\" | $awk ' { ORS = \" \" } { print $0; }'`"

Expand Down
6 changes: 5 additions & 1 deletion source.list
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ os/endian.c
#if OSX
os/error_osx.c
#else
os/error.c
#if HAIKU
os/error_haiku.cpp
#else
os/error.c
#endif
#endif
#if TOS
os/readdir_atari.c
Expand Down
82 changes: 82 additions & 0 deletions src/os/error_haiku.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/** @file src/os/error_haiku.c System dependent error messages for Haiku. */

#include <new>

#include <Alert.h>
#include <AppFileInfo.h>
#include <Application.h>
#include <File.h>
#include <image.h>

extern "C" {

#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "strings.h"

#include "error.h"

static void AppInit(void) {
image_info info;
int32 cookie = 0;
while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
if (info.type == B_APP_IMAGE) {
BFile me(info.name, O_RDONLY);
if (me.InitCheck() == B_OK) {
BAppFileInfo app_info(&me);
if (app_info.InitCheck() == B_OK) {
char signature[B_MIME_TYPE_LENGTH];
if (app_info.GetSignature(signature) == B_OK) {
new BApplication(signature);
return;
}
}
}
}
}
new BApplication("application/x-vnd.opendune");
}

void Error(const char *format, ...) {
char message[512];
va_list ap;

va_start(ap, format);
vsnprintf(message, sizeof(message), format, ap);
va_end(ap);

fputs(message, stderr);

/* Some checks are done before initializing SDL, so we may not have SDL
* nor a BApplication to show the alert
*/
if (be_app == NULL) AppInit();

BAlert* alert = new(std::nothrow) BAlert("Error - OpenDUNE", message,
"OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
if (alert != NULL) {
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
}
}

void Warning(const char *format, ...) {
va_list ap;

va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
}

#ifdef _DEBUG
void Debug(const char *format, ...) {
va_list ap;

va_start(ap, format);
vfprintf(stdout, format, ap);
va_end(ap);
}
#endif

}

0 comments on commit 6b59808

Please sign in to comment.