Author: sandervanderburg
Date: Tue Sep 13 12:17:04 2011
New Revision: 29235
URL: https://ssl.nixos.org/websvn/nix/?rev=29235&sc=1
Log:
Initial implementation of a main class wrapper which resolves runtime
dependencies automatically
Modified:
nixpkgs/trunk/pkgs/build-support/dotnetenv/build-solution.nix
nixpkgs/trunk/pkgs/build-support/dotnetenv/default.nix
Modified: nixpkgs/trunk/pkgs/build-support/dotnetenv/build-solution.nix
==============================================================================
--- nixpkgs/trunk/pkgs/build-support/dotnetenv/build-solution.nix Tue Sep
13 11:00:31 2011 (r29234)
+++ nixpkgs/trunk/pkgs/build-support/dotnetenv/build-solution.nix Tue Sep
13 12:17:04 2011 (r29235)
@@ -7,18 +7,55 @@
, verbosity ? "detailed"
, options ? "/p:Configuration=Debug;Platform=Win32"
, assemblyInputs ? []
-, runtimeAssemblies ? []
, preBuild ? ""
+, wrapMain ? false
+, namespace ? null
+, mainClassName ? null
+, mainClassFile ? null
}:
+assert wrapMain -> namespace != null && mainClassName != null && mainClassFile
!= null;
+
+let
+ wrapperCS = ./Wrapper.cs.in;
+in
stdenv.mkDerivation {
- inherit name src preBuild;
+ inherit name src;
buildInputs = [ dotnetfx ];
+
preConfigure = ''
cd ${baseDir}
'';
+ preBuild = ''
+ ${preBuild}
+
+ # Create wrapper class with main method
+ ${stdenv.lib.optionalString wrapMain ''
+ # Generate assemblySearchPaths string array contents
+ for path in ${toString assemblyInputs}
+ do
+ assemblySearchArray="$assemblySearchPaths @\"$(cygpath --windows
$path | sed 's|\\|\\\\|g')\""
+ done
+
+ sed -e "s|@NAMESPACE@|${namespace}|" \
+ -e "s|@MAINCLASSNAME@|${mainClassName}|" \
+ -e "s|@ASSEMBLYSEARCHPATHS@|$assemblySearchArray|" \
+ ${wrapperCS} > $(dirname ${mainClassFile})/${mainClassName}Wrapper.cs
+
+ # Rename old main method and make it publically accessible
+ # so that the wrapper can invoke it
+ sed -i -e "s|static void Main|public static void Main2|g"
${mainClassFile}
+
+ # Add the wrapper to the C# project file so that will be build as well
+ find . -name \*.csproj | while read file
+ do
+ sed -i -e "s|$(basename ${mainClassFile})|$(basename
${mainClassFile});${mainClassName}Wrapper.cs|" "$file"
+ done
+ ''}
+ '';
+
installPhase = ''
for i in ${toString assemblyInputs}
do
@@ -43,19 +80,5 @@
ensureDir $out
MSBuild.exe ${toString slnFile} /nologo /t:${targets}
/p:IntermediateOutputPath=$(cygpath --windows $out)\\ /p:OutputPath=$(cygpath
--windows $out)\\ /verbosity:${verbosity} ${options}
-
- # Create references to runtime dependencies
- # !!! Should be more efficient (e.g. symlinking)
-
- for i in ${toString runtimeAssemblies}
- do
- cd $i
-
- for j in $(find . -type f)
- do
- mkdir -p $out/$(dirname $j)
- cp $j $out/$(dirname $j)
- done
- done
'';
}
Modified: nixpkgs/trunk/pkgs/build-support/dotnetenv/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/build-support/dotnetenv/default.nix Tue Sep 13
11:00:31 2011 (r29234)
+++ nixpkgs/trunk/pkgs/build-support/dotnetenv/default.nix Tue Sep 13
12:17:04 2011 (r29235)
@@ -5,6 +5,6 @@
inherit stdenv;
dotnetfx = dotnetfx.pkg;
};
-
+
inherit (dotnetfx) assembly20Path wcfPath referenceAssembly30Path
referenceAssembly35Path;
}
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits