Uh oh!
There was an error while loading. Please reload this page.
[build] Reimplement NdkUtils - #6083
Conversation
e554928 to
c145f56CompareUh oh!
There was an error while loading. Please reload this page.
1441c63 to
8386acaComparejonpryor
commented
Jul 14, 2021
Context: #5996 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
a778817 to
a07e025CompareUh oh!
There was an error while loading. Please reload this page.
Context: dotnet#5996 Context: dotnet#5964 Context: dotnet#5964 (comment) The `NdkUtils` class used by Xamarin.Andrid.Build.Tasks to find tooling shipped with the Android NDK, has grown increasingly complicated over the years due to a number of incompatibilities between various versions of the NDK. The code became hard to follow and untidy. This commit attempts to address the issue by replacing the single static `NdkUtils` class with a hierarchy of dynamically instantiated classes rooted in a new base class, `NdkTools`. `NdkUtils` had to be initialized for each thread that needed to access its methods, which led to various issues with concurrency and lack of proper initialization since the initialization had to be done wherever `NdkUtils` was first accessed, meaning that any task using it had to do it. `NdkTools` doesn't require such initialization, instead it provides a factory method called `Create` which takes path to the NDK as its parameter and returns an instance of `NdkTools` child class (or `null` if an error occurs) which the can be safely used by the caller. Callers need not concern themselves with what is the actual type of the returned instance, they access only methods and properties defined in the `NdkTools` base abstract class. The hierarchy of `NdkTools` derivatives is structured and named after the breaking changes in the NDK. For instance, NDK versions before 16 used the GNU compilers, while release 16 and above use the clang compilers - this is reflected in existence of two classes derived from `NdkTools`, `NoClang` for NDKs older than r16 and `WithClang` for the newer ones. The other breaking changes are the addition of unified headers in r19, removal of the `platforms` directory in r22 and removal of GNU Binutils in r23. NDK r23 is recognized in this commit but it is NOT supported. Support for r23 is being worked on in PR dotnet#6073 which will be merged once r23 is out of beta.
Context: #5996
Context: #5964
Context: #5964 (comment)
The
NdkUtilsclass used by Xamarin.Andrid.Build.Tasks to find toolingshipped with the Android NDK, has grown increasingly complicated over
the years due to a number of incompatibilities between various versions
of the NDK. The code became hard to follow and untidy. This commit
attempts to address the issue by replacing the single static
NdkUtilsclass with a hierarchy of dynamically instantiated classes rooted in a
new base class,
NdkTools.NdkUtilshad to be initialized for each thread that needed to accessits methods, which led to various issues with concurrency and lack of
proper initialization since the initialization had to be done wherever
NdkUtilswas first accessed, meaning that any task using it had to doit.
NdkToolsdoesn't require such initialization, instead it provides afactory method called
Createwhich takes path to the NDK as itsparameter and returns an instance of
NdkToolschild class (ornullif an error occurs) which the can be safely used by the caller. Callers
need not concern themselves with what is the actual type of the returned
instance, they access only methods and properties defined in the
NdkToolsbase abstract class.The hierarchy of
NdkToolsderivatives is structured and named afterthe breaking changes in the NDK. For instance, NDK versions before 16
used the GNU compilers, while release 16 and above use the clang
compilers - this is reflected in existence of two classes derived from
NdkTools,NoClangfor NDKs older than r16 andWithClangfor thenewer ones. The other breaking changes are the addition of unified
headers in r19, removal of the
platformsdirectory in r22 and removalof GNU Binutils in r23.
NDK r23 is recognized in this commit but it is NOT supported. Support
for r23 is being worked on in PR #6073 which will be merged once r23 is
out of beta.