Skip to content

Commit

Permalink
Detection: install colord/cocoa dep lib via meson and do not search b…
Browse files Browse the repository at this point in the history
…y relative path anymore
  • Loading branch information
YomikoR committed May 5, 2024
1 parent 7250b10 commit 20f1583
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 27 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,13 @@ Please refer to the Meson build script or the MSVC project.

## OS Dependent Notes

### Path limitations
### Additional libraries

For compatibility reasons, some functions are isolated into independent shared libraries:
- `libiccc_colord.so` when built with Linux X11 and colord;
- `libiccc_cocoa.dylib` when built in macOS with Cocoa.

These shared libraries are loaded by relative path to the main plugin, so their names should not be changed.
Otherwise auto ICC profile detection silently fails.
These shared libraries are loaded by the plugin to make auto ICC profile detection function.

### Display profile detection

Expand Down
6 changes: 4 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ if host_machine.system() == 'linux'
shared_module('iccc_colord', 'src/detection/colord.c',
dependencies: dep_colord,
c_args: auto_profile_args,
name_prefix: 'lib'
name_prefix: 'lib',
install: true
)
endif
sources += ['src/detection/x11.c']
Expand All @@ -62,7 +63,8 @@ elif host_machine.system() == 'darwin'
shared_module('iccc_cocoa', 'src/detection/cocoa.m',
dependencies: dependency('lcms2'),
objc_args: auto_profile_args,
name_prefix: 'lib'
name_prefix: 'lib',
install: true
)
sources += ['src/detection/macos.c']
endif
Expand Down
12 changes: 2 additions & 10 deletions src/detection/macos.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,10 @@

cmsHPROFILE getSystemProfile()
{
// Get the relative path to libiccc_cocoa.dylib
Dl_info dl_info;
dladdr((void *)getSystemProfile, &dl_info);
char this_dll_path[4000];
strcpy(this_dll_path, dl_info.dli_fname);
char *this_dll_dir = dirname(this_dll_path);
char cocoa_dll_path[4000];
sprintf(cocoa_dll_path, "%s/libiccc_cocoa.dylib", this_dll_dir);

void *dll_handle = dlopen(cocoa_dll_path, RTLD_LAZY);
void *dll_handle = dlopen("libiccc_cocoa.dylib", RTLD_LAZY);
if (!dll_handle)
{
fprintf(stderr, "loading iccc_cocoa failed: %s\n", dlerror());
return NULL;
}

Expand Down
14 changes: 2 additions & 12 deletions src/detection/x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,13 @@ cmsHPROFILE getSystemProfile()

# if defined (AUTO_PROFILE_COLORD)

// Get the relative path to libiccc_colord.so

Dl_info dl_info;
dladdr((void *)getSystemProfile, &dl_info);
char this_dll_path[4000];
strcpy(this_dll_path, dl_info.dli_fname);
char *this_dll_dir = dirname(this_dll_path);
char colord_dll_path[4000];
sprintf(colord_dll_path, "%s/libiccc_colord.so", this_dll_dir);

char *icc_file = NULL;

// Load shared library
void *dll_handle = dlopen("libiccc_colord.so", RTLD_LAZY);

void *dll_handle = dlopen(colord_dll_path, RTLD_LAZY);
if (!dll_handle)
{
fprintf(stderr, "loading iccc_colord failed: %s\n", dlerror());
XCloseDisplay(dpy);
return NULL;
}
Expand Down

0 comments on commit 20f1583

Please sign in to comment.