-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try standard system path when pkg-config fails (#444)
Currently Rust-Themis requires pkg-config to successfully find Themis. If it doesn't (for whatever reason) then the crate won't compile. However, the library might be correctly installed in the system under standard paths. This allows us to easily link against it dynamically. Let's support this use case to allow non-packaged installations. If pkg-config successfully locates core Themis library then we just go with it. Otherwise we effectively try to run cc -shared src/dummy.c -lthemis and see if that compiles. If it does then apparently Themis is installed and we can use it by emitting appropriate instructions to Cargo. Note that we support only dynamic linkage in this case. Static linkage will not work because we will have to figure out transitive dependencies like Soter and OpenSSL, which is the reason for preferring pkg-config. * Wrap pkg_config::Library type We're going to rely not only on pkg-config for locating Themis, but we cannot construct pkg_config::Library instances (it has private fields). Use a custom type with the same API instead. * Don't panic immediately on pkg-config failure We're going to provide an alternative code path for when pkg-config fails, so instead of panicking with an error message just output it to stderr and panic later. This enables us to insert some actions in between and prevent the panic. * Add changelog entry
- Loading branch information
Showing
3 changed files
with
87 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2019 (c) rust-themis developers | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//! Dummy file used to verify that the compiler sees native Themis library. | ||
|
||
#include <themis/themis.h> | ||
|
||
void libthemis_sys_unused(void) | ||
{ | ||
themis_gen_ec_key_pair(NULL, NULL, NULL, NULL); | ||
} |