-
Notifications
You must be signed in to change notification settings - Fork 40
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
Version handling: Handle multiple digits #102
Merged
CyberShadow
merged 2 commits into
D-Programming-Deimos:master
from
Geod24:mlang_fix_3.0.10
Aug 10, 2023
Merged
Version handling: Handle multiple digits #102
CyberShadow
merged 2 commits into
D-Programming-Deimos:master
from
Geod24:mlang_fix_3.0.10
Aug 10, 2023
Conversation
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
I have not been able to reproduce any linking issues without directly accessing private symbols either way (i.e. no problems with accessing diff --git a/source/deimos/openssl/opensslv.di b/source/deimos/openssl/opensslv.di
index bd21d55..d7f7680 100644
--- a/source/deimos/openssl/opensslv.di
+++ b/source/deimos/openssl/opensslv.di
@@ -19,89 +19,100 @@ version (DeimosOpenSSL_1_0_0)
{
// https://www.openssl.org/news/changelog.html#openssl-100
// OpenSSL 1.0.0t was released 2015-12-03
- public alias OpenSSLVersion = OpenSSLVersionTemplate!"1.0.0t";
+ public enum OpenSSLVersion = openSSLVersionFromText("1.0.0t");
}
else version (DeimosOpenSSL_1_0_1)
{
// https://www.openssl.org/news/changelog.html#openssl-101
// OpenSSL 1.0.1u was released 2016-09-22
- public alias OpenSSLVersion = OpenSSLVersionTemplate!"1.0.1u";
+ public enum OpenSSLVersion = openSSLVersionFromText("1.0.1u");
}
else version (DeimosOpenSSL_1_0_2)
{
// https://www.openssl.org/news/changelog.html#openssl-102
// OpenSSL 1.0.2t was released 2019-09-10
- public alias OpenSSLVersion = OpenSSLVersionTemplate!"1.0.2t";
+ public enum OpenSSLVersion = openSSLVersionFromText("1.0.2t");
}
else version (DeimosOpenSSL_1_1_0)
{
// https://www.openssl.org/news/changelog.html#openssl-110
// OpenSSL 1.1.0l was released 2019-09-10
- public alias OpenSSLVersion = OpenSSLVersionTemplate!"1.1.0l";
+ public enum OpenSSLVersion = openSSLVersionFromText("1.1.0l");
}
else version (DeimosOpenSSL_1_1_1)
{
// https://www.openssl.org/news/changelog.html#openssl-111
// OpenSSL 1.1.1m was released 2021-12-14
- public alias OpenSSLVersion = OpenSSLVersionTemplate!"1.1.1m";
+ public enum OpenSSLVersion = openSSLVersionFromText("1.1.1m");
}
else version (DeimosOpenSSL_3_0)
{
// https://www.openssl.org/news/changelog.html#openssl-30
// OpenSSL 3.0.3 was released 2022-05-03
- public alias OpenSSLVersion = OpenSSLVersionTemplate!"3.0.3";
+ public enum OpenSSLVersion = openSSLVersionFromText("3.0.3");
}
else version (DeimosOpenSSLAutoDetect)
{
import deimos.openssl.version_;
- public alias OpenSSLVersion = OpenSSLVersionTemplate!OpenSSLTextVersion;
+ public enum OpenSSLVersion = openSSLVersionFromText(OpenSSLTextVersion);
}
else
{
// It was decided in https://github.com/D-Programming-Deimos/openssl/pull/66
// that we should fall back to the latest supported version of the bindings,
// should the user provide neither explicit version nor `DeimosOpenSSLAutoDetect`
- public alias OpenSSLVersion = OpenSSLVersionTemplate!"1.1.0h";
+ public enum OpenSSLVersion = openSSLVersionFromText("1.1.0h");
}
// Publicly aliased above
-private struct OpenSSLVersionTemplate (string textVersion)
+private struct OpenSSLVersionStruct
{
+ string text;
+ uint major, minor, patch;
+ int build;
+}
+
+/*private*/ OpenSSLVersionStruct openSSLVersionFromText(string textVersion)
+{
+ OpenSSLVersionStruct v;
+
import std.ascii : isDigit;
import std.algorithm.iteration : splitter;
import std.algorithm.searching : canFind;
import std.conv : to;
import std.range : dropExactly;
- enum text = textVersion;
+ v.text = textVersion;
- enum uint major = textVersion.splitter('.')
+ v.major = textVersion.splitter('.')
.front.to!uint;
- static assert (major >= 0);
+ assert (v.major >= 0);
- enum uint minor = textVersion.splitter('.')
+ v.minor = textVersion.splitter('.')
.dropExactly(1)
.front.to!uint;
- static assert (minor >= 0);
+ assert (v.minor >= 0);
// `std.algorithm.iteration : splitWhen` not usable at CT
// so we're using `canFind`.
- private enum string patchText = textVersion.splitter('.')
+ string patchText = textVersion.splitter('.')
.dropExactly(2).front;
- private enum patchChar = patchText.canFind!(
+ auto patchChar = patchText.canFind!(
(dchar c) => !c.isDigit());
- enum uint patch = patchText[0 .. $ - patchChar].to!uint;
- static assert (patch >= 0);
+ v.patch = patchText[0 .. $ - patchChar].to!uint;
+ assert (v.patch >= 0);
- static if (patchChar)
+ if (patchChar)
{
- enum int build = (patchText[$ - 1] - '`');
- static assert (build >= 0);
+ v.build = (patchText[$ - 1] - '`');
+ assert (v.build >= 0);
}
else
- enum int build = 0;
+ v.build = 0;
+
+ return v;
}
/* Numeric release version identifier: The new |
Please rebase to fix CI? |
Use an approach which is hopefully more robust in terms of not pulling in link-time dependencies.
CyberShadow
force-pushed
the
mlang_fix_3.0.10
branch
from
August 10, 2023 08:02
336db7b
to
4ee0e55
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@CyberShadow : Not sure how to handle this as I expect it's not compatible with our
.di
approach.