Git fork

Merge branch 'js/ci-buildsystems-cleanup'

Code clean-up around stale CI elements and building with Visual Studio.

* js/ci-buildsystems-cleanup:
config.mak.uname: drop the `vcxproj` target
contrib/buildsystems: drop support for building . vcproj/.vcxproj files
ci: stop linking the `prove` cache

-1950
-5
ci/run-build-and-tests.sh
··· 5 5 6 6 . ${0%/*}/lib.sh 7 7 8 - case "$CI_OS_NAME" in 9 - windows*) cmd //c mklink //j t\\.prove "$(cygpath -aw "$cache_dir/.prove")";; 10 - *) ln -s "$cache_dir/.prove" t/.prove;; 11 - esac 12 - 13 8 run_tests=t 14 9 15 10 case "$jobname" in
-5
ci/run-test-slice.sh
··· 5 5 6 6 . ${0%/*}/lib.sh 7 7 8 - case "$CI_OS_NAME" in 9 - windows*) cmd //c mklink //j t\\.prove "$(cygpath -aw "$cache_dir/.prove")";; 10 - *) ln -s "$cache_dir/.prove" t/.prove;; 11 - esac 12 - 13 8 group "Run tests" make --quiet -C t T="$(cd t && 14 9 ./helper/test-tool path-utils slice-tests "$1" "$2" t[0-9]*.sh | 15 10 tr '\n' ' ')" ||
-76
config.mak.uname
··· 776 776 NO_STRCASESTR = YesPlease 777 777 NO_STRLCPY = YesPlease 778 778 endif 779 - 780 - vcxproj: 781 - # Require clean work tree 782 - git update-index -q --refresh && \ 783 - git diff-files --quiet && \ 784 - git diff-index --cached --quiet HEAD -- 785 - 786 - # Make .vcxproj files and add them 787 - perl contrib/buildsystems/generate -g Vcxproj 788 - git add -f git.sln {*,*/lib,t/helper/*}/*.vcxproj 789 - 790 - # Generate the LinkOrCopyBuiltins.targets and LinkOrCopyRemoteHttp.targets file 791 - (echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \ 792 - echo ' <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \ 793 - for name in $(BUILT_INS);\ 794 - do \ 795 - echo ' <Copy SourceFiles="$$(OutDir)\git.exe" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \ 796 - done && \ 797 - echo ' </Target>' && \ 798 - echo '</Project>') >git/LinkOrCopyBuiltins.targets 799 - (echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \ 800 - echo ' <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \ 801 - for name in $(REMOTE_CURL_ALIASES); \ 802 - do \ 803 - echo ' <Copy SourceFiles="$$(OutDir)\'"$(REMOTE_CURL_PRIMARY)"'" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \ 804 - done && \ 805 - echo ' </Target>' && \ 806 - echo '</Project>') >git-remote-http/LinkOrCopyRemoteHttp.targets 807 - git add -f git/LinkOrCopyBuiltins.targets git-remote-http/LinkOrCopyRemoteHttp.targets 808 - 809 - # Add generated headers 810 - $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(GENERATED_H) 811 - git add -f $(GENERATED_H) 812 - 813 - # Add scripts 814 - rm -f perl/perl.mak 815 - $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(SCRIPT_LIB) $(SCRIPTS) 816 - # Strip out the sane tool path, needed only for building 817 - sed -i '/^git_broken_path_fix ".*/d' git-sh-setup 818 - git add -f $(SCRIPT_LIB) $(SCRIPTS) 819 - 820 - # Add Perl module 821 - $(MAKE) $(LIB_PERL_GEN) 822 - git add -f perl/build 823 - 824 - # Add bin-wrappers, for testing 825 - rm -rf bin-wrappers/ 826 - $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(test_bindir_programs) 827 - # Ensure that the GIT_EXEC_PATH is a Unix-y one, and that the absolute 828 - # path of the repository is not hard-coded (GIT_EXEC_PATH will be set 829 - # by test-lib.sh according to the current setup) 830 - sed -i -e 's/^\(GIT_EXEC_PATH\)=.*/test -n "$${\1##*:*}" ||\ 831 - \1="$$(cygpath -u "$$\1")"/' \ 832 - -e "s|'$$(pwd)|\"\$$GIT_EXEC_PATH\"'|g" bin-wrappers/* 833 - # Ensure that test-* helpers find the .dll files copied to top-level 834 - sed -i 's|^PATH=.*|&:"$$GIT_EXEC_PATH"|' bin-wrappers/test-* 835 - # We do not want to force hard-linking builtins 836 - sed -i 's|\(git\)-\([-a-z]*\)\.exe"|\1.exe" \2|g' \ 837 - bin-wrappers/git-{receive-pack,upload-archive} 838 - git add -f $(test_bindir_programs) 839 - 840 - # Add templates 841 - $(MAKE) -C templates 842 - git add -f templates/boilerplates.made templates/blt/ 843 - 844 - # Add the translated messages 845 - make MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(MOFILES) 846 - git add -f $(MOFILES) 847 - 848 - # Add build options 849 - $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 GIT-BUILD-OPTIONS 850 - git add -f GIT-BUILD-OPTIONS 851 - 852 - # Commit the whole shebang 853 - git commit -m "Generate Visual Studio solution" \ 854 - -m "Auto-generated by \`$(MAKE)$(MAKEFLAGS) $@\`"
-42
contrib/buildsystems/Generators.pm
··· 1 - package Generators; 2 - require Exporter; 3 - 4 - use strict; 5 - use File::Basename; 6 - no strict 'refs'; 7 - use vars qw($VERSION @AVAILABLE); 8 - 9 - our $VERSION = '1.00'; 10 - our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE); 11 - @ISA = qw(Exporter); 12 - 13 - BEGIN { 14 - local(*D); 15 - my $me = $INC{"Generators.pm"}; 16 - die "Couldn't find myself in \@INC, which is required to load the generators!" if ("$me" eq ""); 17 - $me = dirname($me); 18 - if (opendir(D,"$me/Generators")) { 19 - foreach my $gen (readdir(D)) { 20 - next unless ($gen =~ /\.pm$/); 21 - require "${me}/Generators/$gen"; 22 - $gen =~ s,\.pm,,; 23 - push(@AVAILABLE, $gen); 24 - } 25 - closedir(D); 26 - my $gens = join(', ', @AVAILABLE); 27 - } 28 - 29 - push @EXPORT_OK, qw(available); 30 - } 31 - 32 - sub available { 33 - return @AVAILABLE; 34 - } 35 - 36 - sub generate { 37 - my ($gen, $git_dir, $out_dir, $rel_dir, %build_structure) = @_; 38 - return eval("Generators::${gen}::generate(\$git_dir, \$out_dir, \$rel_dir, \%build_structure)") if grep(/^$gen$/, @AVAILABLE); 39 - die "Generator \"${gen}\" is not available!\nAvailable generators are: @AVAILABLE\n"; 40 - } 41 - 42 - 1;
-189
contrib/buildsystems/Generators/QMake.pm
··· 1 - package Generators::QMake; 2 - require Exporter; 3 - 4 - use strict; 5 - use vars qw($VERSION); 6 - 7 - our $VERSION = '1.00'; 8 - our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE); 9 - @ISA = qw(Exporter); 10 - 11 - BEGIN { 12 - push @EXPORT_OK, qw(generate); 13 - } 14 - 15 - sub generate { 16 - my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; 17 - 18 - my @libs = @{$build_structure{"LIBS"}}; 19 - foreach (@libs) { 20 - createLibProject($_, $git_dir, $out_dir, $rel_dir, %build_structure); 21 - } 22 - 23 - my @apps = @{$build_structure{"APPS"}}; 24 - foreach (@apps) { 25 - createAppProject($_, $git_dir, $out_dir, $rel_dir, %build_structure); 26 - } 27 - 28 - createGlueProject($git_dir, $out_dir, $rel_dir, %build_structure); 29 - return 0; 30 - } 31 - 32 - sub createLibProject { 33 - my ($libname, $git_dir, $out_dir, $rel_dir, %build_structure) = @_; 34 - print "Generate $libname lib project\n"; 35 - $rel_dir = "../$rel_dir"; 36 - 37 - my $sources = join(" \\\n\t", sort(map("$rel_dir/$_", @{$build_structure{"LIBS_${libname}_SOURCES"}}))); 38 - my $defines = join(" \\\n\t", sort(@{$build_structure{"LIBS_${libname}_DEFINES"}})); 39 - my $includes= join(" \\\n\t", sort(map("$rel_dir/$_", @{$build_structure{"LIBS_${libname}_INCLUDES"}}))); 40 - my $cflags = join(" ", sort(@{$build_structure{"LIBS_${libname}_CFLAGS"}})); 41 - 42 - my $cflags_debug = $cflags; 43 - $cflags_debug =~ s/-MT/-MTd/; 44 - $cflags_debug =~ s/-O.//; 45 - 46 - my $cflags_release = $cflags; 47 - $cflags_release =~ s/-MTd/-MT/; 48 - 49 - my @tmp = @{$build_structure{"LIBS_${libname}_LFLAGS"}}; 50 - my @tmp2 = (); 51 - foreach (@tmp) { 52 - if (/^-LTCG/) { 53 - } elsif (/^-L/) { 54 - $_ =~ s/^-L/-LIBPATH:$rel_dir\//; 55 - } 56 - push(@tmp2, $_); 57 - } 58 - my $lflags = join(" ", sort(@tmp)); 59 - 60 - my $target = $libname; 61 - $target =~ s/\//_/g; 62 - $defines =~ s/-D//g; 63 - $defines =~ s/"/\\\\"/g; 64 - $includes =~ s/-I//g; 65 - mkdir "$target" || die "Could not create the directory $target for lib project!\n"; 66 - open F, ">$target/$target.pro" || die "Could not open $target/$target.pro for writing!\n"; 67 - print F << "EOM"; 68 - TEMPLATE = lib 69 - TARGET = $target 70 - DESTDIR = $rel_dir 71 - 72 - CONFIG -= qt 73 - CONFIG += static 74 - 75 - QMAKE_CFLAGS = 76 - QMAKE_CFLAGS_RELEASE = $cflags_release 77 - QMAKE_CFLAGS_DEBUG = $cflags_debug 78 - QMAKE_LIBFLAGS = $lflags 79 - 80 - DEFINES += \\ 81 - $defines 82 - 83 - INCLUDEPATH += \\ 84 - $includes 85 - 86 - SOURCES += \\ 87 - $sources 88 - EOM 89 - close F; 90 - } 91 - 92 - sub createAppProject { 93 - my ($appname, $git_dir, $out_dir, $rel_dir, %build_structure) = @_; 94 - print "Generate $appname app project\n"; 95 - $rel_dir = "../$rel_dir"; 96 - 97 - my $sources = join(" \\\n\t", sort(map("$rel_dir/$_", @{$build_structure{"APPS_${appname}_SOURCES"}}))); 98 - my $defines = join(" \\\n\t", sort(@{$build_structure{"APPS_${appname}_DEFINES"}})); 99 - my $includes= join(" \\\n\t", sort(map("$rel_dir/$_", @{$build_structure{"APPS_${appname}_INCLUDES"}}))); 100 - my $cflags = join(" ", sort(@{$build_structure{"APPS_${appname}_CFLAGS"}})); 101 - 102 - my $cflags_debug = $cflags; 103 - $cflags_debug =~ s/-MT/-MTd/; 104 - $cflags_debug =~ s/-O.//; 105 - 106 - my $cflags_release = $cflags; 107 - $cflags_release =~ s/-MTd/-MT/; 108 - 109 - my $libs; 110 - foreach (sort(@{$build_structure{"APPS_${appname}_LIBS"}})) { 111 - $_ =~ s/\//_/g; 112 - $libs .= " $_"; 113 - } 114 - my @tmp = @{$build_structure{"APPS_${appname}_LFLAGS"}}; 115 - my @tmp2 = (); 116 - foreach (@tmp) { 117 - # next if ($_ eq "-NODEFAULTLIB:MSVCRT.lib"); 118 - if (/^-LTCG/) { 119 - } elsif (/^-L/) { 120 - $_ =~ s/^-L/-LIBPATH:$rel_dir\//; 121 - } 122 - push(@tmp2, $_); 123 - } 124 - my $lflags = join(" ", sort(@tmp)); 125 - 126 - my $target = $appname; 127 - $target =~ s/\.exe//; 128 - $target =~ s/\//_/g; 129 - $defines =~ s/-D//g; 130 - $defines =~ s/"/\\\\"/g; 131 - $includes =~ s/-I//g; 132 - mkdir "$target" || die "Could not create the directory $target for app project!\n"; 133 - open F, ">$target/$target.pro" || die "Could not open $target/$target.pro for writing!\n"; 134 - print F << "EOM"; 135 - TEMPLATE = app 136 - TARGET = $target 137 - DESTDIR = $rel_dir 138 - 139 - CONFIG -= qt embed_manifest_exe 140 - CONFIG += console 141 - 142 - QMAKE_CFLAGS = 143 - QMAKE_CFLAGS_RELEASE = $cflags_release 144 - QMAKE_CFLAGS_DEBUG = $cflags_debug 145 - QMAKE_LFLAGS = $lflags 146 - LIBS = $libs 147 - 148 - DEFINES += \\ 149 - $defines 150 - 151 - INCLUDEPATH += \\ 152 - $includes 153 - 154 - win32:QMAKE_LFLAGS += -LIBPATH:$rel_dir 155 - else: QMAKE_LFLAGS += -L$rel_dir 156 - 157 - SOURCES += \\ 158 - $sources 159 - EOM 160 - close F; 161 - } 162 - 163 - sub createGlueProject { 164 - my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; 165 - my $libs = join(" \\ \n", map("\t$_|$_.pro", @{$build_structure{"LIBS"}})); 166 - my $apps = join(" \\ \n", map("\t$_|$_.pro", @{$build_structure{"APPS"}})); 167 - $libs =~ s/\.a//g; 168 - $libs =~ s/\//_/g; 169 - $libs =~ s/\|/\//g; 170 - $apps =~ s/\.exe//g; 171 - $apps =~ s/\//_/g; 172 - $apps =~ s/\|/\//g; 173 - 174 - my $filename = $out_dir; 175 - $filename =~ s/.*\/([^\/]+)$/$1/; 176 - $filename =~ s/\/$//; 177 - print "Generate glue project $filename.pro\n"; 178 - open F, ">$filename.pro" || die "Could not open $filename.pro for writing!\n"; 179 - print F << "EOM"; 180 - TEMPLATE = subdirs 181 - CONFIG += ordered 182 - SUBDIRS += \\ 183 - $libs \\ 184 - $apps 185 - EOM 186 - close F; 187 - } 188 - 189 - 1;
-579
contrib/buildsystems/Generators/Vcproj.pm
··· 1 - package Generators::Vcproj; 2 - require Exporter; 3 - 4 - use strict; 5 - use vars qw($VERSION); 6 - use Digest::SHA qw(sha256_hex); 7 - 8 - our $VERSION = '1.00'; 9 - our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE); 10 - @ISA = qw(Exporter); 11 - 12 - BEGIN { 13 - push @EXPORT_OK, qw(generate); 14 - } 15 - 16 - sub generate_guid ($) { 17 - my $hex = sha256_hex($_[0]); 18 - $hex =~ s/^(.{8})(.{4})(.{4})(.{4})(.{12}).*/{$1-$2-$3-$4-$5}/; 19 - $hex =~ tr/a-z/A-Z/; 20 - return $hex; 21 - } 22 - 23 - sub generate { 24 - my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; 25 - my @libs = @{$build_structure{"LIBS"}}; 26 - foreach (@libs) { 27 - createLibProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure); 28 - } 29 - 30 - my @apps = @{$build_structure{"APPS"}}; 31 - foreach (@apps) { 32 - createAppProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure); 33 - } 34 - 35 - createGlueProject($git_dir, $out_dir, $rel_dir, %build_structure); 36 - return 0; 37 - } 38 - 39 - sub createLibProject { 40 - my ($libname, $git_dir, $out_dir, $rel_dir, $build_structure) = @_; 41 - print "Generate $libname vcproj lib project\n"; 42 - $rel_dir = "..\\$rel_dir"; 43 - $rel_dir =~ s/\//\\/g; 44 - 45 - my $target = $libname; 46 - $target =~ s/\//_/g; 47 - $target =~ s/\.a//; 48 - 49 - my $uuid = generate_guid($libname); 50 - $$build_structure{"LIBS_${target}_GUID"} = $uuid; 51 - 52 - my @srcs = sort(map("$rel_dir\\$_", @{$$build_structure{"LIBS_${libname}_SOURCES"}})); 53 - my @sources; 54 - foreach (@srcs) { 55 - $_ =~ s/\//\\/g; 56 - push(@sources, $_); 57 - } 58 - my $defines = join(",", sort(@{$$build_structure{"LIBS_${libname}_DEFINES"}})); 59 - my $includes= join(";", sort(map("&quot;$rel_dir\\$_&quot;", @{$$build_structure{"LIBS_${libname}_INCLUDES"}}))); 60 - my $cflags = join(" ", sort(@{$$build_structure{"LIBS_${libname}_CFLAGS"}})); 61 - $cflags =~ s/\"/&quot;/g; 62 - $cflags =~ s/</&lt;/g; 63 - $cflags =~ s/>/&gt;/g; 64 - 65 - my $cflags_debug = $cflags; 66 - $cflags_debug =~ s/-MT/-MTd/; 67 - $cflags_debug =~ s/-O.//; 68 - 69 - my $cflags_release = $cflags; 70 - $cflags_release =~ s/-MTd/-MT/; 71 - 72 - my @tmp = @{$$build_structure{"LIBS_${libname}_LFLAGS"}}; 73 - my @tmp2 = (); 74 - foreach (@tmp) { 75 - if (/^-LTCG/) { 76 - } elsif (/^-L/) { 77 - $_ =~ s/^-L/-LIBPATH:$rel_dir\//; 78 - } 79 - push(@tmp2, $_); 80 - } 81 - my $lflags = join(" ", sort(@tmp)); 82 - 83 - $defines =~ s/-D//g; 84 - $defines =~ s/\"/\\&quot;/g; 85 - $defines =~ s/</&lt;/g; 86 - $defines =~ s/>/&gt;/g; 87 - $defines =~ s/\'//g; 88 - $includes =~ s/-I//g; 89 - mkdir "$target" || die "Could not create the directory $target for lib project!\n"; 90 - open F, ">$target/$target.vcproj" || die "Could not open $target/$target.pro for writing!\n"; 91 - binmode F, ":crlf"; 92 - print F << "EOM"; 93 - <?xml version="1.0" encoding = "Windows-1252"?> 94 - <VisualStudioProject 95 - ProjectType="Visual C++" 96 - Version="9,00" 97 - Name="$target" 98 - ProjectGUID="$uuid"> 99 - <Platforms> 100 - <Platform 101 - Name="Win32"/> 102 - </Platforms> 103 - <ToolFiles> 104 - </ToolFiles> 105 - <Configurations> 106 - <Configuration 107 - Name="Debug|Win32" 108 - OutputDirectory="$rel_dir" 109 - ConfigurationType="4" 110 - CharacterSet="0" 111 - IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)" 112 - > 113 - <Tool 114 - Name="VCPreBuildEventTool" 115 - /> 116 - <Tool 117 - Name="VCCustomBuildTool" 118 - /> 119 - <Tool 120 - Name="VCXMLDataGeneratorTool" 121 - /> 122 - <Tool 123 - Name="VCMIDLTool" 124 - /> 125 - <Tool 126 - Name="VCCLCompilerTool" 127 - AdditionalOptions="$cflags_debug" 128 - Optimization="0" 129 - InlineFunctionExpansion="1" 130 - AdditionalIncludeDirectories="$includes" 131 - PreprocessorDefinitions="WIN32,_DEBUG,$defines" 132 - MinimalRebuild="true" 133 - RuntimeLibrary="1" 134 - UsePrecompiledHeader="0" 135 - ProgramDataBaseFileName="\$(IntDir)\\\$(TargetName).pdb" 136 - WarningLevel="3" 137 - DebugInformationFormat="3" 138 - /> 139 - <Tool 140 - Name="VCManagedResourceCompilerTool" 141 - /> 142 - <Tool 143 - Name="VCResourceCompilerTool" 144 - /> 145 - <Tool 146 - Name="VCPreLinkEventTool" 147 - /> 148 - <Tool 149 - Name="VCLibrarianTool" 150 - SuppressStartupBanner="true" 151 - /> 152 - <Tool 153 - Name="VCALinkTool" 154 - /> 155 - <Tool 156 - Name="VCXDCMakeTool" 157 - /> 158 - <Tool 159 - Name="VCBscMakeTool" 160 - /> 161 - <Tool 162 - Name="VCFxCopTool" 163 - /> 164 - <Tool 165 - Name="VCPostBuildEventTool" 166 - /> 167 - </Configuration> 168 - <Configuration 169 - Name="Release|Win32" 170 - OutputDirectory="$rel_dir" 171 - ConfigurationType="4" 172 - CharacterSet="0" 173 - WholeProgramOptimization="1" 174 - IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)" 175 - > 176 - <Tool 177 - Name="VCPreBuildEventTool" 178 - /> 179 - <Tool 180 - Name="VCCustomBuildTool" 181 - /> 182 - <Tool 183 - Name="VCXMLDataGeneratorTool" 184 - /> 185 - <Tool 186 - Name="VCMIDLTool" 187 - /> 188 - <Tool 189 - Name="VCCLCompilerTool" 190 - AdditionalOptions="$cflags_release" 191 - Optimization="2" 192 - InlineFunctionExpansion="1" 193 - EnableIntrinsicFunctions="true" 194 - AdditionalIncludeDirectories="$includes" 195 - PreprocessorDefinitions="WIN32,NDEBUG,$defines" 196 - RuntimeLibrary="0" 197 - EnableFunctionLevelLinking="true" 198 - UsePrecompiledHeader="0" 199 - ProgramDataBaseFileName="\$(IntDir)\\\$(TargetName).pdb" 200 - WarningLevel="3" 201 - DebugInformationFormat="3" 202 - /> 203 - <Tool 204 - Name="VCManagedResourceCompilerTool" 205 - /> 206 - <Tool 207 - Name="VCResourceCompilerTool" 208 - /> 209 - <Tool 210 - Name="VCPreLinkEventTool" 211 - /> 212 - <Tool 213 - Name="VCLibrarianTool" 214 - SuppressStartupBanner="true" 215 - /> 216 - <Tool 217 - Name="VCALinkTool" 218 - /> 219 - <Tool 220 - Name="VCXDCMakeTool" 221 - /> 222 - <Tool 223 - Name="VCBscMakeTool" 224 - /> 225 - <Tool 226 - Name="VCFxCopTool" 227 - /> 228 - <Tool 229 - Name="VCPostBuildEventTool" 230 - /> 231 - </Configuration> 232 - </Configurations> 233 - <Files> 234 - <Filter 235 - Name="Source Files" 236 - Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" 237 - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 238 - EOM 239 - foreach(@sources) { 240 - print F << "EOM"; 241 - <File 242 - RelativePath="$_"/> 243 - EOM 244 - } 245 - print F << "EOM"; 246 - </Filter> 247 - </Files> 248 - <Globals> 249 - </Globals> 250 - </VisualStudioProject> 251 - EOM 252 - close F; 253 - } 254 - 255 - sub createAppProject { 256 - my ($appname, $git_dir, $out_dir, $rel_dir, $build_structure) = @_; 257 - print "Generate $appname vcproj app project\n"; 258 - $rel_dir = "..\\$rel_dir"; 259 - $rel_dir =~ s/\//\\/g; 260 - 261 - my $target = $appname; 262 - $target =~ s/\//_/g; 263 - $target =~ s/\.exe//; 264 - 265 - my $uuid = generate_guid($appname); 266 - $$build_structure{"APPS_${target}_GUID"} = $uuid; 267 - 268 - my @srcs = sort(map("$rel_dir\\$_", @{$$build_structure{"APPS_${appname}_SOURCES"}})); 269 - my @sources; 270 - foreach (@srcs) { 271 - $_ =~ s/\//\\/g; 272 - push(@sources, $_); 273 - } 274 - my $defines = join(",", sort(@{$$build_structure{"APPS_${appname}_DEFINES"}})); 275 - my $includes= join(";", sort(map("&quot;$rel_dir\\$_&quot;", @{$$build_structure{"APPS_${appname}_INCLUDES"}}))); 276 - my $cflags = join(" ", sort(@{$$build_structure{"APPS_${appname}_CFLAGS"}})); 277 - $cflags =~ s/\"/&quot;/g; 278 - $cflags =~ s/</&lt;/g; 279 - $cflags =~ s/>/&gt;/g; 280 - 281 - my $cflags_debug = $cflags; 282 - $cflags_debug =~ s/-MT/-MTd/; 283 - $cflags_debug =~ s/-O.//; 284 - 285 - my $cflags_release = $cflags; 286 - $cflags_release =~ s/-MTd/-MT/; 287 - 288 - my $libs; 289 - foreach (sort(@{$$build_structure{"APPS_${appname}_LIBS"}})) { 290 - $_ =~ s/\//_/g; 291 - $libs .= " $_"; 292 - } 293 - my @tmp = @{$$build_structure{"APPS_${appname}_LFLAGS"}}; 294 - my @tmp2 = (); 295 - foreach (@tmp) { 296 - if (/^-LTCG/) { 297 - } elsif (/^-L/) { 298 - $_ =~ s/^-L/-LIBPATH:$rel_dir\//; 299 - } 300 - push(@tmp2, $_); 301 - } 302 - my $lflags = join(" ", sort(@tmp)) . " -LIBPATH:$rel_dir"; 303 - 304 - $defines =~ s/-D//g; 305 - $defines =~ s/\"/\\&quot;/g; 306 - $defines =~ s/</&lt;/g; 307 - $defines =~ s/>/&gt;/g; 308 - $defines =~ s/\'//g; 309 - $defines =~ s/\\\\/\\/g; 310 - $includes =~ s/-I//g; 311 - mkdir "$target" || die "Could not create the directory $target for lib project!\n"; 312 - open F, ">$target/$target.vcproj" || die "Could not open $target/$target.pro for writing!\n"; 313 - binmode F, ":crlf"; 314 - print F << "EOM"; 315 - <?xml version="1.0" encoding = "Windows-1252"?> 316 - <VisualStudioProject 317 - ProjectType="Visual C++" 318 - Version="9,00" 319 - Name="$target" 320 - ProjectGUID="$uuid"> 321 - <Platforms> 322 - <Platform 323 - Name="Win32"/> 324 - </Platforms> 325 - <ToolFiles> 326 - </ToolFiles> 327 - <Configurations> 328 - <Configuration 329 - Name="Debug|Win32" 330 - OutputDirectory="$rel_dir" 331 - ConfigurationType="1" 332 - CharacterSet="0" 333 - IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)" 334 - > 335 - <Tool 336 - Name="VCPreBuildEventTool" 337 - /> 338 - <Tool 339 - Name="VCCustomBuildTool" 340 - /> 341 - <Tool 342 - Name="VCXMLDataGeneratorTool" 343 - /> 344 - <Tool 345 - Name="VCMIDLTool" 346 - /> 347 - <Tool 348 - Name="VCCLCompilerTool" 349 - AdditionalOptions="$cflags_debug" 350 - Optimization="0" 351 - InlineFunctionExpansion="1" 352 - AdditionalIncludeDirectories="$includes" 353 - PreprocessorDefinitions="WIN32,_DEBUG,$defines" 354 - MinimalRebuild="true" 355 - RuntimeLibrary="1" 356 - UsePrecompiledHeader="0" 357 - ProgramDataBaseFileName="\$(IntDir)\\\$(TargetName).pdb" 358 - WarningLevel="3" 359 - DebugInformationFormat="3" 360 - /> 361 - <Tool 362 - Name="VCManagedResourceCompilerTool" 363 - /> 364 - <Tool 365 - Name="VCResourceCompilerTool" 366 - /> 367 - <Tool 368 - Name="VCPreLinkEventTool" 369 - /> 370 - <Tool 371 - Name="VCLinkerTool" 372 - AdditionalDependencies="$libs" 373 - AdditionalOptions="$lflags" 374 - LinkIncremental="2" 375 - GenerateDebugInformation="true" 376 - SubSystem="1" 377 - TargetMachine="1" 378 - /> 379 - <Tool 380 - Name="VCALinkTool" 381 - /> 382 - <Tool 383 - Name="VCXDCMakeTool" 384 - /> 385 - <Tool 386 - Name="VCBscMakeTool" 387 - /> 388 - <Tool 389 - Name="VCFxCopTool" 390 - /> 391 - <Tool 392 - Name="VCPostBuildEventTool" 393 - /> 394 - </Configuration> 395 - <Configuration 396 - Name="Release|Win32" 397 - OutputDirectory="$rel_dir" 398 - ConfigurationType="1" 399 - CharacterSet="0" 400 - WholeProgramOptimization="1" 401 - IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)" 402 - > 403 - <Tool 404 - Name="VCPreBuildEventTool" 405 - /> 406 - <Tool 407 - Name="VCCustomBuildTool" 408 - /> 409 - <Tool 410 - Name="VCXMLDataGeneratorTool" 411 - /> 412 - <Tool 413 - Name="VCMIDLTool" 414 - /> 415 - <Tool 416 - Name="VCCLCompilerTool" 417 - AdditionalOptions="$cflags_release" 418 - Optimization="2" 419 - InlineFunctionExpansion="1" 420 - EnableIntrinsicFunctions="true" 421 - AdditionalIncludeDirectories="$includes" 422 - PreprocessorDefinitions="WIN32,NDEBUG,$defines" 423 - RuntimeLibrary="0" 424 - EnableFunctionLevelLinking="true" 425 - UsePrecompiledHeader="0" 426 - ProgramDataBaseFileName="\$(IntDir)\\\$(TargetName).pdb" 427 - WarningLevel="3" 428 - DebugInformationFormat="3" 429 - /> 430 - <Tool 431 - Name="VCManagedResourceCompilerTool" 432 - /> 433 - <Tool 434 - Name="VCResourceCompilerTool" 435 - /> 436 - <Tool 437 - Name="VCPreLinkEventTool" 438 - /> 439 - <Tool 440 - Name="VCLinkerTool" 441 - AdditionalDependencies="$libs" 442 - AdditionalOptions="$lflags" 443 - LinkIncremental="1" 444 - GenerateDebugInformation="true" 445 - SubSystem="1" 446 - TargetMachine="1" 447 - OptimizeReferences="2" 448 - EnableCOMDATFolding="2" 449 - /> 450 - <Tool 451 - Name="VCALinkTool" 452 - /> 453 - <Tool 454 - Name="VCXDCMakeTool" 455 - /> 456 - <Tool 457 - Name="VCBscMakeTool" 458 - /> 459 - <Tool 460 - Name="VCFxCopTool" 461 - /> 462 - <Tool 463 - Name="VCPostBuildEventTool" 464 - /> 465 - </Configuration> 466 - </Configurations> 467 - <Files> 468 - <Filter 469 - Name="Source Files" 470 - Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" 471 - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 472 - EOM 473 - foreach(@sources) { 474 - print F << "EOM"; 475 - <File 476 - RelativePath="$_"/> 477 - EOM 478 - } 479 - print F << "EOM"; 480 - </Filter> 481 - </Files> 482 - <Globals> 483 - </Globals> 484 - </VisualStudioProject> 485 - EOM 486 - close F; 487 - } 488 - 489 - sub createGlueProject { 490 - my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; 491 - print "Generate solutions file\n"; 492 - $rel_dir = "..\\$rel_dir"; 493 - $rel_dir =~ s/\//\\/g; 494 - my $SLN_HEAD = "Microsoft Visual Studio Solution File, Format Version 10.00\n# Visual Studio 2008\n"; 495 - my $SLN_PRE = "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = "; 496 - my $SLN_POST = "\nEndProject\n"; 497 - 498 - my @libs = @{$build_structure{"LIBS"}}; 499 - my @tmp; 500 - foreach (@libs) { 501 - $_ =~ s/\//_/g; 502 - $_ =~ s/\.a//; 503 - push(@tmp, $_); 504 - } 505 - @libs = @tmp; 506 - 507 - my @apps = @{$build_structure{"APPS"}}; 508 - @tmp = (); 509 - foreach (@apps) { 510 - $_ =~ s/\//_/g; 511 - $_ =~ s/\.exe//; 512 - if ($_ eq "git" ) { 513 - unshift(@tmp, $_); 514 - } else { 515 - push(@tmp, $_); 516 - } 517 - } 518 - @apps = @tmp; 519 - 520 - open F, ">git.sln" || die "Could not open git.sln for writing!\n"; 521 - binmode F, ":crlf"; 522 - print F "$SLN_HEAD"; 523 - 524 - my $uuid_libgit = $build_structure{"LIBS_libgit_GUID"}; 525 - my $uuid_xdiff_lib = $build_structure{"LIBS_xdiff_lib_GUID"}; 526 - foreach (@apps) { 527 - my $appname = $_; 528 - my $uuid = $build_structure{"APPS_${appname}_GUID"}; 529 - print F "$SLN_PRE"; 530 - print F "\"${appname}\", \"${appname}\\${appname}.vcproj\", \"${uuid}\"\n"; 531 - print F " ProjectSection(ProjectDependencies) = postProject\n"; 532 - print F " ${uuid_libgit} = ${uuid_libgit}\n"; 533 - print F " ${uuid_xdiff_lib} = ${uuid_xdiff_lib}\n"; 534 - print F " EndProjectSection"; 535 - print F "$SLN_POST"; 536 - } 537 - foreach (@libs) { 538 - my $libname = $_; 539 - my $uuid = $build_structure{"LIBS_${libname}_GUID"}; 540 - print F "$SLN_PRE"; 541 - print F "\"${libname}\", \"${libname}\\${libname}.vcproj\", \"${uuid}\""; 542 - print F "$SLN_POST"; 543 - } 544 - 545 - print F << "EOM"; 546 - Global 547 - GlobalSection(SolutionConfigurationPlatforms) = preSolution 548 - Debug|Win32 = Debug|Win32 549 - Release|Win32 = Release|Win32 550 - EndGlobalSection 551 - EOM 552 - print F << "EOM"; 553 - GlobalSection(ProjectConfigurationPlatforms) = postSolution 554 - EOM 555 - foreach (@apps) { 556 - my $appname = $_; 557 - my $uuid = $build_structure{"APPS_${appname}_GUID"}; 558 - print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n"; 559 - print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n"; 560 - print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n"; 561 - print F "\t\t${uuid}.Release|Win32.Build.0 = Release|Win32\n"; 562 - } 563 - foreach (@libs) { 564 - my $libname = $_; 565 - my $uuid = $build_structure{"LIBS_${libname}_GUID"}; 566 - print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n"; 567 - print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n"; 568 - print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n"; 569 - print F "\t\t${uuid}.Release|Win32.Build.0 = Release|Win32\n"; 570 - } 571 - 572 - print F << "EOM"; 573 - EndGlobalSection 574 - EndGlobal 575 - EOM 576 - close F; 577 - } 578 - 579 - 1;
-402
contrib/buildsystems/Generators/Vcxproj.pm
··· 1 - package Generators::Vcxproj; 2 - require Exporter; 3 - 4 - use strict; 5 - use vars qw($VERSION); 6 - use Digest::SHA qw(sha256_hex); 7 - 8 - our $VERSION = '1.00'; 9 - our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE); 10 - @ISA = qw(Exporter); 11 - 12 - BEGIN { 13 - push @EXPORT_OK, qw(generate); 14 - } 15 - 16 - sub generate_guid ($) { 17 - my $hex = sha256_hex($_[0]); 18 - $hex =~ s/^(.{8})(.{4})(.{4})(.{4})(.{12}).*/{$1-$2-$3-$4-$5}/; 19 - $hex =~ tr/a-z/A-Z/; 20 - return $hex; 21 - } 22 - 23 - sub generate { 24 - my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; 25 - my @libs = @{$build_structure{"LIBS"}}; 26 - foreach (@libs) { 27 - createProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure, 1); 28 - } 29 - 30 - my @apps = @{$build_structure{"APPS"}}; 31 - foreach (@apps) { 32 - createProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure, 0); 33 - } 34 - 35 - createGlueProject($git_dir, $out_dir, $rel_dir, %build_structure); 36 - return 0; 37 - } 38 - 39 - sub createProject { 40 - my ($name, $git_dir, $out_dir, $rel_dir, $build_structure, $static_library) = @_; 41 - my $label = $static_library ? "lib" : "app"; 42 - my $prefix = $static_library ? "LIBS_" : "APPS_"; 43 - my $config_type = $static_library ? "StaticLibrary" : "Application"; 44 - print "Generate $name vcxproj $label project\n"; 45 - my $cdup = $name; 46 - $cdup =~ s/[^\/]+/../g; 47 - $cdup =~ s/\//\\/g; 48 - $rel_dir = $rel_dir eq "." ? $cdup : "$cdup\\$rel_dir"; 49 - $rel_dir =~ s/\//\\/g; 50 - 51 - my $target = $name; 52 - if ($static_library) { 53 - $target =~ s/\.a//; 54 - } else { 55 - $target =~ s/\.exe//; 56 - } 57 - 58 - my $uuid = generate_guid($name); 59 - $$build_structure{"$prefix${target}_GUID"} = $uuid; 60 - my $vcxproj = $target; 61 - $vcxproj =~ s/(.*\/)?(.*)/$&\/$2.vcxproj/; 62 - $vcxproj =~ s/([^\/]*)(\/lib)\/(lib.vcxproj)/$1$2\/$1_$3/; 63 - $$build_structure{"$prefix${target}_VCXPROJ"} = $vcxproj; 64 - 65 - my @srcs = sort(map("$rel_dir\\$_", @{$$build_structure{"$prefix${name}_SOURCES"}})); 66 - my @sources; 67 - foreach (@srcs) { 68 - $_ =~ s/\//\\/g; 69 - push(@sources, $_); 70 - } 71 - my $defines = join(";", sort(@{$$build_structure{"$prefix${name}_DEFINES"}})); 72 - my $includes= join(";", sort(map { s/^-I//; s/\//\\/g; File::Spec->file_name_is_absolute($_) ? $_ : "$rel_dir\\$_" } @{$$build_structure{"$prefix${name}_INCLUDES"}})); 73 - my $cflags = join(" ", sort(map { s/^-[GLMOWZ].*//; s/.* .*/"$&"/; $_; } @{$$build_structure{"$prefix${name}_CFLAGS"}})); 74 - $cflags =~ s/</&lt;/g; 75 - $cflags =~ s/>/&gt;/g; 76 - 77 - my $libs_release = "\n "; 78 - my $libs_debug = "\n "; 79 - if (!$static_library && $name ne 'headless-git') { 80 - $libs_release = join(";", sort(grep /^(?!libgit\.lib|xdiff\/lib\.lib|vcs-svn\/lib\.lib|reftable\/libreftable\.lib)/, @{$$build_structure{"$prefix${name}_LIBS"}})); 81 - $libs_debug = $libs_release; 82 - $libs_debug =~ s/zlib\.lib/zlibd\.lib/g; 83 - $libs_debug =~ s/libexpat\.lib/libexpatd\.lib/g; 84 - $libs_debug =~ s/libcurl\.lib/libcurl-d\.lib/g; 85 - } 86 - 87 - $defines =~ s/-D//g; 88 - $defines =~ s/</&lt;/g; 89 - $defines =~ s/>/&gt;/g; 90 - $defines =~ s/\'//g; 91 - 92 - die "Could not create the directory $target for $label project!\n" unless (-d "$target" || mkdir "$target"); 93 - 94 - open F, ">$vcxproj" or die "Could not open $vcxproj for writing!\n"; 95 - binmode F, ":crlf :utf8"; 96 - print F chr(0xFEFF); 97 - print F << "EOM"; 98 - <?xml version="1.0" encoding="utf-8"?> 99 - <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 100 - <ItemGroup Label="ProjectConfigurations"> 101 - <ProjectConfiguration Include="Debug|Win32"> 102 - <Configuration>Debug</Configuration> 103 - <Platform>Win32</Platform> 104 - </ProjectConfiguration> 105 - <ProjectConfiguration Include="Release|Win32"> 106 - <Configuration>Release</Configuration> 107 - <Platform>Win32</Platform> 108 - </ProjectConfiguration> 109 - <ProjectConfiguration Include="Debug|x64"> 110 - <Configuration>Debug</Configuration> 111 - <Platform>x64</Platform> 112 - </ProjectConfiguration> 113 - <ProjectConfiguration Include="Release|x64"> 114 - <Configuration>Release</Configuration> 115 - <Platform>x64</Platform> 116 - </ProjectConfiguration> 117 - </ItemGroup> 118 - <PropertyGroup Label="Globals"> 119 - <ProjectGuid>$uuid</ProjectGuid> 120 - <Keyword>Win32Proj</Keyword> 121 - <VCPKGArch Condition="'\$(Platform)'=='Win32'">x86-windows</VCPKGArch> 122 - <VCPKGArch Condition="'\$(Platform)'!='Win32'">x64-windows</VCPKGArch> 123 - <VCPKGArchDirectory>$cdup\\compat\\vcbuild\\vcpkg\\installed\\\$(VCPKGArch)</VCPKGArchDirectory> 124 - <VCPKGBinDirectory Condition="'\$(Configuration)'=='Debug'">\$(VCPKGArchDirectory)\\debug\\bin</VCPKGBinDirectory> 125 - <VCPKGLibDirectory Condition="'\$(Configuration)'=='Debug'">\$(VCPKGArchDirectory)\\debug\\lib</VCPKGLibDirectory> 126 - <VCPKGBinDirectory Condition="'\$(Configuration)'!='Debug'">\$(VCPKGArchDirectory)\\bin</VCPKGBinDirectory> 127 - <VCPKGLibDirectory Condition="'\$(Configuration)'!='Debug'">\$(VCPKGArchDirectory)\\lib</VCPKGLibDirectory> 128 - <VCPKGIncludeDirectory>\$(VCPKGArchDirectory)\\include</VCPKGIncludeDirectory> 129 - <VCPKGLibs Condition="'\$(Configuration)'=='Debug'">$libs_debug</VCPKGLibs> 130 - <VCPKGLibs Condition="'\$(Configuration)'!='Debug'">$libs_release</VCPKGLibs> 131 - </PropertyGroup> 132 - <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.Default.props" /> 133 - <PropertyGroup Condition="'\$(Configuration)'=='Debug'" Label="Configuration"> 134 - <UseDebugLibraries>true</UseDebugLibraries> 135 - <LinkIncremental>true</LinkIncremental> 136 - </PropertyGroup> 137 - <PropertyGroup Condition="'\$(Configuration)'=='Release'" Label="Configuration"> 138 - <UseDebugLibraries>false</UseDebugLibraries> 139 - <WholeProgramOptimization>true</WholeProgramOptimization> 140 - </PropertyGroup> 141 - <PropertyGroup> 142 - <ConfigurationType>$config_type</ConfigurationType> 143 - <PlatformToolset>v140</PlatformToolset> 144 - <!-- <CharacterSet>UTF-8</CharacterSet> --> 145 - <OutDir>..\\</OutDir> 146 - <!-- <IntDir>\$(ProjectDir)\$(Configuration)\\</IntDir> --> 147 - </PropertyGroup> 148 - <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.props" /> 149 - <ImportGroup Label="ExtensionSettings"> 150 - </ImportGroup> 151 - <ImportGroup Label="Shared"> 152 - </ImportGroup> 153 - <ImportGroup Label="PropertySheets"> 154 - <Import Project="\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props" Condition="exists('\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props')" Label="LocalAppDataPlatform" /> 155 - </ImportGroup> 156 - <PropertyGroup Label="UserMacros" /> 157 - <PropertyGroup> 158 - <GenerateManifest>false</GenerateManifest> 159 - <EnableManagedIncrementalBuild>true</EnableManagedIncrementalBuild> 160 - </PropertyGroup> 161 - <ItemDefinitionGroup> 162 - <ClCompile> 163 - <AdditionalOptions>$cflags %(AdditionalOptions)</AdditionalOptions> 164 - <AdditionalIncludeDirectories>$cdup;$cdup\\compat;$cdup\\compat\\regex;$cdup\\compat\\win32;$cdup\\compat\\poll;$cdup\\compat\\vcbuild\\include;\$(VCPKGIncludeDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> 165 - <EnableParallelCodeGeneration /> 166 - <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> 167 - <PrecompiledHeader /> 168 - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> 169 - </ClCompile> 170 - <Lib> 171 - <SuppressStartupBanner>true</SuppressStartupBanner> 172 - </Lib> 173 - <Link> 174 - <AdditionalLibraryDirectories>\$(VCPKGLibDirectory);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> 175 - <AdditionalDependencies>\$(VCPKGLibs);\$(AdditionalDependencies)</AdditionalDependencies> 176 - <AdditionalOptions>invalidcontinue.obj %(AdditionalOptions)</AdditionalOptions> 177 - <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> 178 - <ManifestFile>$cdup\\compat\\win32\\git.manifest</ManifestFile> 179 - <SubSystem>Console</SubSystem> 180 - </Link> 181 - EOM 182 - if ($target eq 'libgit') { 183 - print F << "EOM"; 184 - <PreBuildEvent Condition="!Exists('$cdup\\compat\\vcbuild\\vcpkg\\installed\\\$(VCPKGArch)\\include\\openssl\\ssl.h')"> 185 - <Message>Initialize VCPKG</Message> 186 - <Command>del "$cdup\\compat\\vcbuild\\vcpkg"</Command> 187 - <Command>call "$cdup\\compat\\vcbuild\\vcpkg_install.bat"</Command> 188 - </PreBuildEvent> 189 - EOM 190 - } 191 - print F << "EOM"; 192 - </ItemDefinitionGroup> 193 - <ItemDefinitionGroup Condition="'\$(Platform)'=='Win32'"> 194 - <Link> 195 - <TargetMachine>MachineX86</TargetMachine> 196 - </Link> 197 - </ItemDefinitionGroup> 198 - <ItemDefinitionGroup Condition="'\$(Configuration)'=='Debug'"> 199 - <ClCompile> 200 - <Optimization>Disabled</Optimization> 201 - <PreprocessorDefinitions>WIN32;_DEBUG;$defines;%(PreprocessorDefinitions)</PreprocessorDefinitions> 202 - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> 203 - </ClCompile> 204 - <Link> 205 - <GenerateDebugInformation>true</GenerateDebugInformation> 206 - </Link> 207 - </ItemDefinitionGroup> 208 - <ItemDefinitionGroup Condition="'\$(Configuration)'=='Release'"> 209 - <ClCompile> 210 - <Optimization>MaxSpeed</Optimization> 211 - <IntrinsicFunctions>true</IntrinsicFunctions> 212 - <PreprocessorDefinitions>WIN32;NDEBUG;$defines;%(PreprocessorDefinitions)</PreprocessorDefinitions> 213 - <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> 214 - <FunctionLevelLinking>true</FunctionLevelLinking> 215 - <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> 216 - </ClCompile> 217 - <Link> 218 - <GenerateDebugInformation>true</GenerateDebugInformation> 219 - <EnableCOMDATFolding>true</EnableCOMDATFolding> 220 - <OptimizeReferences>true</OptimizeReferences> 221 - </Link> 222 - </ItemDefinitionGroup> 223 - <ItemGroup> 224 - EOM 225 - foreach(@sources) { 226 - print F << "EOM"; 227 - <ClCompile Include="$_" /> 228 - EOM 229 - } 230 - print F << "EOM"; 231 - </ItemGroup> 232 - EOM 233 - if ((!$static_library || $target =~ 'vcs-svn' || $target =~ 'xdiff') && !($name =~ /headless-git/)) { 234 - my $uuid_libgit = $$build_structure{"LIBS_libgit_GUID"}; 235 - my $uuid_libreftable = $$build_structure{"LIBS_reftable/libreftable_GUID"}; 236 - my $uuid_xdiff_lib = $$build_structure{"LIBS_xdiff/lib_GUID"}; 237 - 238 - print F << "EOM"; 239 - <ItemGroup> 240 - <ProjectReference Include="$cdup\\libgit\\libgit.vcxproj"> 241 - <Project>$uuid_libgit</Project> 242 - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> 243 - </ProjectReference> 244 - EOM 245 - if (!($name =~ /xdiff|libreftable/)) { 246 - print F << "EOM"; 247 - <ProjectReference Include="$cdup\\reftable\\libreftable\\libreftable.vcxproj"> 248 - <Project>$uuid_libreftable</Project> 249 - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> 250 - </ProjectReference> 251 - EOM 252 - } 253 - if (!($name =~ 'xdiff')) { 254 - print F << "EOM"; 255 - <ProjectReference Include="$cdup\\xdiff\\lib\\xdiff_lib.vcxproj"> 256 - <Project>$uuid_xdiff_lib</Project> 257 - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> 258 - </ProjectReference> 259 - EOM 260 - } 261 - if ($name =~ /(test-(line-buffer|svn-fe)|^git-remote-testsvn)\.exe$/) { 262 - my $uuid_vcs_svn_lib = $$build_structure{"LIBS_vcs-svn/lib_GUID"}; 263 - print F << "EOM"; 264 - <ProjectReference Include="$cdup\\vcs-svn\\lib\\vcs-svn_lib.vcxproj"> 265 - <Project>$uuid_vcs_svn_lib</Project> 266 - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> 267 - </ProjectReference> 268 - EOM 269 - } 270 - print F << "EOM"; 271 - </ItemGroup> 272 - EOM 273 - } 274 - print F << "EOM"; 275 - <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.targets" /> 276 - EOM 277 - if (!$static_library) { 278 - print F << "EOM"; 279 - <Target Name="${target}_AfterBuild" AfterTargets="AfterBuild"> 280 - <ItemGroup> 281 - <DLLsAndPDBs Include="\$(VCPKGBinDirectory)\\*.dll;\$(VCPKGBinDirectory)\\*.pdb" /> 282 - </ItemGroup> 283 - <Copy SourceFiles="@(DLLsAndPDBs)" DestinationFolder="\$(OutDir)" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" /> 284 - <MakeDir Directories="..\\templates\\blt\\branches" /> 285 - </Target> 286 - EOM 287 - } 288 - if ($target eq 'git') { 289 - print F " <Import Project=\"LinkOrCopyBuiltins.targets\" />\n"; 290 - } 291 - if ($target eq 'git-remote-http') { 292 - print F " <Import Project=\"LinkOrCopyRemoteHttp.targets\" />\n"; 293 - } 294 - print F << "EOM"; 295 - </Project> 296 - EOM 297 - close F; 298 - } 299 - 300 - sub createGlueProject { 301 - my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; 302 - print "Generate solutions file\n"; 303 - $rel_dir = "..\\$rel_dir"; 304 - $rel_dir =~ s/\//\\/g; 305 - my $SLN_HEAD = "Microsoft Visual Studio Solution File, Format Version 11.00\n# Visual Studio 2010\n"; 306 - my $SLN_PRE = "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = "; 307 - my $SLN_POST = "\nEndProject\n"; 308 - 309 - my @libs = @{$build_structure{"LIBS"}}; 310 - my @tmp; 311 - foreach (@libs) { 312 - $_ =~ s/\.a//; 313 - push(@tmp, $_); 314 - } 315 - @libs = @tmp; 316 - 317 - my @apps = @{$build_structure{"APPS"}}; 318 - @tmp = (); 319 - foreach (@apps) { 320 - $_ =~ s/\.exe//; 321 - if ($_ eq "git" ) { 322 - unshift(@tmp, $_); 323 - } else { 324 - push(@tmp, $_); 325 - } 326 - } 327 - @apps = @tmp; 328 - 329 - open F, ">git.sln" || die "Could not open git.sln for writing!\n"; 330 - binmode F, ":crlf :utf8"; 331 - print F chr(0xFEFF); 332 - print F "$SLN_HEAD"; 333 - 334 - foreach (@apps) { 335 - my $appname = $_; 336 - my $uuid = $build_structure{"APPS_${appname}_GUID"}; 337 - print F "$SLN_PRE"; 338 - my $vcxproj = $build_structure{"APPS_${appname}_VCXPROJ"}; 339 - $vcxproj =~ s/\//\\/g; 340 - $appname =~ s/.*\///; 341 - print F "\"${appname}\", \"${vcxproj}\", \"${uuid}\""; 342 - print F "$SLN_POST"; 343 - } 344 - foreach (@libs) { 345 - my $libname = $_; 346 - my $uuid = $build_structure{"LIBS_${libname}_GUID"}; 347 - print F "$SLN_PRE"; 348 - my $vcxproj = $build_structure{"LIBS_${libname}_VCXPROJ"}; 349 - $vcxproj =~ s/\//\\/g; 350 - $libname =~ s/\//_/g; 351 - print F "\"${libname}\", \"${vcxproj}\", \"${uuid}\""; 352 - print F "$SLN_POST"; 353 - } 354 - 355 - print F << "EOM"; 356 - Global 357 - GlobalSection(SolutionConfigurationPlatforms) = preSolution 358 - Debug|x64 = Debug|x64 359 - Debug|x86 = Debug|x86 360 - Release|x64 = Release|x64 361 - Release|x86 = Release|x86 362 - EndGlobalSection 363 - EOM 364 - print F << "EOM"; 365 - GlobalSection(ProjectConfigurationPlatforms) = postSolution 366 - EOM 367 - foreach (@apps) { 368 - my $appname = $_; 369 - my $uuid = $build_structure{"APPS_${appname}_GUID"}; 370 - print F "\t\t${uuid}.Debug|x64.ActiveCfg = Debug|x64\n"; 371 - print F "\t\t${uuid}.Debug|x64.Build.0 = Debug|x64\n"; 372 - print F "\t\t${uuid}.Debug|x86.ActiveCfg = Debug|Win32\n"; 373 - print F "\t\t${uuid}.Debug|x86.Build.0 = Debug|Win32\n"; 374 - print F "\t\t${uuid}.Release|x64.ActiveCfg = Release|x64\n"; 375 - print F "\t\t${uuid}.Release|x64.Build.0 = Release|x64\n"; 376 - print F "\t\t${uuid}.Release|x86.ActiveCfg = Release|Win32\n"; 377 - print F "\t\t${uuid}.Release|x86.Build.0 = Release|Win32\n"; 378 - } 379 - foreach (@libs) { 380 - my $libname = $_; 381 - my $uuid = $build_structure{"LIBS_${libname}_GUID"}; 382 - print F "\t\t${uuid}.Debug|x64.ActiveCfg = Debug|x64\n"; 383 - print F "\t\t${uuid}.Debug|x64.Build.0 = Debug|x64\n"; 384 - print F "\t\t${uuid}.Debug|x86.ActiveCfg = Debug|Win32\n"; 385 - print F "\t\t${uuid}.Debug|x86.Build.0 = Debug|Win32\n"; 386 - print F "\t\t${uuid}.Release|x64.ActiveCfg = Release|x64\n"; 387 - print F "\t\t${uuid}.Release|x64.Build.0 = Release|x64\n"; 388 - print F "\t\t${uuid}.Release|x86.ActiveCfg = Release|Win32\n"; 389 - print F "\t\t${uuid}.Release|x86.Build.0 = Release|Win32\n"; 390 - } 391 - 392 - print F << "EOM"; 393 - EndGlobalSection 394 - GlobalSection(SolutionProperties) = preSolution 395 - HideSolutionNode = FALSE 396 - EndGlobalSection 397 - EndGlobal 398 - EOM 399 - close F; 400 - } 401 - 402 - 1;
-395
contrib/buildsystems/engine.pl
··· 1 - #!/usr/bin/perl -w 2 - ###################################################################### 3 - # Do not call this script directly! 4 - # 5 - # The generate script ensures that @INC is correct before the engine 6 - # is executed. 7 - # 8 - # Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com> 9 - ###################################################################### 10 - use strict; 11 - use File::Basename; 12 - use File::Spec; 13 - use Cwd; 14 - use Generators; 15 - use Text::ParseWords; 16 - 17 - my (%build_structure, %compile_options, @makedry); 18 - my $out_dir = getcwd(); 19 - my $git_dir = $out_dir; 20 - $git_dir =~ s=\\=/=g; 21 - $git_dir = dirname($git_dir) while (!-e "$git_dir/git.c" && "$git_dir" ne ""); 22 - die "Couldn't find Git repo" if ("$git_dir" eq ""); 23 - 24 - my @gens = Generators::available(); 25 - my $gen = "Vcproj"; 26 - 27 - sub showUsage 28 - { 29 - my $genlist = join(', ', @gens); 30 - print << "EOM"; 31 - generate usage: 32 - -g <GENERATOR> --gen <GENERATOR> Specify the buildsystem generator (default: $gen) 33 - Available: $genlist 34 - -o <PATH> --out <PATH> Specify output directory generation (default: .) 35 - --make-out <PATH> Write the output of GNU Make into a file 36 - -i <FILE> --in <FILE> Specify input file, instead of running GNU Make 37 - -h,-? --help This help 38 - EOM 39 - exit 0; 40 - } 41 - 42 - # Parse command-line options 43 - my $make_out; 44 - while (@ARGV) { 45 - my $arg = shift @ARGV; 46 - if ("$arg" eq "-h" || "$arg" eq "--help" || "$arg" eq "-?") { 47 - showUsage(); 48 - exit(0); 49 - } elsif("$arg" eq "--out" || "$arg" eq "-o") { 50 - $out_dir = shift @ARGV; 51 - } elsif("$arg" eq "--make-out") { 52 - $make_out = shift @ARGV; 53 - } elsif("$arg" eq "--gen" || "$arg" eq "-g") { 54 - $gen = shift @ARGV; 55 - } elsif("$arg" eq "--in" || "$arg" eq "-i") { 56 - my $infile = shift @ARGV; 57 - open(F, "<$infile") || die "Couldn't open file $infile"; 58 - @makedry = <F>; 59 - close(F); 60 - } else { 61 - die "Unknown option: " . $arg; 62 - } 63 - } 64 - 65 - # NOT using File::Spec->rel2abs($path, $base) here, as 66 - # it fails badly for me in the msysgit environment 67 - $git_dir = File::Spec->rel2abs($git_dir); 68 - $out_dir = File::Spec->rel2abs($out_dir); 69 - my $rel_dir = makeOutRel2Git($git_dir, $out_dir); 70 - 71 - # Print some information so the user feels informed 72 - print << "EOM"; 73 - ----- 74 - Generator: $gen 75 - Git dir: $git_dir 76 - Out dir: $out_dir 77 - ----- 78 - Running GNU Make to figure out build structure... 79 - EOM 80 - 81 - # Pipe a make --dry-run into a variable, if not already loaded from file 82 - # Capture the make dry stderr to file for review (will be empty for a release build). 83 - 84 - my $ErrsFile = "msvc-build-makedryerrors.txt"; 85 - @makedry = `make -C $git_dir -n MSVC=1 SKIP_VCPKG=1 V=1 2>$ErrsFile` 86 - if !@makedry; 87 - # test for an empty Errors file and remove it 88 - unlink $ErrsFile if -f -z $ErrsFile; 89 - 90 - if (defined $make_out) { 91 - open OUT, ">" . $make_out; 92 - print OUT @makedry; 93 - close OUT; 94 - } 95 - 96 - # Parse the make output into usable info 97 - parseMakeOutput(); 98 - 99 - # Finally, ask the generator to start generating.. 100 - Generators::generate($gen, $git_dir, $out_dir, $rel_dir, %build_structure); 101 - 102 - # main flow ends here 103 - # ------------------------------------------------------------------------------------------------- 104 - 105 - 106 - # 1) path: /foo/bar/baz 2) path: /foo/bar/baz 3) path: /foo/bar/baz 107 - # base: /foo/bar/baz/temp base: /foo/bar base: /tmp 108 - # rel: .. rel: baz rel: ../foo/bar/baz 109 - sub makeOutRel2Git 110 - { 111 - my ($path, $base) = @_; 112 - my $rel; 113 - if ("$path" eq "$base") { 114 - return "."; 115 - } elsif ($base =~ /^$path/) { 116 - # case 1 117 - my $tmp = $base; 118 - $tmp =~ s/^$path//; 119 - foreach (split('/', $tmp)) { 120 - $rel .= "../" if ("$_" ne ""); 121 - } 122 - } elsif ($path =~ /^$base/) { 123 - # case 2 124 - $rel = $path; 125 - $rel =~ s/^$base//; 126 - $rel = "./$rel"; 127 - } else { 128 - my $tmp = $base; 129 - foreach (split('/', $tmp)) { 130 - $rel .= "../" if ("$_" ne ""); 131 - } 132 - $rel .= $path; 133 - } 134 - $rel =~ s/\/\//\//g; # simplify 135 - $rel =~ s/\/$//; # don't end with / 136 - return $rel; 137 - } 138 - 139 - sub parseMakeOutput 140 - { 141 - print "Parsing GNU Make output to figure out build structure...\n"; 142 - my $line = 0; 143 - while (my $text = shift @makedry) { 144 - my $ate_next; 145 - do { 146 - $ate_next = 0; 147 - $line++; 148 - chomp $text; 149 - chop $text if ($text =~ /\r$/); 150 - if ($text =~ /\\$/) { 151 - $text =~ s/\\$//; 152 - $text .= shift @makedry; 153 - $ate_next = 1; 154 - } 155 - } while($ate_next); 156 - 157 - if ($text =~ /^test /) { 158 - # options to test (eg -o) may be mistaken for linker options 159 - next; 160 - } 161 - 162 - if ($text =~ /^(mkdir|msgfmt) /) { 163 - # options to the Portable Object translations 164 - # the line "mkdir ... && msgfmt ..." contains no linker options 165 - next; 166 - } 167 - 168 - if($text =~ / -c /) { 169 - # compilation 170 - handleCompileLine($text, $line); 171 - 172 - } elsif ($text =~ / -o /) { 173 - # linking executable 174 - handleLinkLine($text, $line); 175 - 176 - } elsif ($text =~ /\.o / && $text =~ /\.a /) { 177 - # libifying 178 - handleLibLine($text, $line); 179 - # 180 - # } elsif ($text =~ /^cp /) { 181 - # # copy file around 182 - # 183 - # } elsif ($text =~ /^rm -f /) { 184 - # # shell command 185 - # 186 - # } elsif ($text =~ /^make[ \[]/) { 187 - # # make output 188 - # 189 - # } elsif ($text =~ /^echo /) { 190 - # # echo to file 191 - # 192 - # } elsif ($text =~ /^if /) { 193 - # # shell conditional 194 - # 195 - # } elsif ($text =~ /^tclsh /) { 196 - # # translation stuff 197 - # 198 - # } elsif ($text =~ /^umask /) { 199 - # # handling boilerplates 200 - # 201 - # } elsif ($text =~ /\$\(\:\)/) { 202 - # # ignore 203 - # 204 - # } elsif ($text =~ /^FLAGS=/) { 205 - # # flags check for dependencies 206 - # 207 - # } elsif ($text =~ /^'\/usr\/bin\/perl' -MError -e/) { 208 - # # perl commands for copying files 209 - # 210 - # } elsif ($text =~ /generate-cmdlist\.sh/) { 211 - # # command for generating list of commands 212 - # 213 - # } elsif ($text =~ /new locations or Tcl/) { 214 - # # command for detecting Tcl/Tk changes 215 - # 216 - # } elsif ($text =~ /mkdir -p/) { 217 - # # command creating path 218 - # 219 - # } elsif ($text =~ /: no custom templates yet/) { 220 - # # whatever 221 - # 222 - # } else { 223 - # print "Unhandled (line: $line): $text\n"; 224 - } 225 - } 226 - 227 - # use Data::Dumper; 228 - # print "Parsed build structure:\n"; 229 - # print Dumper(%build_structure); 230 - } 231 - 232 - # variables for the compilation part of each step 233 - my (@defines, @incpaths, @cflags, @sources); 234 - 235 - sub clearCompileStep 236 - { 237 - @defines = (); 238 - @incpaths = (); 239 - @cflags = (); 240 - @sources = (); 241 - } 242 - 243 - sub removeDuplicates 244 - { 245 - my (%dupHash, $entry); 246 - %dupHash = map { $_, 1 } @defines; 247 - @defines = keys %dupHash; 248 - 249 - %dupHash = map { $_, 1 } @incpaths; 250 - @incpaths = keys %dupHash; 251 - 252 - %dupHash = map { $_, 1 } @cflags; 253 - @cflags = keys %dupHash; 254 - } 255 - 256 - sub handleCompileLine 257 - { 258 - my ($line, $lineno) = @_; 259 - my @parts = shellwords($line); 260 - my $sourcefile; 261 - shift(@parts); # ignore cmd 262 - while (my $part = shift @parts) { 263 - if ("$part" eq "-o") { 264 - # ignore object file 265 - shift @parts; 266 - } elsif ("$part" eq "-c") { 267 - # ignore compile flag 268 - } elsif ("$part" eq "-c") { 269 - } elsif ($part =~ /^.?-I/) { 270 - push(@incpaths, $part); 271 - } elsif ($part =~ /^.?-D/) { 272 - push(@defines, $part); 273 - } elsif ($part =~ /^-/) { 274 - push(@cflags, $part); 275 - } elsif ($part =~ /\.(c|cc|cpp)$/) { 276 - $sourcefile = $part; 277 - } else { 278 - die "Unhandled compiler option @ line $lineno: $part"; 279 - } 280 - } 281 - @{$compile_options{"${sourcefile}_CFLAGS"}} = @cflags; 282 - @{$compile_options{"${sourcefile}_DEFINES"}} = @defines; 283 - @{$compile_options{"${sourcefile}_INCPATHS"}} = @incpaths; 284 - clearCompileStep(); 285 - } 286 - 287 - sub handleLibLine 288 - { 289 - my ($line, $lineno) = @_; 290 - my (@objfiles, @lflags, $libout, $part); 291 - # kill cmd and rm 'prefix' 292 - $line =~ s/^rm -f .* && .* rcs //; 293 - my @parts = shellwords($line); 294 - while ($part = shift @parts) { 295 - if ($part =~ /^-/) { 296 - push(@lflags, $part); 297 - } elsif ($part =~ /\.(o|obj)$/) { 298 - push(@objfiles, $part); 299 - } elsif ($part =~ /\.(a|lib)$/) { 300 - $libout = $part; 301 - $libout =~ s/\.a$//; 302 - } else { 303 - die "Unhandled lib option @ line $lineno: $part"; 304 - } 305 - } 306 - # print "LibOut: '$libout'\nLFlags: @lflags\nOfiles: @objfiles\n"; 307 - # exit(1); 308 - foreach (@objfiles) { 309 - my $sourcefile = $_; 310 - $sourcefile =~ s/\.o$/.c/; 311 - push(@sources, $sourcefile); 312 - push(@cflags, @{$compile_options{"${sourcefile}_CFLAGS"}}); 313 - push(@defines, @{$compile_options{"${sourcefile}_DEFINES"}}); 314 - push(@incpaths, @{$compile_options{"${sourcefile}_INCPATHS"}}); 315 - } 316 - removeDuplicates(); 317 - 318 - push(@{$build_structure{"LIBS"}}, $libout); 319 - @{$build_structure{"LIBS_${libout}"}} = ("_DEFINES", "_INCLUDES", "_CFLAGS", "_SOURCES", 320 - "_OBJECTS"); 321 - @{$build_structure{"LIBS_${libout}_DEFINES"}} = @defines; 322 - @{$build_structure{"LIBS_${libout}_INCLUDES"}} = @incpaths; 323 - @{$build_structure{"LIBS_${libout}_CFLAGS"}} = @cflags; 324 - @{$build_structure{"LIBS_${libout}_LFLAGS"}} = @lflags; 325 - @{$build_structure{"LIBS_${libout}_SOURCES"}} = @sources; 326 - @{$build_structure{"LIBS_${libout}_OBJECTS"}} = @objfiles; 327 - clearCompileStep(); 328 - } 329 - 330 - sub handleLinkLine 331 - { 332 - my ($line, $lineno) = @_; 333 - my (@objfiles, @lflags, @libs, $appout, $part); 334 - my @parts = shellwords($line); 335 - shift(@parts); # ignore cmd 336 - while ($part = shift @parts) { 337 - if ($part =~ /^-IGNORE/) { 338 - push(@lflags, $part); 339 - } elsif ($part =~ /^-[GRIMDO]/) { 340 - # eat compiler flags 341 - } elsif ("$part" eq "-o") { 342 - $appout = shift @parts; 343 - } elsif ("$part" eq "-lz") { 344 - push(@libs, "zlib.lib"); 345 - } elsif ("$part" eq "-lcrypto") { 346 - push(@libs, "libcrypto.lib"); 347 - } elsif ("$part" eq "-lssl") { 348 - push(@libs, "libssl.lib"); 349 - } elsif ("$part" eq "-lcurl") { 350 - push(@libs, "libcurl.lib"); 351 - } elsif ("$part" eq "-lexpat") { 352 - push(@libs, "libexpat.lib"); 353 - } elsif ("$part" eq "-liconv") { 354 - push(@libs, "iconv.lib"); 355 - } elsif ($part =~ /^[-\/]/) { 356 - push(@lflags, $part); 357 - } elsif ($part =~ /\.(a|lib)$/) { 358 - $part =~ s/\.a$/.lib/; 359 - push(@libs, $part); 360 - } elsif ($part eq 'invalidcontinue.obj') { 361 - # ignore - known to MSVC 362 - } elsif ($part =~ /\.o$/) { 363 - push(@objfiles, $part); 364 - } elsif ($part =~ /\.obj$/) { 365 - # do nothing, 'make' should not be producing .obj, only .o files 366 - } else { 367 - die "Unhandled link option @ line $lineno: $part"; 368 - } 369 - } 370 - # print "AppOut: '$appout'\nLFlags: @lflags\nLibs : @libs\nOfiles: @objfiles\n"; 371 - # exit(1); 372 - foreach (@objfiles) { 373 - my $sourcefile = $_; 374 - $sourcefile =~ s/^headless-git\.o$/compat\/win32\/headless.c/; 375 - $sourcefile =~ s/\.o$/.c/; 376 - push(@sources, $sourcefile); 377 - push(@cflags, @{$compile_options{"${sourcefile}_CFLAGS"}}); 378 - push(@defines, @{$compile_options{"${sourcefile}_DEFINES"}}); 379 - push(@incpaths, @{$compile_options{"${sourcefile}_INCPATHS"}}); 380 - } 381 - removeDuplicates(); 382 - 383 - removeDuplicates(); 384 - push(@{$build_structure{"APPS"}}, $appout); 385 - @{$build_structure{"APPS_${appout}"}} = ("_DEFINES", "_INCLUDES", "_CFLAGS", "_LFLAGS", 386 - "_SOURCES", "_OBJECTS", "_LIBS"); 387 - @{$build_structure{"APPS_${appout}_DEFINES"}} = @defines; 388 - @{$build_structure{"APPS_${appout}_INCLUDES"}} = @incpaths; 389 - @{$build_structure{"APPS_${appout}_CFLAGS"}} = @cflags; 390 - @{$build_structure{"APPS_${appout}_LFLAGS"}} = @lflags; 391 - @{$build_structure{"APPS_${appout}_SOURCES"}} = @sources; 392 - @{$build_structure{"APPS_${appout}_OBJECTS"}} = @objfiles; 393 - @{$build_structure{"APPS_${appout}_LIBS"}} = @libs; 394 - clearCompileStep(); 395 - }
-29
contrib/buildsystems/generate
··· 1 - #!/usr/bin/perl -w 2 - ###################################################################### 3 - # Generate buildsystem files 4 - # 5 - # This script generate buildsystem files based on the output of a 6 - # GNU Make --dry-run, enabling Windows users to develop Git with their 7 - # trusted IDE with native projects. 8 - # 9 - # Note: 10 - # It is not meant as *the* way of building Git with MSVC, but merely a 11 - # convenience. The correct way of building Git with MSVC is to use the 12 - # GNU Make tool to build with the maintained Makefile in the root of 13 - # the project. If you have the msysgit environment installed and 14 - # available in your current console, together with the Visual Studio 15 - # environment you wish to build for, all you have to do is run the 16 - # command: 17 - # make MSVC=1 18 - # 19 - # Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com> 20 - ###################################################################### 21 - use strict; 22 - use File::Basename; 23 - use Cwd; 24 - 25 - my $git_dir = getcwd(); 26 - $git_dir =~ s=\\=/=g; 27 - $git_dir = dirname($git_dir) while (!-e "$git_dir/git.c" && "$git_dir" ne ""); 28 - die "Couldn't find Git repo" if ("$git_dir" eq ""); 29 - exec join(" ", ("PERL5LIB=${git_dir}/contrib/buildsystems ${git_dir}/contrib/buildsystems/engine.pl", @ARGV));
-228
contrib/buildsystems/parse.pl
··· 1 - #!/usr/bin/perl -w 2 - ###################################################################### 3 - # Do not call this script directly! 4 - # 5 - # The generate script ensures that @INC is correct before the engine 6 - # is executed. 7 - # 8 - # Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com> 9 - ###################################################################### 10 - use strict; 11 - use File::Basename; 12 - use Cwd; 13 - 14 - my $file = $ARGV[0]; 15 - die "No file provided!" if !defined $file; 16 - 17 - my ($cflags, $target, $type, $line); 18 - 19 - open(F, "<$file") || die "Couldn't open file $file"; 20 - my @data = <F>; 21 - close(F); 22 - 23 - while (my $text = shift @data) { 24 - my $ate_next; 25 - do { 26 - $ate_next = 0; 27 - $line++; 28 - chomp $text; 29 - chop $text if ($text =~ /\r$/); 30 - if ($text =~ /\\$/) { 31 - $text =~ s/\\$//; 32 - $text .= shift @data; 33 - $ate_next = 1; 34 - } 35 - } while($ate_next); 36 - 37 - if($text =~ / -c /) { 38 - # compilation 39 - handleCompileLine($text, $line); 40 - 41 - } elsif ($text =~ / -o /) { 42 - # linking executable 43 - handleLinkLine($text, $line); 44 - 45 - } elsif ($text =~ /\.o / && $text =~ /\.a /) { 46 - # libifying 47 - handleLibLine($text, $line); 48 - 49 - # } elsif ($text =~ /^cp /) { 50 - # # copy file around 51 - # 52 - # } elsif ($text =~ /^rm -f /) { 53 - # # shell command 54 - # 55 - # } elsif ($text =~ /^make[ \[]/) { 56 - # # make output 57 - # 58 - # } elsif ($text =~ /^echo /) { 59 - # # echo to file 60 - # 61 - # } elsif ($text =~ /^if /) { 62 - # # shell conditional 63 - # 64 - # } elsif ($text =~ /^tclsh /) { 65 - # # translation stuff 66 - # 67 - # } elsif ($text =~ /^umask /) { 68 - # # handling boilerplates 69 - # 70 - # } elsif ($text =~ /\$\(\:\)/) { 71 - # # ignore 72 - # 73 - # } elsif ($text =~ /^FLAGS=/) { 74 - # # flags check for dependencies 75 - # 76 - # } elsif ($text =~ /^'\/usr\/bin\/perl' -MError -e/) { 77 - # # perl commands for copying files 78 - # 79 - # } elsif ($text =~ /generate-cmdlist\.sh/) { 80 - # # command for generating list of commands 81 - # 82 - # } elsif ($text =~ /^test / && $text =~ /|| rm -f /) { 83 - # # commands removing executables, if they exist 84 - # 85 - # } elsif ($text =~ /new locations or Tcl/) { 86 - # # command for detecting Tcl/Tk changes 87 - # 88 - # } elsif ($text =~ /mkdir -p/) { 89 - # # command creating path 90 - # 91 - # } elsif ($text =~ /: no custom templates yet/) { 92 - # # whatever 93 - 94 - } else { 95 - # print "Unhandled (line: $line): $text\n"; 96 - } 97 - } 98 - close(F); 99 - 100 - # use Data::Dumper; 101 - # print "Parsed build structure:\n"; 102 - # print Dumper(%build_structure); 103 - 104 - # ------------------------------------------------------------------- 105 - # Functions under here 106 - # ------------------------------------------------------------------- 107 - my (%build_structure, @defines, @incpaths, @cflags, @sources); 108 - 109 - sub clearCompileStep 110 - { 111 - @defines = (); 112 - @incpaths = (); 113 - @cflags = (); 114 - @sources = (); 115 - } 116 - 117 - sub removeDuplicates 118 - { 119 - my (%dupHash, $entry); 120 - %dupHash = map { $_, 1 } @defines; 121 - @defines = keys %dupHash; 122 - 123 - %dupHash = map { $_, 1 } @incpaths; 124 - @incpaths = keys %dupHash; 125 - 126 - %dupHash = map { $_, 1 } @cflags; 127 - @cflags = keys %dupHash; 128 - 129 - %dupHash = map { $_, 1 } @sources; 130 - @sources = keys %dupHash; 131 - } 132 - 133 - sub handleCompileLine 134 - { 135 - my ($line, $lineno) = @_; 136 - my @parts = split(' ', $line); 137 - shift(@parts); # ignore cmd 138 - while (my $part = shift @parts) { 139 - if ("$part" eq "-o") { 140 - # ignore object file 141 - shift @parts; 142 - } elsif ("$part" eq "-c") { 143 - # ignore compile flag 144 - } elsif ("$part" eq "-c") { 145 - } elsif ($part =~ /^.?-I/) { 146 - push(@incpaths, $part); 147 - } elsif ($part =~ /^.?-D/) { 148 - push(@defines, $part); 149 - } elsif ($part =~ /^-/) { 150 - push(@cflags, $part); 151 - } elsif ($part =~ /\.(c|cc|cpp)$/) { 152 - push(@sources, $part); 153 - } else { 154 - die "Unhandled compiler option @ line $lineno: $part"; 155 - } 156 - } 157 - #print "Sources: @sources\nCFlags: @cflags\nDefine: @defines\nIncpat: @incpaths\n"; 158 - #exit(1); 159 - } 160 - 161 - sub handleLibLine 162 - { 163 - my ($line, $lineno) = @_; 164 - my (@objfiles, @lflags, $libout, $part); 165 - # kill cmd and rm 'prefix' 166 - $line =~ s/^rm -f .* && .* rcs //; 167 - my @parts = split(' ', $line); 168 - while ($part = shift @parts) { 169 - if ($part =~ /^-/) { 170 - push(@lflags, $part); 171 - } elsif ($part =~ /\.(o|obj)$/) { 172 - push(@objfiles, $part); 173 - } elsif ($part =~ /\.(a|lib)$/) { 174 - $libout = $part; 175 - } else { 176 - die "Unhandled lib option @ line $lineno: $part"; 177 - } 178 - } 179 - #print "LibOut: '$libout'\nLFlags: @lflags\nOfiles: @objfiles\n"; 180 - #exit(1); 181 - removeDuplicates(); 182 - push(@{$build_structure{"LIBS"}}, $libout); 183 - @{$build_structure{"LIBS_${libout}"}} = ("_DEFINES", "_INCLUDES", "_CFLAGS", "_SOURCES", 184 - "_OBJECTS"); 185 - @{$build_structure{"LIBS_${libout}_DEFINES"}} = @defines; 186 - @{$build_structure{"LIBS_${libout}_INCLUDES"}} = @incpaths; 187 - @{$build_structure{"LIBS_${libout}_CFLAGS"}} = @cflags; 188 - @{$build_structure{"LIBS_${libout}_SOURCES"}} = @sources; 189 - @{$build_structure{"LIBS_${libout}_OBJECTS"}} = @objfiles; 190 - clearCompileStep(); 191 - } 192 - 193 - sub handleLinkLine 194 - { 195 - my ($line, $lineno) = @_; 196 - my (@objfiles, @lflags, @libs, $appout, $part); 197 - my @parts = split(' ', $line); 198 - shift(@parts); # ignore cmd 199 - while ($part = shift @parts) { 200 - if ($part =~ /^-[GRIDO]/) { 201 - # eat compiler flags 202 - } elsif ("$part" eq "-o") { 203 - $appout = shift @parts; 204 - } elsif ($part =~ /^-/) { 205 - push(@lflags, $part); 206 - } elsif ($part =~ /\.(a|lib)$/) { 207 - push(@libs, $part); 208 - } elsif ($part =~ /\.(o|obj)$/) { 209 - push(@objfiles, $part); 210 - } else { 211 - die "Unhandled lib option @ line $lineno: $part"; 212 - } 213 - } 214 - #print "AppOut: '$appout'\nLFlags: @lflags\nLibs : @libs\nOfiles: @objfiles\n"; 215 - #exit(1); 216 - removeDuplicates(); 217 - push(@{$build_structure{"APPS"}}, $appout); 218 - @{$build_structure{"APPS_${appout}"}} = ("_DEFINES", "_INCLUDES", "_CFLAGS", "_LFLAGS", 219 - "_SOURCES", "_OBJECTS", "_LIBS"); 220 - @{$build_structure{"APPS_${appout}_DEFINES"}} = @defines; 221 - @{$build_structure{"APPS_${appout}_INCLUDES"}} = @incpaths; 222 - @{$build_structure{"APPS_${appout}_CFLAGS"}} = @cflags; 223 - @{$build_structure{"APPS_${appout}_LFLAGS"}} = @lflags; 224 - @{$build_structure{"APPS_${appout}_SOURCES"}} = @sources; 225 - @{$build_structure{"APPS_${appout}_OBJECTS"}} = @objfiles; 226 - @{$build_structure{"APPS_${appout}_LIBS"}} = @libs; 227 - clearCompileStep(); 228 - }