forked from shadowsocks/badvpn
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finishing Nix build method for Windows.
- Loading branch information
Showing
4 changed files
with
72 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
This describes the supported build method for building for Windows. | ||
|
||
Build can only be done on Linux and the Nix package manager must be installed first. | ||
Install Nix from: http://nixos.org/nix/ | ||
|
||
Then you need to checkout a slignely patched version of the Nix packages collections. | ||
This is needed because it has fixes enabling cross-compilation of NSPR and NSS to Windows. | ||
|
||
git clone -b cross-mingw-nss --single-branch https://github.com/ambrop72/nixpkgs | ||
|
||
It may be faster to download a zip from Github: https://github.com/ambrop72/nixpkgs/archive/cross-mingw-nss.zip | ||
|
||
Then you can build with the following command from the badvpn source directory: | ||
|
||
NIX_PATH=nixpkgs=<path-to-nixpkgs> nix-build build-win32.nix -A badvpnPkgs.badvpn -o <output-link-path> | ||
|
||
Upon success the chosen <output-link-path> will be a symlink to a directory with the build outputs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,51 @@ | ||
{ stdenv, cmake, pkgconfig, openssl, nspr, nss, debug ? false }: | ||
let | ||
compileFlags = "-O3 ${stdenv.lib.optionalString (!debug) "-DNDEBUG"}"; | ||
in | ||
stdenv.mkDerivation { | ||
name = "badvpn"; | ||
{ stdenv, cmake, pkgconfig, openssl, nspr, nss, zlib, sqlite, zip, debug ? false }: | ||
|
||
rec { | ||
badvpn = ( | ||
let | ||
compileFlags = "-O3 ${stdenv.lib.optionalString (!debug) "-DNDEBUG"}"; | ||
in | ||
stdenv.mkDerivation { | ||
name = "badvpn"; | ||
|
||
src = stdenv.lib.cleanSource ./.; | ||
|
||
nativeBuildInputs = [ cmake pkgconfig ]; | ||
buildInputs = [ openssl nspr nss ]; | ||
|
||
NIX_CFLAGS_COMPILE = "-I${nspr.crossDrv.dev}/include/nspr -I${nss.crossDrv.dev}/include/nss -ggdb"; | ||
NIX_CFLAGS_LINK = ["-ggdb"]; | ||
|
||
preConfigure = '' | ||
cmakeFlagsArray=( "-DCMAKE_BUILD_TYPE=" "-DCMAKE_C_FLAGS=${compileFlags}" "-DCMAKE_SYSTEM_NAME=Windows" ); | ||
''; | ||
|
||
postInstall = '' | ||
for lib in eay32; do | ||
cp ${openssl.crossDrv.bin}/bin/lib$lib.dll $out/bin/ | ||
done | ||
for lib in nspr4 plc4 plds4; do | ||
cp ${nspr.crossDrv.out}/lib/lib$lib.dll $out/bin/ | ||
done | ||
for lib in nss3 nssutil3 smime3 ssl3 softokn3 freebl3; do | ||
cp ${nss.crossDrv.out}/lib/$lib.dll $out/bin/ | ||
done | ||
cp ${zlib.crossDrv.out}/bin/zlib1.dll $out/bin/ | ||
cp ${sqlite.crossDrv.out}/bin/libsqlite3-0.dll $out/bin/ | ||
_linkDLLs() { true; } | ||
''; | ||
|
||
dontCrossStrip = true; | ||
}).crossDrv; | ||
|
||
src = stdenv.lib.cleanSource ./.; | ||
|
||
nativeBuildInputs = [ cmake pkgconfig ]; | ||
buildInputs = [ openssl nspr nss ]; | ||
|
||
NIX_CFLAGS_COMPILE = "-I${nspr.crossDrv}/include/nspr -I${nss.crossDrv}/include/nss"; | ||
|
||
preConfigure = '' | ||
cmakeFlagsArray=( "-DCMAKE_BUILD_TYPE=" "-DCMAKE_C_FLAGS=${compileFlags}" "-DCMAKE_SYSTEM_NAME=Windows" ); | ||
''; | ||
|
||
postInstall = '' | ||
for lib in eay32; do | ||
cp ${openssl.crossDrv}/bin/lib$lib.dll $out/bin/ | ||
done | ||
for lib in nspr4 plc4 plds4; do | ||
cp ${nspr.crossDrv}/lib/lib$lib.dll $out/bin/ | ||
done | ||
for lib in nss3 nssutil3 smime3 ssl3; do | ||
cp ${nss.crossDrv}/lib/$lib.dll $out/bin/ | ||
done | ||
''; | ||
badvpnZip = stdenv.mkDerivation { | ||
name = "badvpn.zip"; | ||
unpackPhase = "true"; | ||
nativeBuildInputs = [ zip ]; | ||
installPhase = '' | ||
mkdir badvpn-win32 | ||
ln -s ${badvpn}/bin badvpn-win32/bin | ||
zip -q -r $out badvpn-win32 | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters