tic-80: update to unstable-2021-12-18

Building with SDL is not working for now so we built it with sokol. It
also has new outputs separating with the console and the development
tools.
This commit is contained in:
Gabriel Arazas 2021-12-18 17:34:04 +08:00
parent b24005894d
commit 5c5d6dac93
3 changed files with 150 additions and 28 deletions

View File

@ -1,28 +0,0 @@
{ stdenv, lib, alsaLib, cmake, fetchFromGitHub, freeglut, gtk3, libGLU, libglvnd
, mesa, pkgconfig }:
stdenv.mkDerivation rec {
pname = "tic-80";
version = "ad6fac460480ca2eff25e6ef142460b9ff7bdcef";
src = fetchFromGitHub {
owner = "nesbox";
repo = "TIC-80";
rev = "8ba1ae484fed6904a76894804a99f4ea1e0af754";
sha256 = "sha256-/BL7wbD/qeAWVJXAF4B6v5iD8SjjHKg48DBAjcXSa/I=";
fetchSubmodules = true;
};
nativeBuildInputs = [ cmake pkgconfig ];
buildInputs = [ alsaLib freeglut gtk3 libGLU libglvnd mesa ];
cmakeFlags = [ "-DBUILD_PRO=ON" ];
meta = with lib; {
description = "A fantasy computer with built-in game dev tools.";
homepage = "https://tic80.com/";
license = licenses.mit;
};
}

View File

@ -0,0 +1,75 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 35a60dc..43b044f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -247,13 +247,13 @@ if(NOT RAKE)
endif()
set(MRUBY_BUILDDIR ${CMAKE_SOURCE_DIR}/build/mruby)
-set(MRUBY_DIR ${THIRDPARTY_DIR}/mruby)
+set(MRUBY_DIR @mruby@)
if(ANDROID)
set(MRUBY_CONFIG ${MRUBY_BUILDDIR}/tic_android.rb)
else()
set(MRUBY_CONFIG ${MRUBY_BUILDDIR}/tic_default.rb)
endif()
-set(MRUBY_LIB ${MRUBY_DIR}/build/target/lib/libmruby.a)
+set(MRUBY_LIB ${MRUBY_DIR}/lib/libmruby.a)
if(MSVC)
set(MRUBY_TOOLCHAIN visualcpp)
@@ -271,26 +271,6 @@ if(ANDROID_NDK_HOME)
set(MRUBY_RAKE_EXTRA_OPTS "${MRUBY_RAKE_EXTRA_OPTS} ANDROID_NDK_HOME=${ANDROID_NDK_HOME}")
endif()
-ExternalProject_Add(mruby_vendor
- SOURCE_DIR ${MRUBY_DIR}
- CONFIGURE_COMMAND ""
- BUILD_IN_SOURCE TRUE
- BUILD_COMMAND
- ${RAKE} clean all "MRUBY_CONFIG=${MRUBY_CONFIG}"
- "TARGET_CC=\"${CMAKE_C_COMPILER}\""
- "TARGET_AR=\"${CMAKE_AR}\""
- "TARGET_CFLAGS=${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BUILD_TYPE_UC}}"
- "TARGET_LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_LINKER_FLAGS_${BUILD_TYPE_UC}}"
- "BUILD_TYPE=${BUILD_TYPE_UC}"
- "MRUBY_SYSROOT=${MRUBY_SYSROOT}"
- "MRUBY_TOOLCHAIN=${MRUBY_TOOLCHAIN}"
- "ANDROID_ARCH=${CMAKE_ANDROID_ARCH_ABI}"
- "ANDROID_PLATFORM=android-${CMAKE_SYSTEM_VERSION}"
- ${MRUBY_RAKE_EXTRA_OPTS}
- INSTALL_COMMAND ""
- BUILD_BYPRODUCTS ${MRUBY_LIB}
-)
-
add_library(mruby STATIC IMPORTED GLOBAL)
set_property(TARGET mruby APPEND
PROPERTY IMPORTED_LOCATION ${MRUBY_LIB}
@@ -298,7 +278,6 @@ set_property(TARGET mruby APPEND
set_property(TARGET mruby APPEND
PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MRUBY_DIR}/include
)
-add_dependencies(mruby mruby_vendor)
################################
# SQUIRREL
@@ -1055,6 +1034,19 @@ if(BUILD_SOKOL)
target_link_options(tic80-sokol PRIVATE -static -mconsole)
endif()
+ if(LINUX)
+ configure_file("${PROJECT_SOURCE_DIR}/build/linux/tic80.desktop.in" "${PROJECT_SOURCE_DIR}/build/linux/tic80.desktop")
+
+ install(TARGETS tic80-sokol DESTINATION bin)
+
+ SET(TIC80_DESKTOP_DIR "share/applications/")
+ SET(TIC80_PIXMAPS_DIR "share/icons/")
+
+ install (FILES ${PROJECT_SOURCE_DIR}/build/linux/tic80.desktop DESTINATION ${TIC80_DESKTOP_DIR})
+ install (FILES ${PROJECT_SOURCE_DIR}/build/linux/tic80.xml DESTINATION ${TIC80_DESKTOP_DIR})
+ install (FILES ${PROJECT_SOURCE_DIR}/build/linux/tic80.png DESTINATION ${TIC80_PIXMAPS_DIR})
+ endif()
+
target_link_libraries(tic80-sokol tic80studio sokol)
endif()

75
pkgs/tic-80/default.nix Normal file
View File

@ -0,0 +1,75 @@
# Build the TIC-80 virtual computer console with the PRO version. The
# developers are kind enough to make it easy to compile it if you know
# how.
{ stdenv, lib, alsaLib, cmake, fetchFromGitHub, freeglut, gtk3, libGLU, git
, libglvnd, mesa, rake, mruby, SDL2, pkgconfig, valgrind, sndio, libsamplerate
, zlib, pulseaudioSupport ? stdenv.isLinux, libpulseaudio, waylandSupport ? true
, wayland, libxkbcommon, esoundSupport ? true, espeak, jackSupport ? true, jack2
}:
# TODO: Fix the timestamp in the help section.
# TODO: Wait for SDL v2.0.18 for more Wayland support?
stdenv.mkDerivation rec {
pname = "tic-80";
version = "unstable-2021-12-18";
src = fetchFromGitHub {
owner = "nesbox";
repo = "TIC-80";
rev = "03d73e8d92b57b7396c3c13bc5fb54d4cbb29ed7";
sha256 = "sha256-AFxSpWaPhVFvF9gTx0UZmX8niNEw1VAKJOtx7F5uHhQ=";
fetchSubmodules = true;
};
# We're only replacing 'mruby' since it will have the most complications to
# build. Also, it uses the same version as the nixpkgs version as of
# 2021-12-18 which is v3.0.0.
patches = [ ./change-cmake.patch ];
postPatch = ''
substituteInPlace CMakeLists.txt --replace '@mruby@' "${mruby}"
'';
nativeBuildInputs = [ cmake pkgconfig ];
buildInputs = [
alsaLib
freeglut
gtk3
libsamplerate
libGLU
libglvnd
mesa
git
SDL2
zlib
mruby
rake
valgrind
sndio
] ++ lib.optional pulseaudioSupport libpulseaudio
++ lib.optional jackSupport jack2 ++ lib.optional esoundSupport espeak
++ lib.optionals (stdenv.isLinux && waylandSupport) [
wayland
libxkbcommon
];
# TODO: Replace SOKOL-built version with SDL.
cmakeFlags = [ "-DBUILD_PRO=ON" "-DBUILD_SDL=OFF" "-DBUILD_SOKOL=ON" ];
# Export all of the TIC-80-related utilities.
outputs = [ "out" "dev" ];
postInstall = ''
install -Dm755 bin/* -t $dev/bin
install -Dm644 lib/* -t $dev/lib
install -Dm644 ../include/* -t $dev/include
mkdir -p $out/share/tic80
cp -r ../demos $out/share/tic80/
mv $out/bin/tic80{-sokol,}
'';
meta = with lib; {
description = "A fantasy computer with built-in game dev tools.";
homepage = "https://tic80.com/";
license = licenses.mit;
};
}