Viewer on Mac.

- Support ObjC / ObjC++
  - Build SDL on Mac.
  - Build viewer on Mac.

Patched from Jim's CL.

BUG=skia:

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3760

Change-Id: I12663f2ed2969e22f51aefed560fbc22b2524167
Reviewed-on: https://skia-review.googlesource.com/3760
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Mike Klein 2016-10-20 10:17:47 -04:00 committed by Skia Commit-Bot
parent 580046bc1a
commit 43c2526665
4 changed files with 210 additions and 1 deletions

View File

@ -1182,7 +1182,7 @@ if (skia_enable_tools) {
testonly = true
}
if (skia_enable_gpu && (is_linux || is_win)) {
if (skia_enable_gpu && (is_linux || is_win || is_mac)) {
executable("viewer") {
sources = [
"tools/viewer/GMSlide.cpp",
@ -1211,6 +1211,13 @@ if (skia_enable_tools) {
"tools/viewer/sk_app/win/Window_win.cpp",
"tools/viewer/sk_app/win/main_win.cpp",
]
} else if (is_mac) {
sources += [
"tools/viewer/sk_app/mac/GLWindowContext_mac.cpp",
"tools/viewer/sk_app/mac/RasterWindowContext_mac.cpp",
"tools/viewer/sk_app/mac/Window_mac.cpp",
"tools/viewer/sk_app/mac/main_mac.cpp",
]
}
if (skia_use_vulkan) {
@ -1234,6 +1241,9 @@ if (skia_enable_tools) {
":views",
"//third_party/jsoncpp",
]
if (is_mac) {
deps += [ "//third_party/libsdl" ]
}
testonly = true
}
}

View File

@ -200,6 +200,7 @@ config("default") {
config("warnings") {
cflags = []
cflags_cc = []
cflags_objc = []
if (is_win) {
cflags += [
"/W3", # Turn on lots of warnings.
@ -288,6 +289,10 @@ config("warnings") {
"-Wno-c++98-compat-pedantic",
"-Wno-undefined-func-template",
]
cflags_objc += [
"-Wno-direct-ivar-access",
"-Wno-objc-interface-ivars",
]
}
}
}
@ -484,6 +489,26 @@ toolchain("gcc_like") {
description = "compile {{source}}"
}
tool("objc") {
depfile = "{{output}}.d"
command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objc}} -c {{source}} -o {{output}}"
depsformat = "gcc"
outputs = [
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
]
description = "compile {{source}}"
}
tool("objcxx") {
depfile = "{{output}}.d"
command = "$cc_wrapper $cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objc}} -c {{source}} -o {{output}}"
depsformat = "gcc"
outputs = [
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
]
description = "compile {{source}}"
}
tool("asm") {
depfile = "{{output}}.d"
command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"

158
third_party/libsdl/BUILD.gn vendored Normal file
View File

@ -0,0 +1,158 @@
# Copyright 2016 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
declare_args() {
}
import("../third_party.gni")
third_party("libsdl") {
public_include_dirs = [ "../externals/sdl/include" ]
include_dirs = [ "." ]
sources = [
"../externals/sdl/src/SDL.c",
"../externals/sdl/src/SDL_assert.c",
"../externals/sdl/src/SDL_error.c",
"../externals/sdl/src/SDL_hints.c",
"../externals/sdl/src/SDL_log.c",
"../externals/sdl/src/atomic/SDL_atomic.c",
"../externals/sdl/src/atomic/SDL_spinlock.c",
"../externals/sdl/src/audio/SDL_audio.c",
"../externals/sdl/src/audio/SDL_audiocvt.c",
"../externals/sdl/src/audio/SDL_audiodev.c",
"../externals/sdl/src/audio/SDL_audiotypecvt.c",
"../externals/sdl/src/audio/SDL_mixer.c",
"../externals/sdl/src/audio/SDL_wave.c",
"../externals/sdl/src/cpuinfo/SDL_cpuinfo.c",
"../externals/sdl/src/dynapi/SDL_dynapi.c",
"../externals/sdl/src/events/SDL_clipboardevents.c",
"../externals/sdl/src/events/SDL_dropevents.c",
"../externals/sdl/src/events/SDL_events.c",
"../externals/sdl/src/events/SDL_gesture.c",
"../externals/sdl/src/events/SDL_keyboard.c",
"../externals/sdl/src/events/SDL_mouse.c",
"../externals/sdl/src/events/SDL_quit.c",
"../externals/sdl/src/events/SDL_touch.c",
"../externals/sdl/src/events/SDL_windowevents.c",
"../externals/sdl/src/file/SDL_rwops.c",
"../externals/sdl/src/haptic/SDL_haptic.c",
"../externals/sdl/src/haptic/dummy/SDL_syshaptic.c",
"../externals/sdl/src/joystick/SDL_gamecontroller.c",
"../externals/sdl/src/joystick/SDL_joystick.c",
"../externals/sdl/src/joystick/dummy/SDL_sysjoystick.c",
"../externals/sdl/src/power/SDL_power.c",
"../externals/sdl/src/render/SDL_render.c",
"../externals/sdl/src/render/SDL_yuv_sw.c",
"../externals/sdl/src/render/software/SDL_blendfillrect.c",
"../externals/sdl/src/render/software/SDL_blendline.c",
"../externals/sdl/src/render/software/SDL_blendpoint.c",
"../externals/sdl/src/render/software/SDL_drawline.c",
"../externals/sdl/src/render/software/SDL_drawpoint.c",
"../externals/sdl/src/render/software/SDL_render_sw.c",
"../externals/sdl/src/render/software/SDL_rotate.c",
"../externals/sdl/src/stdlib/SDL_getenv.c",
"../externals/sdl/src/stdlib/SDL_iconv.c",
"../externals/sdl/src/stdlib/SDL_malloc.c",
"../externals/sdl/src/stdlib/SDL_qsort.c",
"../externals/sdl/src/stdlib/SDL_stdlib.c",
"../externals/sdl/src/stdlib/SDL_string.c",
"../externals/sdl/src/thread/SDL_thread.c",
"../externals/sdl/src/timer/SDL_timer.c",
"../externals/sdl/src/video/SDL_RLEaccel.c",
"../externals/sdl/src/video/SDL_blit.c",
"../externals/sdl/src/video/SDL_blit_0.c",
"../externals/sdl/src/video/SDL_blit_1.c",
"../externals/sdl/src/video/SDL_blit_A.c",
"../externals/sdl/src/video/SDL_blit_N.c",
"../externals/sdl/src/video/SDL_blit_auto.c",
"../externals/sdl/src/video/SDL_blit_copy.c",
"../externals/sdl/src/video/SDL_blit_slow.c",
"../externals/sdl/src/video/SDL_bmp.c",
"../externals/sdl/src/video/SDL_clipboard.c",
"../externals/sdl/src/video/SDL_egl.c",
"../externals/sdl/src/video/SDL_fillrect.c",
"../externals/sdl/src/video/SDL_pixels.c",
"../externals/sdl/src/video/SDL_rect.c",
"../externals/sdl/src/video/SDL_shape.c",
"../externals/sdl/src/video/SDL_stretch.c",
"../externals/sdl/src/video/SDL_surface.c",
"../externals/sdl/src/video/SDL_video.c",
]
defines = [
"HAVE_ACOS",
"HAVE_ASIN",
"HAVE_ATAN",
"HAVE_ATAN2",
"HAVE_CEIL",
"HAVE_COPYSIGN",
"HAVE_COS",
"HAVE_COSF",
"HAVE_FABS",
"HAVE_FLOOR",
"HAVE_LOG",
"HAVE_POW",
"HAVE_SCALBN",
"HAVE_SIN",
"HAVE_SINF",
"HAVE_SQRT",
"HAVE_SQRTF",
"HAVE_TAN",
"HAVE_TANF",
"SDL_HAPTIC_DISABLED=1",
"SDL_JOYSTICK_DISABLED=1",
"USING_PREMAKE_CONFIG_H",
]
libs = []
if (!is_win) {
defines += [
"SDL_LOADSO_DLOPEN=1",
"SDL_THREAD_PTHREAD=1",
"SDL_THREAD_PTHREAD_RECURSIVE_MUTEX=1",
"SDL_TIMER_UNIX=1",
"SDL_VIDEO_OPENGL=1",
"SDL_VIDEO_RENDER_OGL=1",
]
sources += [
"../externals/sdl/src/loadso/dlopen/SDL_sysloadso.c",
"../externals/sdl/src/render/opengl/SDL_render_gl.c",
"../externals/sdl/src/render/opengl/SDL_shaders_gl.c",
"../externals/sdl/src/thread/pthread/SDL_syscond.c",
"../externals/sdl/src/thread/pthread/SDL_sysmutex.c",
"../externals/sdl/src/thread/pthread/SDL_syssem.c",
"../externals/sdl/src/thread/pthread/SDL_systhread.c",
"../externals/sdl/src/thread/pthread/SDL_systls.c",
"../externals/sdl/src/timer/unix/SDL_systimer.c",
]
}
if (is_mac) {
sources += [
"../externals/sdl/src/file/cocoa/SDL_rwopsbundlesupport.m",
"../externals/sdl/src/filesystem/cocoa/SDL_sysfilesystem.m",
"../externals/sdl/src/video/cocoa/SDL_cocoaclipboard.m",
"../externals/sdl/src/video/cocoa/SDL_cocoaevents.m",
"../externals/sdl/src/video/cocoa/SDL_cocoakeyboard.m",
"../externals/sdl/src/video/cocoa/SDL_cocoamessagebox.m",
"../externals/sdl/src/video/cocoa/SDL_cocoamodes.m",
"../externals/sdl/src/video/cocoa/SDL_cocoamouse.m",
"../externals/sdl/src/video/cocoa/SDL_cocoamousetap.m",
"../externals/sdl/src/video/cocoa/SDL_cocoaopengl.m",
"../externals/sdl/src/video/cocoa/SDL_cocoashape.m",
"../externals/sdl/src/video/cocoa/SDL_cocoavideo.m",
"../externals/sdl/src/video/cocoa/SDL_cocoawindow.m",
]
defines += [
"SDL_FILESYSTEM_COCOA=1",
"SDL_VIDEO_DRIVER_COCOA=1",
"SDL_VIDEO_OPENGL_CGL=1",
]
libs += [
"Carbon.framework",
"IOKit.framework",
]
}
}

16
third_party/libsdl/SDL_config_premake.h vendored Normal file
View File

@ -0,0 +1,16 @@
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/*
* We don't want any of SDL's prebaked SDL_config.h files.
* Instead we set all the defines we need in GN (third_party/libsdl/BUILD.gn).
* This header is just the barest basics of an SDL_config.h we can get away with.
*/
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>