fbrosson | 533407a | 2018-04-04 21:44:29 +0000 | [diff] [blame] | 1 | #!/usr/bin/env perl |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 2 | |
Dave Rodgman | 0f459d7 | 2023-01-10 15:09:19 +0000 | [diff] [blame] | 3 | # Generate main file, individual apps and solution files for |
Bence Szépkúti | 0719d7c | 2024-03-12 16:45:55 +0100 | [diff] [blame] | 4 | # MS Visual Studio 2017 |
Manuel Pégourié-Gonnard | 2d34fe3 | 2014-05-07 17:51:20 +0200 | [diff] [blame] | 5 | # |
Dave Rodgman | 0f459d7 | 2023-01-10 15:09:19 +0000 | [diff] [blame] | 6 | # Must be run from Mbed TLS root or scripts directory. |
Manuel Pégourié-Gonnard | 2d34fe3 | 2014-05-07 17:51:20 +0200 | [diff] [blame] | 7 | # Takes no argument. |
Bence Szépkúti | 700ee44 | 2020-05-26 00:33:31 +0200 | [diff] [blame] | 8 | # |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 9 | # Copyright The Mbed TLS Contributors |
Dave Rodgman | 16799db | 2023-11-02 19:47:20 +0000 | [diff] [blame] | 10 | # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Manuel Pégourié-Gonnard | 684e9dc | 2013-09-20 15:11:44 +0200 | [diff] [blame] | 11 | |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 12 | use warnings; |
| 13 | use strict; |
Manuel Pégourié-Gonnard | 41e8b62 | 2014-05-09 12:27:49 +0200 | [diff] [blame] | 14 | use Digest::MD5 'md5_hex'; |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 15 | |
Bence Szépkúti | fac1122 | 2024-03-12 16:38:23 +0100 | [diff] [blame] | 16 | my $vsx_dir = "visualc/VS2017"; |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 17 | my $vsx_ext = "vcxproj"; |
Bence Szépkúti | fac1122 | 2024-03-12 16:38:23 +0100 | [diff] [blame] | 18 | my $vsx_app_tpl_file = "scripts/data_files/vs2017-app-template.$vsx_ext"; |
| 19 | my $vsx_main_tpl_file = "scripts/data_files/vs2017-main-template.$vsx_ext"; |
Manuel Pégourié-Gonnard | 813e585 | 2015-01-26 15:42:27 +0000 | [diff] [blame] | 20 | my $vsx_main_file = "$vsx_dir/mbedTLS.$vsx_ext"; |
Bence Szépkúti | fac1122 | 2024-03-12 16:38:23 +0100 | [diff] [blame] | 21 | my $vsx_sln_tpl_file = "scripts/data_files/vs2017-sln-template.sln"; |
Manuel Pégourié-Gonnard | 813e585 | 2015-01-26 15:42:27 +0000 | [diff] [blame] | 22 | my $vsx_sln_file = "$vsx_dir/mbedTLS.sln"; |
Manuel Pégourié-Gonnard | 2d34fe3 | 2014-05-07 17:51:20 +0200 | [diff] [blame] | 23 | |
| 24 | my $programs_dir = 'programs'; |
Harry Ramsey | 03f4957 | 2025-02-17 12:04:23 +0000 | [diff] [blame] | 25 | my $framework_programs_dir = 'framework/tests/programs'; |
Darryl Green | 588e8cb | 2018-07-20 13:27:58 +0100 | [diff] [blame] | 26 | my $mbedtls_header_dir = 'include/mbedtls'; |
| 27 | my $psa_header_dir = 'include/psa'; |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 28 | my $source_dir = 'library'; |
David Horstmann | 2ab59f0 | 2024-11-06 16:24:49 +0000 | [diff] [blame] | 29 | my $tls_test_source_dir = 'tests/src'; |
| 30 | my $tls_test_header_dir = 'tests/include/test'; |
David Horstmann | dcf42a0 | 2024-11-08 14:40:12 +0000 | [diff] [blame] | 31 | my $test_source_dir = 'framework/tests/src'; |
| 32 | my $test_header_dir = 'framework/tests/include/test'; |
| 33 | my $test_drivers_header_dir = 'framework/tests/include/test/drivers'; |
| 34 | my $test_drivers_source_dir = 'framework/tests/src/drivers'; |
Gilles Peskine | 13fac98 | 2020-02-12 20:34:22 +0100 | [diff] [blame] | 35 | |
| 36 | my @thirdparty_header_dirs = qw( |
| 37 | 3rdparty/everest/include/everest |
| 38 | ); |
| 39 | my @thirdparty_source_dirs = qw( |
| 40 | 3rdparty/everest/library |
| 41 | 3rdparty/everest/library/kremlib |
| 42 | 3rdparty/everest/library/legacy |
| 43 | ); |
Gilles Peskine | b41f88f | 2020-02-12 20:45:18 +0100 | [diff] [blame] | 44 | |
Gilles Peskine | 7156d8c | 2020-02-19 20:08:44 +0100 | [diff] [blame] | 45 | # Directories to add to the include path. |
| 46 | # Order matters in case there are files with the same name in more than |
| 47 | # one directory: the compiler will use the first match. |
| 48 | my @include_directories = qw( |
| 49 | include |
| 50 | 3rdparty/everest/include/ |
| 51 | 3rdparty/everest/include/everest |
Dave Rodgman | 378ecdd | 2023-01-10 15:08:30 +0000 | [diff] [blame] | 52 | 3rdparty/everest/include/everest/vs2013 |
Gilles Peskine | 7156d8c | 2020-02-19 20:08:44 +0100 | [diff] [blame] | 53 | 3rdparty/everest/include/everest/kremlib |
David Horstmann | 0f33bfa | 2024-11-08 12:23:28 +0000 | [diff] [blame] | 54 | tests/include |
David Horstmann | dcf42a0 | 2024-11-08 14:40:12 +0000 | [diff] [blame] | 55 | framework/tests/include |
Harry Ramsey | 03f4957 | 2025-02-17 12:04:23 +0000 | [diff] [blame] | 56 | framework/tests/programs |
Gilles Peskine | 7156d8c | 2020-02-19 20:08:44 +0100 | [diff] [blame] | 57 | ); |
| 58 | my $include_directories = join(';', map {"../../$_"} @include_directories); |
| 59 | |
Gilles Peskine | 66c3dc4 | 2020-06-03 02:25:17 +0200 | [diff] [blame] | 60 | # Directories to add to the include path when building the library, but not |
| 61 | # when building tests or applications. |
| 62 | my @library_include_directories = qw( |
| 63 | library |
| 64 | ); |
| 65 | my $library_include_directories = |
| 66 | join(';', map {"../../$_"} (@library_include_directories, |
| 67 | @include_directories)); |
| 68 | |
Gilles Peskine | b41f88f | 2020-02-12 20:45:18 +0100 | [diff] [blame] | 69 | my @excluded_files = qw( |
Gilles Peskine | 13fac98 | 2020-02-12 20:34:22 +0100 | [diff] [blame] | 70 | 3rdparty/everest/library/Hacl_Curve25519.c |
| 71 | ); |
Gilles Peskine | b41f88f | 2020-02-12 20:45:18 +0100 | [diff] [blame] | 72 | my %excluded_files = (); |
| 73 | foreach (@excluded_files) { $excluded_files{$_} = 1 } |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 74 | |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 75 | my $vsx_hdr_tpl = <<EOT; |
Gilles Peskine | 6e245c6 | 2021-04-22 20:09:25 +0200 | [diff] [blame] | 76 | <ClInclude Include="..\\..\\{NAME}" /> |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 77 | EOT |
| 78 | my $vsx_src_tpl = <<EOT; |
Gilles Peskine | 6e245c6 | 2021-04-22 20:09:25 +0200 | [diff] [blame] | 79 | <ClCompile Include="..\\..\\{NAME}" /> |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 80 | EOT |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 81 | |
Manuel Pégourié-Gonnard | 0598faf | 2014-05-09 12:56:03 +0200 | [diff] [blame] | 82 | my $vsx_sln_app_entry_tpl = <<EOT; |
Gilles Peskine | 6e245c6 | 2021-04-22 20:09:25 +0200 | [diff] [blame] | 83 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "{APPNAME}", "{APPNAME}.vcxproj", "{GUID}" |
| 84 | ProjectSection(ProjectDependencies) = postProject |
| 85 | {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} |
| 86 | EndProjectSection |
| 87 | EndProject |
Manuel Pégourié-Gonnard | 0598faf | 2014-05-09 12:56:03 +0200 | [diff] [blame] | 88 | EOT |
| 89 | |
| 90 | my $vsx_sln_conf_entry_tpl = <<EOT; |
Gilles Peskine | 6e245c6 | 2021-04-22 20:09:25 +0200 | [diff] [blame] | 91 | {GUID}.Debug|Win32.ActiveCfg = Debug|Win32 |
| 92 | {GUID}.Debug|Win32.Build.0 = Debug|Win32 |
| 93 | {GUID}.Debug|x64.ActiveCfg = Debug|x64 |
| 94 | {GUID}.Debug|x64.Build.0 = Debug|x64 |
| 95 | {GUID}.Release|Win32.ActiveCfg = Release|Win32 |
| 96 | {GUID}.Release|Win32.Build.0 = Release|Win32 |
| 97 | {GUID}.Release|x64.ActiveCfg = Release|x64 |
| 98 | {GUID}.Release|x64.Build.0 = Release|x64 |
Manuel Pégourié-Gonnard | 0598faf | 2014-05-09 12:56:03 +0200 | [diff] [blame] | 99 | EOT |
| 100 | |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 101 | exit( main() ); |
| 102 | |
Manuel Pégourié-Gonnard | 2d34fe3 | 2014-05-07 17:51:20 +0200 | [diff] [blame] | 103 | sub check_dirs { |
Gilles Peskine | 13fac98 | 2020-02-12 20:34:22 +0100 | [diff] [blame] | 104 | foreach my $d (@thirdparty_header_dirs, @thirdparty_source_dirs) { |
| 105 | if (not (-d $d)) { return 0; } |
| 106 | } |
Manuel Pégourié-Gonnard | 51f14be | 2015-05-14 13:04:03 +0200 | [diff] [blame] | 107 | return -d $vsx_dir |
Darryl Green | 588e8cb | 2018-07-20 13:27:58 +0100 | [diff] [blame] | 108 | && -d $mbedtls_header_dir |
| 109 | && -d $psa_header_dir |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 110 | && -d $source_dir |
Ronald Cron | 8dc0af2 | 2020-06-05 16:00:22 +0200 | [diff] [blame] | 111 | && -d $test_source_dir |
David Horstmann | 2ab59f0 | 2024-11-06 16:24:49 +0000 | [diff] [blame] | 112 | && -d $tls_test_source_dir |
Steven Cooreman | 16141ed | 2021-04-08 10:58:33 +0200 | [diff] [blame] | 113 | && -d $test_drivers_source_dir |
Ronald Cron | 8dc0af2 | 2020-06-05 16:00:22 +0200 | [diff] [blame] | 114 | && -d $test_header_dir |
David Horstmann | 2ab59f0 | 2024-11-06 16:24:49 +0000 | [diff] [blame] | 115 | && -d $tls_test_header_dir |
Steven Cooreman | a70d588 | 2020-07-16 20:26:18 +0200 | [diff] [blame] | 116 | && -d $test_drivers_header_dir |
Harry Ramsey | 03f4957 | 2025-02-17 12:04:23 +0000 | [diff] [blame] | 117 | && -d $programs_dir |
| 118 | && -d $framework_programs_dir; |
Manuel Pégourié-Gonnard | 2d34fe3 | 2014-05-07 17:51:20 +0200 | [diff] [blame] | 119 | } |
| 120 | |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 121 | sub slurp_file { |
| 122 | my ($filename) = @_; |
| 123 | |
| 124 | local $/ = undef; |
Gilles Peskine | 6e245c6 | 2021-04-22 20:09:25 +0200 | [diff] [blame] | 125 | open my $fh, '<:crlf', $filename or die "Could not read $filename\n"; |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 126 | my $content = <$fh>; |
| 127 | close $fh; |
| 128 | |
| 129 | return $content; |
| 130 | } |
| 131 | |
Manuel Pégourié-Gonnard | 411f73e | 2014-05-09 13:00:18 +0200 | [diff] [blame] | 132 | sub content_to_file { |
| 133 | my ($content, $filename) = @_; |
| 134 | |
Gilles Peskine | 6e245c6 | 2021-04-22 20:09:25 +0200 | [diff] [blame] | 135 | open my $fh, '>:crlf', $filename or die "Could not write to $filename\n"; |
Manuel Pégourié-Gonnard | 411f73e | 2014-05-09 13:00:18 +0200 | [diff] [blame] | 136 | print $fh $content; |
| 137 | close $fh; |
| 138 | } |
| 139 | |
Manuel Pégourié-Gonnard | 41e8b62 | 2014-05-09 12:27:49 +0200 | [diff] [blame] | 140 | sub gen_app_guid { |
| 141 | my ($path) = @_; |
| 142 | |
Manuel Pégourié-Gonnard | 813e585 | 2015-01-26 15:42:27 +0000 | [diff] [blame] | 143 | my $guid = md5_hex( "mbedTLS:$path" ); |
Manuel Pégourié-Gonnard | 41e8b62 | 2014-05-09 12:27:49 +0200 | [diff] [blame] | 144 | $guid =~ s/(.{8})(.{4})(.{4})(.{4})(.{12})/\U{$1-$2-$3-$4-$5}/; |
| 145 | |
| 146 | return $guid; |
| 147 | } |
| 148 | |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 149 | sub gen_app { |
| 150 | my ($path, $template, $dir, $ext) = @_; |
| 151 | |
Manuel Pégourié-Gonnard | 41e8b62 | 2014-05-09 12:27:49 +0200 | [diff] [blame] | 152 | my $guid = gen_app_guid( $path ); |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 153 | $path =~ s!/!\\!g; |
| 154 | (my $appname = $path) =~ s/.*\\//; |
Gilles Peskine | a1023e2 | 2023-11-03 19:16:56 +0100 | [diff] [blame] | 155 | my $is_test_app = ($path =~ m/^test\\/); |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 156 | |
Harry Ramsey | 03f4957 | 2025-02-17 12:04:23 +0000 | [diff] [blame] | 157 | my $srcs; |
| 158 | if( $appname eq "metatest" or $appname eq "query_compile_time_config" or |
| 159 | $appname eq "query_included_headers" or $appname eq "zeroize" ) { |
| 160 | $srcs = "<ClCompile Include=\"..\\..\\framework\\tests\\programs\\$appname.c\" \/>"; |
| 161 | } else { |
| 162 | $srcs = "<ClCompile Include=\"..\\..\\programs\\$path.c\" \/>"; |
| 163 | } |
| 164 | |
Andres Amaya Garcia | c84a65d | 2018-10-30 21:46:21 +0000 | [diff] [blame] | 165 | if( $appname eq "ssl_client2" or $appname eq "ssl_server2" or |
| 166 | $appname eq "query_compile_time_config" ) { |
Gilles Peskine | 6e245c6 | 2021-04-22 20:09:25 +0200 | [diff] [blame] | 167 | $srcs .= "\n <ClCompile Include=\"..\\..\\programs\\test\\query_config.c\" \/>"; |
Andres Amaya Garcia | c84a65d | 2018-10-30 21:46:21 +0000 | [diff] [blame] | 168 | } |
Gilles Peskine | a3ed34f | 2021-01-05 21:11:16 +0100 | [diff] [blame] | 169 | if( $appname eq "ssl_client2" or $appname eq "ssl_server2" ) { |
Gilles Peskine | 6e245c6 | 2021-04-22 20:09:25 +0200 | [diff] [blame] | 170 | $srcs .= "\n <ClCompile Include=\"..\\..\\programs\\ssl\\ssl_test_lib.c\" \/>"; |
Gilles Peskine | a3ed34f | 2021-01-05 21:11:16 +0100 | [diff] [blame] | 171 | } |
Andres Amaya Garcia | c84a65d | 2018-10-30 21:46:21 +0000 | [diff] [blame] | 172 | |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 173 | my $content = $template; |
Andres Amaya Garcia | c84a65d | 2018-10-30 21:46:21 +0000 | [diff] [blame] | 174 | $content =~ s/<SOURCES>/$srcs/g; |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 175 | $content =~ s/<APPNAME>/$appname/g; |
Manuel Pégourié-Gonnard | 41e8b62 | 2014-05-09 12:27:49 +0200 | [diff] [blame] | 176 | $content =~ s/<GUID>/$guid/g; |
Gilles Peskine | a1023e2 | 2023-11-03 19:16:56 +0100 | [diff] [blame] | 177 | $content =~ s/INCLUDE_DIRECTORIES\n/($is_test_app ? |
| 178 | $library_include_directories : |
| 179 | $include_directories)/ge; |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 180 | |
Manuel Pégourié-Gonnard | 411f73e | 2014-05-09 13:00:18 +0200 | [diff] [blame] | 181 | content_to_file( $content, "$dir/$appname.$ext" ); |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | sub get_app_list { |
Gilles Peskine | b0fa9d2 | 2021-04-22 20:07:44 +0200 | [diff] [blame] | 185 | my $makefile_contents = slurp_file('programs/Makefile'); |
| 186 | $makefile_contents =~ /\n\s*APPS\s*=[\\\s]*(.*?)(?<!\\)[\#\n]/s |
| 187 | or die "Cannot find APPS = ... in programs/Makefile\n"; |
| 188 | return split /(?:\s|\\)+/, $1; |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 189 | } |
| 190 | |
Manuel Pégourié-Gonnard | 2d34fe3 | 2014-05-07 17:51:20 +0200 | [diff] [blame] | 191 | sub gen_app_files { |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 192 | my @app_list = @_; |
| 193 | |
Manuel Pégourié-Gonnard | 2d34fe3 | 2014-05-07 17:51:20 +0200 | [diff] [blame] | 194 | my $vsx_tpl = slurp_file( $vsx_app_tpl_file ); |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 195 | |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 196 | for my $app ( @app_list ) { |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 197 | gen_app( $app, $vsx_tpl, $vsx_dir, $vsx_ext ); |
| 198 | } |
Manuel Pégourié-Gonnard | 2d34fe3 | 2014-05-07 17:51:20 +0200 | [diff] [blame] | 199 | } |
| 200 | |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 201 | sub gen_entry_list { |
Manuel Pégourié-Gonnard | cd8f844 | 2014-05-08 12:53:58 +0200 | [diff] [blame] | 202 | my ($tpl, @names) = @_; |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 203 | |
| 204 | my $entries; |
Manuel Pégourié-Gonnard | cd8f844 | 2014-05-08 12:53:58 +0200 | [diff] [blame] | 205 | for my $name (@names) { |
| 206 | (my $entry = $tpl) =~ s/{NAME}/$name/g; |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 207 | $entries .= $entry; |
| 208 | } |
| 209 | |
| 210 | return $entries; |
| 211 | } |
| 212 | |
| 213 | sub gen_main_file { |
Gilles Peskine | b41f88f | 2020-02-12 20:45:18 +0100 | [diff] [blame] | 214 | my ($headers, $sources, |
| 215 | $hdr_tpl, $src_tpl, |
| 216 | $main_tpl, $main_out) = @_; |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 217 | |
Gilles Peskine | b41f88f | 2020-02-12 20:45:18 +0100 | [diff] [blame] | 218 | my $header_entries = gen_entry_list( $hdr_tpl, @$headers ); |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 219 | my $source_entries = gen_entry_list( $src_tpl, @$sources ); |
| 220 | |
| 221 | my $out = slurp_file( $main_tpl ); |
Gilles Peskine | 6e245c6 | 2021-04-22 20:09:25 +0200 | [diff] [blame] | 222 | $out =~ s/SOURCE_ENTRIES\n/$source_entries/m; |
| 223 | $out =~ s/HEADER_ENTRIES\n/$header_entries/m; |
| 224 | $out =~ s/INCLUDE_DIRECTORIES\n/$library_include_directories/g; |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 225 | |
Manuel Pégourié-Gonnard | 411f73e | 2014-05-09 13:00:18 +0200 | [diff] [blame] | 226 | content_to_file( $out, $main_out ); |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 227 | } |
| 228 | |
Manuel Pégourié-Gonnard | 0598faf | 2014-05-09 12:56:03 +0200 | [diff] [blame] | 229 | sub gen_vsx_solution { |
| 230 | my (@app_names) = @_; |
| 231 | |
| 232 | my ($app_entries, $conf_entries); |
| 233 | for my $path (@app_names) { |
| 234 | my $guid = gen_app_guid( $path ); |
| 235 | (my $appname = $path) =~ s!.*/!!; |
| 236 | |
| 237 | my $app_entry = $vsx_sln_app_entry_tpl; |
| 238 | $app_entry =~ s/{APPNAME}/$appname/g; |
| 239 | $app_entry =~ s/{GUID}/$guid/g; |
| 240 | |
| 241 | $app_entries .= $app_entry; |
| 242 | |
| 243 | my $conf_entry = $vsx_sln_conf_entry_tpl; |
| 244 | $conf_entry =~ s/{GUID}/$guid/g; |
| 245 | |
| 246 | $conf_entries .= $conf_entry; |
| 247 | } |
| 248 | |
| 249 | my $out = slurp_file( $vsx_sln_tpl_file ); |
Gilles Peskine | 6e245c6 | 2021-04-22 20:09:25 +0200 | [diff] [blame] | 250 | $out =~ s/APP_ENTRIES\n/$app_entries/m; |
| 251 | $out =~ s/CONF_ENTRIES\n/$conf_entries/m; |
Manuel Pégourié-Gonnard | 0598faf | 2014-05-09 12:56:03 +0200 | [diff] [blame] | 252 | |
Manuel Pégourié-Gonnard | 411f73e | 2014-05-09 13:00:18 +0200 | [diff] [blame] | 253 | content_to_file( $out, $vsx_sln_file ); |
Manuel Pégourié-Gonnard | 0598faf | 2014-05-09 12:56:03 +0200 | [diff] [blame] | 254 | } |
| 255 | |
Andres Amaya Garcia | 3c5f949 | 2018-01-11 19:51:27 +0000 | [diff] [blame] | 256 | sub del_vsx_files { |
| 257 | unlink glob "'$vsx_dir/*.$vsx_ext'"; |
| 258 | unlink $vsx_main_file; |
| 259 | unlink $vsx_sln_file; |
| 260 | } |
| 261 | |
Manuel Pégourié-Gonnard | 2d34fe3 | 2014-05-07 17:51:20 +0200 | [diff] [blame] | 262 | sub main { |
| 263 | if( ! check_dirs() ) { |
| 264 | chdir '..' or die; |
Dave Rodgman | 0f459d7 | 2023-01-10 15:09:19 +0000 | [diff] [blame] | 265 | check_dirs or die "Must be run from Mbed TLS root or scripts dir\n"; |
Manuel Pégourié-Gonnard | 2d34fe3 | 2014-05-07 17:51:20 +0200 | [diff] [blame] | 266 | } |
| 267 | |
Andres Amaya Garcia | 3c5f949 | 2018-01-11 19:51:27 +0000 | [diff] [blame] | 268 | # Remove old files to ensure that, for example, project files from deleted |
| 269 | # apps are not kept |
| 270 | del_vsx_files(); |
| 271 | |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 272 | my @app_list = get_app_list(); |
Gilles Peskine | b41f88f | 2020-02-12 20:45:18 +0100 | [diff] [blame] | 273 | my @header_dirs = ( |
| 274 | $mbedtls_header_dir, |
| 275 | $psa_header_dir, |
Ronald Cron | 8dc0af2 | 2020-06-05 16:00:22 +0200 | [diff] [blame] | 276 | $test_header_dir, |
David Horstmann | 2ab59f0 | 2024-11-06 16:24:49 +0000 | [diff] [blame] | 277 | $tls_test_header_dir, |
Steven Cooreman | a70d588 | 2020-07-16 20:26:18 +0200 | [diff] [blame] | 278 | $test_drivers_header_dir, |
Gilles Peskine | b41f88f | 2020-02-12 20:45:18 +0100 | [diff] [blame] | 279 | $source_dir, |
Harry Ramsey | 03f4957 | 2025-02-17 12:04:23 +0000 | [diff] [blame] | 280 | $framework_programs_dir, |
Gilles Peskine | b41f88f | 2020-02-12 20:45:18 +0100 | [diff] [blame] | 281 | @thirdparty_header_dirs, |
| 282 | ); |
| 283 | my @headers = (map { <$_/*.h> } @header_dirs); |
| 284 | my @source_dirs = ( |
| 285 | $source_dir, |
Ronald Cron | 8dc0af2 | 2020-06-05 16:00:22 +0200 | [diff] [blame] | 286 | $test_source_dir, |
David Horstmann | 2ab59f0 | 2024-11-06 16:24:49 +0000 | [diff] [blame] | 287 | $tls_test_source_dir, |
Steven Cooreman | 16141ed | 2021-04-08 10:58:33 +0200 | [diff] [blame] | 288 | $test_drivers_source_dir, |
Gilles Peskine | b41f88f | 2020-02-12 20:45:18 +0100 | [diff] [blame] | 289 | @thirdparty_source_dirs, |
| 290 | ); |
| 291 | my @sources = (map { <$_/*.c> } @source_dirs); |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 292 | |
Gilles Peskine | b41f88f | 2020-02-12 20:45:18 +0100 | [diff] [blame] | 293 | @headers = grep { ! $excluded_files{$_} } @headers; |
| 294 | @sources = grep { ! $excluded_files{$_} } @sources; |
| 295 | map { s!/!\\!g } @headers; |
| 296 | map { s!/!\\!g } @sources; |
Christoph M. Wintersteiger | 48d26c2 | 2018-12-06 18:59:19 +0000 | [diff] [blame] | 297 | |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 298 | gen_app_files( @app_list ); |
Manuel Pégourié-Gonnard | 0aafa5c | 2014-05-08 11:33:30 +0200 | [diff] [blame] | 299 | |
Gilles Peskine | b41f88f | 2020-02-12 20:45:18 +0100 | [diff] [blame] | 300 | gen_main_file( \@headers, \@sources, |
| 301 | $vsx_hdr_tpl, $vsx_src_tpl, |
| 302 | $vsx_main_tpl_file, $vsx_main_file ); |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 303 | |
Manuel Pégourié-Gonnard | 0598faf | 2014-05-09 12:56:03 +0200 | [diff] [blame] | 304 | gen_vsx_solution( @app_list ); |
Manuel Pégourié-Gonnard | cd8f844 | 2014-05-08 12:53:58 +0200 | [diff] [blame] | 305 | |
Manuel Pégourié-Gonnard | 1b57878 | 2013-09-16 13:33:42 +0200 | [diff] [blame] | 306 | return 0; |
| 307 | } |