lol

Initial implementation of a main class wrapper which resolves runtime dependencies automatically

svn path=/nixpkgs/trunk/; revision=29235

+40 -17
+39 -16
pkgs/build-support/dotnetenv/build-solution.nix
··· 7 , verbosity ? "detailed" 8 , options ? "/p:Configuration=Debug;Platform=Win32" 9 , assemblyInputs ? [] 10 - , runtimeAssemblies ? [] 11 , preBuild ? "" 12 }: 13 14 stdenv.mkDerivation { 15 - inherit name src preBuild; 16 17 buildInputs = [ dotnetfx ]; 18 preConfigure = '' 19 cd ${baseDir} 20 ''; 21 22 installPhase = '' 23 for i in ${toString assemblyInputs} 24 do ··· 43 44 ensureDir $out 45 MSBuild.exe ${toString slnFile} /nologo /t:${targets} /p:IntermediateOutputPath=$(cygpath --windows $out)\\ /p:OutputPath=$(cygpath --windows $out)\\ /verbosity:${verbosity} ${options} 46 - 47 - # Create references to runtime dependencies 48 - # !!! Should be more efficient (e.g. symlinking) 49 - 50 - for i in ${toString runtimeAssemblies} 51 - do 52 - cd $i 53 - 54 - for j in $(find . -type f) 55 - do 56 - mkdir -p $out/$(dirname $j) 57 - cp $j $out/$(dirname $j) 58 - done 59 - done 60 ''; 61 }
··· 7 , verbosity ? "detailed" 8 , options ? "/p:Configuration=Debug;Platform=Win32" 9 , assemblyInputs ? [] 10 , preBuild ? "" 11 + , wrapMain ? false 12 + , namespace ? null 13 + , mainClassName ? null 14 + , mainClassFile ? null 15 }: 16 17 + assert wrapMain -> namespace != null && mainClassName != null && mainClassFile != null; 18 + 19 + let 20 + wrapperCS = ./Wrapper.cs.in; 21 + in 22 stdenv.mkDerivation { 23 + inherit name src; 24 25 buildInputs = [ dotnetfx ]; 26 + 27 preConfigure = '' 28 cd ${baseDir} 29 ''; 30 31 + preBuild = '' 32 + ${preBuild} 33 + 34 + # Create wrapper class with main method 35 + ${stdenv.lib.optionalString wrapMain '' 36 + # Generate assemblySearchPaths string array contents 37 + for path in ${toString assemblyInputs} 38 + do 39 + assemblySearchArray="$assemblySearchPaths @\"$(cygpath --windows $path | sed 's|\\|\\\\|g')\"" 40 + done 41 + 42 + sed -e "s|@NAMESPACE@|${namespace}|" \ 43 + -e "s|@MAINCLASSNAME@|${mainClassName}|" \ 44 + -e "s|@ASSEMBLYSEARCHPATHS@|$assemblySearchArray|" \ 45 + ${wrapperCS} > $(dirname ${mainClassFile})/${mainClassName}Wrapper.cs 46 + 47 + # Rename old main method and make it publically accessible 48 + # so that the wrapper can invoke it 49 + sed -i -e "s|static void Main|public static void Main2|g" ${mainClassFile} 50 + 51 + # Add the wrapper to the C# project file so that will be build as well 52 + find . -name \*.csproj | while read file 53 + do 54 + sed -i -e "s|$(basename ${mainClassFile})|$(basename ${mainClassFile});${mainClassName}Wrapper.cs|" "$file" 55 + done 56 + ''} 57 + ''; 58 + 59 installPhase = '' 60 for i in ${toString assemblyInputs} 61 do ··· 80 81 ensureDir $out 82 MSBuild.exe ${toString slnFile} /nologo /t:${targets} /p:IntermediateOutputPath=$(cygpath --windows $out)\\ /p:OutputPath=$(cygpath --windows $out)\\ /verbosity:${verbosity} ${options} 83 ''; 84 }
+1 -1
pkgs/build-support/dotnetenv/default.nix
··· 5 inherit stdenv; 6 dotnetfx = dotnetfx.pkg; 7 }; 8 - 9 inherit (dotnetfx) assembly20Path wcfPath referenceAssembly30Path referenceAssembly35Path; 10 }
··· 5 inherit stdenv; 6 dotnetfx = dotnetfx.pkg; 7 }; 8 + 9 inherit (dotnetfx) assembly20Path wcfPath referenceAssembly30Path referenceAssembly35Path; 10 }