-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from Geod24/openssl-3
Move the version detection script from `vibe-d:tls` to `deimos/openssl`
- Loading branch information
Showing
82 changed files
with
312 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Generated version file | ||
/source/deimos/openssl/version_.d | ||
|
||
# DUB artifacts | ||
/.dub/ | ||
/openssl | ||
/*-test-library |
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,36 @@ | ||
OpenSSL D interface | ||
------------------- | ||
|
||
From the OpenSSL website: | ||
|
||
> The OpenSSL Project is a collaborative effort to develop a robust, | ||
> commercial-grade, full-featured, and Open Source toolkit | ||
> implementing the Secure Sockets Layer (SSL v2/v3) and Transport | ||
> Layer Security (TLS v1) protocols as well as a full-strength general | ||
> purpose cryptography library. The project is managed by a worldwide | ||
> community of volunteers that use the Internet to communicate, plan, | ||
> and develop the OpenSSL toolkit and its related documentation. | ||
This repository contains D bindings for OpenSSL. | ||
|
||
Status: Varies, depending on targeted OpenSSL version. | ||
|
||
The OpenSSL headers are huge (>35k LOC) and make quite liberal use of the C | ||
preprocessor, and thus a fully automatic translation is as desirable as | ||
it is infeasible. This repository contains the result of a semi-automatic | ||
approach, and while all header files have been ported (and successfully | ||
compile), some preprocessor artifacts still need to be ported (currently | ||
commented out and tagged with a `FIXME` note). | ||
|
||
The latest version of this package aims to provide compatibility with | ||
[current versions of OpenSSL](https://www.openssl.org/news/changelog.html); | ||
to facilitate this, a build script will detect the OpenSSL version on the | ||
host system and configure the bindings appropriately. This will be done | ||
automatically when using these bindings with Dub. | ||
|
||
### License | ||
|
||
The OpenSSL toolkit is under a dual license, i.e. both the conditions | ||
of the OpenSSL License and the original SSLeay license apply to the toolkit. | ||
See the OpenSSL distribution for details. These interface files are a derived | ||
work and do not impose any additional restrictions. |
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,112 @@ | ||
/+ dub.sdl: | ||
name "script" | ||
+/ | ||
|
||
/** | ||
* This program will attempt to detect which version of openssl is installed | ||
* | ||
* End-users might have different versions of OpenSSL installed. | ||
* The version might ever differ among members of a development team. | ||
* | ||
* This script attempts to first calls `pkg-config` to find out the version, | ||
* then reverts to calling the `openssl` binary if `pkg-config` didn't work. | ||
* | ||
* It is called directly as a `preGenerateCommand` (see dub.sdl). | ||
* To use it with another build system, pass the directory in which to write | ||
* the `version_.d` file as first and only argument. The directory | ||
* must exist, this script will not create it. | ||
*/ | ||
module generate_version; | ||
|
||
import std.algorithm; | ||
import std.conv; | ||
import std.file; | ||
import std.functional; | ||
import std.path; | ||
import std.process; | ||
import std.range; | ||
import std.stdio; | ||
import std.string; | ||
import std.uni; | ||
|
||
// file full path is: $SOME_PATH/openssl/scripts/generate_version.d | ||
// We want: $SOME_PATH/openssl/deimos/openssl/ | ||
immutable TARGET_DIR_PATH = __FILE_FULL_PATH__ | ||
.dirName.dirName.buildPath("source", "deimos", "openssl"); | ||
|
||
void main(string[] args) | ||
{ | ||
string target; | ||
|
||
if (args.length == 2) | ||
{ | ||
assert(args[1].isDir(), | ||
"OpenSSL version detection: Argument '" ~ args[1] ~ "' is not a directory"); | ||
target = args[1].buildPath("version_.d"); | ||
} | ||
else | ||
{ | ||
assert(args.length == 1, | ||
"OpenSSL version detection expects only one argument, " ~ | ||
"a directory path where to write `version_.d`"); | ||
target = TARGET_DIR_PATH.buildPath("version_.d"); | ||
} | ||
|
||
string opensslVersion; | ||
try | ||
{ | ||
const res = execute(["pkg-config", "openssl", "--modversion"]); | ||
if (res.status == 0) | ||
opensslVersion = res.output.strip(); | ||
} | ||
catch (Exception e) {} | ||
|
||
if (!opensslVersion.length) try | ||
{ | ||
const res = execute(["openssl", "version"]).output; | ||
if (res.canFind("OpenSSL ")) | ||
{ | ||
opensslVersion = res.splitter(" ").dropOne.front.filter!(not!(std.uni.isAlpha)).text; | ||
} | ||
else if (res.canFind("LibreSSL ")) | ||
{ | ||
writeln("\tWarning: Your default openssl binary points to LibreSSL, which is not supported."); | ||
version (OSX) | ||
{ | ||
writeln("\tOn Mac OSX, this is the default behavior."); | ||
writeln("\tIf you installed openssl via a package manager, you need to tell DUB how to find it."); | ||
writeln("\tAssuming brew, run [brew link openssl] and follow the instructions for pkg-config.\n"); | ||
} | ||
} | ||
} | ||
catch (Exception e) {} | ||
|
||
if (!opensslVersion.length) | ||
{ | ||
writeln("\tWarning: Could not find OpenSSL version via pkg-config nor by calling the openssl binary."); | ||
writeln("\tAssuming version 1.1.0."); | ||
writeln("\tYou might need to export PKG_CONFIG_PATH or install the openssl package if you have a library-only package."); | ||
opensslVersion = "1.1.0h"; | ||
} | ||
auto data = format(q{/** | ||
* Provide the version of the libssl being linked to at compile time | ||
* | ||
* This module was auto-generated by deimos/openssl's script/generate_version.d | ||
* Manual edit might get overwritten by later build. | ||
* | ||
* This module should not be directly dependend upon. | ||
* Instead, use `deimos.openssl.opensslv`, which handles explicit overrides | ||
* provides a uniform interface, and a few utilities. | ||
*/ | ||
module deimos.openssl.version_; | ||
|
||
/// Ditto | ||
package enum OpenSSLTextVersion = "%s"; | ||
}, opensslVersion); | ||
|
||
// Only write the file iff it has changed or didn't exist before. | ||
// This way timestamp-based build system will not rebuild, | ||
// and changes on the installed OpenSSL will be correctly detected. | ||
if (!target.exists || target.readText.strip != data.strip) | ||
data.toFile(target); | ||
} |
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.