Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ vapidir = meson.current_source_dir() / 'vapi/'

add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), language: 'c')

add_project_arguments(['--vapidir', vapidir], language: 'vala')
vala_flags = ['--vapidir', vapidir]

if get_option('nvidia').enabled()
vala_flags += ['--define', 'NVIDIA_SUPPORT']
endif

add_project_arguments(vala_flags, language: 'vala')

# subprojects should be skipped: https://mesonbuild.com/Release-notes-for-0-58-0.html#skip-subprojects-installation
# needs meson 0.58.0
Expand Down Expand Up @@ -48,8 +54,10 @@ app_dependencies = [
meson.get_compiler('c').find_library('pci'),
meson.get_compiler('vala').find_library('pci', dirs: vapidir),

meson.get_compiler('c').find_library('XNVCtrl'),
meson.get_compiler('vala').find_library('libxnvctrl', dirs: vapidir),
# Allow building without nvidia libraries because they're not packaged or does not run
# on some distros due to incompatibility with muslc. Also they're not needed on ARM architecture
meson.get_compiler('c').find_library('XNVCtrl', required: get_option('nvidia').enabled()),
meson.get_compiler('vala').find_library('libxnvctrl', dirs: vapidir, required: get_option('nvidia').enabled()),
]

config_data = configuration_data()
Expand Down
3 changes: 2 additions & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
option('indicator-wingpanel', type : 'feature', value : 'disabled', description : 'Enables the Indicator for Wingpanel.')
option('indicator-wingpanel', type : 'feature', value : 'disabled', description : 'Enables the Indicator for Wingpanel.')
option('nvidia', type : 'feature', value : 'enabled', description : 'Build with NVIDIA support.')
2 changes: 2 additions & 0 deletions src/Resources/GPU/GPUNvidia.vala
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class Monitor.GPUNvidia : IGPU, Object {
}

private void update_nv_resources () {
#if NVIDIA_SUPPORT
nvidia_resources_temperature = NVCtrl.XNVCTRLQueryAttribute (
nvidia_display,
0,
Expand Down Expand Up @@ -119,6 +120,7 @@ public class Monitor.GPUNvidia : IGPU, Object {
nvidia_fb_percentage = int.parse (((string) nvidia_used).split_set ("=,")[3]);
debug ("USED_GRAPHICS: %d%\n", nvidia_percentage);
debug ("USED_FB_MEMORY: %d%\n", nvidia_fb_percentage);
#endif

if (!nvidia_resources_used) {
warning ("Could not query NV_CTRL_STRING_GPU_UTILIZATION attribute!\n");
Expand Down