diff --git a/.travis.yml b/.travis.yml index bca534ac3..e480ebab9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ addons: - python-dev - python-numpy - python-pil - - realpath before_install: - curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add - diff --git a/BUILD b/BUILD index ca547f465..8523d465f 100644 --- a/BUILD +++ b/BUILD @@ -686,8 +686,9 @@ genrule( " A=$$(dirname $$s); " + " B=$${A/assets/}; " + " mkdir -p $(@D)/baselab$${B}; " + - " ln -s -L -t $(@D)/baselab$${B} $$(realpath $${s}); " + + " ln -s -L -t $(@D)/baselab$${B} $$($(location //deepmind/support:realpath) $${s}); " + "done", + tools = ["//deepmind/support:realpath"], visibility = ["//visibility:public"], ) @@ -703,8 +704,9 @@ genrule( cmd = "for s in $(SRCS); do " + " A=$$(dirname $$s); " + " mkdir -p $(@D)/baselab/$${A}; " + - " ln -s -L -t $(@D)/baselab/$${A} $$(realpath $${s}); " + + " ln -s -L -t $(@D)/baselab/$${A} $$($(location //deepmind/support:realpath) $${s}); " + "done", + tools = ["//deepmind/support:realpath"], visibility = ["//visibility:public"], ) @@ -719,8 +721,9 @@ genrule( outs = ["baselab/maps" + f[len("assets/maps/built"):] for f in BUILT_MAPS], cmd = "for s in $(SRCS); do " + " mkdir -p $(@D)/baselab/maps; " + - " ln -s -L -t $(@D)/baselab/maps $$(realpath $${s}); " + + " ln -s -L -t $(@D)/baselab/maps $$($(location //deepmind/support:realpath) $${s}); " + "done", + tools = ["//deepmind/support:realpath"], visibility = ["//visibility:public"], ) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index c7d989d8e..f9b737e97 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -14,6 +14,8 @@ state](https://github.com/ioquake/ioq3/tree/29db64070aa0bae49953bddbedbed5e317af48ba). 5. Lua 5.1 is now downloaded and built from source, and is thus no longer a required local dependency. +6. A minimal version of the "realpath" utility is now bundled with the code, + and thus "realpath" is no longer a required local dependency. ### Bug Fixes: diff --git a/deepmind/support/BUILD b/deepmind/support/BUILD index 36676217d..2b4eb7d7b 100644 --- a/deepmind/support/BUILD +++ b/deepmind/support/BUILD @@ -23,3 +23,13 @@ cc_library( hdrs = ["test_srcdir.h"], defines = ["SUPPRESS_COMMANDLINE_FLAGS"], ) + +cc_binary( + name = "realpath", + srcs = ["realpath.c"], + copts = [ + "-std=c99", + "-D_BSD_SOURCE", + "-D_POSIX_C_SOURCE", + ], +) diff --git a/deepmind/support/realpath.c b/deepmind/support/realpath.c new file mode 100644 index 000000000..aad951204 --- /dev/null +++ b/deepmind/support/realpath.c @@ -0,0 +1,46 @@ +// Copyright (C) 2018 Google Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +//////////////////////////////////////////////////////////////////////////////// +// +// A minimal driver for Posix realpath(). Not every Posix system supplies such +// a driver, and even on those that do it might require a separate installation +// step. This implements the equivalent of "realpath -e" on Linux. + +#include +#include +#include +#include + +int main(int argc, char* argv[]) { + int num_errors = 0; + errno = 0; + + for (int i = 1; i < argc; ++i) { + char* p = realpath(argv[i], NULL); + if (p == NULL) { + fprintf(stderr, "Error resolving path '%s', error was: '%s'\n", + argv[i], strerror(errno)); + errno = 0; + ++num_errors; + } else { + fprintf(stdout, "%s\n", p); + free(p); + } + } + + return num_errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/docs/users/build.md b/docs/users/build.md index 4b9ffb409..5550b6cba 100644 --- a/docs/users/build.md +++ b/docs/users/build.md @@ -31,7 +31,7 @@ are documented in a [separate section](#python-dependencies) below. ```shell $ sudo apt-get install libffi-dev gettext freeglut3-dev libsdl2-dev \ - libosmesa6-dev python-dev python-numpy python-pil realpath + libosmesa6-dev python-dev python-numpy python-pil ``` * On Red Hat Enterprise Linux Server: