2018-04-04 22:26:56 +00:00
|
|
|
#!/usr/bin/env perl
|
2013-09-16 11:33:42 +00:00
|
|
|
|
2018-04-12 01:35:19 +00:00
|
|
|
# Generate main file, individual apps and solution files for MS Visual Studio
|
|
|
|
# 2010
|
2014-05-07 15:51:20 +00:00
|
|
|
#
|
2015-01-26 15:42:27 +00:00
|
|
|
# Must be run from mbedTLS root or scripts directory.
|
2014-05-07 15:51:20 +00:00
|
|
|
# Takes no argument.
|
2020-05-25 22:33:31 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2013-2018, Arm Limited, All Rights Reserved
|
Update license headers to Apache-2.0 OR GPL-2.0-or-later
This will allow us to ship the LTS branches in a single archive
This commit was generated using the following script:
# ========================
#!/bin/sh
header1='\ * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later\
*\
* This file is provided under the Apache License 2.0, or the\
* GNU General Public License v2.0 or later.\
*\
* **********\
* Apache License 2.0:\
*\
* Licensed under the Apache License, Version 2.0 (the "License"); you may\
* not use this file except in compliance with the License.\
* You may obtain a copy of the License at\
*\
* http://www.apache.org/licenses/LICENSE-2.0\
*\
* Unless required by applicable law or agreed to in writing, software\
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\
* See the License for the specific language governing permissions and\
* limitations under the License.\
*\
* **********\
*\
* **********\
* GNU General Public License v2.0 or later:\
*\
* This program is free software; you can redistribute it and/or modify\
* it under the terms of the GNU General Public License as published by\
* the Free Software Foundation; either version 2 of the License, or\
* (at your option) any later version.\
*\
* This program is distributed in the hope that it will be useful,\
* but WITHOUT ANY WARRANTY; without even the implied warranty of\
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
* GNU General Public License for more details.\
*\
* You should have received a copy of the GNU General Public License along\
* with this program; if not, write to the Free Software Foundation, Inc.,\
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\
*\
* **********'
find -path './.git' -prune -o '(' -name '*.c' -o -name '*.cpp' -o -name '*.fmt' -o -name '*.h' ')' -print | xargs sed -i "
# Normalize the first line of the copyright headers (no text on the first line of a block comment)
/^\/\*.*Copyright.*Arm/I s/\/\*/&\n */
# Insert new copyright header
/SPDX-License-Identifier/ i\
$header1
# Delete old copyright header
/SPDX-License-Identifier/,$ {
# Delete lines until the one preceding the mbedtls declaration
N
1,/This file is part of/ {
/This file is part of/! D
}
}
"
# Format copyright header for inclusion into scripts
header2=$(echo "$header1" | sed 's/^\\\? \* \?/#/')
find -path './.git' -prune -o '(' -name '*.gdb' -o -name '*.pl' -o -name '*.py' -o -name '*.sh' ')' -print | xargs sed -i "
# Insert new copyright header
/SPDX-License-Identifier/ i\
$header2
# Delete old copyright header
/SPDX-License-Identifier/,$ {
# Delete lines until the one preceding the mbedtls declaration
N
1,/This file is part of/ {
/This file is part of/! D
}
}
"
# ========================
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2020-06-05 11:02:18 +00:00
|
|
|
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
|
|
|
#
|
|
|
|
# This file is provided under the Apache License 2.0, or the
|
|
|
|
# GNU General Public License v2.0 or later.
|
|
|
|
#
|
|
|
|
# **********
|
|
|
|
# Apache License 2.0:
|
2020-05-25 23:54:15 +00:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2020-05-25 22:33:31 +00:00
|
|
|
#
|
Update license headers to Apache-2.0 OR GPL-2.0-or-later
This will allow us to ship the LTS branches in a single archive
This commit was generated using the following script:
# ========================
#!/bin/sh
header1='\ * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later\
*\
* This file is provided under the Apache License 2.0, or the\
* GNU General Public License v2.0 or later.\
*\
* **********\
* Apache License 2.0:\
*\
* Licensed under the Apache License, Version 2.0 (the "License"); you may\
* not use this file except in compliance with the License.\
* You may obtain a copy of the License at\
*\
* http://www.apache.org/licenses/LICENSE-2.0\
*\
* Unless required by applicable law or agreed to in writing, software\
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\
* See the License for the specific language governing permissions and\
* limitations under the License.\
*\
* **********\
*\
* **********\
* GNU General Public License v2.0 or later:\
*\
* This program is free software; you can redistribute it and/or modify\
* it under the terms of the GNU General Public License as published by\
* the Free Software Foundation; either version 2 of the License, or\
* (at your option) any later version.\
*\
* This program is distributed in the hope that it will be useful,\
* but WITHOUT ANY WARRANTY; without even the implied warranty of\
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
* GNU General Public License for more details.\
*\
* You should have received a copy of the GNU General Public License along\
* with this program; if not, write to the Free Software Foundation, Inc.,\
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\
*\
* **********'
find -path './.git' -prune -o '(' -name '*.c' -o -name '*.cpp' -o -name '*.fmt' -o -name '*.h' ')' -print | xargs sed -i "
# Normalize the first line of the copyright headers (no text on the first line of a block comment)
/^\/\*.*Copyright.*Arm/I s/\/\*/&\n */
# Insert new copyright header
/SPDX-License-Identifier/ i\
$header1
# Delete old copyright header
/SPDX-License-Identifier/,$ {
# Delete lines until the one preceding the mbedtls declaration
N
1,/This file is part of/ {
/This file is part of/! D
}
}
"
# Format copyright header for inclusion into scripts
header2=$(echo "$header1" | sed 's/^\\\? \* \?/#/')
find -path './.git' -prune -o '(' -name '*.gdb' -o -name '*.pl' -o -name '*.py' -o -name '*.sh' ')' -print | xargs sed -i "
# Insert new copyright header
/SPDX-License-Identifier/ i\
$header2
# Delete old copyright header
/SPDX-License-Identifier/,$ {
# Delete lines until the one preceding the mbedtls declaration
N
1,/This file is part of/ {
/This file is part of/! D
}
}
"
# ========================
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2020-06-05 11:02:18 +00:00
|
|
|
# **********
|
|
|
|
#
|
|
|
|
# **********
|
|
|
|
# GNU General Public License v2.0 or later:
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
#
|
|
|
|
# **********
|
|
|
|
#
|
2020-05-25 22:33:31 +00:00
|
|
|
# This file is part of Mbed TLS (https://tls.mbed.org)
|
2013-09-20 13:11:44 +00:00
|
|
|
|
2013-09-16 11:33:42 +00:00
|
|
|
use warnings;
|
|
|
|
use strict;
|
2014-05-09 10:27:49 +00:00
|
|
|
use Digest::MD5 'md5_hex';
|
2013-09-16 11:33:42 +00:00
|
|
|
|
2014-05-07 15:51:20 +00:00
|
|
|
my $vsx_dir = "visualc/VS2010";
|
2013-09-16 11:33:42 +00:00
|
|
|
my $vsx_ext = "vcxproj";
|
2014-05-07 15:51:20 +00:00
|
|
|
my $vsx_app_tpl_file = "scripts/data_files/vs2010-app-template.$vsx_ext";
|
2014-05-08 09:33:30 +00:00
|
|
|
my $vsx_main_tpl_file = "scripts/data_files/vs2010-main-template.$vsx_ext";
|
2015-01-26 15:42:27 +00:00
|
|
|
my $vsx_main_file = "$vsx_dir/mbedTLS.$vsx_ext";
|
2014-05-09 10:56:03 +00:00
|
|
|
my $vsx_sln_tpl_file = "scripts/data_files/vs2010-sln-template.sln";
|
2015-01-26 15:42:27 +00:00
|
|
|
my $vsx_sln_file = "$vsx_dir/mbedTLS.sln";
|
2014-05-07 15:51:20 +00:00
|
|
|
|
|
|
|
my $programs_dir = 'programs';
|
2015-03-09 17:05:11 +00:00
|
|
|
my $header_dir = 'include/mbedtls';
|
2014-05-08 09:33:30 +00:00
|
|
|
my $source_dir = 'library';
|
|
|
|
|
|
|
|
# Need windows line endings!
|
|
|
|
my $vsx_hdr_tpl = <<EOT;
|
2014-05-08 10:53:58 +00:00
|
|
|
<ClInclude Include="..\\..\\{NAME}" />\r
|
2014-05-08 09:33:30 +00:00
|
|
|
EOT
|
|
|
|
my $vsx_src_tpl = <<EOT;
|
2014-05-08 10:53:58 +00:00
|
|
|
<ClCompile Include="..\\..\\{NAME}" />\r
|
2014-05-08 09:33:30 +00:00
|
|
|
EOT
|
2013-09-16 11:33:42 +00:00
|
|
|
|
2014-05-09 10:56:03 +00:00
|
|
|
my $vsx_sln_app_entry_tpl = <<EOT;
|
|
|
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "{APPNAME}", "{APPNAME}.vcxproj", "{GUID}"\r
|
|
|
|
ProjectSection(ProjectDependencies) = postProject\r
|
|
|
|
{46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554}\r
|
|
|
|
EndProjectSection\r
|
|
|
|
EndProject\r
|
|
|
|
EOT
|
|
|
|
|
|
|
|
my $vsx_sln_conf_entry_tpl = <<EOT;
|
|
|
|
{GUID}.Debug|Win32.ActiveCfg = Debug|Win32\r
|
|
|
|
{GUID}.Debug|Win32.Build.0 = Debug|Win32\r
|
|
|
|
{GUID}.Debug|x64.ActiveCfg = Debug|x64\r
|
|
|
|
{GUID}.Debug|x64.Build.0 = Debug|x64\r
|
|
|
|
{GUID}.Release|Win32.ActiveCfg = Release|Win32\r
|
|
|
|
{GUID}.Release|Win32.Build.0 = Release|Win32\r
|
|
|
|
{GUID}.Release|x64.ActiveCfg = Release|x64\r
|
|
|
|
{GUID}.Release|x64.Build.0 = Release|x64\r
|
|
|
|
EOT
|
|
|
|
|
2013-09-16 11:33:42 +00:00
|
|
|
exit( main() );
|
|
|
|
|
2014-05-07 15:51:20 +00:00
|
|
|
sub check_dirs {
|
2015-05-14 11:04:03 +00:00
|
|
|
return -d $vsx_dir
|
2014-05-08 09:33:30 +00:00
|
|
|
&& -d $header_dir
|
|
|
|
&& -d $source_dir
|
2014-05-07 15:51:20 +00:00
|
|
|
&& -d $programs_dir;
|
|
|
|
}
|
|
|
|
|
2013-09-16 11:33:42 +00:00
|
|
|
sub slurp_file {
|
|
|
|
my ($filename) = @_;
|
|
|
|
|
|
|
|
local $/ = undef;
|
|
|
|
open my $fh, '<', $filename or die "Could not read $filename\n";
|
|
|
|
my $content = <$fh>;
|
|
|
|
close $fh;
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
|
2014-05-09 11:00:18 +00:00
|
|
|
sub content_to_file {
|
|
|
|
my ($content, $filename) = @_;
|
|
|
|
|
|
|
|
open my $fh, '>', $filename or die "Could not write to $filename\n";
|
|
|
|
print $fh $content;
|
|
|
|
close $fh;
|
|
|
|
}
|
|
|
|
|
2014-05-09 10:27:49 +00:00
|
|
|
sub gen_app_guid {
|
|
|
|
my ($path) = @_;
|
|
|
|
|
2015-01-26 15:42:27 +00:00
|
|
|
my $guid = md5_hex( "mbedTLS:$path" );
|
2014-05-09 10:27:49 +00:00
|
|
|
$guid =~ s/(.{8})(.{4})(.{4})(.{4})(.{12})/\U{$1-$2-$3-$4-$5}/;
|
|
|
|
|
|
|
|
return $guid;
|
|
|
|
}
|
|
|
|
|
2013-09-16 11:33:42 +00:00
|
|
|
sub gen_app {
|
|
|
|
my ($path, $template, $dir, $ext) = @_;
|
|
|
|
|
2014-05-09 10:27:49 +00:00
|
|
|
my $guid = gen_app_guid( $path );
|
2013-09-16 11:33:42 +00:00
|
|
|
$path =~ s!/!\\!g;
|
|
|
|
(my $appname = $path) =~ s/.*\\//;
|
|
|
|
|
|
|
|
my $content = $template;
|
|
|
|
$content =~ s/<PATHNAME>/$path/g;
|
|
|
|
$content =~ s/<APPNAME>/$appname/g;
|
2014-05-09 10:27:49 +00:00
|
|
|
$content =~ s/<GUID>/$guid/g;
|
2013-09-16 11:33:42 +00:00
|
|
|
|
2014-05-09 11:00:18 +00:00
|
|
|
content_to_file( $content, "$dir/$appname.$ext" );
|
2013-09-16 11:33:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub get_app_list {
|
2014-05-07 15:51:20 +00:00
|
|
|
my $app_list = `cd $programs_dir && make list`;
|
2013-09-16 11:33:42 +00:00
|
|
|
die "make list failed: $!\n" if $?;
|
|
|
|
|
|
|
|
return split /\s+/, $app_list;
|
|
|
|
}
|
|
|
|
|
2014-05-07 15:51:20 +00:00
|
|
|
sub gen_app_files {
|
2014-05-08 09:33:30 +00:00
|
|
|
my @app_list = @_;
|
|
|
|
|
2014-05-07 15:51:20 +00:00
|
|
|
my $vsx_tpl = slurp_file( $vsx_app_tpl_file );
|
2013-09-16 11:33:42 +00:00
|
|
|
|
2014-05-08 09:33:30 +00:00
|
|
|
for my $app ( @app_list ) {
|
2013-09-16 11:33:42 +00:00
|
|
|
gen_app( $app, $vsx_tpl, $vsx_dir, $vsx_ext );
|
|
|
|
}
|
2014-05-07 15:51:20 +00:00
|
|
|
}
|
|
|
|
|
2014-05-08 09:33:30 +00:00
|
|
|
sub gen_entry_list {
|
2014-05-08 10:53:58 +00:00
|
|
|
my ($tpl, @names) = @_;
|
2014-05-08 09:33:30 +00:00
|
|
|
|
|
|
|
my $entries;
|
2014-05-08 10:53:58 +00:00
|
|
|
for my $name (@names) {
|
|
|
|
(my $entry = $tpl) =~ s/{NAME}/$name/g;
|
2014-05-08 09:33:30 +00:00
|
|
|
$entries .= $entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $entries;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub gen_main_file {
|
|
|
|
my ($headers, $sources, $hdr_tpl, $src_tpl, $main_tpl, $main_out) = @_;
|
|
|
|
|
|
|
|
my $header_entries = gen_entry_list( $hdr_tpl, @$headers );
|
|
|
|
my $source_entries = gen_entry_list( $src_tpl, @$sources );
|
|
|
|
|
|
|
|
my $out = slurp_file( $main_tpl );
|
|
|
|
$out =~ s/SOURCE_ENTRIES\r\n/$source_entries/m;
|
|
|
|
$out =~ s/HEADER_ENTRIES\r\n/$header_entries/m;
|
|
|
|
|
2014-05-09 11:00:18 +00:00
|
|
|
content_to_file( $out, $main_out );
|
2014-05-08 09:33:30 +00:00
|
|
|
}
|
|
|
|
|
2014-05-09 10:56:03 +00:00
|
|
|
sub gen_vsx_solution {
|
|
|
|
my (@app_names) = @_;
|
|
|
|
|
|
|
|
my ($app_entries, $conf_entries);
|
|
|
|
for my $path (@app_names) {
|
|
|
|
my $guid = gen_app_guid( $path );
|
|
|
|
(my $appname = $path) =~ s!.*/!!;
|
|
|
|
|
|
|
|
my $app_entry = $vsx_sln_app_entry_tpl;
|
|
|
|
$app_entry =~ s/{APPNAME}/$appname/g;
|
|
|
|
$app_entry =~ s/{GUID}/$guid/g;
|
|
|
|
|
|
|
|
$app_entries .= $app_entry;
|
|
|
|
|
|
|
|
my $conf_entry = $vsx_sln_conf_entry_tpl;
|
|
|
|
$conf_entry =~ s/{GUID}/$guid/g;
|
|
|
|
|
|
|
|
$conf_entries .= $conf_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $out = slurp_file( $vsx_sln_tpl_file );
|
|
|
|
$out =~ s/APP_ENTRIES\r\n/$app_entries/m;
|
|
|
|
$out =~ s/CONF_ENTRIES\r\n/$conf_entries/m;
|
|
|
|
|
2014-05-09 11:00:18 +00:00
|
|
|
content_to_file( $out, $vsx_sln_file );
|
2014-05-09 10:56:03 +00:00
|
|
|
}
|
|
|
|
|
2018-01-11 19:51:27 +00:00
|
|
|
sub del_vsx_files {
|
|
|
|
unlink glob "'$vsx_dir/*.$vsx_ext'";
|
|
|
|
unlink $vsx_main_file;
|
|
|
|
unlink $vsx_sln_file;
|
|
|
|
}
|
|
|
|
|
2014-05-07 15:51:20 +00:00
|
|
|
sub main {
|
|
|
|
if( ! check_dirs() ) {
|
|
|
|
chdir '..' or die;
|
2015-01-26 15:42:27 +00:00
|
|
|
check_dirs or die "Must but run from mbedTLS root or scripts dir\n";
|
2014-05-07 15:51:20 +00:00
|
|
|
}
|
|
|
|
|
2018-01-11 19:51:27 +00:00
|
|
|
# Remove old files to ensure that, for example, project files from deleted
|
|
|
|
# apps are not kept
|
|
|
|
del_vsx_files();
|
|
|
|
|
2014-05-08 09:33:30 +00:00
|
|
|
my @app_list = get_app_list();
|
|
|
|
my @headers = <$header_dir/*.h>;
|
|
|
|
my @sources = <$source_dir/*.c>;
|
|
|
|
map { s!/!\\!g } @headers;
|
|
|
|
map { s!/!\\!g } @sources;
|
|
|
|
|
|
|
|
gen_app_files( @app_list );
|
|
|
|
|
|
|
|
gen_main_file( \@headers, \@sources,
|
|
|
|
$vsx_hdr_tpl, $vsx_src_tpl,
|
|
|
|
$vsx_main_tpl_file, $vsx_main_file );
|
2013-09-16 11:33:42 +00:00
|
|
|
|
2014-05-09 10:56:03 +00:00
|
|
|
gen_vsx_solution( @app_list );
|
2014-05-08 10:53:58 +00:00
|
|
|
|
2013-09-16 11:33:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|