aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA person <agooglygooglr@gmail.com>2024-06-10 22:38:19 -0400
committerdec05eba <dec05eba@protonmail.com>2024-06-11 17:01:51 +0200
commitdfa7dc6659755b7a8385aad5003fd80483dd4ffe (patch)
tree4644056c6eef43103dcaeab53d1a3d9cfe3a15cc
parente43934e2d2219bdd9a99c78463aa47cfc0404dcd (diff)
Migrate to Meson build system
-rwxr-xr-xbuild.sh53
-rwxr-xr-xdebug-install.sh14
-rwxr-xr-xextra/meson_post_install.sh5
-rwxr-xr-xinstall.sh16
-rw-r--r--meson.build58
-rw-r--r--meson_options.txt1
-rwxr-xr-xuninstall.sh11
7 files changed, 76 insertions, 82 deletions
diff --git a/build.sh b/build.sh
deleted file mode 100755
index b353406..0000000
--- a/build.sh
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/sh -e
-
-script_dir=$(dirname "$0")
-cd "$script_dir"
-
-CC=${CC:-gcc}
-CXX=${CXX:-g++}
-
-opts="-O2 -g0 -DNDEBUG -Wall -Wextra -Wshadow"
-[ -n "$DEBUG" ] && opts="-O0 -g3 -Wall -Wextra -Wshadow";
-
-build_gsr_kms_server() {
- # TODO: -fcf-protection=full, not supported on arm
- extra_opts="-fstack-protector-all"
- dependencies="libdrm"
- includes="$(pkg-config --cflags $dependencies)"
- libs="$(pkg-config --libs $dependencies) -ldl"
- $CC -c kms/server/kms_server.c $opts $extra_opts $includes
- $CC -o gsr-kms-server kms_server.o $libs $opts $extra_opts
-}
-
-build_gsr() {
- dependencies="libavcodec libavformat libavutil x11 xcomposite xrandr xfixes libpulse libswresample libavfilter libva libcap libdrm wayland-egl wayland-client"
- includes="$(pkg-config --cflags $dependencies)"
- libs="$(pkg-config --libs $dependencies) -ldl -pthread -lm"
- $CC -c src/capture/capture.c $opts $includes
- $CC -c src/capture/nvfbc.c $opts $includes
- $CC -c src/capture/xcomposite.c $opts $includes
- $CC -c src/capture/xcomposite_cuda.c $opts $includes
- $CC -c src/capture/xcomposite_vaapi.c $opts $includes
- $CC -c src/capture/kms_vaapi.c $opts $includes
- $CC -c src/capture/kms_cuda.c $opts $includes
- $CC -c src/capture/kms.c $opts $includes
- $CC -c kms/client/kms_client.c $opts $includes
- $CC -c src/egl.c $opts $includes
- $CC -c src/cuda.c $opts $includes
- $CC -c src/xnvctrl.c $opts $includes
- $CC -c src/overclock.c $opts $includes
- $CC -c src/window_texture.c $opts $includes
- $CC -c src/shader.c $opts $includes
- $CC -c src/color_conversion.c $opts $includes
- $CC -c src/utils.c $opts $includes
- $CC -c src/library_loader.c $opts $includes
- $CC -c src/cursor.c $opts $includes
- $CXX -c src/sound.cpp $opts $includes
- $CXX -c src/main.cpp $opts $includes
- $CXX -o gpu-screen-recorder capture.o nvfbc.o kms_client.o egl.o cuda.o xnvctrl.o overclock.o window_texture.o shader.o \
- color_conversion.o utils.o library_loader.o cursor.o xcomposite.o xcomposite_cuda.o xcomposite_vaapi.o kms_vaapi.o kms_cuda.o kms.o sound.o main.o $libs $opts
-}
-
-build_gsr_kms_server
-build_gsr
-echo "Successfully built gpu-screen-recorder"
diff --git a/debug-install.sh b/debug-install.sh
index 096eefa..02e96ac 100755
--- a/debug-install.sh
+++ b/debug-install.sh
@@ -5,16 +5,8 @@ cd "$script_dir"
[ $(id -u) -ne 0 ] && echo "You need root privileges to run the install script" && exit 1
-DEBUG=1 ./build.sh
-
-install -Dm755 "gsr-kms-server" "/usr/bin/gsr-kms-server"
-install -Dm755 "gpu-screen-recorder" "/usr/bin/gpu-screen-recorder"
-if [ -d "/usr/lib/systemd/user" ]; then
- install -Dm644 "extra/gpu-screen-recorder.service" "/usr/lib/systemd/user/gpu-screen-recorder.service"
-fi
-# Not necessary, but removes the password prompt when trying to record a monitor on amd/intel or nvidia wayland
-setcap cap_sys_admin+ep /usr/bin/gsr-kms-server
-# Not necessary, but allows use of EGL_CONTEXT_PRIORITY_LEVEL_IMG which allows gpu screen recorder to run without being limited to game fps under heavy load on AMD/Intel
-setcap cap_sys_nice+ep /usr/bin/gpu-screen-recorder
+test -d build || meson setup build
+meson configure --buildtype=debug build
+ninja -C build install
echo "Successfully installed gpu-screen-recorder (debug)"
diff --git a/extra/meson_post_install.sh b/extra/meson_post_install.sh
new file mode 100755
index 0000000..f1f6a5a
--- /dev/null
+++ b/extra/meson_post_install.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+setcap cap_sys_admin+ep ${MESON_INSTALL_DESTDIR_PREFIX}/bin/gsr-kms-server \
+ || echo "\n!!! Please re-run install as root\n"
+setcap cap_sys_nice+ep ${MESON_INSTALL_DESTDIR_PREFIX}/bin/gpu-screen-recorder
diff --git a/install.sh b/install.sh
index 0833307..adbc663 100755
--- a/install.sh
+++ b/install.sh
@@ -5,18 +5,8 @@ cd "$script_dir"
[ $(id -u) -ne 0 ] && echo "You need root privileges to run the install script" && exit 1
-./build.sh
-strip gsr-kms-server
-strip gpu-screen-recorder
-
-install -Dm755 "gsr-kms-server" "/usr/bin/gsr-kms-server"
-install -Dm755 "gpu-screen-recorder" "/usr/bin/gpu-screen-recorder"
-if [ -d "/usr/lib/systemd/user" ]; then
- install -Dm644 "extra/gpu-screen-recorder.service" "/usr/lib/systemd/user/gpu-screen-recorder.service"
-fi
-# Not necessary, but removes the password prompt when trying to record a monitor on amd/intel or nvidia wayland
-setcap cap_sys_admin+ep /usr/bin/gsr-kms-server
-# Not necessary, but allows use of EGL_CONTEXT_PRIORITY_LEVEL_IMG which allows gpu screen recorder to run without being limited to game fps under heavy load on AMD/Intel
-setcap cap_sys_nice+ep /usr/bin/gpu-screen-recorder
+test -d build || meson setup build
+meson configure --buildtype=release build
+ninja -C build install
echo "Successfully installed gpu-screen-recorder"
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..99bac8e
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,58 @@
+project('gpu-screen-recorder', ['c', 'cpp'])
+
+add_project_arguments('-Wall', '-Wextra', '-Wshadow', language : ['c', 'cpp'])
+if get_option('buildtype') == 'debug'
+ add_project_arguments('-g3', language : ['c', 'cpp'])
+elif get_option('buildtype') == 'release'
+ add_project_arguments('-DNDEBUG', language : ['c', 'cpp'])
+endif
+
+src = [
+ 'src/capture/capture.c',
+ 'src/capture/nvfbc.c',
+ 'src/capture/xcomposite.c',
+ 'src/capture/xcomposite_cuda.c',
+ 'src/capture/xcomposite_vaapi.c',
+ 'src/capture/kms_vaapi.c',
+ 'src/capture/kms_cuda.c',
+ 'src/capture/kms.c',
+ 'kms/client/kms_client.c',
+ 'src/egl.c',
+ 'src/cuda.c',
+ 'src/xnvctrl.c',
+ 'src/overclock.c',
+ 'src/window_texture.c',
+ 'src/shader.c',
+ 'src/color_conversion.c',
+ 'src/utils.c',
+ 'src/library_loader.c',
+ 'src/cursor.c',
+ 'src/sound.cpp',
+ 'src/main.cpp',
+]
+dep = [
+ dependency('libavcodec'),
+ dependency('libavformat'),
+ dependency('libavutil'),
+ dependency('x11'),
+ dependency('xcomposite'),
+ dependency('xrandr'),
+ dependency('xfixes'),
+ dependency('libpulse'),
+ dependency('libswresample'),
+ dependency('libavfilter'),
+ dependency('libva'),
+ dependency('libcap'),
+ dependency('libdrm'),
+ dependency('wayland-egl'),
+ dependency('wayland-client'),
+]
+
+executable('gsr-kms-server', 'kms/server/kms_server.c', dependencies : dependency('libdrm'), c_args : '-fstack-protector-all', install : true)
+executable('gpu-screen-recorder', src, dependencies : dep, install : true)
+
+if get_option('systemd') == true
+ install_data(files('extra/gpu-screen-recorder.service'), install_dir : '/usr/lib/systemd/user')
+endif
+
+meson.add_install_script('extra/meson_post_install.sh')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..05aac3c
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('systemd', type : 'boolean', value : false, description : 'Install systemd service file')
diff --git a/uninstall.sh b/uninstall.sh
index 9457d1f..b8aac26 100755
--- a/uninstall.sh
+++ b/uninstall.sh
@@ -1,9 +1,10 @@
-#!/bin/sh
+#!/bin/sh -e
+
+script_dir=$(dirname "$0")
+cd "$script_dir"
[ $(id -u) -ne 0 ] && echo "You need root privileges to run the uninstall script" && exit 1
-rm -f "/usr/bin/gsr-kms-server"
-rm -f "/usr/bin/gpu-screen-recorder"
-rm -f "/usr/lib/systemd/user/gpu-screen-recorder.service"
+ninja -C build uninstall
-echo "Successfully uninstalled gpu-screen-recorder" \ No newline at end of file
+echo "Successfully uninstalled gpu-screen-recorder"