1# Copyright 2018 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15licenses(["notice"]) 16 17# Common include paths 18sdl_includes = [ 19 "include", 20 "src/video/khronos", 21] 22 23objc_library( 24 name = "sdl2_objc", 25 srcs = glob([ 26 "src/**/*.h", 27 "include/*.h", 28 ]), 29 includes = sdl_includes, 30 non_arc_srcs = glob([ 31 "src/audio/coreaudio/*.m", 32 "src/file/cocoa/*.m", 33 "src/filesystem/cocoa/*.m", 34 "src/render/metal/*.m", 35 "src/video/cocoa/*.m", 36 ]), 37 sdk_frameworks = [ 38 "AudioToolbox", 39 "Carbon", 40 "CoreAudio", 41 "CoreVideo", 42 "Cocoa", 43 "ForceFeedback", 44 "IOKit", 45 "OpenGL", 46 "Metal", 47 ], 48 alwayslink = 1, 49) 50 51sdl_srcs = glob( 52 include = [ 53 "src/**/*.c", 54 "src/**/*.h", 55 ], 56 exclude = [ 57 "src/video/qnx/**", 58 "src/haptic/windows/**", 59 "src/test/*.c", 60 "src/thread/generic/*.c", 61 "src/core/linux/*.c", 62 ], 63) 64 65# In general, we bundle SDL2. However, on Linux that would require a header 66# generated by --configure, and a lot of buildflags and installing dev headers 67# is in general less painful, so we just link it dynamically. 68cc_library( 69 name = "sdl2", 70 srcs = select({ 71 "@com_google_quic_trace//buildenv:linux": [], 72 "@com_google_quic_trace//buildenv:osx": sdl_srcs, 73 }), 74 hdrs = glob(["include/*.h"]), 75 includes = sdl_includes, 76 linkopts = select({ 77 "@com_google_quic_trace//buildenv:linux": ["-lSDL2"], 78 "@com_google_quic_trace//buildenv:osx": [], 79 }), 80 textual_hdrs = glob(["src/thread/generic/*.c"]), 81 visibility = ["//visibility:public"], 82 deps = select({ 83 "@com_google_quic_trace//buildenv:linux": [], 84 "@com_google_quic_trace//buildenv:osx": [":sdl2_objc"], 85 }), 86) 87