Solvespace-qt port

I managed to get Solvespace working in haiku few days back. Now i have been modeling with it and it is very stable and works very good.

Guide:

Install following packages, i am not fully sure if these are enough:

pkgman install qt6_base_devel
pkgman install json_c_devel
pkgman install xlibe_devel
pkgman install zlib_devel
pkgman install libpng16_devel
pkgman install freetype_devel

Clone repository and submodules:

git clone https://github.com/solvespace/solvespace.git solvespace-3.2
cd solvespace-3.2/
git checkout v3.2
git submodule update --init --recursive
git status
git submodule status

Open file:

nano src/platform/platform.cpp

Find this:

#include <mimalloc.h>

Add this below it:

#if defined(__HAIKU__)
#include <kernel/image.h>
#endif

Next find this:

#    if defined(__linux__)
static const char *selfSymlink = "/proc/self/exe";
#    elif defined(__NetBSD__)
static const char *selfSymlink = "/proc/curproc/exe";
#    elif defined(__OpenBSD__) || defined(__FreeBSD__)
static const char *selfSymlink = "/proc/curproc/file";
#    else
static const char *selfSymlink = "";
#    endif

Remove these two lines:

#    else
static const char *selfSymlink = "";

The resulting code should look like this:

#    if defined(__linux__)
static const char *selfSymlink = "/proc/self/exe";
#    elif defined(__NetBSD__)
static const char *selfSymlink = "/proc/curproc/exe";
#    elif defined(__OpenBSD__) || defined(__FreeBSD__)
static const char *selfSymlink = "/proc/curproc/file";
#    endif

Find this:

static Platform::Path FindLocalResourceDir() {
    // Find out the path to the running binary.

Add the following between those two lines:

#if defined(__HAIKU__)
    image_info info;
    int32 cookie = 0;

    while(get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
        if(info.type != B_APP_IMAGE) {
            continue;
        }

        Platform::Path selfPath = Path::From(info.name);

        Platform::Path resourceDir =
            selfPath.Parent().Parent().Join("res");

        struct stat st;
        if(stat(resourceDir.raw.c_str(), &st) != -1) {
            return resourceDir;
        }

        resourceDir =
            selfPath.Parent().Parent().Join("share").Join("solvespace");

        if(stat(resourceDir.raw.c_str(), &st) != -1) {
            return resourceDir;
        }

        break;
    }

    return Path::From(UNIX_DATADIR);

#else

And one more thing to find:

    // No executable-adjacent resource directory; use the one from compile-time prefix.
    return Path::From(UNIX_DATADIR);
}

Change it to this:

    // No executable-adjacent resource directory; use the one from compile-time prefix.
    return Path::From(UNIX_DATADIR);
#endif
}

Compile it:

mkdir build-haiku-qt
cd build-haiku-qt
cmake .. -DUSE_QT_GUI=ON
cmake --build . -j2

Start Solvespace (QT version):

./bin/solvespace-qt

I hope that i didn’t forgot anything..

3 Likes

Great! Any chance of upstreaming your changes to the main repository?

Seems like i cannot login github anymore, but maybe someone here who can, could inform this thread to solvespace devs.

Edit: And just for a note, this is compiled against Haiku beta 6 release.

I just tried to compile my changes against current solvespace master and it worked just fine. App works and i modeled same model than with v3.2 and everything worked ok.

I compiled with these optimizations. Speed increase was pretty clear.. i think enabling openmp affected most.

> cmake .. -DUSE_QT_GUI=ON -DENABLE_OPENMP=ON -DENABLE_LTO=ON -DCMAKE_BUILD_TYPE=Release