@@ -3,6 +3,8 @@ import 'dart:io';
33import 'package:code_assets/code_assets.dart' ;
44import 'package:hooks/hooks.dart' ;
55
6+ import 'android_ndk.dart' ;
7+
68const version = '3.5.4' ;
79const sourceCodeUrl = 'https://github.com/openssl/openssl/releases/download/openssl-$version /openssl-$version .tar.gz' ;
810const openSslDirName = 'openssl-$version ' ;
@@ -26,7 +28,21 @@ void main(List<String> args) async {
2628
2729 // build source code, depends on the OS we are running on
2830 // Read https://github.com/openssl/openssl/blob/openssl-3.5.4/INSTALL.md#building-openssl
29- final configName = resolveConfigName (input.config.code.targetOS, input.config.code.targetArchitecture);
31+ final configName = resolveConfigName (
32+ input.config.code.targetOS,
33+ input.config.code.targetArchitecture,
34+ input.config.code.targetOS == OS .iOS ? input.config.code.iOS.targetSdk : null ,
35+ );
36+ if (input.config.code.targetOS == OS .android) {
37+ final ndkRoot = await resolveAndroidNdkRoot ();
38+ environment['ANDROID_NDK_ROOT' ] = ndkRoot;
39+ environment['ANDROID_NDK_HOME' ] = ndkRoot;
40+
41+ final toolchainBin = resolveAndroidToolchainBinDir (ndkRoot);
42+ final existingPath = Platform .environment['PATH' ] ?? '' ;
43+ final pathSeparator = Platform .isWindows ? ';' : ':' ;
44+ environment['PATH' ] = '$toolchainBin $pathSeparator $existingPath ' ;
45+ }
3046 switch (OS .current) {
3147 case OS .windows:
3248 final msvcEnv = await resolveWindowsBuildEnvironment (input.config.code.targetArchitecture);
@@ -93,12 +109,12 @@ void main(List<String> args) async {
93109 // determine the libName from OS and Link mode
94110 final libName = switch ((input.config.code.targetOS, input.config.code.linkModePreference)) {
95111 (OS .windows, LinkModePreference .static || LinkModePreference .preferStatic) => 'libcrypto_static.lib' ,
96- (OS .macOS, LinkModePreference .static || LinkModePreference .preferStatic) => 'libcrypto.a' ,
97- (OS .linux, LinkModePreference .static || LinkModePreference .preferStatic) => 'libcrypto.a' ,
112+ (OS .macOS || OS .iOS , LinkModePreference .static || LinkModePreference .preferStatic) => 'libcrypto.a' ,
113+ (OS .linux || OS .android , LinkModePreference .static || LinkModePreference .preferStatic) => 'libcrypto.a' ,
98114 (OS .windows, LinkModePreference .dynamic || LinkModePreference .preferDynamic) =>
99115 'libcrypto-3-${input .config .code .targetArchitecture .name }.dll' ,
100- (OS .macOS, LinkModePreference .dynamic || LinkModePreference .preferDynamic) => 'libcrypto.dylib' ,
101- (OS .linux, LinkModePreference .dynamic || LinkModePreference .preferDynamic) => 'libcrypto.so' ,
116+ (OS .macOS || OS .iOS , LinkModePreference .dynamic || LinkModePreference .preferDynamic) => 'libcrypto.dylib' ,
117+ (OS .linux || OS .android , LinkModePreference .dynamic || LinkModePreference .preferDynamic) => 'libcrypto.so' ,
102118 _ => throw UnsupportedError (
103119 'Unsupported target OS: ${input .config .code .targetOS .name } or link mode preference: ${input .config .code .linkModePreference .name }' ,
104120 ),
@@ -142,7 +158,8 @@ Future<bool> isProgramInstalled(String programName) async {
142158 }
143159}
144160
145- String resolveConfigName (OS os, Architecture architecture) {
161+ String resolveConfigName (OS os, Architecture architecture, IOSSdk ? iosSdk) {
162+ final isIosSimulator = iosSdk == IOSSdk .iPhoneSimulator;
146163 return switch ((os, architecture)) {
147164 (OS .android, Architecture .arm) => 'android-arm' ,
148165 (OS .android, Architecture .arm64) => 'android-arm64' ,
@@ -151,7 +168,7 @@ String resolveConfigName(OS os, Architecture architecture) {
151168 (OS .android, Architecture .riscv64) => 'android-riscv64' ,
152169
153170 (OS .iOS, Architecture .arm) => 'ios-xcrun' ,
154- (OS .iOS, Architecture .arm64) => 'ios64-xcrun' ,
171+ (OS .iOS, Architecture .arm64) => isIosSimulator ? 'iossimulator-arm64-xcrun' : 'ios64-xcrun' ,
155172 (OS .iOS, Architecture .ia32) => 'iossimulator-i386-xcrun' ,
156173 (OS .iOS, Architecture .x64) => 'iossimulator-x86_64-xcrun' ,
157174
0 commit comments