Merge pull request #35 from rollerozxa/linux-stuff-pt2

Linux stuff pt2
This commit is contained in:
Emil Romanus 2022-08-09 15:43:58 +02:00 committed by GitHub
commit b5f86f0b0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 51 additions and 38 deletions

View file

@ -62,29 +62,31 @@ $ ./go
Principia will launch if everything was successful. Note that the compilation might take up to 10 minutes depending on your system.
## Building on Linux (Debian)
## Building on Linux
Install dependencies:
Install dependencies (example is for Debian-based packages):
$ sudo apt-get install automake libgtk2.0-dev libgl-dev libxss-dev libxxf86vm-dev libasound2-dev libudev-dev valgrind
$ sudo apt-get install automake libgtk2.0-dev libgl-dev libxss-dev libxxf86vm-dev libasound2-dev libudev-dev valgrind
Navigate to the build-linux directory and start the building process:
$ cd build-linux;
$ cd build-linux;
$ ./autogen.sh
$ ./configure
$ ./go
$ ./autogen.sh
If everything goes well, Principia will start by default unless `--silent` is passed to the `go` script.
$ ./configure
### Packaging for Linux
When building Principia for packaging, you would want to use the following command to replace the above. It will clean the source tree, build a release version and not automatically run Principia.
$ ./go
./go --clean --release --silent
If everything goes well, Principia will start but then freeze at the loading screen due some uninitialize directories. Terminate Principia by replying 'y' in the gdb prompt in the terminal, then in the same terminal, go up a directory and launch it from the parent directory instead:
$ cd ..
$ build-linux/apparatus2
Right now Principia needs to be installed with its executable next to the data directories. Putting all of that in `/opt/principia/` and symlinking `/usr/bin/principia` => `/opt/principia/principia` should do for now.
(this bug will be fixed in short)
The `build-linux` directory contains desktop files and an usable icon, which can be installed into `/usr/share/applications/` and `/usr/share/pixmaps` respectively. `principia-url-handler.desktop` is for handling principia:// protocol links and is confirmed to work on at least Firefox and Chromium.
## Building for Android (on Linux)

View file

@ -1 +0,0 @@
../data-pc

1
build-linux/data-pc Symbolic link
View file

@ -0,0 +1 @@
../data-pc/

View file

@ -1 +0,0 @@
../data-shared

1
build-linux/data-shared Symbolic link
View file

@ -0,0 +1 @@
../data-shared/

View file

@ -148,10 +148,8 @@ if [ "$run" -eq "1" ]; then
elif [ "$debug" -eq "4" ]; then # --leak
valgrind --suppressions=./valgrind.supp --tool=memcheck --leak-check=full --show-possibly-lost=yes --track-origins=yes ./apparatus2
elif [ "$debug" -eq "1" ]; then
cd ../
gdb -ex run -ex quit build-linux/apparatus2
gdb -ex run -ex quit ./apparatus2
else
cd ../
build-linux/apparatus2
./apparatus2
fi
fi

View file

@ -1,5 +0,0 @@
#!/bin/sh
gconftool-2 -t string -s /desktop/gnome/url-handlers/principia/command "`pwd`/principia %s"
gconftool-2 -s /desktop/gnome/url-handlers/principia/needs_terminal false -t bool
gconftool-2 -t bool -s /desktop/gnome/url-handlers/principia/enabled true

0
build-screenshot-linux/autogen.sh Normal file → Executable file
View file

View file

@ -1 +0,0 @@
../data-pc

View file

@ -0,0 +1 @@
../data-pc/

View file

@ -1 +0,0 @@
../data-shared

View file

@ -0,0 +1 @@
../data-shared/

0
build-screenshot-linux/go Normal file → Executable file
View file

View file

@ -643,7 +643,7 @@ tproject_set_args(int argc, char **argv)
void
tproject_window_size_changed(void)
{
if (!settings["window_maximized"]->v.b) {
if (!settings["window_maximized"]->v.b && settings["autosave_screensize"]->v.b) {
settings["window_width"]->v.i = _tms.window_width;
settings["window_height"]->v.i = _tms.window_height;
}

View file

@ -70,6 +70,9 @@ _settings::init()
this->add("window_height", S_INT32, _tms.window_height);
this->add("window_maximized", S_BOOL, 0);
// False for now to allow for resetting the screensize if resizing somehow breaks it.
this->add("autosave_screensize",S_BOOL, false);
#if defined(TMS_BACKEND_IOS)
this->add("shadow_quality", S_UINT8, is_shitty ? 0 : 1);
#else

View file

@ -3528,6 +3528,11 @@ struct table_setting_row settings_interface_rows[] = {
"A restart is required for this change to take effect",
"uiscale",
setting_row_type::create_hscale(0.25, 2.0, 0.05),
},{
"Autosave screen size",
"Save the screen size when resizing the window.",
"autosave_screensize",
setting_row_type::create_checkbox()
}, {
"Display object ID",
"Display ID of object on selection (bottom-left corner).",

View file

@ -6,6 +6,8 @@
#include <sys/types.h>
#include <pwd.h>
#include <cxxabi.h>
#include <unistd.h>
#include <libgen.h>
#include <tms/core/project.h>
#include <tms/core/event.h>
@ -46,8 +48,8 @@ int _pipe_listener(void *p)
ssize_t sz;
while (1) {
tms_infof("attempting to open principia.run O_RDONLY");
while ((pipe_h = open("principia.run", O_RDONLY)) == -1) {
tms_infof("attempting to open /tmp/principia.run O_RDONLY");
while ((pipe_h = open("/tmp/principia.run", O_RDONLY)) == -1) {
if (errno != EINTR)
return 1;
}
@ -57,7 +59,7 @@ int _pipe_listener(void *p)
if (sz > 0) {
buf[sz] = '\0';
_args[1] = buf;
_args[1] = buf;
tproject_set_args(2, _args);
}
}
@ -78,7 +80,7 @@ main(int argc, char **argv)
SDL_Event ev;
int done = 0;
int status = mkfifo("principia.run", S_IWUSR | S_IRUSR);
int status = mkfifo("/tmp/principia.run", S_IWUSR | S_IRUSR);
int skip_pipe = 0;
if (status == 0) {
@ -89,9 +91,9 @@ main(int argc, char **argv)
skip_pipe = 1;
}
}
if (!skip_pipe) {
if ((pipe_h = open("principia.run", O_WRONLY | O_NONBLOCK)) == -1) {
if ((pipe_h = open("/tmp/principia.run", O_WRONLY | O_NONBLOCK)) == -1) {
if (errno != ENXIO) {
skip_pipe = 1;
tms_infof("error: %s", strerror(errno));
@ -116,6 +118,12 @@ main(int argc, char **argv)
SDL_CreateThread(_pipe_listener, "_pipe_listener", 0);
}
char buf[512];
readlink("/proc/self/exe", buf, 511);
dirname(buf);
tms_infof("chdirring to %s", buf);
chdir(buf);
char path[512];
const char *storage = tbackend_get_storage_path();
static const char *dirs[] = {
@ -200,7 +208,6 @@ main(int argc, char **argv)
switch (ev.window.event) {
case SDL_WINDOWEVENT_RESIZED:
{
#ifdef DEBUG
tms_infof("Window %d resized to %dx%d",
ev.window.windowID, ev.window.data1,
ev.window.data2);
@ -218,7 +225,6 @@ main(int argc, char **argv)
SDL_SetWindowSize(_window, _tms.window_width, _tms.window_height);
tproject_window_size_changed();
#endif
}
break;
}
@ -529,8 +535,15 @@ tbackend_init_surface()
_tms.yppcm = 107.f/2.54f * 1.5f;
#endif
uint32_t flags = 0;
flags |= SDL_WINDOW_OPENGL;
flags |= SDL_WINDOW_SHOWN;
flags |= SDL_WINDOW_RESIZABLE;
tms_progressf("Creating window... ");
_window = SDL_CreateWindow("Principia", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, _tms.window_width, _tms.window_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
_window = SDL_CreateWindow("Principia", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, _tms.window_width, _tms.window_height, flags);
if (_window == NULL) {
tms_progressf("ERROR: %s\n", SDL_GetError());
exit(1);

View file

@ -1 +0,0 @@
../

View file

@ -0,0 +1 @@
../

View file

@ -307,7 +307,6 @@ WinMain(HINSTANCE hi, HINSTANCE hp, LPSTR cl, int cs)
break;
case SDL_WINDOWEVENT_RESIZED:
{
#ifdef DEBUG
tms_infof("Window %d resized to %dx%d",
ev.window.windowID, ev.window.data1,
ev.window.data2);
@ -323,7 +322,6 @@ WinMain(HINSTANCE hi, HINSTANCE hp, LPSTR cl, int cs)
SDL_SetWindowSize(_window, _tms.window_width, _tms.window_height);
tproject_window_size_changed();
#endif
}
break;
case SDL_WINDOWEVENT_MINIMIZED:
@ -523,9 +521,8 @@ tbackend_init_surface()
flags |= SDL_WINDOW_OPENGL;
flags |= SDL_WINDOW_SHOWN;
#ifdef DEBUG
flags |= SDL_WINDOW_RESIZABLE;
#endif
#ifdef RECORDING
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
#endif