Home | History | Annotate | Download | only in platform
      1 # Copyright 2014 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import("//build/config/ui.gni")
      6 import("//third_party/WebKit/Source/build/scripts/scripts.gni")
      7 import("//third_party/WebKit/Source/config.gni")
      8 import("//third_party/WebKit/Source/platform/platform_generated.gni")
      9 
     10 # Most targets in this file are private actions so use that as the default.
     11 visibility = ":*"
     12 
     13 # TODO(GYP) Remove when test targets link (depends on ffmpeg)
     14 enable_blink_platform_test_targets = false
     15 
     16 
     17 import("//third_party/yasm/yasm_assemble.gni")
     18 
     19 platform_gypi = exec_script(
     20     "//build/gypi_to_gn.py",
     21     [ rebase_path("blink_platform.gypi") ],
     22     "scope",
     23     [ "blink_platform.gypi" ])
     24 if (enable_blink_platform_test_targets) {
     25 heap_gypi = exec_script(
     26     "//build/gypi_to_gn.py",
     27     [ rebase_path("heap/blink_heap.gypi") ],
     28     "scope",
     29     [ "heap/blink_heap.gypi" ])
     30 }
     31 
     32 blink_platform_neon_files = [
     33   "graphics/cpu/arm/WebGLImageConversionNEON.h",
     34   "graphics/cpu/arm/filters/FEBlendNEON.h",
     35   "graphics/cpu/arm/filters/FECompositeArithmeticNEON.h",
     36   "graphics/cpu/arm/filters/FEGaussianBlurNEON.h",
     37   "graphics/cpu/arm/filters/NEONHelpers.h",
     38 ]
     39 
     40 # blink_common in blink_platform.gyp
     41 component("blink_common") {
     42   visibility = "//third_party/WebKit/*"
     43   sources = [
     44     "exported/WebCString.cpp",
     45     "exported/WebString.cpp",
     46     "exported/WebCommon.cpp",
     47   ]
     48 
     49   defines = [
     50     "BLINK_COMMON_IMPLEMENTATION=1",
     51     "INSIDE_BLINK",
     52   ]
     53 
     54   configs += [
     55     "//build/config/compiler:wexit_time_destructors",
     56     "//third_party/WebKit/Source:config",
     57     "//third_party/WebKit/Source:non_test_config",
     58   ]
     59 
     60   deps = [
     61     "//third_party/WebKit/Source/wtf",
     62   ]
     63 }
     64 
     65 # Chromium's version of WebCore includes the following Objective-C classes. The
     66 # system-provided WebCore framework may also provide these classes. Because of
     67 # the nature of Objective-C binding (dynamically at runtime), it's possible for
     68 # the Chromium-provided versions to interfere with the system-provided
     69 # versions. This may happen when a system framework attempts to use
     70 # core.framework, such as when converting an HTML-flavored string to an
     71 # NSAttributedString. The solution is to force Objective-C class names that
     72 # would conflict to use alternate names.
     73 #
     74 # This list will hopefully shrink but may also grow. Its performance is
     75 # monitored by the "Check Objective-C Rename" postbuild step, and any
     76 # suspicious-looking symbols not handled here or whitelisted in that step will
     77 # cause a build failure.
     78 #
     79 # If this is unhandled, the console will receive log messages
     80 # such as:
     81 # com.google.Chrome[] objc[]: Class ScrollbarPrefsObserver is implemented in both .../Google Chrome.app/Contents/Versions/.../Google Chrome Helper.app/Contents/MacOS/../../../Google Chrome Framework.framework/Google Chrome Framework and /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/WebCore. One of the two will be used. Which one is undefined.
     82 if (is_mac) {
     83   config("mac_objc_renaming") {
     84     defines = [
     85       "WebCascadeList=ChromiumWebCoreObjCWebCascadeList",
     86       "WebFontCache=ChromiumWebCoreObjCWebFontCache",
     87       "WebScrollAnimationHelperDelegate=ChromiumWebCoreObjCWebScrollAnimationHelperDelegate",
     88       "WebScrollbarPainterControllerDelegate=ChromiumWebCoreObjCWebScrollbarPainterControllerDelegate",
     89       "WebScrollbarPainterDelegate=ChromiumWebCoreObjCWebScrollbarPainterDelegate",
     90       "WebScrollbarPartAnimation=ChromiumWebCoreObjCWebScrollbarPartAnimation",
     91       "WebCoreFlippedView=ChromiumWebCoreObjCWebCoreFlippedView",
     92       "WebCoreTextFieldCell=ChromiumWebCoreObjCWebCoreTextFieldCell",
     93       "WebCoreRenderThemeNotificationObserver=ChromiumWebCoreObjCWebCoreRenderThemeNotificationObserver",
     94     ]
     95   }
     96 }
     97 
     98 # FontFamilyNames action in make_platform_generated in
     99 # platform_generated.gyp
    100 action("font_family_names") {
    101   script = "../build/scripts/make_names.py"
    102 
    103   font_family_names_in = "fonts/FontFamilyNames.in"
    104   source_prereqs = make_names_files + [ font_family_names_in ]
    105 
    106   outputs = [
    107     "$blink_platform_output_dir/FontFamilyNames.cpp",
    108     "$blink_platform_output_dir/FontFamilyNames.h",
    109   ]
    110 
    111   args = [
    112     rebase_path(font_family_names_in, root_build_dir),
    113     "--output_dir",
    114     rebase_path(blink_platform_output_dir, root_build_dir),
    115   ]
    116 }
    117 
    118 # RuntimeEnabledFeatures action in make_platform_generated in
    119 # platform_generated.gyp
    120 action("runtime_enabled_features") {
    121   script = "../build/scripts/make_runtime_features.py"
    122 
    123   runtime_enabled_features_in = "RuntimeEnabledFeatures.in"
    124   source_prereqs = scripts_for_in_files + [
    125     runtime_enabled_features_in,
    126     "../build/scripts/templates/RuntimeEnabledFeatures.cpp.tmpl",
    127     "../build/scripts/templates/RuntimeEnabledFeatures.h.tmpl",
    128   ]
    129 
    130   outputs = [
    131     "$blink_platform_output_dir/RuntimeEnabledFeatures.cpp",
    132     "$blink_platform_output_dir/RuntimeEnabledFeatures.h",
    133   ]
    134 
    135   args = [
    136     rebase_path(runtime_enabled_features_in, root_build_dir),
    137     "--output_dir",
    138     rebase_path(blink_platform_output_dir, root_build_dir),
    139   ]
    140 }
    141 
    142 # ColorData action in make_platform_generated in platform_generated.gyp
    143 action("color_data") {
    144   script = "../build/scripts/gperf.py"
    145 
    146   color_data_gperf = "ColorData.gperf"
    147   source_prereqs = [ color_data_gperf ]
    148 
    149   output_file = "$blink_platform_output_dir/ColorData.cpp"
    150   outputs = [ output_file ]
    151 
    152   args = [
    153     gperf_exe,
    154     "--key-positions=*",
    155     "-D", "-s", "2",
    156     rebase_path(color_data_gperf, root_build_dir),
    157     "--output-file=" + rebase_path(output_file, root_build_dir),
    158   ]
    159 }
    160 
    161 # This isn't strictly necessary since we can just add the deps to "platform",
    162 # but it helps to have the targets match the GYP build.
    163 group("make_platform_generated") {
    164   visibility = "//third_party/WebKit/Source/*"
    165   deps = [
    166     ":blink_common",
    167     ":color_data",
    168     ":font_family_names",
    169     ":runtime_enabled_features",
    170   ]
    171 }
    172 
    173 # TODO(brettw) Objective C Renaming postbuild steps on Mac.
    174 # blink_platform target in blink_platform.gyp
    175 component("platform") {
    176   visibility = "//third_party/WebKit/*"
    177   output_name = "blink_platform"
    178 
    179   sources = platform_gypi.platform_files
    180   sources -= blink_platform_neon_files
    181 
    182   # Add in the generated files.
    183   sources +=
    184     get_target_outputs(":font_family_names") +
    185     get_target_outputs(":runtime_enabled_features") +
    186     get_target_outputs(":color_data")
    187 
    188   configs += [
    189     "//third_party/WebKit/Source:config",
    190     "//third_party/WebKit/Source:non_test_config",
    191   ]
    192 
    193   defines = [
    194     "BLINK_PLATFORM_IMPLEMENTATION=1",
    195     "INSIDE_BLINK",
    196   ]
    197 
    198   include_dirs = [
    199     #"$angle_path/include",
    200     "$root_gen_dir/blink",
    201   ]
    202 
    203   deps = [
    204     ":heap_asm_stubs",
    205     ":make_platform_generated",
    206     "//gpu/command_buffer/client:gles2_c_lib",
    207     "//skia",
    208     "//third_party:jpeg",
    209     "//third_party/harfbuzz-ng",
    210     "//third_party/iccjpeg",
    211     "//third_party/icu",
    212     "//third_party/libpng",
    213     "//third_party/libwebp",
    214     "//third_party/ots",
    215     "//third_party/qcms",
    216     "//third_party/WebKit/Source/wtf",
    217     "//third_party/WebKit/Source/platform/heap",
    218     "//url",
    219     "//v8",
    220   ]
    221 
    222   forward_dependent_configs_from = [
    223     "//gpu/command_buffer/client:gles2_c_lib",
    224     "//skia",
    225     "//third_party:jpeg",
    226     "//third_party/iccjpeg",
    227     "//third_party/libpng",
    228     "//third_party/libwebp",
    229     "//third_party/ots",
    230     "//third_party/qcms",
    231     "//url",
    232     "//v8",
    233   ]
    234 
    235   if (is_mac) {
    236     sources -= [
    237       "fonts/harfbuzz/FontHarfBuzz.cpp",
    238       "fonts/harfbuzz/FontPlatformDataHarfBuzz.cpp",
    239       "fonts/harfbuzz/HarfBuzzFaceSkia.cpp",
    240       "fonts/opentype/OpenTypeTypes.h",
    241       "fonts/opentype/OpenTypeVerticalData.cpp",
    242       "fonts/opentype/OpenTypeVerticalData.h",
    243       # The Mac currently uses FontCustomPlatformDataMac.cpp instead.
    244       "fonts/skia/FontCustomPlatformDataSkia.cpp",
    245       "fonts/skia/FontCacheSkia.cpp",
    246       "fonts/skia/SimpleFontDataSkia.cpp",
    247       # Uses LocaleMac instead.
    248       "text/LocaleICU.cpp",
    249       "text/LocaleICU.h",
    250       # Uses KillRingMac.mm instead.
    251       "KillRingNone.cpp",
    252       # Mac uses only ScrollAnimatorMac.
    253       "scroll/ScrollbarThemeNonMacCommon.cpp",
    254       "scroll/ScrollbarThemeNonMacCommon.h",
    255       "scroll/ScrollAnimatorNone.cpp",
    256       "scroll/ScrollAnimatorNone.h",
    257     ]
    258 
    259     # Some Mac-specific parts of WebKit won't compile without having this
    260     # prefix header injected.
    261     cflags = [
    262       "-include",
    263       rebase_path("../core/WebCorePrefixMac.h", root_build_dir),
    264     ]
    265 
    266     defines += [ "WebFontCache=ChromiumWebCoreObjCWebFontCache" ]
    267     configs += [ ":mac_objc_renaming" ]
    268     libs = [
    269       "Accelerate.framework",
    270       "Carbon.framework",
    271       "Foundation.framework",
    272     ]
    273   } else {
    274     sources -= [
    275       # FIXME: We will eventually compile this too, but for now it's
    276       # only used on mac.
    277       "fonts/FontPlatformData.cpp",
    278       "fonts/harfbuzz/HarfBuzzFaceCoreText.cpp",
    279       "geometry/cg/FloatPointCG.cpp",
    280       "geometry/cg/FloatRectCG.cpp",
    281       "geometry/cg/FloatSizeCG.cpp",
    282       "geometry/cg/IntPointCG.cpp",
    283       "geometry/cg/IntRectCG.cpp",
    284       "geometry/cg/IntSizeCG.cpp",
    285     ]
    286   }
    287 
    288   if (is_win) {
    289     sources -= [
    290       # Uses LocaleWin instead.
    291       "text/LocaleICU.cpp",
    292       "text/LocaleICU.h",
    293     ]
    294     cflags = [
    295       "/wd4267",  # Conversion from 'size_t' to 'type', possible loss of data.
    296       "/wd4334",  # Result of 32-bit shift implicitly converted to 64 bits.
    297       "/wd4724",  # Modulo by 0.
    298     ]
    299   } else {
    300     sources -= [
    301       "clipboard/ClipboardUtilitiesWin.cpp",
    302       "fonts/opentype/OpenTypeUtilities.cpp",
    303       "fonts/opentype/OpenTypeUtilities.h",
    304       "text/LocaleWin.cpp",
    305     ]
    306   }
    307 
    308   if (is_android) {
    309     # Add in some Linux files also shared with Android.
    310     set_sources_assignment_filter([])
    311     sources += [
    312       "exported/linux/WebFontRenderStyle.cpp",
    313       "fonts/linux/FontPlatformDataLinuxHarfBuzz.cpp",
    314     ]
    315     set_sources_assignment_filter(sources_assignment_filter)
    316   } else {
    317     sources -= [
    318       "scroll/ScrollbarThemeAndroid.cpp",
    319     ]
    320   }
    321 
    322   if (is_linux) {
    323     direct_dependent_configs = [ "//build/config/linux:fontconfig" ]
    324   }
    325 
    326   if (!use_default_render_theme) {
    327     sources -= [
    328       "scroll/ScrollbarThemeAura.cpp",
    329       "scroll/ScrollbarThemeAura.h",
    330     ]
    331   }
    332 
    333   if (cpu_arch == "arm") {
    334     deps += [ ":blink_arm_neon" ]
    335   }
    336 
    337   if (use_webaudio_ffmpeg) {
    338     include_dirs += [ "//third_party/ffmpeg" ]
    339     # TODO(GYP)
    340     #deps += [ "//third_party/ffmpeg" ]
    341   }
    342   if (use_openmax_dl_fft) {
    343     include_dirs += [ "//third_party/openmax_dl" ]
    344     # TODO(GYP)
    345     # deps += [ "//third_party/openmax_dl/dl" ]
    346   }
    347 }
    348 
    349 yasm_assemble("heap_asm_stubs") {
    350   if (cpu_arch == "x86" || cpu_arch == "x64") {
    351     sources = [ "heap/asm/SaveRegisters_x86.asm" ]
    352   } else if (cpu_arch == "arm") {
    353     sources = [ "heap/asm/SaveRegisters_arm.S" ]
    354   } else if (cpu_arch == "arm64") {
    355     sources = [ "heap/asm/SaveRegisters_arm64.S" ]
    356   } else if (cpu_arch == "mipsel") {
    357     sources = [ "heap/asm/SaveRegisters_mips.S" ]
    358   }
    359 
    360   yasm_flags = []
    361   if (is_mac) {
    362     # Necessary to ensure symbols end up with a _ prefix; added by
    363     # yasm_compile.gypi for Windows, but not Mac.
    364     yasm_flags += [ "-DPREFIX" ]
    365   }
    366   if (cpu_arch == "x64") {
    367     if (is_win) {
    368       yasm_flags += [ "-DX64WIN=1" ]
    369     } else {
    370       yasm_flags += [ "-DX64POSIX=1" ]
    371     }
    372   } else if (cpu_arch == "x86") {
    373     yasm_flags += [ "-DIA32=1" ]
    374   } else if (cpu_arch == "arm") {
    375     yasm_flags += [ "-DARM=1" ]
    376   }
    377 }
    378 
    379 source_set("heap_run_all_tests") {
    380   sources = [
    381     "heap/RunAllTests.cpp"
    382   ]
    383 
    384   configs += [
    385     "//third_party/WebKit/Source/wtf:wtf_config",
    386     "//third_party/WebKit/Source:config",
    387     "//third_party/WebKit/Source:non_test_config",
    388   ]
    389 
    390   deps = [
    391     "//base/test:test_support",
    392     "//testing/gmock",
    393     "//testing/gtest",
    394     "//third_party/WebKit/Source/wtf",
    395   ]
    396 }
    397 
    398 if (enable_blink_platform_test_targets) {
    399 
    400 test("heap_unittests") {
    401   output_name = "blink_heap_unittests"
    402 
    403   sources = rebase_path(heap_gypi.platform_heap_test_files, ".", "heap")
    404 
    405   configs += [
    406     "//third_party/WebKit/Source:config",
    407   ]
    408 
    409   deps = [
    410     ":heap_run_all_tests",
    411     ":platform",
    412     "//base",
    413     "//base/allocator",
    414     "//testing/gmock",
    415     "//testing/gtest",
    416     "//third_party/WebKit/Source/wtf",
    417     "//third_party/WebKit/Source/wtf:unittest_helpers",
    418   ]
    419 }
    420 
    421 }
    422 
    423 source_set("platform_run_all_tests") {
    424   sources = [
    425     "testing/RunAllTests.cpp"
    426   ]
    427 
    428   configs += [
    429     "//third_party/WebKit/Source/wtf:wtf_config",
    430     "//third_party/WebKit/Source:config",
    431     "//third_party/WebKit/Source:non_test_config",
    432   ]
    433 
    434   deps = [
    435     "//base/test:test_support",
    436     "//testing/gmock",
    437     "//testing/gtest",
    438     "//third_party/WebKit/Source/wtf",
    439   ]
    440 }
    441 
    442 if (enable_blink_platform_test_targets) {
    443 
    444 test("platform_unittests") {
    445   output_name = "blink_platform_unittests"
    446 
    447   sources = platform_gypi.platform_test_files
    448 
    449   configs += [
    450     "//third_party/WebKit/Source:config",
    451   ]
    452 
    453   deps = [
    454     ":blink_common",
    455     ":platform_run_all_tests",
    456     ":platform",
    457     "//base",
    458     "//base/allocator",
    459     "//skia",
    460     "//testing/gmock",
    461     "//testing/gtest",
    462     "//third_party/WebKit/Source/wtf",
    463     "//third_party/WebKit/Source/wtf:unittest_helpers",
    464     "//url",
    465   ]
    466 
    467   defines = [
    468     "INSIDE_BLINK",
    469   ]
    470 
    471   include_dirs = [
    472     "$root_gen_dir/blink",
    473   ]
    474 }
    475 
    476 }
    477 
    478 
    479 if (cpu_arch == "arm") {
    480   source_set("blink_arm_neon") {
    481     sources = blink_platform_neon_files
    482 
    483     # The *NEON.cpp files fail to compile when -mthumb is passed. Force
    484     # them to build in ARM mode.
    485     # See https://bugs.webkit.org/show_bug.cgi?id=62916.
    486     # TODO(GYP)
    487     #'cflags': ['-marm'],
    488     #    'conditions': [
    489     #      ['OS=="android"', {
    490     #        'cflags!': ['-mthumb'],
    491     #      }],
    492     #    ],
    493 
    494     deps = [ ":blink_common" ]
    495   }
    496 }
    497