Fixed .bat file to handle xcopy command not in path.
authorlateralusX <lateralusx.github@gmail.com>
Thu, 2 Jun 2016 09:34:15 +0000 (11:34 +0200)
committerlateralusX <lateralusx.github@gmail.com>
Wed, 15 Jun 2016 07:44:24 +0000 (09:44 +0200)
Also added support to not always replace config.h/version.h since that triggers
unnecessary rebuilds during development. New script will check if there is
an actual difference in the config.h/version.h file before doing the copy.

msvc/compare-config-content.ps1 [new file with mode: 0644]
msvc/compare-config-files.ps1 [new file with mode: 0644]
msvc/install.bat
msvc/libmono.bat
msvc/libmono.vcxproj
msvc/package.bat
msvc/winsetup.bat

diff --git a/msvc/compare-config-content.ps1 b/msvc/compare-config-content.ps1
new file mode 100644 (file)
index 0000000..0ed84ba
--- /dev/null
@@ -0,0 +1,51 @@
+##############################################################################
+##
+## compare-config-content
+##
+##############################################################################
+
+<#
+
+.SYNOPSIS
+
+Compares mono build configuration content detecting diff's.
+
+#>
+
+param(
+    ## first config source to compare.
+    $mono_config_source1,
+
+    ## second config source to compare.
+    $mono_config_source2
+)
+
+if ((Test-Path -isvalid $mono_config_source1) -And (Test-Path $mono_config_source1))
+{
+       $mono_config_source1_content = Get-Content $mono_config_source1
+}
+else
+{
+       $mono_config_source1_content = $mono_config_source1
+}
+
+if ((Test-Path -isvalid $mono_config_source2) -And (Test-Path $mono_config_source2))
+{
+       $mono_config_source2_content = Get-Content $mono_config_source2
+}
+else
+{
+       $mono_config_source2_content = $mono_config_source2
+}
+
+## Compare content.
+$comparedLines = Compare-Object $mono_config_source1_content $mono_config_source2_content -IncludeEqual | Sort-Object { $_.InputObject.ReadCount }
+$comparedLines | foreach {
+    if($_.SideIndicator -ne "==")
+    {
+               Write-Host "Changes detected."
+               exit 1;
+    }
+}
+
+exit 0;
\ No newline at end of file
diff --git a/msvc/compare-config-files.ps1 b/msvc/compare-config-files.ps1
new file mode 100644 (file)
index 0000000..9122f1e
--- /dev/null
@@ -0,0 +1,58 @@
+##############################################################################
+##
+## compare-config-files
+##
+##############################################################################
+
+<#
+
+.SYNOPSIS
+
+Compares mono build configuration files detecting incompatible changes.
+
+#>
+
+param(
+    ## winconfig header file.
+    $mono_winconfig,
+
+    ## config header file.
+    $mono_config,
+
+       ## The master configuration file, optional.
+       $mono_config_ac
+)
+
+## Get the content from each config file
+$mono_winconfig_content = Get-Content $mono_winconfig
+$mono_config_content = Get-Content $mono_config
+
+## Compare config files.
+$comparedLines = Compare-Object $mono_winconfig_content $mono_config_content -IncludeEqual | Sort-Object { $_.InputObject.ReadCount }
+
+$comparedLines | foreach {
+
+    if($_.SideIndicator -ne "==")
+    {
+               ##Look for diffs.
+               $mono_version = (Select-String -InputObject $_.InputObject -pattern '#define VERSION \"(.*)\"')
+               if ($mono_version -eq $null) {
+                       Write-Host "Changes detected, versions doesn't match. Configuration must to be replaced."
+                       exit 1;
+               }
+    }
+}
+
+if ($mono_config_ac -ne $null -And $mono_config_ac -ne "") {
+
+       $mono_version_ac = (Select-String -path $mono_config_ac -pattern 'AC_INIT\(mono, \[(.*)\]').Matches[0].Groups[1].Value
+       $mono_version = (Select-String -path $mono_config -pattern '#define VERSION \"(.*)\"').Matches[0].Groups[1].Value
+
+       if($mono_version_ac -ne $mono_version)
+       {
+               Write-Host "Changes detected, versions doesn't match. Configuration must to be replaced."
+               exit 1;
+       }
+}
+
+exit 0;
index 0baa5857f74701e0a0e6b23dc3d58222e0e7129c..1a433991a7d53c754281b49475de26e4b88d6cde 100644 (file)
@@ -6,8 +6,12 @@ SET BUILD_DIR=%3
 SET INSTALL_DIR=%4
 SET ARGUMENTS=%5
 
+SET XCOPY_COMMAND=%windir%\system32\xcopy
+
 SET BUILD_DIR=%BUILD_DIR:"=%
+SET BUILD_DIR=%BUILD_DIR:/=\%
 SET INSTALL_DIR=%INSTALL_DIR:"=%
+SET INSTALL_DIR=%INSTALL_DIR:/=\%
 
 IF "" == "%PLATFORM%" (
        ECHO Error: No platform parameter set.
@@ -33,18 +37,10 @@ IF "\" == "%BUILD_DIR:~-1%" (
        SET BUILD_DIR=%BUILD_DIR:~0,-1%
 )
 
-IF "/" == "%BUILD_DIR:~-1%" (
-       SET BUILD_DIR=%BUILD_DIR:~0,-1%
-)
-
 IF "\" == "%INSTALL_DIR:~-1%" (
        SET INSTALL_DIR=%INSTALL_DIR:~0,-1%
 )
 
-IF "/" == "%INSTALL_DIR:~-1%" (
-       SET INSTALL_DIR=%INSTALL_DIR:~0,-1%
-)
-
 IF NOT EXIST %BUILD_DIR% (
        ECHO Error: '%BUILD_DIR%', directory doesn't eixst.
        GOTO ON_ERROR
@@ -70,15 +66,15 @@ IF "-v" == "%ARGUMENTS%" (
 )
 
 IF "-q" == "%ARGUMENTS%" (
-       SET "OPTIONS=/s /e /q /y ^>nul"
+       SET "OPTIONS=/s /e /q /y"
 )
 
-ECHO Installing mono build %PLATFORM% %CONFIG% from %BUILD_DIR% into %INSTALL_DIR% ...
+ECHO Installing mono build %PLATFORM% %CONFIG% from %PACKAGE_DIR% into %INSTALL_DIR% ...
 
-SET RUN=xcopy "%PACKAGE_DIR%\*.*" "%INSTALL_DIR%" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%PACKAGE_DIR%\*.*" "%INSTALL_DIR%" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-ECHO Installing of mono build %PLATFORM% %CONFIG% from %BUILD_DIR% into %INSTALL_DIR% DONE. 
+ECHO Installing of mono build %PLATFORM% %CONFIG% from %PACKAGE_DIR% into %INSTALL_DIR% DONE.
 
 EXIT /b 0
 
@@ -87,4 +83,14 @@ EXIT /b 0
        EXIT /b 1
 
 @ECHO on
+
+:runCommand
+
+       IF "-q" == "%~2" (
+               %~1 >nul 2>&1
+       ) ELSE (
+               %~1
+       )
+
+goto :EOF
        
\ No newline at end of file
index d5501450f5e7e8d730861368027068d60dcd9ef8..6509ac127cab864b57d42f6d2ef28bcb7d0dcd8f 100644 (file)
@@ -4,8 +4,12 @@ SET SOURCE_ROOT=%1
 SET TARGET_ROOT=%2
 SET ARGUMENTS=%3
 
+SET XCOPY_COMMAND=%windir%\system32\xcopy
+
 SET TARGET_ROOT=%TARGET_ROOT:"=%
+SET TARGET_ROOT=%TARGET_ROOT:/=\%
 SET SOURCE_ROOT=%SOURCE_ROOT:"=%
+SET SOURCE_ROOT=%SOURCE_ROOT:/=\%
 
 IF "" == "%SOURCE_ROOT%" (
        ECHO Error: No source root parameter set.
@@ -43,36 +47,36 @@ IF "-v" == "%ARGUMENTS%" (
 )
 
 IF "-q" == "%ARGUMENTS%" (
-       SET "OPTIONS=/q /y ^>nul"
+       SET "OPTIONS=/q /y"
 )
 
-ECHO Copying mono include files from '%SOURCE_ROOT%' to '%TARGET_ROOT%' ...
+ECHO Copying mono include files from %SOURCE_ROOT% to %TARGET_ROOT% ...
 
-SET RUN=xcopy "%SOURCE_ROOT%\cil\opcode.def" "%TARGET_ROOT%\cil\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%SOURCE_ROOT%\cil\opcode.def" "%TARGET_ROOT%\cil\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-SET RUN=xcopy "%SOURCE_ROOT%\mini\jit.h" "%TARGET_ROOT%\jit\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%SOURCE_ROOT%\mini\jit.h" "%TARGET_ROOT%\jit\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-SET RUN=xcopy "%SOURCE_ROOT%\metadata\*.h" "%TARGET_ROOT%\metadata\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%SOURCE_ROOT%\metadata\*.h" "%TARGET_ROOT%\metadata\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-SET RUN=xcopy "%SOURCE_ROOT%\utils\mono-counters.h" "%TARGET_ROOT%\utils\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%SOURCE_ROOT%\utils\mono-counters.h" "%TARGET_ROOT%\utils\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-SET RUN=xcopy "%SOURCE_ROOT%\utils\mono-dl-fallback.h" "%TARGET_ROOT%\utils\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%SOURCE_ROOT%\utils\mono-dl-fallback.h" "%TARGET_ROOT%\utils\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-SET RUN=xcopy "%SOURCE_ROOT%\utils\mono-error.h" "%TARGET_ROOT%\utils\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%SOURCE_ROOT%\utils\mono-error.h" "%TARGET_ROOT%\utils\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-SET RUN=xcopy "%SOURCE_ROOT%\utils\mono-logger.h" "%TARGET_ROOT%\utils\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%SOURCE_ROOT%\utils\mono-logger.h" "%TARGET_ROOT%\utils\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-SET RUN=xcopy "%SOURCE_ROOT%\utils\mono-publib.h" "%TARGET_ROOT%\utils\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%SOURCE_ROOT%\utils\mono-publib.h" "%TARGET_ROOT%\utils\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-ECHO Copying mono include files from '%SOURCE_ROOT%' to '%TARGET_ROOT%' DONE.
+ECHO Copying mono include files from %SOURCE_ROOT% to %TARGET_ROOT% DONE.
 
 EXIT /b 0
 
@@ -81,3 +85,13 @@ EXIT /b 0
        EXIT /b 1
 
 @ECHO on
+
+:runCommand
+
+       IF "-q" == "%~2" (
+               %~1 >nul 2>&1
+       ) ELSE (
+               %~1
+       )
+
+goto :EOF
index 05fd05d73ff6163de648673d1c80807a28be5bfb..7905958fe8a83450c3feeaf41ce0a9ac3f9bb6b1 100644 (file)
   </PropertyGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
     <PreBuildEvent>\r
-      <Command>echo #define FULL_VERSION "Visual Studio built mono" &gt; ..\mono\mini\version.h</Command>\r
+      <Command>\r
+      </Command>\r
     </PreBuildEvent>\r
     <ClCompile>\r
       <AdditionalOptions>/D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions)</AdditionalOptions>\r
   </ItemDefinitionGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
     <PreBuildEvent>\r
-      <Command>echo #define FULL_VERSION "Visual Studio built mono" &gt; ..\mono\mini\version.h</Command>\r
+      <Command>\r
+      </Command>\r
     </PreBuildEvent>\r
     <Midl>\r
       <TargetEnvironment>X64</TargetEnvironment>\r
   </ItemDefinitionGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
     <PreBuildEvent>\r
-      <Command>echo #define FULL_VERSION "Visual Studio built mono" &gt; ..\mono\mini\version.h</Command>\r
+      <Command>\r
+      </Command>\r
     </PreBuildEvent>\r
     <ClCompile>\r
       <AdditionalOptions>/D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions)</AdditionalOptions>\r
   </ItemDefinitionGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
     <PreBuildEvent>\r
-      <Command>echo #define FULL_VERSION "Visual Studio built mono" &gt; ..\mono\mini\version.h</Command>\r
+      <Command>\r
+      </Command>\r
     </PreBuildEvent>\r
     <Midl>\r
       <TargetEnvironment>X64</TargetEnvironment>\r
index e3bf41a008ab32e8f0e8bea8390c5636788fe8f6..df29a8ba6f2d0819476f7685fe8143dc1c5efe41 100644 (file)
@@ -5,7 +5,10 @@ SET CONFIG=%2
 SET BUILD_DIR=%3
 SET ARGUMENTS=%4
 
+SET XCOPY_COMMAND=%windir%\system32\xcopy
+
 SET BUILD_DIR=%BUILD_DIR:"=%
+SET BUILD_DIR=%BUILD_DIR:/=\%
 
 IF "" == "%PLATFORM%" (
        ECHO Error: No platform parameter set.
@@ -31,10 +34,6 @@ IF "\" == "%BUILD_DIR:~-1%" (
        SET BUILD_DIR=%BUILD_DIR:~0,-1%
 )
 
-IF "/" == "%BUILD_DIR:~-1%" (
-       SET BUILD_DIR=%BUILD_DIR:~0,-1%
-)
-
 IF NOT EXIST %BUILD_DIR%\%PLATFORM%\lib\%CONFIG% (
        ECHO Error: No lib directory available for %PLATFORM% %CONFIG% at '%BUILD_DIR%'. Any build availalbe for platform, configuration pair?
        GOTO ON_ERROR
@@ -54,35 +53,35 @@ IF "-v" == "%ARGUMENTS%" (
 )
 
 IF "-q" == "%ARGUMENTS%" (
-       SET "OPTIONS=/s /e /q /y ^>nul"
+       SET "OPTIONS=/s /e /q /y"
 )
 
 ECHO Packaging mono build %PLATFORM% %CONFIG% into '%PACKAGE_DIR%' ...
 
 IF EXIST %PACKAGE_DIR% rmdir %PACKAGE_DIR% /s /q
-mkdir "%PACKAGE_DIR%"
-mkdir "%PACKAGE_DIR%\include\mono-2.0"
+mkdir %PACKAGE_DIR%
+mkdir %PACKAGE_DIR%\include\mono-2.0
 
-SET RUN=xcopy ".\include\*.*" "%PACKAGE_DIR%\include\mono-2.0\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% ".\include\*.*" "%PACKAGE_DIR%\include\mono-2.0\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-SET RUN=xcopy "%BUILD_DIR%\%PLATFORM%\lib\%CONFIG%\*.lib" "%PACKAGE_DIR%\lib\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%BUILD_DIR%\%PLATFORM%\lib\%CONFIG%\*.lib" "%PACKAGE_DIR%\lib\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-SET RUN=xcopy "%BUILD_DIR%\%PLATFORM%\lib\%CONFIG%\*.pdb" "%PACKAGE_DIR%\lib\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%BUILD_DIR%\%PLATFORM%\lib\%CONFIG%\*.pdb" "%PACKAGE_DIR%\lib\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-SET RUN=xcopy "%BUILD_DIR%\%PLATFORM%\bin\%CONFIG%\*.exe" "%PACKAGE_DIR%\bin\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%BUILD_DIR%\%PLATFORM%\bin\%CONFIG%\*.exe" "%PACKAGE_DIR%\bin\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-SET RUN=xcopy "%BUILD_DIR%\%PLATFORM%\bin\%CONFIG%\*.dll" "%PACKAGE_DIR%\bin\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%BUILD_DIR%\%PLATFORM%\bin\%CONFIG%\*.dll" "%PACKAGE_DIR%\bin\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-SET RUN=xcopy "%BUILD_DIR%\%PLATFORM%\bin\%CONFIG%\*.pdb" "%PACKAGE_DIR%\bin\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%BUILD_DIR%\%PLATFORM%\bin\%CONFIG%\*.pdb" "%PACKAGE_DIR%\bin\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
-SET RUN=xcopy "%BUILD_DIR%\%PLATFORM%\bin\%CONFIG%\*.lib" "%PACKAGE_DIR%\bin\" %OPTIONS%
-%RUN%
+SET RUN=%XCOPY_COMMAND% "%BUILD_DIR%\%PLATFORM%\bin\%CONFIG%\*.lib" "%PACKAGE_DIR%\bin\" %OPTIONS%
+call :runCommand "%RUN%" %ARGUMENTS%
 
 ECHO Packaging of mono build %PLATFORM% %CONFIG% into '%PACKAGE_DIR%' DONE. 
 
@@ -93,3 +92,13 @@ EXIT /b 0
        EXIT /b 1
 
 @ECHO on
+
+:runCommand
+
+       IF "-q" == "%~2" (
+               %~1 >nul 2>&1
+       ) ELSE (
+               %~1
+       )
+
+goto :EOF
index 73f2a1b5cfa27d9b76c8791eaf3d1dfbf6784552..a05395ca491b2fa58eabf042b27bd7116a848737 100755 (executable)
@@ -1,17 +1,55 @@
-@echo off
-cd ..
-if exist config.h if not exist cygconfig.h copy config.h cygconfig.h
-if exist eglib\config.h if not exist eglib\cygconfig.h copy eglib\config.h eglib\cygconfig.h
-copy winconfig.h config.h
-copy eglib\winconfig.h eglib\config.h
-%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -Command "(Get-Content config.h) -replace '#MONO_VERSION#', (Select-String -path configure.ac -pattern 'AC_INIT\(mono, \[(.*)\]').Matches[0].Groups[1].Value | Set-Content config.h"
-goto end
-:error
-echo fatal error: the VSDepenancies directory was not found in the "mono" directory
-echo error: you must download and unzip that file
-exit /b 100
-goto end
-:ok
-echo OK
-:end
-exit /b 0
+@ECHO off
+
+SET CONFIG_H=..\config.h
+SET EGLIB_CONFIG_H=..\eglib\config.h
+SET CYG_CONFIG_H=..\cygconfig.h
+SET EGLIB_CYG_CONFIG_H=..\eglib\cygconfig.h
+SET WIN_CONFIG_H=..\winconfig.h
+SET EGLIB_WIN_CONFIG_H=..\eglib\winconfig.h
+SET CONFIGURE_AC=..\configure.ac
+SET VERSION_H=..\mono\mini\version.h
+
+
+ECHO Setting up Mono configuration headers...
+
+IF EXIST %CONFIG_H% (
+       IF NOT EXIST %CYG_CONFIG_H% (
+               ECHO copy %CONFIG_H% %CYG_CONFIG_H%
+               copy %CONFIG_H% %CYG_CONFIG_H%
+       )
+)
+
+IF EXIST %EGLIB_CONFIG_H% (
+       IF NOT EXIST %EGLIB_CYG_CONFIG_H% (
+               ECHO copy %EGLIB_CONFIG_H% %EGLIB_CYG_CONFIG_H%
+               copy %EGLIB_CONFIG_H% %EGLIB_CYG_CONFIG_H%
+       )
+)
+
+%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -NonInteractive -File compare-config-files.ps1 %WIN_CONFIG_H% %CONFIG_H% %CONFIGURE_AC% >$null 2>&1
+
+IF NOT %ERRORLEVEL% == 0 (
+       ECHO copy %WIN_CONFIG_H% %CONFIG_H%
+       copy %WIN_CONFIG_H% %CONFIG_H%
+       %windir%\system32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -Command "(Get-Content %CONFIG_H%) -replace '#MONO_VERSION#', (Select-String -path %CONFIGURE_AC% -pattern 'AC_INIT\(mono, \[(.*)\]').Matches[0].Groups[1].Value | Set-Content %CONFIG_H%" >$null 2>&1
+)
+
+%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -NonInteractive -File compare-config-files.ps1 %EGLIB_WIN_CONFIG_H% %EGLIB_CONFIG_H% >$null 2>&1
+
+IF NOT %ERRORLEVEL% == 0 (
+       ECHO copy %EGLIB_WIN_CONFIG_H% %EGLIB_CONFIG_H%
+       copy %EGLIB_WIN_CONFIG_H% %EGLIB_CONFIG_H%
+)
+
+SET VERSION_CONTENT="#define FULL_VERSION \"Visual Studio built mono\""
+%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -NonInteractive -File compare-config-content.ps1 %VERSION_CONTENT% %VERSION_H%
+
+
+IF NOT %ERRORLEVEL% == 0 (
+       ECHO Configure %VERSION_H%
+       ECHO #define FULL_VERSION "Visual Studio built mono"> %VERSION_H%
+)
+
+ECHO Successfully setup Mono configuration headers.
+
+EXIT /b 0