Skip to content

Building on FreeBSD #1941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 31, 2022
Merged

Building on FreeBSD #1941

merged 4 commits into from
May 31, 2022

Conversation

peterhil
Copy link
Contributor

These instructions and changes allow to build the project on FreeBSD 13.0-RELEASE-p11.

I tested a few games, and everything seemed to work, including audio.
I could not find where the path to swrast_dri.so is defined, so I just added a note to the README.md about it.

@remi6397
Copy link
Contributor

TIC-80 builds out-of-the-box for me on 13.1-RELEASE without SDLGPU. I have a port for it:

PORTNAME=	tic-80
PORTVERSION=	1.0.2164
DISTVERSIONPREFIX=	v
CATEGORIES=	games

LICENSE=    MIT
COMMENT?=	A fantasy computer for making, playing and sharing tiny games

USES=	cmake

CMAKE_ARGS=	-DBUILD_LIBRETRO:BOOL=false \
	-DBUILD_SDL:BOOL=true \
	-DEXTRA_LDFLAGS=-L/usr/local/lib \
	-DCMAKE_C_FLAGS=-I/usr/local/include

PLIST_FILES=	bin/tic80 share/applications/tic80.desktop share/applications/tic80.xml share/icons/tic80.png

USE_GITHUB=	yes
GH_TUPLE=   cofyc:argparse:0d5f5d0:argparse/vendor/argparse \
	nesbox:blip-buf:330226d:blip_buf/vendor/blip-buf \
	smuehlst:circle-stdlib:fdb3c4a:circle_stdlib/vendor/circle-stdlib \
	tronkko:dirent:c885633:dirent/vendor/dirent \
	svaarala:duktape-releases:28f915a:duktape/vendor/duktape \
	nesbox:giflib:1aa11b0:giflib/vendor/giflib \
	nodejs:http-parser:ec8b5ee:http_parser/vendor/http-parser \
	glennrp:libpng:dbe3e0c:libpng/vendor/libpng \
	libuv:libuv:9c3d692:libuv/vendor/libuv \
	nesbox:lpeg:73d8614:lpeg/vendor/lpeg \
	lua:lua:75ea9cc:lua/vendor/lua \
	nesbox:moonscript:1717928:moonscript/vendor/moonscript \
	mruby:mruby:0f45836:mruby/vendor/mruby \
	grimfang4:sdl-gpu:e3d350b:sdl_gpu/vendor/sdl-gpu \
	libsdl-org:SDL:b424665:sdl2/vendor/sdl2 \
	floooh:sokol:487822d:sokol/vendor/sokol \
	albertodemichelis:squirrel:9dcf74f:squirrel/vendor/squirrel \
	wasm3:wasm3:a3abb3f:wasm3/vendor/wasm3 \
	wren-lang:wren:4a18fc4:wren/vendor/wren \
	kuba--:zip:d7df626:zip/vendor/zip \
	madler:zlib:cacf7f1:zlib/vendor/zlib
GH_ACCOUNT=	nesbox
GH_PROJECT=	TIC-80

OPTIONS_DEFINE=	PRO SDLGPU
OPTIONS_DEFAULT?=	PRO

PRO_DESC=	Build the Pro version
PRO_CMAKE_BOOL=	BUILD_PRO

SDLGPU_DESC=	Build SDLGPU and the CRT shader
SDLGPU_CMAKE_BOOL=	BUILD_SDLGPU

.include <bsd.port.options.mk>

.include <bsd.port.mk>

# Any copyright is dedicated to the Public Domain.
# https://creativecommons.org/publicdomain/zero/1.0/
# vim: set ts=12 sts=12 sw=12 :

As for the DRI, I have no such problems with nVidia drivers, so unless it's something with SDLGPU, something might be wrong with your system.

@peterhil
Copy link
Contributor Author

peterhil commented May 28, 2022

As for the DRI, I have no such problems with nVidia drivers, so unless it's something with SDLGPU, something might be wrong with your system.

Well, you add the FreeBSD libs with the port definition, I add them in the CMakeLists.txt. Either approach makes the build work.

Without symlinking the swrast_dri.so from /usr/local/lib/dri/ directory to /usr/local/lib/dri-devel/, I get the error below. So it just uses the wrong directory.

I built Tic-80 with:
cmake .. -DBUILD_PRO=On -DBUILD_PLAYER=On -DBUILD_SDL=On

/usr/home/peterhil/code/games/tic80/src/TIC-80/build/ ./bin/tic80 

 TIC-80 tiny computer
 version 1.0.2159-dev Pro (a611ded)
 https://tic80.com (C) 2017-2022
libGL error: MESA-LOADER: failed to open swrast: Cannot open "/usr/local/lib/dri-devel/swrast_dri.so" (search paths /usr/local/lib/dri-devel, suffix _dri)
libGL error: failed to load driver: swrast
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  151 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  163
  Current serial number in output stream:  164

@peterhil
Copy link
Contributor Author

unless it's something with SDLGPU

Building with:
cmake .. -DBUILD_PRO=On -DBUILD_PLAYER=On -DBUILD_SDL=On -DBUILD_SDLGPU=On

Fails with:

Consolidate compiler generated dependencies of target sdlgpu
[ 48%] Building C object CMakeFiles/sdlgpu.dir/vendor/sdl-gpu/src/renderer_OpenGL_1.c.o
In file included from /usr/home/peterhil/code/games/tic80/src/TIC-80/vendor/sdl-gpu/src/renderer_OpenGL_1.c:1:
In file included from /usr/home/peterhil/code/games/tic80/src/TIC-80/vendor/sdl-gpu/include/SDL_gpu_OpenGL_1.h:14:
/usr/home/peterhil/code/games/tic80/src/TIC-80/vendor/sdl-gpu/src/externals/glew/GL/glew.h:1202:14: fatal error: 'GL/glu.h' file not found
#    include <GL/glu.h>
             ^~~~~~~~~~
1 error generated.
*** [CMakeFiles/sdlgpu.dir/vendor/sdl-gpu/src/renderer_OpenGL_1.c.o] Error code 1

So probably sdl-gpu's CMakeLists.txt would need to be modified in the similar way as I have done here in this pull request...

@peterhil
Copy link
Contributor Author

Without symlinking the swrast_dri.so from /usr/local/lib/dri/ directory to /usr/local/lib/dri-devel/, I get the error below. So it just uses the wrong directory.

Somebody else on FreeBSD also wondered why swrast_dri.so is missing from dir-devel directory on this Mesa bug #5610.

Copy link
Collaborator

@joshgoebel joshgoebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no way to test this but these changes look reasonable.

Copy link
Contributor

@remi6397 remi6397 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, it makes no sense to forcefully inject include and link paths, we're not doing this for /usr. That's just not TIC's business. As for the DRI perplexities, I also don't really think that belongs here either.

I'd love to be able to export carts for FreeBSD though, that'd be really welcome. :)

@nesbox nesbox merged commit 0dd7bd7 into nesbox:main May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants