Initial implementation of a main class wrapper which resolves runtime dependencies automatically
svn path=/nixpkgs/trunk/; revision=29235
This commit is contained in:
parent
f75f1871d7
commit
610d109f75
@ -7,18 +7,55 @@
|
|||||||
, verbosity ? "detailed"
|
, verbosity ? "detailed"
|
||||||
, options ? "/p:Configuration=Debug;Platform=Win32"
|
, options ? "/p:Configuration=Debug;Platform=Win32"
|
||||||
, assemblyInputs ? []
|
, assemblyInputs ? []
|
||||||
, runtimeAssemblies ? []
|
|
||||||
, preBuild ? ""
|
, 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 {
|
stdenv.mkDerivation {
|
||||||
inherit name src preBuild;
|
inherit name src;
|
||||||
|
|
||||||
buildInputs = [ dotnetfx ];
|
buildInputs = [ dotnetfx ];
|
||||||
|
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
cd ${baseDir}
|
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 = ''
|
installPhase = ''
|
||||||
for i in ${toString assemblyInputs}
|
for i in ${toString assemblyInputs}
|
||||||
do
|
do
|
||||||
@ -43,19 +80,5 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
ensureDir $out
|
ensureDir $out
|
||||||
MSBuild.exe ${toString slnFile} /nologo /t:${targets} /p:IntermediateOutputPath=$(cygpath --windows $out)\\ /p:OutputPath=$(cygpath --windows $out)\\ /verbosity:${verbosity} ${options}
|
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
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
inherit stdenv;
|
inherit stdenv;
|
||||||
dotnetfx = dotnetfx.pkg;
|
dotnetfx = dotnetfx.pkg;
|
||||||
};
|
};
|
||||||
|
|
||||||
inherit (dotnetfx) assembly20Path wcfPath referenceAssembly30Path referenceAssembly35Path;
|
inherit (dotnetfx) assembly20Path wcfPath referenceAssembly30Path referenceAssembly35Path;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user