Skip to content

Commit

Permalink
force apply glibc-2.17 to vizdoom binary (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinkle23897 authored Jan 20, 2022
1 parent cbed26f commit 55996cf
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
release:
runs-on: [self-hosted, Linux, X64, Wheel]
runs-on: ${{ matrix.python-version }}
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
test:
runs-on: [self-hosted, Linux, X64]
runs-on: [self-hosted, Linux, X64, Test]
steps:
- name: Cancel previous run
uses: styfle/cancel-workflow-action@0.9.1
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ docker-release:
docker run --network=host -v `pwd`/wheelhouse:/whl -it $(PROJECT_NAME)-release:$(COMMIT_HASH) bash -c "cp wheelhouse/* /whl"
echo successfully build docker image with tag $(PROJECT_NAME)-release:$(COMMIT_HASH)

pypi-wheel: bazel-clean auditwheel-install bazel-build
pypi-wheel: auditwheel-install bazel-build
ls dist/*.whl | xargs auditwheel repair --plat manylinux_2_17_x86_64

release-test1:
Expand Down
2 changes: 2 additions & 0 deletions envpool/make_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def test_make_atari(self) -> None:
self.assertEqual(env_dm.action_spec().num_values, 18)

def test_make_vizdoom(self) -> None:
spec = envpool.make_spec("MyWayHome-v1")
print(spec)
env = envpool.make_gym("MyWayHome-v1")
print(env)
self.assertIsInstance(env, gym.Env)
Expand Down
15 changes: 3 additions & 12 deletions envpool/vizdoom/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ genrule(
cmd = "mkdir -p $(OUTS) && cp $(SRCS) $(OUTS)",
)

genrule(
name = "gen_vizdoom_exe",
srcs = [
"@vizdoom",
"@vizdoom//:vizdoom_pk3",
"@freedoom",
],
outs = ["bin"],
cmd = "mkdir -p $(OUTS) && cp $(SRCS) $(OUTS)",
)

cc_library(
name = "utils",
hdrs = ["utils.h"],
Expand Down Expand Up @@ -68,7 +57,9 @@ py_library(
name = "vizdoom",
srcs = ["__init__.py"],
data = [
":gen_vizdoom_exe",
"//envpool/vizdoom/bin:vizdoom_bin",
"//envpool/vizdoom/bin:vizdoom_pk3",
"//envpool/vizdoom/bin:freedoom",
":gen_vizdoom_maps",
":vizdoom_envpool.so",
],
Expand Down
25 changes: 25 additions & 0 deletions envpool/vizdoom/bin/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package(default_visibility = ["//visibility:public"])

genrule(
name = "vizdoom_bin",
srcs = ["@vizdoom//:vizdoom"],
outs = ["vizdoom"],
cmd = "cp $< $@",
executable = True,
)

genrule(
name = "vizdoom_pk3",
srcs = ["@vizdoom//:vizdoom_pk3"],
outs = ["vizdoom.pk3"],
cmd = "cp $< $@",
executable = True,
)

genrule(
name = "freedoom",
srcs = ["@freedoom"],
outs = ["freedoom2.wad"],
cmd = "cp $< $@",
executable = True,
)
11 changes: 11 additions & 0 deletions envpool/workspace0.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ def workspace():
],
)

maybe(
http_archive,
name = "glibc_version_header",
sha256 = "57db74f933b7a9ea5c653498640431ce0e52aaef190d6bb586711ec4f8aa2b9e",
strip_prefix = "glibc_version_header-0.1/version_headers/",
urls = [
"https://github.com/wheybags/glibc_version_header/archive/refs/tags/0.1.tar.gz",
],
build_file = "//third_party/glibc_version_header:glibc_version_header.BUILD",
)

maybe(
http_archive,
name = "concurrentqueue",
Expand Down
Empty file.
5 changes: 5 additions & 0 deletions third_party/glibc_version_header/glibc_version_header.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
filegroup(
name = "glibc_2_17",
srcs = ["force_link_glibc_2.17.h"],
visibility = ["//visibility:public"],
)
50 changes: 44 additions & 6 deletions third_party/vizdoom/vizdoom.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ load("@envpool//third_party:common.bzl", "template_rule")

cc_binary(
name = "arithchk",
srcs = ["gdtoa/arithchk.c"],
srcs = [
"gdtoa/arithchk.c",
"@glibc_version_header//:glibc_2_17",
],
copts = [
"-include $(execpath @glibc_version_header//:glibc_2_17)",
],
)

genrule(
Expand All @@ -18,6 +24,10 @@ cc_binary(
srcs = [
"gdtoa/qnan.c",
":arith.h",
"@glibc_version_header//:glibc_2_17",
],
copts = [
"-include $(execpath @glibc_version_header//:glibc_2_17)",
],
)

Expand All @@ -37,13 +47,15 @@ cc_library(
"gdtoa/misc.c",
":arith.h",
":gd_qnan.h",
"@glibc_version_header//:glibc_2_17",
],
hdrs = glob(["gdtoa/*.h"]),
copts = [
"-Wall",
"-Wextra",
"-DINFNAN_CHECK",
"-DMULTIPLE_THREADS",
"-include $(execpath @glibc_version_header//:glibc_2_17)",
],
strip_include_prefix = "gdtoa",
)
Expand All @@ -58,6 +70,7 @@ cc_library(
"bzip2/decompress.c",
"bzip2/huffman.c",
"bzip2/randtable.c",
"@glibc_version_header//:glibc_2_17",
],
hdrs = glob([
"bzip2/*.h",
Expand All @@ -67,6 +80,7 @@ cc_library(
"-Wall",
"-Wextra",
"-fomit-frame-pointer",
"-include $(execpath @glibc_version_header//:glibc_2_17)",
],
strip_include_prefix = "bzip2",
)
Expand All @@ -91,7 +105,9 @@ cc_library(
"lzma/C/Threads.c",
"lzma/C/LzFindMt.c",
],
),
) + [
"@glibc_version_header//:glibc_2_17",
],
hdrs = glob(
[
"lzma/C/*.h",
Expand All @@ -107,6 +123,7 @@ cc_library(
"-Wextra",
"-fomit-frame-pointer",
"-D_7ZIP_PPMD_SUPPPORT",
"-include $(execpath @glibc_version_header//:glibc_2_17)",
],
strip_include_prefix = "lzma/C",
)
Expand All @@ -123,15 +140,23 @@ cc_binary(
"tools/re2c/scanner.cc",
"tools/re2c/substr.cc",
"tools/re2c/translate.cc",
"@glibc_version_header//:glibc_2_17",
] + glob(["tools/re2c/*.h"]),
copts = [
"-DHAVE_CONFIG_H",
"-include $(execpath @glibc_version_header//:glibc_2_17)",
],
)

cc_binary(
name = "lemon",
srcs = ["tools/lemon/lemon.c"],
srcs = [
"tools/lemon/lemon.c",
"@glibc_version_header//:glibc_2_17",
],
copts = [
"-include $(execpath @glibc_version_header//:glibc_2_17)",
],
)

genrule(
Expand Down Expand Up @@ -177,7 +202,9 @@ cc_library(
"dumb/**/*.h",
"dumb/**/*.c",
"dumb/**/*.inc",
]),
]) + [
"@glibc_version_header//:glibc_2_17",
],
hdrs = glob([
"dumb/include/*.h",
]),
Expand All @@ -187,6 +214,7 @@ cc_library(
"-Wno-pointer-sign",
"-Wno-uninitialized",
"-Wno-unused-but-set-variable",
"-include $(execpath @glibc_version_header//:glibc_2_17)",
],
includes = [
"dumb/include",
Expand All @@ -198,14 +226,17 @@ cc_library(
srcs = glob([
"game-music-emu/gme/*.cpp",
"game-music-emu/gme/*.h",
]),
]) + [
"@glibc_version_header//:glibc_2_17",
],
hdrs = [
"game-music-emu/gme/gme.h",
],
copts = [
"-DLIBGME_VISIBILITY",
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
"-include $(execpath @glibc_version_header//:glibc_2_17)",
],
strip_include_prefix = "game-music-emu",
)
Expand Down Expand Up @@ -300,12 +331,14 @@ cc_library(
"src/*.h",
]) + [
"src/oplsynth/fmopl.cpp",
"@glibc_version_header//:glibc_2_17",
],
copts = [
"-Dstricmp=strcasecmp",
"-Dstrnicmp=strncasecmp",
"-fno-tree-dominator-opts",
"-fno-tree-fre",
"-include $(execpath @glibc_version_header//:glibc_2_17)",
],
includes = [
"src",
Expand All @@ -316,12 +349,16 @@ cc_binary(
name = "zipdir",
srcs = [
"tools/zipdir/zipdir.c",
"@glibc_version_header//:glibc_2_17",
],
deps = [
":bzip2",
":lzma",
"@zlib",
],
copts = [
"-include $(execpath @glibc_version_header//:glibc_2_17)",
],
)

filegroup(
Expand Down Expand Up @@ -688,14 +725,14 @@ cc_binary(
"src/viz_message_queue.cpp",
"src/viz_shared_memory.cpp",
"src/viz_system.cpp",
"@glibc_version_header//:glibc_2_17",
],
copts = [
"-Dstricmp=strcasecmp",
"-Dstrnicmp=strncasecmp",
"-DNO_GTK=1",
"-DNO_FMOD=1",
"-DNO_OPENAL=1",
"-std=c++11",
"-fPIC",
"-fomit-frame-pointer",
"-D__forceinline=inline",
Expand All @@ -715,6 +752,7 @@ cc_binary(
"-msse",
"-msse2",
"-mmmx",
"-include $(execpath @glibc_version_header//:glibc_2_17)",
],
data = [
":vizdoom_pk3",
Expand Down

0 comments on commit 55996cf

Please sign in to comment.