From 7156d8cda95e54595b2f45a9b87cbb0d2882c3ea Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 19 Feb 2020 20:08:44 +0100 Subject: [PATCH] Don't hard-code include paths in templates generate_visualc_files.pl has a list of directories that it pulls headers from, so it knows what directories to put on the include path. Make it inject the include path into the output files, rather than hard-coding the include paths in template files. A similar change (but with different code) was made in Mbed TLS in commit b78cf2b261f5549184c7a2e6aea472da879606af "Adjust visual studio file generation to always use the crypto submodule". No semantic change: this commit does not change the generated files. --- scripts/data_files/vs2010-app-template.vcxproj | 16 ++++++++++++---- scripts/data_files/vs2010-main-template.vcxproj | 16 ++++++++++++---- scripts/generate_visualc_files.pl | 14 ++++++++++++++ 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/scripts/data_files/vs2010-app-template.vcxproj b/scripts/data_files/vs2010-app-template.vcxproj index 5480a445c..e7bb122d8 100644 --- a/scripts/data_files/vs2010-app-template.vcxproj +++ b/scripts/data_files/vs2010-app-template.vcxproj @@ -93,7 +93,9 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - ../../include;../../3rdparty/everest/include/;../../3rdparty/everest/include/everest;../../3rdparty/everest/include/everest/vs2010;../../3rdparty/everest/include/everest/kremlib + +INCLUDE_DIRECTORIES + Console @@ -113,7 +115,9 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - ../../include;../../3rdparty/everest/include/;../../3rdparty/everest/include/everest;../../3rdparty/everest/include/everest/vs2010;../../3rdparty/everest/include/everest/kremlib + +INCLUDE_DIRECTORIES + Console @@ -135,7 +139,9 @@ true true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - ../../include;../../3rdparty/everest/include/;../../3rdparty/everest/include/everest;../../3rdparty/everest/include/everest/vs2010;../../3rdparty/everest/include/everest/kremlib + +INCLUDE_DIRECTORIES + Console @@ -155,7 +161,9 @@ true true WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - ../../include;../../3rdparty/everest/include/;../../3rdparty/everest/include/everest;../../3rdparty/everest/include/everest/vs2010;../../3rdparty/everest/include/everest/kremlib + +INCLUDE_DIRECTORIES + Console diff --git a/scripts/data_files/vs2010-main-template.vcxproj b/scripts/data_files/vs2010-main-template.vcxproj index 7071cd28a..81bbbe669 100644 --- a/scripts/data_files/vs2010-main-template.vcxproj +++ b/scripts/data_files/vs2010-main-template.vcxproj @@ -86,7 +86,9 @@ Level3 Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;MBEDTLS_EXPORTS;KRML_VERIFIED_UINT128;%(PreprocessorDefinitions) - ../../include;../../3rdparty/everest/include/;../../3rdparty/everest/include/everest;../../3rdparty/everest/include/everest/vs2010;../../3rdparty/everest/include/everest/kremlib + +INCLUDE_DIRECTORIES + CompileAsC @@ -101,7 +103,9 @@ Level3 Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;MBEDTLS_EXPORTS;KRML_VERIFIED_UINT128;%(PreprocessorDefinitions) - ../../include;../../3rdparty/everest/include/;../../3rdparty/everest/include/everest;../../3rdparty/everest/include/everest/vs2010;../../3rdparty/everest/include/everest/kremlib + +INCLUDE_DIRECTORIES + CompileAsC @@ -118,7 +122,9 @@ true true WIN32;NDEBUG;_WINDOWS;_USRDLL;MBEDTLS_EXPORTS;KRML_VERIFIED_UINT128;%(PreprocessorDefinitions) - ../../include;../../3rdparty/everest/include/;../../3rdparty/everest/include/everest;../../3rdparty/everest/include/everest/vs2010;../../3rdparty/everest/include/everest/kremlib + +INCLUDE_DIRECTORIES + Windows @@ -136,7 +142,9 @@ true true WIN64;NDEBUG;_WINDOWS;_USRDLL;MBEDTLS_EXPORTS;KRML_VERIFIED_UINT128;%(PreprocessorDefinitions) - ../../include;../../3rdparty/everest/include/;../../3rdparty/everest/include/everest;../../3rdparty/everest/include/everest/vs2010;../../3rdparty/everest/include/everest/kremlib + +INCLUDE_DIRECTORIES + Windows diff --git a/scripts/generate_visualc_files.pl b/scripts/generate_visualc_files.pl index 5565729f9..5b3bfcc47 100755 --- a/scripts/generate_visualc_files.pl +++ b/scripts/generate_visualc_files.pl @@ -32,6 +32,18 @@ my @thirdparty_source_dirs = qw( 3rdparty/everest/library/legacy ); +# Directories to add to the include path. +# Order matters in case there are files with the same name in more than +# one directory: the compiler will use the first match. +my @include_directories = qw( + include + 3rdparty/everest/include/ + 3rdparty/everest/include/everest + 3rdparty/everest/include/everest/vs2010 + 3rdparty/everest/include/everest/kremlib +); +my $include_directories = join(';', map {"../../$_"} @include_directories); + my @excluded_files = qw( 3rdparty/everest/library/Hacl_Curve25519.c ); @@ -123,6 +135,7 @@ sub gen_app { $content =~ s//$srcs/g; $content =~ s//$appname/g; $content =~ s//$guid/g; + $content =~ s/\r\nINCLUDE_DIRECTORIES\r\n +/$include_directories/g; content_to_file( $content, "$dir/$appname.$ext" ); } @@ -167,6 +180,7 @@ sub gen_main_file { my $out = slurp_file( $main_tpl ); $out =~ s/SOURCE_ENTRIES\r\n/$source_entries/m; $out =~ s/HEADER_ENTRIES\r\n/$header_entries/m; + $out =~ s/\r\nINCLUDE_DIRECTORIES\r\n +/$include_directories/g; content_to_file( $out, $main_out ); }