Skip to content

Commit

Permalink
ci: Add macos build
Browse files Browse the repository at this point in the history
  • Loading branch information
Zer0-One committed Dec 12, 2023
1 parent 7650574 commit ed3b450
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ build:linux --features=layering_check
build:linux --cxxopt='-std=c++2b'
build:linux --cxxopt='-fno-rtti'

build:macos --features=layering_check
build:macos --cxxopt='-std=c++2b'
build:macos --cxxopt='-fno-rtti'

# Force DWARF-4 format for debug symbols for compatibility with valgrind.
# See: https://bugs.kde.org/show_bug.cgi?id=452758
build:linux --copt='-gdwarf-4'
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ jobs:
echo "<html><body><h1>Example</h1><p>This is an example page.</p></body></html>" >example.html
./bazelisk run browser:tui file://$(pwd)/example.html
macos:
runs-on: macos-13
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
# This build relies on an ICU pre-installed via homebrew.
- run: export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"; export PATH="/usr/local/opt/icu4c/bin:/usr/local/opt/icu4c/sbin:$PATH"; bazelisk build //...
- run: export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"; export PATH="/usr/local/opt/icu4c/bin:/usr/local/opt/icu4c/sbin:$PATH"; bazelisk test //...

windows-msvc:
runs-on: windows-2022
timeout-minutes: 40
Expand Down
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ http_archive(
http_archive(
name = "bazel_clang_tidy",
# Hack to have every .h-header treated as C++.
patch_cmds = ["""sed -i '47i \\ args.add("-xc++")' clang_tidy/clang_tidy.bzl"""],
patch_cmds = ["""sed -i'' -e '47i\\\n args.add("-xc++")' clang_tidy/clang_tidy.bzl"""],
sha256 = "e2721c47f4215ac36ad1da55ebdb968a094125dbc397aa7733f067001600b2ee",
strip_prefix = "bazel_clang_tidy-133d89a6069ce253a92d32a93fdb7db9ef100e9d",
url = "https://github.com/erenon/bazel_clang_tidy/archive/133d89a6069ce253a92d32a93fdb7db9ef100e9d.tar.gz",
Expand All @@ -82,7 +82,7 @@ http_archive(
# boringssl//:ssl cheats and pulls in private includes from boringssl//:crypto.
http_archive(
name = "boringssl", # OpenSSL + ISC
patch_cmds = ["""sed -i '33i package(features=["-layering_check"])' BUILD"""],
patch_cmds = ["""sed -i'' -e '33i\\\npackage(features=["-layering_check"])' BUILD"""],
sha256 = "6369980cd79b3847a17a8e078dce37688671911a6fadb1c84e27fb505d827511",
strip_prefix = "boringssl-22b3ea0c113b544e4334377541cabe8d8038d0c7",
url = "https://github.com/google/boringssl/archive/22b3ea0c113b544e4334377541cabe8d8038d0c7.tar.gz",
Expand Down Expand Up @@ -187,7 +187,7 @@ http_archive(
# in MSVC debug builds with "cannot seek string_view iterator after end".
# See: https://github.com/SFML/SFML/issues/2113
patch_cmds = [
"sed -i 's/if (begin + trailingBytes < end)/if (trailingBytes < std::distance(begin, end))/' include/SFML/System/Utf.inl",
"sed -i'' -e 's/if (begin + trailingBytes < end)/if (trailingBytes < std::distance(begin, end))/' include/SFML/System/Utf.inl",
],
sha256 = "6124b5fe3d96e7f681f587e2d5b456cd0ec460393dfe46691f1933d6bde0640b",
strip_prefix = "SFML-2.5.1",
Expand Down
4 changes: 4 additions & 0 deletions gfx/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ cc_library(
# sfml leaks this into our code.
"-Wno-implicit-fallthrough",
],
"@platforms//os:macos": [
# sfml leaks this into our code.
"-Wno-implicit-fallthrough",
],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
Expand Down
4 changes: 4 additions & 0 deletions net/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ NET_COPTS = HASTUR_COPTS + select({
"-Wno-shadow",
"-Wno-unknown-pragmas",
],
"@platforms//os:macos": [
"-Wno-shadow",
"-Wno-unknown-pragmas",
],
"//conditions:default": [],
})

Expand Down
8 changes: 8 additions & 0 deletions os/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,28 @@ cc_library(

OS_DEPS = select({
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"@platforms//os:windows": [":windows_setup"],
})

OS_LOCAL_DEFINES = select({
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"@platforms//os:windows": ["WIN32_LEAN_AND_MEAN"],
})

cc_library(
name = "memory",
srcs = select({
"@platforms//os:linux": ["memory_linux.cpp"],
"@platforms//os:macos": ["memory_linux.cpp"],
"@platforms//os:windows": ["memory_windows.cpp"],
}),
hdrs = ["memory.h"],
copts = HASTUR_COPTS,
linkopts = select({
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"@platforms//os:windows": [
"-DEFAULTLIB:Kernel32",
],
Expand All @@ -50,12 +54,14 @@ cc_library(
name = "system_info",
srcs = select({
"@platforms//os:linux": ["system_info_linux.cpp"],
"@platforms//os:macos": ["system_info_linux.cpp"],
"@platforms//os:windows": ["system_info_windows.cpp"],
}),
hdrs = ["system_info.h"],
copts = HASTUR_COPTS,
linkopts = select({
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"@platforms//os:windows": [
"-DEFAULTLIB:Shcore",
"-DEFAULTLIB:User32",
Expand All @@ -82,12 +88,14 @@ cc_library(
name = "xdg",
srcs = select({
"@platforms//os:linux": ["xdg_linux.cpp"],
"@platforms//os:macos": ["xdg_linux.cpp"],
"@platforms//os:windows": ["xdg_windows.cpp"],
}),
hdrs = ["xdg.h"],
copts = HASTUR_COPTS,
linkopts = select({
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"@platforms//os:windows": [
"-DEFAULTLIB:Shell32",
"-DEFAULTLIB:Kernel32",
Expand Down
1 change: 1 addition & 0 deletions third_party/ftxui.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ cc_library(
includes = ["include/"],
local_defines = select({
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"@platforms//os:windows": [
"_UNICODE",
"UNICODE",
Expand Down
6 changes: 2 additions & 4 deletions third_party/icu.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ cc_library(
}),
linkstatic = True,
local_defines = ["U_TOOLUTIL_IMPLEMENTATION"] + select({
"@platforms//os:windows": [],
"//conditions:default": [
"U_ELF",
],
"@platforms//os:linux": ["U_ELF"],
"//conditions:default": [],
}),
strip_include_prefix = "source/tools/toolutil",
visibility = ["//visibility:private"],
Expand Down
10 changes: 8 additions & 2 deletions third_party/imgui-sfml.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ IMGUI_SFML_COPTS = select({
"@platforms//os:linux": [
"-Wno-switch",
],
"@platforms//os:macos": [
"-Wno-switch",
],
"//conditions:default": [],
})

Expand All @@ -16,13 +19,16 @@ cc_library(
includes = ["."],
linkopts = select({
"@platforms//os:linux": ["-lGL"],
"@platforms//os:macos": ["-lGL"],
"@platforms//os:windows": ["-DEFAULTLIB:opengl32"],
}),
visibility = ["//visibility:public"],
deps = [
"@imgui",
"@sfml//:graphics",
"@sfml//:system",
"@sfml//:window",
],
] + select({
"@platforms//os:macos": ["@sfml//:window_macos"],
"//conditions:default": ["@sfml//:window"],
}),
)
45 changes: 45 additions & 0 deletions third_party/sfml.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ cc_library(
"src/SFML/System/Unix/**/*.cpp",
"src/SFML/System/Unix/**/*.hpp",
]),
"@platforms//os:macos": glob([
"src/SFML/System/Unix/**/*.cpp",
"src/SFML/System/Unix/**/*.hpp",
]),
"@platforms//os:windows": glob([
"src/SFML/System/Win32/**/*.cpp",
"src/SFML/System/Win32/**/*.hpp",
Expand All @@ -28,6 +32,9 @@ cc_library(
"@platforms//os:linux": [
"-pthread",
],
"@platforms//os:macos": [
"-pthread",
],
"@platforms//os:windows": [
"-DEFAULTLIB:winmm",
],
Expand Down Expand Up @@ -76,6 +83,10 @@ cc_library(
],
}),
strip_include_prefix = "include/",
target_compatible_with = select({
"@platforms//os:macos": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [":system"] + select({
"@platforms//os:linux": [
Expand All @@ -86,6 +97,35 @@ cc_library(
}),
)

objc_library(
name = "window_macos",
srcs = glob(
include = [
"src/SFML/Window/*.cpp",
"src/SFML/Window/*.hpp",
"src/SFML/Window/OSX/*.cpp",
"src/SFML/Window/OSX/*.hpp",
"src/SFML/Window/OSX/*.m",
"src/SFML/Window/OSX/*.mm",
],
exclude = [
"src/SFML/Window/EGLCheck.cpp",
"src/SFML/Window/EGLCheck.hpp",
"src/SFML/Window/EglContext.cpp",
"src/SFML/Window/EglContext.hpp",
],
),
hdrs = glob(["include/SFML/Window/*"]),
copts = ["-Iexternal/sfml/src/"],
defines = SFML_DEFINES,
target_compatible_with = select({
"@platforms//os:macos": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
visibility = ["//visibility:public"],
deps = [":system"],
)

cc_library(
name = "graphics",
srcs = glob(
Expand All @@ -103,6 +143,11 @@ cc_library(
"-lGL",
"-lX11",
],
#"@platforms//os:macos": [
# "-lGL",
# "-lX11",
#],
"@platforms//os:macos": [],
"@platforms//os:windows": [],
}),
strip_include_prefix = "include/",
Expand Down
1 change: 1 addition & 0 deletions third_party/spdlog.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ cc_library(
includes = ["include/"],
linkopts = select({
"@platforms//os:linux": ["-lpthread"],
"@platforms//os:macos": ["-lpthread"],
"@platforms//os:windows": [],
}),
strip_include_prefix = "include",
Expand Down
8 changes: 7 additions & 1 deletion third_party/unifex.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ genrule(
name = "config_header",
srcs = ["include/unifex/config.hpp.in"],
outs = ["include/unifex/config.hpp"],
cmd = "cat $< | sed -r 's/^#cmakedefine01 (.*)/#define \\1 1/g' - | sed '/^#cmakedefine/d' | sed s/@libunifex_VERSION_MAJOR@/0/g | sed s/@libunifex_VERSION_MINOR@/1/g >$@",
cmd = "cat $< | sed -r 's/^#cmakedefine01 (.*)/#define \\1 1/g' | sed '/^#cmakedefine/d' | sed s/@libunifex_VERSION_MAJOR@/0/g | sed s/@libunifex_VERSION_MINOR@/1/g >$@",
)

cc_library(
name = "unifex",
srcs = glob(["source/*.cpp"]) + select({
"@platforms//os:linux": glob(["source/linux/*"]),
"@platforms//os:macos": [],
"@platforms//os:windows": glob([
"include/unifex/win32/detail/*.hpp",
"source/win32/*",
Expand All @@ -22,6 +23,7 @@ cc_library(
"include/unifex/detail/*.hpp",
]) + [":config_header"] + select({
"@platforms//os:linux": glob(["include/unifex/linux/*.hpp"]),
"@platforms//os:macos": [],
"@platforms//os:windows": glob(["include/unifex/win32/*.hpp"]),
}),
includes = ["include/"],
Expand All @@ -35,6 +37,10 @@ cc_library(
name = src[:-4],
size = "small",
srcs = [src],
#target_compatible_with = select({
# "@platforms//os:macos": ["@platforms//:incompatible"],
# "//conditions:default": [],
#}),
deps = [":unifex"],
) for src in glob(["examples/*.cpp"])]

Expand Down
1 change: 1 addition & 0 deletions third_party/zlib.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cc_library(
includes = ["."],
local_defines = select({
"@platforms//os:linux": ["Z_HAVE_UNISTD_H"],
"@platforms//os:macos": ["Z_HAVE_UNISTD_H"],
"@platforms//os:windows": [],
}),
visibility = ["//visibility:public"],
Expand Down
1 change: 1 addition & 0 deletions type/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ cc_test(
SFML_TYPE_COPTS = HASTUR_COPTS + select({
# SFML leaks this into our code.
"@platforms//os:linux": ["-Wno-implicit-fallthrough"],
"@platforms//os:macos": ["-Wno-implicit-fallthrough"],
"//conditions:default": [],
})

Expand Down

0 comments on commit ed3b450

Please sign in to comment.