From c40e80d5a59fef874bfb64ba22f40e0f48f71e45 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 17 Nov 2015 11:49:23 -0500 Subject: [PATCH] Added C++ to the build and started writing the actual Haiku code. I think this isg oing to have to require a GCC 4 hybrid... --- GNUbaserules.mk | 20 +++++++++++++++++++- GNUmakefile.libui | 2 +- darwin/GNUosspecific.mk | 1 + haiku/GNUmakeinc.mk | 7 ++++--- haiku/GNUosspecific.mk | 1 + haiku/main.cpp | 41 ++++++++++++++++++++++++++++++++++++++++ haiku/uipriv_haiku.hpp | 6 ++++++ unix/GNUosspecific.mk | 1 + windows/GNUosspecific.mk | 1 + 9 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 haiku/main.cpp create mode 100644 haiku/uipriv_haiku.hpp diff --git a/GNUbaserules.mk b/GNUbaserules.mk index cd66f0bc..42d8ffe2 100644 --- a/GNUbaserules.mk +++ b/GNUbaserules.mk @@ -2,6 +2,7 @@ OFILES = \ $(subst /,_,$(CFILES)) \ + $(subst /,_,$(CXXFILES)) \ $(subst /,_,$(MFILES)) \ $(subst /,_,$(RCFILES)) @@ -14,6 +15,13 @@ CFLAGS += \ -Wno-switch \ --std=c99 +CXXFLAGS += \ + -g \ + -Wall -Wextra \ + -Wno-unused-parameter \ + -Wno-switch \ + --std=c++03 + LDFLAGS += \ -g @@ -27,8 +35,14 @@ endif OUT = $(OUTDIR)/$(NAME)$(SUFFIX) +ifdef CXXFILES + reallinker = $(CXX) +else + reallinker = $(CC) +endif + $(OUT): $(OFILES) | $(OUTDIR) - @$(CC) -o $(OUT) $(OFILES) $(LDFLAGS) + @$(reallinker) -o $(OUT) $(OFILES) $(LDFLAGS) @echo ====== Linked $(OUT) .SECONDEXPANSION: @@ -37,6 +51,10 @@ $(OBJDIR)/%.c.o: $$(subst _,/,%).c $(HFILES) | $(OBJDIR) @$(CC) -o $@ -c $< $(CFLAGS) @echo ====== Compiled $< +$(OBJDIR)/%.cpp.o: $$(subst _,/,%).cpp $(HFILES) | $(OBJDIR) + @$(CXX) -o $@ -c $< $(CXXFLAGS) + @echo ====== Compiled $< + $(OBJDIR)/%.m.o: $$(subst _,/,%).m $(HFILES) | $(OBJDIR) @$(CC) -o $@ -c $< $(CFLAGS) @echo ====== Compiled $< diff --git a/GNUmakefile.libui b/GNUmakefile.libui index 628f10fc..0ee4dc71 100644 --- a/GNUmakefile.libui +++ b/GNUmakefile.libui @@ -10,7 +10,7 @@ include $(OS)/GNUmakeinc.mk HFILES += \ ui.h \ - ui_$(OS).h + ui_$(OS)$(OSHSUFFIX) NAME = libui diff --git a/darwin/GNUosspecific.mk b/darwin/GNUosspecific.mk index b38372d8..ca44f8d8 100644 --- a/darwin/GNUosspecific.mk +++ b/darwin/GNUosspecific.mk @@ -2,3 +2,4 @@ EXESUFFIX = LIBSUFFIX = .dylib +OSHSUFFIX = .h diff --git a/haiku/GNUmakeinc.mk b/haiku/GNUmakeinc.mk index 0647c623..71b1faf8 100644 --- a/haiku/GNUmakeinc.mk +++ b/haiku/GNUmakeinc.mk @@ -1,12 +1,13 @@ # 22 april 2015 -CFILES += \ +CXXFILES += \ + haiku/main.cpp HFILES += \ - haiku/uipriv_haiku.h + haiku/uipriv_haiku.hpp # thanks ebassi in irc.gimp.net/#gtk+ -CFLAGS += \ +CXXFLAGS += \ -D_UI_EXTERN='__attribute__((visibility("default"))) extern' \ -fvisibility=hidden \ -fPIC diff --git a/haiku/GNUosspecific.mk b/haiku/GNUosspecific.mk index 0e2a497c..acd12f97 100644 --- a/haiku/GNUosspecific.mk +++ b/haiku/GNUosspecific.mk @@ -2,3 +2,4 @@ EXESUFFIX = LIBSUFFIX = .so +OSHSUFFIX = .hpp diff --git a/haiku/main.cpp b/haiku/main.cpp new file mode 100644 index 00000000..75dddac1 --- /dev/null +++ b/haiku/main.cpp @@ -0,0 +1,41 @@ +// 17 november 2015 +#include "uipriv_haiku.hpp" + +static BApplication *app; + +uiInitOptions options; + +const char *uiInit(uiInitOptions *o) +{ + status_t err; + + options = *o; + // TODO properly set the MIME type + app = new BApplication("application/x-vnd.andlabs.libui", &err); + if (err != B_NO_ERROR) { + delete app; + // TODO + return "fail"; + } + return NULL; +} + +void uiUninit(void) +{ + delete app; +} + +void uiFreeInitError(const char *err) +{ + // TODO +} + +void uiMain(void) +{ + app->Run(); +} + +void uiQuit(void) +{ + app->Quit(); +} diff --git a/haiku/uipriv_haiku.hpp b/haiku/uipriv_haiku.hpp new file mode 100644 index 00000000..d7763c70 --- /dev/null +++ b/haiku/uipriv_haiku.hpp @@ -0,0 +1,6 @@ +// 17 november 2015 +// TODO versioning macros? +#include +#include "../ui.h" +#include "../ui_haiku.hpp" +#include "../common/uipriv.h" diff --git a/unix/GNUosspecific.mk b/unix/GNUosspecific.mk index 0e2a497c..ac298ffb 100644 --- a/unix/GNUosspecific.mk +++ b/unix/GNUosspecific.mk @@ -2,3 +2,4 @@ EXESUFFIX = LIBSUFFIX = .so +OSHSUFFIX = .h diff --git a/windows/GNUosspecific.mk b/windows/GNUosspecific.mk index 874039f6..87ee2eef 100644 --- a/windows/GNUosspecific.mk +++ b/windows/GNUosspecific.mk @@ -2,6 +2,7 @@ EXESUFFIX = .exe LIBSUFFIX = .dll +OSHSUFFIX = .h # TODO only when cross-compiling? ifeq ($(ARCH),amd64)