Skip to content

Commit

Permalink
MacOSX support: workspace changes
Browse files Browse the repository at this point in the history
We no longer build glib from source, but instead require it to be
available locally.

Also modify other "local system" repositories to point at homebrew
directory locations.

This is not strictly better or worse than the master branch, since
users would generally be expected to adjust the local repositories
anyway, but at the same time this is not something we'll want to
integrate into master.

Also update the README.md to state the nature of this branch.
  • Loading branch information
tkoeppe committed Oct 19, 2018
1 parent ddd927f commit 048cb06
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 261 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# Experimental MacOSX port

This is _not_ the main _DeepMind Lab_ branch.

This is an experimental, non-functional development branch that contains
incompatible changes to make _DeepMind Lab_ work on MacOSX.

**Notable changes:**

* Different use of `sendfile` in `public/dmlab_so_loader.cc`.
* `glib` is no longer compiled from source, but must instead be
provided locally.

You need to pass `--apple_platform_type=macos` to all Bazel invocations.

You may want to use homebrew to install the following packages:
`glib`, `sdl2`, `python@2`, `numpy`. We also consume a dependency `-liconv`,
but that just seems to work.

The headful SDL renderer works (e.g. `//:game`, or `//:python_random_agent`
with `--define=graphics=sdl`). The headless renderers for OSMesa, GLX and EGL
do not work yet, apparently because we are missing the relevant library
dependencies. A native MacOSX "glimp" implementation seems like the best next
step (but is not complete yet).

<br><br><br>

# <img src="/docs/template/logo.png" alt="DeepMind Lab">

*DeepMind Lab* is a 3D learning environment based on id Software's
Expand Down
21 changes: 8 additions & 13 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ new_http_archive(
],
)

new_http_archive(
name = "glib_archive",
build_file = "glib.BUILD",
sha256 = "0cbb3d31c9d181bbcc97cba3d9dbe3250f75e2da25e5f7c8bf5a993fe54baf6a",
strip_prefix = "glib-2.55.1",
urls = [
"https://mirror.bazel.build/ftp.gnome.org/pub/gnome/sources/glib/2.55/glib-2.55.1.tar.xz",
"https://ftp.gnome.org/pub/gnome/sources/glib/2.55/glib-2.55.1.tar.xz",
],
)

new_http_archive(
name = "jpeg_archive",
build_file = "jpeg.BUILD",
Expand Down Expand Up @@ -98,14 +87,20 @@ new_http_archive(
)

# TODO: Replace with hermetic build
new_local_repository(
name = "glib_archive",
build_file = "glib.BUILD",
path ="/Users/ThisCouldBeYou/homebrew/Cellar/glib/2.56.1",
)

new_local_repository(
name = "sdl_system",
build_file = "sdl.BUILD",
path = "/usr",
path = "/Users/ThisCouldBeYou/homebrew/Cellar/sdl2/2.0.8",
)

new_local_repository(
name = "python_system",
build_file = "python.BUILD",
path = "/usr",
path = "/Users/ThisCouldBeYou/homebrew/Cellar",
)
246 changes: 4 additions & 242 deletions glib.BUILD
Original file line number Diff line number Diff line change
@@ -1,246 +1,8 @@
genrule(
name = "gen_configure",
srcs = [
"configure",
"config.guess",
"config.sub",
"install-sh",
"ltmain.sh",
"missing",
"glib/glib.h",
"po/LINGUAS",
] + glob(["**/*.in"]),
outs = [
"config.h",
"glibconfig.h",
],
cmd = "./$(location configure) --silent --disable-fam --disable-libmount --disable-dtrace --disable-compile-warnings --with-pcre=internal " +
"&& cp --verbose -- config.h $(location config.h)" +
"&& cp --verbose -- glib/glibconfig.h $(location glibconfig.h)",
)

cc_library(
name = "charset",
srcs = [
"config.h",
"glib/libcharset/localcharset.c",
],
hdrs = ["glib/libcharset/localcharset.h"],
copts = [
"-DHAVE_CONFIG_H",
"-DLIBDIR='\"/nonexistent\"'",
],
)

cc_library(
name = "glib",
srcs = [
"glib/deprecated/gallocator.c",
"glib/deprecated/gcache.c",
"glib/deprecated/gcompletion.c",
"glib/deprecated/grel.c",
"glib/deprecated/gthread.h",
"glib/deprecated/gthread-deprecated.c",
"glib/garray.c",
"glib/gasyncqueue.c",
"glib/gasyncqueueprivate.h",
"glib/gatomic.c",
"glib/gbacktrace.c",
"glib/gbase64.c",
"glib/gbitlock.c",
"glib/gbookmarkfile.c",
"glib/gbytes.c",
"glib/gcharset.c",
"glib/gcharsetprivate.h",
"glib/gchecksum.c",
"glib/gconvert.c",
"glib/gdataset.c",
"glib/gdatasetprivate.h",
"glib/gdate.c",
"glib/gdatetime.c",
"glib/gdir.c",
"glib/genviron.c",
"glib/gerror.c",
"glib/gfileutils.c",
"glib/ggettext.c",
"glib/ghash.c",
"glib/ghmac.c",
"glib/ghook.c",
"glib/ghostutils.c",
"glib/giochannel.c",
"glib/giounix.c",
"glib/gkeyfile.c",
"glib/glib-autocleanups.h",
"glib/glib-init.c",
"glib/glib-init.h",
"glib/glib-private.c",
"glib/glib-unix.c",
"glib/glist.c",
"glib/gmain.c",
"glib/gmain-internal.h",
"glib/gmappedfile.c",
"glib/gmarkup.c",
"glib/gmem.c",
"glib/gmessages.c",
"glib/gnode.c",
"glib/goption.c",
"glib/gpattern.c",
"glib/gpoll.c",
"glib/gprimes.c",
"glib/gprintf.c",
"glib/gqsort.c",
"glib/gquark.c",
"glib/gqueue.c",
"glib/grand.c",
"glib/gregex.c",
"glib/gscanner.c",
"glib/gsequence.c",
"glib/gshell.c",
"glib/gslice.c",
"glib/gslist.c",
"glib/gspawn.c",
"glib/gstdio.c",
"glib/gstdioprivate.h",
"glib/gstrfuncs.c",
"glib/gstring.c",
"glib/gstringchunk.c",
"glib/gtestutils.c",
"glib/gthread.c",
"glib/gthread-posix.c",
"glib/gthreadpool.c",
"glib/gthreadprivate.h",
"glib/gtimer.c",
"glib/gtimezone.c",
"glib/gtranslit.c",
"glib/gtranslit-data.h",
"glib/gtrashstack.c",
"glib/gtree.c",
"glib/gunibreak.c",
"glib/gunibreak.h",
"glib/gunicodeprivate.h",
"glib/gunicollate.c",
"glib/gunidecomp.c",
"glib/gunidecomp.h",
"glib/guniprop.c",
"glib/gurifuncs.c",
"glib/gutf8.c",
"glib/gutils.c",
"glib/guuid.h",
"glib/gvariant.c",
"glib/gvariant-core.c",
"glib/gvariant-core.h",
"glib/gvariant-internal.h",
"glib/gvariant-parser.c",
"glib/gvariant-serialiser.c",
"glib/gvariant-serialiser.h",
"glib/gvarianttype.c",
"glib/gvarianttypeinfo.c",
"glib/gvarianttypeinfo.h",
"glib/gversion.c",
"glib/gwakeup.c",
"glib/gwakeup.h",
"glib/libcharset/libcharset.h",
"glib/pcre/pcre.h",
],
hdrs = [
"config.h",
"glib/deprecated/gallocator.h",
"glib/deprecated/gcache.h",
"glib/deprecated/gcompletion.h",
"glib/deprecated/gmain.h",
"glib/deprecated/grel.h",
"glib/galloca.h",
"glib/garray.h",
"glib/gasyncqueue.h",
"glib/gatomic.h",
"glib/gbacktrace.h",
"glib/gbase64.h",
"glib/gbitlock.h",
"glib/gbookmarkfile.h",
"glib/gbytes.h",
"glib/gcharset.h",
"glib/gchecksum.h",
"glib/gconstructor.h",
"glib/gconvert.h",
"glib/gdataset.h",
"glib/gdate.h",
"glib/gdatetime.h",
"glib/gdir.h",
"glib/genviron.h",
"glib/gerror.h",
"glib/gfileutils.h",
"glib/ggettext.h",
"glib/ghash.h",
"glib/ghmac.h",
"glib/ghook.h",
"glib/ghostutils.h",
"glib/giochannel.h",
"glib/gkeyfile.h",
"glib/glib.h",
"glib/glib-private.h",
"glib/glib-unix.h",
"glib/glib_trace.h",
"glib/glibintl.h",
"glib/glist.h",
"glib/gmacros.h",
"glib/gmain.h",
"glib/gmappedfile.h",
"glib/gmarkup.h",
"glib/gmem.h",
"glib/gmessages.h",
"glib/gmirroringtable.h",
"glib/gnode.h",
"glib/goption.h",
"glib/gpattern.h",
"glib/gpoll.h",
"glib/gprimes.h",
"glib/gprintf.h",
"glib/gprintfint.h",
"glib/gqsort.h",
"glib/gquark.h",
"glib/gqueue.h",
"glib/grand.h",
"glib/gregex.h",
"glib/gscanner.h",
"glib/gscripttable.h",
"glib/gsequence.h",
"glib/gshell.h",
"glib/gslice.h",
"glib/gslist.h",
"glib/gspawn.h",
"glib/gstdio.h",
"glib/gstrfuncs.h",
"glib/gstring.h",
"glib/gstringchunk.h",
"glib/gtestutils.h",
"glib/gthread.h",
"glib/gthreadpool.h",
"glib/gtimer.h",
"glib/gtimezone.h",
"glib/gtrashstack.h",
"glib/gtree.h",
"glib/gtypes.h",
"glib/gunichartables.h",
"glib/gunicode.h",
"glib/gunicomp.h",
"glib/gurifuncs.h",
"glib/gutils.h",
"glib/gvariant.h",
"glib/gvarianttype.h",
"glib/gversion.h",
"glib/gversionmacros.h",
"glib/valgrind.h",
"glibconfig.h",
],
copts = [
"-Iexternal/glib_archive/glib",
"-DGLIB_COMPILATION",
"-DG_DISABLE_CAST_CHECKS",
"-DG_LOG_DOMAIN='\"GLib\"'",
"-DHAVE_CONFIG_H",
"-DPCRE_STATIC",
],
includes = ["."],
srcs = ["lib/libglib-2.0.0.dylib"],
hdrs = glob(["include/glib-2.0/**/*.h", "lib/glib-2.0/**/*.h"]),
includes = ["include/glib-2.0", "lib/glib-2.0/include"],
visibility = ["//visibility:public"],
deps = [":charset"],
linkopts = ["-liconv"],
)
12 changes: 8 additions & 4 deletions python.BUILD
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Description:
# Build rule for Python and Numpy.
# This rule works for Debian and Ubuntu. Other platforms might keep the
# headers in different places, cf. 'How to build DeepMind Lab' in build.md.

cc_library(
name = "python",
hdrs = glob(["include/python2.7/*.h"]),
includes = ["include/python2.7"],
hdrs = glob([
"python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/include/python2.7/*.h",
"numpy/1.15.2/lib/python2.7/site-packages/numpy/core/include/numpy/*.h",
]),
includes = [
"python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/include/python2.7",
"numpy/1.15.2/lib/python2.7/site-packages/numpy/core/include",
],
visibility = ["//visibility:public"],
)
3 changes: 1 addition & 2 deletions sdl.BUILD
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Description:
# Build rule for SDL2.
# Compiler and linker flags found with `sdl2-config --libs --cflags`.

cc_library(
name = "sdl2",
hdrs = glob(["include/SDL2/*.h"]),
srcs = ["lib/libSDL2-2.0.0.dylib"],
defines = ["_REENTRANT"],
includes = ["include/SDL2"],
linkopts = ["-lSDL2"],
visibility = ["//visibility:public"],
)

0 comments on commit 048cb06

Please sign in to comment.