Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixCMake doesn't correctly fix $libDir to $developLibDir #301

Open
mtl1979 opened this issue Oct 17, 2024 · 9 comments
Open

fixCMake doesn't correctly fix $libDir to $developLibDir #301

mtl1979 opened this issue Oct 17, 2024 · 9 comments

Comments

@mtl1979
Copy link

mtl1979 commented Oct 17, 2024

CMake's configuration files use relative paths and thus trying to use full path of $libDir doesn't work...

One solution is to search for }/lib instead as that will catch relative paths where the base directory or "prefix" is a variable.

@Begasus
Copy link
Contributor

Begasus commented Oct 17, 2024

This has always been an issue for packaging rizin (maybe still something could be fixed upstream), but so far this fixed (still checking) it for me, thanks on that pointer @mtl1979 :)

sed -i 's,\${PACKAGE_PREFIX_DIR}/lib,${PACKAGE_PREFIX_DIR}/develop/'${relativeLibDir}'',g \
    $libDir/cmake/rz_*/rz_*Config.cmake

@mtl1979
Copy link
Author

mtl1979 commented Oct 17, 2024

I counted 7 recipes having either uncommented or commented call to fixCMake... Some of them used sed in addition to fix what fixCMake skipped... I didn't count recipes that use sed only to fix any files generated by CMake...

@mtl1979
Copy link
Author

mtl1979 commented Oct 17, 2024

This has always been an issue for packaging rizin (maybe still something could be fixed upstream), but so far this fixed (still checking) it for me, thanks on that pointer @mtl1979 :)

sed -i 's,\${PACKAGE_PREFIX_DIR}/lib,${PACKAGE_PREFIX_DIR}/develop/'${relativeLibDir}'',g \
    $libDir/cmake/rz_*/rz_*Config.cmake

As pointed out on IRC, I think that the single quotes are in wrong places... I'm not sure why ${relativeLibDir} would need to be quoted if the whole string is already quoted... Also, the last single quote is too early...

@Begasus
Copy link
Contributor

Begasus commented Oct 17, 2024

As pointed out on IRC, I think that the single quotes are in wrong places... I'm not sure why ${relativeLibDir} would need to be quoted if the whole string is already quoted... Also, the last single quote is too early...

Thought the relativeLibDir would be needed for 32bit, but that has already been taken care for, this works on 64bit and 32bit:

sed -i 's,\${PACKAGE_PREFIX_DIR}/lib,${PACKAGE_PREFIX_DIR}/develop/lib,g'
    $libDir/cmake/rz_*/rz_*Config.cmake

@Begasus
Copy link
Contributor

Begasus commented Oct 17, 2024

Rizin is a bit different in this case, it uses meson/ninja as build system and some python scripts to fill in the paths in the cmake config files, I guess in most cases with cmake builds this will probably fine without any sed magic.

@jmairboeck
Copy link
Member

What it really should do is replace $relativeLibDir with $relativeDevelopLibDir, but the problem is that $relativeLibDir is just lib on primary architectures, which is a bit short to match for.

Unfortunately, CMake files aren't as standardized as pkg-config files, so fixCmake will always have a harder time to replace things correctly than fixPkgconfig.

Maybe using sed in addition to or instead of fixCmake will still be the best solution for some recipes.

@jmairboeck
Copy link
Member

As pointed out on IRC, I think that the single quotes are in wrong places... I'm not sure why ${relativeLibDir} would need to be quoted if the whole string is already quoted... Also, the last single quote is too early...

That is actually "de-quoting" ${relativeLibDir} (not quoting it again), i.e. it ends the quoted string, then comes the variable, then another quoted string starts (which is actually unneeded, because as it is written here, it is just empty, and the ,g doesn't need to be quoted because it contains no special characters). In single-quotes, shell variables aren't expanded, unlike with double quotes.

@mtl1979
Copy link
Author

mtl1979 commented Oct 17, 2024

That is actually "de-quoting" ${relativeLibDir} (not quoting it again), i.e. it ends the quoted string, then comes the variable, then another quoted string starts (which is actually unneeded, because as it is written here, it is just empty, and the ,g doesn't need to be quoted because it contains no special characters). In single-quotes, shell variables aren't expanded, unlike with double quotes.

I know what's the difference between single and double quotes... In this case double quotes might have been better choice as first $ is already escaped, so variable expansion doesn't happen.

@mtl1979
Copy link
Author

mtl1979 commented Oct 17, 2024

Maybe using sed in addition to or instead of fixCmake will still be the best solution for some recipes.

Some recipes are using sed in addition to fixCMake as fixCMake still works with fixing header paths... I didn't count how many recipes use sed without fixCMake as it would have taken more than just one use of "inrecipe" function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants