Skip to content

Commit fdeb4cb

Browse files
committed
deps: add template for generated headers
OpenSSL 3.0 has a number of header files that are generated, and currently these headers are copied into the architecture specific directories. This is done for each asm type, 'asm', 'asm_avx2', and 'no-asm' which has takes up quite a lot of disk space and also becomes an issue with the headers.tar file which has increased due to this. This commit adds copies the headers to a common directory for the architecture, for example with linux-x86_64 there will be a directory named deps/openssl/config/archs/linux-x86_64/common/include where the headers will be copied (into subdirectories 'openssl' and 'crypto'. And in the original locations a header file with the same name will be generated which points (includes) the common header file. Fixes: #42081
1 parent 0c9273d commit fdeb4cb

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "../../../common/%%- $path -%%"

deps/openssl/config/generate_gypi.pl

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
our $src_dir = "../openssl";
4040
our $arch_dir = "../config/archs/$arch";
41+
our $arch_common_dir = "$arch_dir/common";
4142
our $base_dir = "$arch_dir/$asm";
4243

4344
my $is_win = ($arch =~/^VC-WIN/);
@@ -59,6 +60,14 @@
5960
"$base_dir/apps",
6061
{
6162
error => \my $make_path_err});
63+
64+
if (not $is_win) {
65+
make_path("$arch_common_dir/include", "$arch_common_dir/include/openssl",
66+
"$arch_common_dir/include/crypto",
67+
{
68+
error => \my $make_path_err});
69+
}
70+
6271
if (@$make_path_err) {
6372
for my $diag (@$make_path_err) {
6473
my ($file, $message) = %$diag;
@@ -367,13 +376,35 @@
367376
system($cmd2) == 0 or die "Error in system($cmd2)";
368377

369378

379+
370380
sub copy_headers {
371381
my @headers = split / /, $_[0];
372382
my $inc_dir = $_[1];
383+
my $header_path = "";
384+
my $arch_header_include_template = Text::Template->new(TYPE => 'FILE',
385+
SOURCE => 'arch_include.h.tmpl',
386+
DELIMITERS => [ "%%-", "-%%" ]
387+
);
373388
foreach my $header_name (@headers) {
374-
# Copy the header from OpenSSL source directory to the arch specific dir.
375-
#print("copy header $src_dir/include/$inc_dir/${header_name}.h to $base_dir/include/$inc_dir \n");
376-
copy("$src_dir/include/$inc_dir/${header_name}.h",
377-
"$base_dir/include/$inc_dir/") or die "Copy failed: $!";
389+
$header_path = "include/$inc_dir/${header_name}.h";
390+
if ($is_win) {
391+
#print("copy header $src_dir/$header_path to $base_dir/$header_path \n");
392+
copy("$src_dir/$header_path",
393+
"$base_dir/include/$inc_dir/") or die "Copy failed: $!";
394+
} else {
395+
#print("copy header $src_dir/$header_path to $arch_common_dir/$header_path \n");
396+
copy("$src_dir/$header_path",
397+
"$arch_common_dir/$header_path") or die "Copy failed: $!";
398+
# Generate a header file with the same name in the arch dependant directory
399+
# which points to the common directory. This is done to avoid copying
400+
# duplicate headers.
401+
my $arch_header_include = $arch_header_include_template->fill_in(
402+
HASH => {
403+
path => "$header_path",
404+
});
405+
open(ARCH_HEADER_INC, "> $base_dir/$header_path");
406+
print ARCH_HEADER_INC "$arch_header_include";
407+
close(ARCH_HEADER_INC);
408+
}
378409
}
379410
}

0 commit comments

Comments
 (0)