Merge pull request #143294 from AndersonTorres/new-arcan

arcan.arcan: fix static openal issues
This commit is contained in:
Anderson Torres 2021-10-30 19:37:56 -03:00 committed by GitHub
commit 1473238d4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 149 additions and 35 deletions

View file

@ -0,0 +1,15 @@
diff -Naur source-old/src/CMakeLists.txt source-new/src/CMakeLists.txt
--- source-old/src/CMakeLists.txt 1969-12-31 21:00:01.000000000 -0300
+++ source-new/src/CMakeLists.txt 2021-10-29 12:03:06.461399341 -0300
@@ -362,10 +360,8 @@
if (EXISTS ${EXTERNAL_SRC_DIR}/git/openal AND STATIC_OPENAL)
amsg("${CL_YEL}Building OpenAL static from external/git mirror${CL_RST}")
ExternalProject_Add(OpenAL
- SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/openal
+ SOURCE_DIR "${EXTERNAL_SRC_DIR}/git/openal"
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/openal_static
- UPDATE_COMMAND ""
- GIT_REPOSITORY "${EXTERNAL_SRC_DIR}/git/openal"
${EXTERNAL_DEFS}
${CMAKE_EXTERNAL_DEFS}
-DALSOFT_BACKEND_DSOUND=OFF

View file

@ -0,0 +1,17 @@
diff -Naur source-old/src/CMakeLists.txt source-new/src/CMakeLists.txt
--- source-old/src/CMakeLists.txt 1969-12-31 21:00:01.000000000 -0300
+++ source-new/src/CMakeLists.txt 2021-10-29 12:03:06.461399341 -0300
@@ -419,12 +415,7 @@
set(LUA_TAG "luajit51")
if (EXISTS ${EXTERNAL_SRC_DIR}/git/luajit)
ExternalProject_Add(luajit
- SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/luajit
- GIT_REPOSITORY "${EXTERNAL_SRC_DIR}/git/luajit"
- CONFIGURE_COMMAND ""
- GIT_TAG "v2.1.0-beta3"
- UPDATE_COMMAND ""
- INSTALL_COMMAND ""
+ SOURCE_DIR "${EXTERNAL_SRC_DIR}/git/luajit"
BUILD_IN_SOURCE 1
BUILD_COMMAND "${EXTMAKE_CMD}"
DEFAULT_CC=${CMAKE_C_COMPILER}

View file

@ -0,0 +1,15 @@
diff -Naur source-old/src/frameserver/decode/default/CMakeLists.txt source-new/src/frameserver/decode/default/CMakeLists.txt
--- source-old/src/frameserver/decode/default/CMakeLists.txt 1969-12-31 21:00:01.000000000 -0300
+++ source-new/src/frameserver/decode/default/CMakeLists.txt 2021-10-29 12:01:31.989933725 -0300
@@ -62,10 +62,8 @@
if (STATIC_LIBUVC)
pkg_check_modules(LIBUSB_1 REQUIRED libusb-1.0)
ExternalProject_Add(libuvc
- SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/frameserver/decode/libuvc"
+ SOURCE_DIR "${EXTERNAL_SRC_DIR}/git/libuvc"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/libuvc_static"
- UPDATE_COMMAND ""
- GIT_REPOSITORY "${EXTERNAL_SRC_DIR}/git/libuvc"
${EXTERNAL_DEFS}
${CMAKE_EXTERNAL_DEFS}
-DBUILD_UVC_STATIC=ON

View file

@ -0,0 +1,14 @@
diff -Naur source-old/src/CMakeLists.txt source-new/src/CMakeLists.txt
--- source-old/src/CMakeLists.txt 1969-12-31 21:00:01.000000000 -0300
+++ source-new/src/CMakeLists.txt 2021-10-29 12:03:06.461399341 -0300
@@ -317,9 +317,7 @@
find_package(BZip2 REQUIRED QUIET)
pkg_check_modules(HARFBUZZ REQUIRED QUIET harfbuzz)
ExternalProject_Add(Freetype
- SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/freetype"
- UPDATE_COMMAND ""
- GIT_REPOSITORY "${EXTERNAL_SRC_DIR}/git/freetype"
+ SOURCE_DIR "${EXTERNAL_SRC_DIR}/git/freetype"
${EXTERNAL_DEFS}
${CMAKE_EXTERNAL_DEFS}
-DWITH_ZLIB=OFF

View file

@ -0,0 +1,25 @@
{ fetchgit, fetchFromGitHub }:
{
letoram-openal-src = fetchFromGitHub {
owner = "letoram";
repo = "openal";
rev = "1c7302c580964fee9ee9e1d89ff56d24f934bdef";
hash = "sha256-InqU59J0zvwJ20a7KU54xTM7d76VoOlFbtj7KbFlnTU=";
};
freetype-src = fetchgit {
url = "git://git.sv.nongnu.org/freetype/freetype2.git";
rev = "94cb3a2eb96b3f17a1a3bd0e6f7da97c0e1d8f57";
sha256 = "sha256-LzjqunX/T8khF2UjPlPYiQOwMGem8MqPYneR2LdZ5Fg=";
};
libuvc-src = fetchgit {
owner = "libuvc";
repo = "libuvc";
rev = "b2b01ae6a2875d05c99eb256bb15815018d6e837";
sha256 = "sha256-2zCTjyodRARkHM/Q0r4bdEH9LO1Z9xPCnY2xE4KZddA=";
};
luajit-src = fetchgit {
url = "https://luajit.org/git/luajit-2.0.git";
rev = "d3294fa63b344173db68dd612c6d3801631e28d4";
sha256 = "sha256-1iHBXcbYhWN4M8g5oH09S1j1WrjYzI6qcRbHsdfpRkk=";
};
}

View file

@ -1,6 +1,7 @@
{ lib { lib
, stdenv , stdenv
, fetchFromGitHub , fetchFromGitHub
, fetchgit
, SDL2 , SDL2
, cmake , cmake
, espeak , espeak
@ -23,6 +24,7 @@
, libvncserver , libvncserver
, libxcb , libxcb
, libxkbcommon , libxkbcommon
, lua
, luajit , luajit
, makeWrapper , makeWrapper
, mesa , mesa
@ -36,22 +38,16 @@
, xcbutil , xcbutil
, xcbutilwm , xcbutilwm
, xz , xz
, buildManpages ? true, ruby , buildManPages ? true, ruby
, useBuiltinLua ? true
, useStaticFreetype ? false
, useStaticLibuvc ? false
, useStaticOpenAL ? true
, useStaticSqlite ? false
}: }:
let
# TODO: investigate vendoring, especially OpenAL
# WARN: vendoring of OpenAL is required for running arcan_lwa
# INFO: maybe it needs leaveDotGit, but it is dangerous/impure
letoram-openal-src = fetchFromGitHub {
owner = "letoram";
repo = "openal";
rev = "1c7302c580964fee9ee9e1d89ff56d24f934bdef";
hash = "sha256-InqU59J0zvwJ20a7KU54xTM7d76VoOlFbtj7KbFlnTU=";
};
in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "arcan"; pname = "arcan" + lib.optionalString useStaticOpenAL "-static-openal";
version = "0.6.1pre1+unstable=2021-10-16"; version = "0.6.1pre1+unstable=2021-10-16";
src = fetchFromGitHub { src = fetchFromGitHub {
@ -61,28 +57,11 @@ stdenv.mkDerivation rec {
hash = "sha256-4FodFuO51ehvyjH4YaF/xBY9dwA6cP/e6/BvEsH4w7U="; hash = "sha256-4FodFuO51ehvyjH4YaF/xBY9dwA6cP/e6/BvEsH4w7U=";
}; };
postUnpack = ''
pushd .
cd $sourceRoot/external/git/
cp -a ${letoram-openal-src}/ openal/
chmod --recursive 744 openal/
popd
'';
# TODO: work with upstream in order to get rid of these hardcoded paths
postPatch = ''
substituteInPlace ./src/platform/posix/paths.c \
--replace "/usr/bin" "$out/bin" \
--replace "/usr/share" "$out/share"
substituteInPlace ./src/CMakeLists.txt --replace "SETUID" "# SETUID"
'';
nativeBuildInputs = [ nativeBuildInputs = [
cmake cmake
makeWrapper makeWrapper
pkg-config pkg-config
] ++ lib.optionals buildManpages [ ] ++ lib.optionals buildManPages [
ruby ruby
]; ];
@ -108,6 +87,7 @@ stdenv.mkDerivation rec {
libvncserver libvncserver
libxcb libxcb
libxkbcommon libxkbcommon
lua
luajit luajit
mesa mesa
openal openal
@ -121,11 +101,54 @@ stdenv.mkDerivation rec {
xz xz
]; ];
patches = [
# Nixpkgs-specific: redirect vendoring
./000-openal.patch
./001-luajit.patch
./002-libuvc.patch
./003-freetype.patch
];
# Emulate external/git/clone.sh
postUnpack = let
inherit (import ./clone-sources.nix { inherit fetchFromGitHub fetchgit; })
letoram-openal-src freetype-src libuvc-src luajit-src;
in
''
pushd $sourceRoot/external/git/
''
+ (lib.optionalString useStaticOpenAL ''
cp -a ${letoram-openal-src}/ openal
chmod --recursive 744 openal
'')
+ (lib.optionalString useStaticFreetype ''
cp -a ${freetype-src}/ freetype
chmod --recursive 744 freetype
'')
+ (lib.optionalString useStaticLibuvc ''
cp -a ${libuvc-src}/ libuvc
chmod --recursive 744 libuvc
'')
+ (lib.optionalString useBuiltinLua ''
cp -a ${luajit-src}/ luajit
chmod --recursive 744 luajit
'') +
''
popd
'';
postPatch = ''
substituteInPlace ./src/platform/posix/paths.c \
--replace "/usr/bin" "$out/bin" \
--replace "/usr/share" "$out/share"
substituteInPlace ./src/CMakeLists.txt --replace "SETUID" "# SETUID"
'';
# INFO: According to the source code, the manpages need to be generated before # INFO: According to the source code, the manpages need to be generated before
# the configure phase # the configure phase
preConfigure = lib.optionalString buildManpages '' preConfigure = lib.optionalString buildManPages ''
pushd . pushd doc
cd doc
ruby docgen.rb mangen ruby docgen.rb mangen
popd popd
''; '';
@ -136,7 +159,12 @@ stdenv.mkDerivation rec {
"-DDISTR_TAG=Nixpkgs" "-DDISTR_TAG=Nixpkgs"
"-DENGINE_BUILDTAG=${version}" "-DENGINE_BUILDTAG=${version}"
"-DHYBRID_SDL=on" "-DHYBRID_SDL=on"
"-DSTATIC_OPENAL=off" "-DBUILTIN_LUA=${if useBuiltinLua then "on" else "off"}"
"-DDISABLE_JIT=${if useBuiltinLua then "on" else "off"}"
"-DSTATIC_FREETYPE=${if useStaticFreetype then "on" else "off"}"
"-DSTATIC_LIBUVC=${if useStaticLibuvc then "on" else "off"}"
"-DSTATIC_OPENAL=${if useStaticOpenAL then "on" else "off"}"
"-DSTATIC_SQLite3=${if useStaticSqlite then "on" else "off"}"
"../src" "../src"
]; ];