mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-19 02:44:17 +03:00
zeroad: refactor, split data from binaries
This commit is contained in:
parent
6a76ee237d
commit
5eddbc10c9
@ -1,19 +1,24 @@
|
||||
{ stdenv, fetchurl, version, releaseType }:
|
||||
{ stdenv, fetchurl }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "0ad-data-${version}";
|
||||
version = "0.0.20";
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://releases.wildfiregames.com/0ad-${version}-${releaseType}-unix-data.tar.xz";
|
||||
url = "http://releases.wildfiregames.com/0ad-${version}-alpha-unix-data.tar.xz";
|
||||
sha256 = "1lzl8chfqbgs1n9vpn0xaqd70kpwiibfk196iblyq6qkms3v6pnv";
|
||||
};
|
||||
|
||||
patchPhase = ''
|
||||
installPhase = ''
|
||||
rm binaries/data/tools/fontbuilder/fonts/*.txt
|
||||
mkdir -p $out/share/0ad
|
||||
cp -r binaries/data $out/share/0ad/
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/0ad
|
||||
cp -r binaries/data/* $out/share/0ad/
|
||||
'';
|
||||
meta = with stdenv.lib; {
|
||||
description = "A free, open-source game of ancient warfare -- data files";
|
||||
homepage = "http://wildfiregames.com/0ad/";
|
||||
license = licenses.cc-by-sa-30;
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
|
@ -1,131 +1,14 @@
|
||||
{ stdenv, callPackage, fetchurl, python27
|
||||
, pkgconfig, spidermonkey_31, boost, icu, libxml2, libpng
|
||||
, libjpeg, zlib, curl, libogg, libvorbis, enet, miniupnpc
|
||||
, openal, mesa, xproto, libX11, libXcursor, nspr, SDL, SDL2
|
||||
, gloox, nvidia-texture-tools
|
||||
, withEditor ? true, wxGTK ? null
|
||||
}:
|
||||
|
||||
assert withEditor -> wxGTK != null;
|
||||
{ newScope }:
|
||||
|
||||
let
|
||||
version = "0.0.20";
|
||||
callPackage = newScope self;
|
||||
|
||||
releaseType = "alpha";
|
||||
self = {
|
||||
zeroad-unwrapped = callPackage ./game.nix { };
|
||||
|
||||
zeroadData = callPackage ./data.nix { inherit version releaseType; };
|
||||
zeroad-data = callPackage ./data.nix { };
|
||||
|
||||
archForPremake =
|
||||
if stdenv.lib.hasPrefix "x86_64-" stdenv.system then "x64" else
|
||||
if stdenv.lib.hasPrefix "i686-" stdenv.system then "x32" else "ERROR";
|
||||
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
name = "0ad-${version}";
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://releases.wildfiregames.com/0ad-${version}-${releaseType}-unix-build.tar.xz";
|
||||
sha256 = "13n61xhjsawda3kl7112la41bqkbqmq4yhr3slydsz856z5xb5m3";
|
||||
zeroad = callPackage ./wrapper.nix { };
|
||||
};
|
||||
|
||||
buildInputs = [
|
||||
zeroadData python27 pkgconfig spidermonkey_31 boost icu
|
||||
libxml2 libpng libjpeg zlib curl libogg libvorbis enet
|
||||
miniupnpc openal mesa xproto libX11 libXcursor nspr
|
||||
SDL SDL2 gloox nvidia-texture-tools
|
||||
] ++ stdenv.lib.optional withEditor wxGTK;
|
||||
|
||||
NIX_CFLAGS_COMPILE = [
|
||||
"-I${xproto}/include/X11"
|
||||
"-I${libX11.dev}/include/X11"
|
||||
"-I${libXcursor.dev}/include/X11"
|
||||
"-I${SDL.dev}/include/SDL"
|
||||
"-I${SDL2}/include/SDL2"
|
||||
];
|
||||
|
||||
patchPhase = ''
|
||||
sed -i 's/MOZJS_MINOR_VERSION/false \&\& MOZJS_MINOR_VERSION/' source/scriptinterface/ScriptTypes.h
|
||||
'';
|
||||
|
||||
configurePhase = ''
|
||||
# Delete shipped libraries which we don't need.
|
||||
rm -rf libraries/source/{enet,miniupnpc,nvtt,spidermonkey}
|
||||
|
||||
# Build shipped premake.
|
||||
make -C build/premake/premake4/build/gmake.unix
|
||||
|
||||
# Run premake.
|
||||
pushd build/premake
|
||||
./premake4/bin/release/premake4 \
|
||||
--file="premake4.lua" \
|
||||
--outpath="../workspaces/gcc/" \
|
||||
--platform=${archForPremake} \
|
||||
--os=linux \
|
||||
--with-system-nvtt \
|
||||
--with-system-enet \
|
||||
--with-system-miniupnpc \
|
||||
--with-system-mozjs31 \
|
||||
${ if withEditor then "--atlas" else "" } \
|
||||
--collada \
|
||||
--bindir="$out"/bin \
|
||||
--libdir="$out"/lib/0ad \
|
||||
--datadir="$out"/share/0ad \
|
||||
--without-tests \
|
||||
gmake
|
||||
popd
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
# Build bundled fcollada.
|
||||
make -C libraries/source/fcollada/src
|
||||
|
||||
# Build 0ad.
|
||||
make -C build/workspaces/gcc verbose=1
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
# Copy executables.
|
||||
mkdir -p "$out"/bin
|
||||
cp binaries/system/pyrogenesis "$out"/bin/0ad
|
||||
((${ toString withEditor })) && cp binaries/system/ActorEditor "$out"/bin/
|
||||
|
||||
# Copy l10n data.
|
||||
mkdir -p "$out"/share/0ad
|
||||
cp -r binaries/data/l10n "$out"/share/0ad/
|
||||
|
||||
# Copy libraries.
|
||||
mkdir -p "$out"/lib/0ad
|
||||
cp binaries/system/libCollada.so "$out"/lib/0ad/
|
||||
((${ toString withEditor })) && cp binaries/system/libAtlasUI.so "$out"/lib/0ad/
|
||||
|
||||
# Create links to data files.
|
||||
ln -s -t "$out"/share/0ad "${zeroadData}"/share/0ad/*
|
||||
|
||||
# Copy icon.
|
||||
mkdir -p "$out"/share/icons
|
||||
cp build/resources/0ad.png "$out"/share/icons/
|
||||
|
||||
# Copy/fix desktop item.
|
||||
mkdir -p "$out"/share/applications
|
||||
while read LINE; do
|
||||
if [[ $LINE = "Exec=0ad" ]]; then
|
||||
echo "Exec=$out/bin/zeroad"
|
||||
elif [[ $LINE = "Icon=0ad" ]]; then
|
||||
echo "Icon=$out/share/icons/0ad.png"
|
||||
else
|
||||
echo "$LINE"
|
||||
fi
|
||||
done <build/resources/0ad.desktop >"$out"/share/applications/0ad.desktop
|
||||
'';
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "A free, open-source game of ancient warfare";
|
||||
homepage = "http://wildfiregames.com/0ad/";
|
||||
license = with licenses; [
|
||||
gpl2 lgpl21 mit cc-by-sa-30
|
||||
licenses.zlib # otherwise masked by pkgs.zlib
|
||||
];
|
||||
platforms = [ "x86_64-linux" "i686-linux" ];
|
||||
hydraPlatforms = []; # the data are too big (~1.5 GB)
|
||||
};
|
||||
}
|
||||
in self
|
||||
|
96
pkgs/games/0ad/game.nix
Normal file
96
pkgs/games/0ad/game.nix
Normal file
@ -0,0 +1,96 @@
|
||||
{ stdenv, lib, callPackage, perl, fetchurl, python2
|
||||
, pkgconfig, spidermonkey_31, boost, icu, libxml2, libpng
|
||||
, libjpeg, zlib, curl, libogg, libvorbis, enet, miniupnpc
|
||||
, openal, mesa, xproto, libX11, libXcursor, nspr, SDL, SDL2
|
||||
, gloox, nvidia-texture-tools
|
||||
, withEditor ? true, wxGTK ? null
|
||||
}:
|
||||
|
||||
assert withEditor -> wxGTK != null;
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "0ad-${version}";
|
||||
version = "0.0.20";
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://releases.wildfiregames.com/0ad-${version}-alpha-unix-build.tar.xz";
|
||||
sha256 = "13n61xhjsawda3kl7112la41bqkbqmq4yhr3slydsz856z5xb5m3";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ python2 perl pkgconfig ];
|
||||
|
||||
buildInputs = [
|
||||
spidermonkey_31 boost icu libxml2 libpng libjpeg
|
||||
zlib curl libogg libvorbis enet miniupnpc openal
|
||||
mesa xproto libX11 libXcursor nspr SDL2 gloox
|
||||
nvidia-texture-tools
|
||||
] ++ lib.optional withEditor wxGTK;
|
||||
|
||||
NIX_CFLAGS_COMPILE = [
|
||||
"-I${xproto}/include/X11"
|
||||
"-I${libX11.dev}/include/X11"
|
||||
"-I${libXcursor.dev}/include/X11"
|
||||
"-I${SDL.dev}/include/SDL"
|
||||
"-I${SDL2}/include/SDL2"
|
||||
];
|
||||
|
||||
patches = [ ./rootdir_env.patch ];
|
||||
|
||||
postPatch = ''
|
||||
sed -i 's/MOZJS_MINOR_VERSION/false \&\& MOZJS_MINOR_VERSION/' source/scriptinterface/ScriptTypes.h
|
||||
'';
|
||||
|
||||
configurePhase = ''
|
||||
# Delete shipped libraries which we don't need.
|
||||
rm -rf libraries/source/{enet,miniupnpc,nvtt,spidermonkey}
|
||||
|
||||
# Update Makefiles
|
||||
pushd build/workspaces
|
||||
./update-workspaces.sh \
|
||||
--with-system-nvtt \
|
||||
--with-system-mozjs31 \
|
||||
${lib.optionalString withEditor "--enable-atlas"} \
|
||||
--bindir="$out"/bin \
|
||||
--libdir="$out"/lib/0ad \
|
||||
--without-tests \
|
||||
-j $NIX_BUILD_CORES
|
||||
popd
|
||||
|
||||
# Move to the build directory.
|
||||
pushd build/workspaces/gcc
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
installPhase = ''
|
||||
popd
|
||||
|
||||
# Copy executables.
|
||||
install -Dm755 binaries/system/pyrogenesis "$out"/bin/0ad
|
||||
${lib.optionalString withEditor ''
|
||||
install -Dm755 binaries/system/ActorEditor "$out"/bin/ActorEditor
|
||||
''}
|
||||
|
||||
# Copy l10n data.
|
||||
mkdir -p "$out"/share/0ad/data
|
||||
cp -r binaries/data/l10n "$out"/share/0ad/data
|
||||
|
||||
# Copy libraries.
|
||||
mkdir -p "$out"/lib/0ad
|
||||
cp binaries/system/*.so "$out"/lib/0ad/
|
||||
|
||||
# Copy icon.
|
||||
install -D build/resources/0ad.png "$out"/share/icons/hicolor/128x128/0ad.png
|
||||
install -D build/resources/0ad.desktop "$out"/share/applications/0ad.desktop
|
||||
'';
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "A free, open-source game of ancient warfare";
|
||||
homepage = "http://wildfiregames.com/0ad/";
|
||||
license = with licenses; [
|
||||
gpl2 lgpl21 mit cc-by-sa-30
|
||||
licenses.zlib # otherwise masked by pkgs.zlib
|
||||
];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
38
pkgs/games/0ad/rootdir_env.patch
Normal file
38
pkgs/games/0ad/rootdir_env.patch
Normal file
@ -0,0 +1,38 @@
|
||||
diff -ru3 0ad-0.0.20-alpha/source/ps/GameSetup/Paths.cpp 0ad-0.0.20-alpha-new/source/ps/GameSetup/Paths.cpp
|
||||
--- 0ad-0.0.20-alpha/source/ps/GameSetup/Paths.cpp 2015-02-14 04:45:13.000000000 +0300
|
||||
+++ 0ad-0.0.20-alpha-new/source/ps/GameSetup/Paths.cpp 2016-11-03 16:23:47.241514876 +0300
|
||||
@@ -155,32 +155,8 @@
|
||||
|
||||
/*static*/ OsPath Paths::Root(const OsPath& argv0)
|
||||
{
|
||||
-#if OS_ANDROID
|
||||
- return OsPath("/sdcard/0ad"); // TODO: this is kind of bogus
|
||||
-#else
|
||||
-
|
||||
- // get full path to executable
|
||||
- OsPath pathname = sys_ExecutablePathname(); // safe, but requires OS-specific implementation
|
||||
- if(pathname.empty()) // failed, use argv[0] instead
|
||||
- {
|
||||
- errno = 0;
|
||||
- pathname = wrealpath(argv0);
|
||||
- if(pathname.empty())
|
||||
- WARN_IF_ERR(StatusFromErrno());
|
||||
- }
|
||||
-
|
||||
- // make sure it's valid
|
||||
- if(!FileExists(pathname))
|
||||
- {
|
||||
- LOGERROR("Cannot find executable (expected at '%s')", pathname.string8());
|
||||
- WARN_IF_ERR(StatusFromErrno());
|
||||
- }
|
||||
-
|
||||
- for(size_t i = 0; i < 2; i++) // remove "system/name.exe"
|
||||
- pathname = pathname.Parent();
|
||||
- return pathname;
|
||||
-
|
||||
-#endif
|
||||
+ UNUSED2(argv0);
|
||||
+ return getenv("ZEROAD_ROOTDIR");
|
||||
}
|
||||
|
||||
/*static*/ OsPath Paths::RootData(const OsPath& argv0)
|
21
pkgs/games/0ad/wrapper.nix
Normal file
21
pkgs/games/0ad/wrapper.nix
Normal file
@ -0,0 +1,21 @@
|
||||
{ buildEnv, makeWrapper, zeroad-unwrapped, zeroad-data }:
|
||||
|
||||
assert zeroad-unwrapped.version == zeroad-data.version;
|
||||
|
||||
buildEnv {
|
||||
name = "zeroad-${zeroad-unwrapped.version}";
|
||||
inherit (zeroad-unwrapped) meta;
|
||||
|
||||
buildInputs = [ makeWrapper ];
|
||||
|
||||
paths = [ zeroad-unwrapped zeroad-data ];
|
||||
|
||||
pathsToLink = [ "/" "/bin" ];
|
||||
|
||||
postBuild = ''
|
||||
for i in $out/bin/*; do
|
||||
wrapProgram "$i" \
|
||||
--set ZEROAD_ROOTDIR "$out/share/0ad"
|
||||
done
|
||||
'';
|
||||
}
|
@ -16003,7 +16003,9 @@ in
|
||||
|
||||
keen4 = callPackage ../games/keen4 { };
|
||||
|
||||
zeroad = callPackage ../games/0ad { };
|
||||
zeroadPackages = callPackage ../games/0ad { };
|
||||
|
||||
zeroad = zeroadPackages.zeroad;
|
||||
|
||||
### DESKTOP ENVIRONMENTS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user