1# Copyright 2015 Google Inc.
2#
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5    # GYP file to build various tools.
6#
7# To build on Linux:
8#  ./gyp_skia tools.gyp && make tools
9#
10{
11  'includes': [
12    'apptype_console.gypi',
13  ],
14  'targets': [
15    {
16      # Build all executable targets defined below.
17      'target_name': 'tools',
18      'type': 'none',
19      'dependencies': [
20        'bench_pictures',
21        'chrome_fuzz',
22        'dump_record',
23        'filter',
24        'gpuveto',
25        'lua_app',
26        'lua_pictures',
27        'imgconv',
28        'pinspect',
29        'render_pdfs',
30        'render_pictures',
31        'skdiff',
32        'skhello',
33        'skp2svg',
34        'skpdiff',
35        'skpinfo',
36        'skpmaker',
37        'test_image_decoder',
38        'test_public_includes',
39      ],
40      'conditions': [
41        ['skia_shared_lib',
42          {
43            'dependencies': [
44              'sklua', # This can only be built if skia is built as a shared library
45            ],
46          },
47        ],
48      ],
49    },
50    {
51      'target_name': 'chrome_fuzz',
52      'type': 'executable',
53      'sources': [
54        '../tools/chrome_fuzz.cpp',
55      ],
56      'dependencies': [
57        'skia_lib.gyp:skia_lib',
58      ],
59    },
60    {
61      'target_name': 'crash_handler',
62        'type': 'static_library',
63        'sources': [ '../tools/CrashHandler.cpp' ],
64        'dependencies': [ 'skia_lib.gyp:skia_lib' ],
65        'direct_dependent_settings': {
66          'include_dirs': [ '../tools' ],
67        },
68        'conditions': [
69          [ 'skia_is_bot', {
70            'defines': [ 'SK_CRASH_HANDLER' ],
71          }],
72        ],
73
74        'all_dependent_settings': {
75          'msvs_settings': {
76            'VCLinkerTool': {
77              'AdditionalDependencies': [ 'Dbghelp.lib' ],
78            }
79          },
80        }
81    },
82    {
83      'target_name': 'resources',
84      'type': 'static_library',
85      'sources': [ '../tools/Resources.cpp' ],
86      'dependencies': [
87        'flags.gyp:flags',
88        'skia_lib.gyp:skia_lib',
89      ],
90      'direct_dependent_settings': {
91        'include_dirs': [ '../tools', ],
92      },
93    },
94    {
95      'target_name': 'sk_tool_utils',
96      'type': 'static_library',
97      'sources': [
98        '../tools/sk_tool_utils.cpp',
99        '../tools/sk_tool_utils_font.cpp',
100      ],
101      'include_dirs': [
102        '../src/fonts',
103      ],
104      'dependencies': [
105        'resources',
106        'flags.gyp:flags',
107        'skia_lib.gyp:skia_lib',
108      ],
109      'direct_dependent_settings': {
110        'include_dirs': [ '../tools', ],
111      },
112    },
113    {
114      'target_name' : 'timer',
115      'type': 'static_library',
116      'sources': [
117        '../tools/timer/Timer.cpp',
118        '../tools/timer/TimerData.cpp',
119      ],
120      'include_dirs': [
121        '../src/core',
122        '../src/gpu',
123      ],
124      'direct_dependent_settings': {
125        'include_dirs': ['../tools/timer'],
126      },
127      'dependencies': [
128        'skia_lib.gyp:skia_lib',
129        'jsoncpp.gyp:jsoncpp',
130      ],
131      'conditions': [
132        ['skia_gpu == 1', {
133          'sources': [ '../tools/timer/GpuTimer.cpp' ],
134        }],
135        [ 'skia_os in ["mac", "ios"]', {
136          'sources': [ '../tools/timer/SysTimer_mach.cpp' ],
137        }],
138        [ 'skia_os == "win"', {
139          'sources': [ '../tools/timer/SysTimer_windows.cpp' ],
140        }],
141        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "android", "chromeos"]', {
142          'sources': [ '../tools/timer/SysTimer_posix.cpp' ],
143        }],
144        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
145          'link_settings': { 'libraries': [ '-lrt' ] },
146        }],
147      ],
148    },
149    {
150      'target_name': 'skdiff',
151      'type': 'executable',
152      'sources': [
153        '../tools/skdiff.cpp',
154        '../tools/skdiff.h',
155        '../tools/skdiff_html.cpp',
156        '../tools/skdiff_html.h',
157        '../tools/skdiff_main.cpp',
158        '../tools/skdiff_utils.cpp',
159        '../tools/skdiff_utils.h',
160      ],
161      'dependencies': [
162        'skia_lib.gyp:skia_lib',
163      ],
164    },
165    {
166      'target_name': 'skpdiff',
167      'type': 'executable',
168      'sources': [
169        '../tools/skpdiff/skpdiff_main.cpp',
170        '../tools/skpdiff/SkDiffContext.cpp',
171        '../tools/skpdiff/SkImageDiffer.cpp',
172        '../tools/skpdiff/SkPMetric.cpp',
173        '../tools/skpdiff/skpdiff_util.cpp',
174      ],
175      'include_dirs': [
176        '../src/core/', # needed for SkTLList.h
177        '../tools/',    # needed for picture_utils::replace_char
178      ],
179      'dependencies': [
180        'flags.gyp:flags',
181        'skia_lib.gyp:skia_lib',
182        'tools.gyp:picture_utils',
183      ],
184      'cflags': [
185        '-O3',
186      ],
187      'conditions': [
188        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
189          'link_settings': {
190            'libraries': [
191              '-lrt',
192            ],
193          },
194        }],
195        ['skia_opencl', {
196          'sources': [
197            '../tools/skpdiff/SkCLImageDiffer.cpp',
198            '../tools/skpdiff/SkDifferentPixelsMetric_opencl.cpp',
199          ],
200          'conditions': [
201            [ 'skia_os == "mac"', {
202              'link_settings': {
203                'libraries': [
204                  '$(SDKROOT)/System/Library/Frameworks/OpenCL.framework',
205                ]
206              }
207            }, {
208              'link_settings': {
209                'libraries': [
210                  '-lOpenCL',
211                ],
212              },
213            }],
214          ],
215        }, { # !skia_opencl
216          'sources': [
217            '../tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp',
218          ],
219        }],
220      ],
221    },
222    {
223      'target_name': 'skpmaker',
224      'type': 'executable',
225      'sources': [
226        '../tools/skpmaker.cpp',
227      ],
228      'include_dirs': [
229        '../src/core',
230      ],
231      'dependencies': [
232        'flags.gyp:flags',
233        'skia_lib.gyp:skia_lib',
234      ],
235    },
236    {
237      'target_name': 'skimagediff',
238      'type': 'executable',
239      'sources': [
240        '../tools/skdiff.cpp',
241        '../tools/skdiff.h',
242        '../tools/skdiff_html.cpp',
243        '../tools/skdiff_html.h',
244        '../tools/skdiff_image.cpp',
245        '../tools/skdiff_utils.cpp',
246        '../tools/skdiff_utils.h',
247      ],
248      'dependencies': [
249        'skia_lib.gyp:skia_lib',
250      ],
251    },
252    {
253      'target_name': 'skhello',
254      'type': 'executable',
255      'dependencies': [
256        'flags.gyp:flags',
257        'pdf.gyp:pdf',
258        'skia_lib.gyp:skia_lib',
259      ],
260      'sources': [
261        '../tools/skhello.cpp',
262      ],
263    },
264    {
265      'target_name': 'skpinfo',
266      'type': 'executable',
267      'sources': [
268        '../tools/skpinfo.cpp',
269      ],
270      'include_dirs': [
271        '../src/core/',
272      ],
273      'dependencies': [
274        'flags.gyp:flags',
275        'skia_lib.gyp:skia_lib',
276      ],
277    },
278    {
279      # Superseded by dm, should be removed.
280      'target_name': 'skp2svg',
281      'type': 'executable',
282      'sources': [
283        '../src/svg/skp2svg.cpp',
284        '../tools/LazyDecodeBitmap.cpp',
285      ],
286      'include_dirs': [
287        '../src/core/',
288        '../src/lazy/',
289        '../tools/',
290      ],
291      'dependencies': [
292        'flags.gyp:flags',
293        'skia_lib.gyp:skia_lib',
294        'svg.gyp:svg',
295        'xml.gyp:xml',
296      ],
297    },
298    {
299      'target_name': 'gpuveto',
300      'type': 'executable',
301      'sources': [
302        '../tools/gpuveto.cpp',
303        '../tools/LazyDecodeBitmap.cpp',
304      ],
305      'include_dirs': [
306        '../src/core/',
307        '../src/images',
308        '../src/lazy',
309      ],
310      'dependencies': [
311        'flags.gyp:flags',
312        'skia_lib.gyp:skia_lib',
313      ],
314    },
315    {
316      'target_name': 'lua_app',
317      'type': 'executable',
318      'sources': [
319        '../tools/lua/lua_app.cpp',
320        '../src/utils/SkLua.cpp',
321      ],
322      'include_dirs': [
323        # Lua exposes GrReduceClip which in turn requires src/core for SkTLList
324        '../src/gpu/',
325        '../src/core/',
326      ],
327      'dependencies': [
328        'effects.gyp:effects',
329        'images.gyp:images',
330        'lua.gyp:lua',
331        'pdf.gyp:pdf',
332        'ports.gyp:ports',
333        'skia_lib.gyp:skia_lib',
334      ],
335    },
336    {
337      'target_name': 'lua_pictures',
338      'type': 'executable',
339      'sources': [
340        '../tools/lua/lua_pictures.cpp',
341        '../src/utils/SkLuaCanvas.cpp',
342        '../src/utils/SkLua.cpp',
343      ],
344      'include_dirs': [
345        # Lua exposes GrReduceClip which in turn requires src/core for SkTLList
346        '../src/gpu/',
347        '../src/core/',
348      ],
349      'dependencies': [
350        'effects.gyp:effects',
351        'flags.gyp:flags',
352        'images.gyp:images',
353        'lua.gyp:lua',
354        'tools.gyp:picture_renderer',
355        'tools.gyp:picture_utils',
356        'pdf.gyp:pdf',
357        'ports.gyp:ports',
358        'skia_lib.gyp:skia_lib',
359      ],
360    },
361    {
362      'target_name': 'render_pictures',
363      'type': 'executable',
364      'sources': [
365        '../tools/render_pictures_main.cpp',
366      ],
367      'include_dirs': [
368        '../src/core',
369        '../src/images',
370        '../src/lazy',
371        '../src/pipe/utils/',
372      ],
373      'dependencies': [
374        'flags.gyp:flags',
375        'skia_lib.gyp:skia_lib',
376        'tools.gyp:picture_renderer',
377        'tools.gyp:picture_utils',
378      ],
379    },
380    {
381      'target_name': 'bench_pictures',
382      'type': 'executable',
383      'sources': [
384        '../bench/BenchLogger.cpp',
385        '../bench/BenchLogger.h',
386        '../tools/PictureBenchmark.cpp',
387        '../tools/PictureResultsWriter.h',
388        '../tools/bench_pictures_main.cpp',
389      ],
390      'include_dirs': [
391        '../src/core/',
392        '../bench',
393        '../src/lazy/',
394      ],
395      'dependencies': [
396        'timer',
397        'crash_handler',
398        'flags.gyp:flags',
399        'jsoncpp.gyp:jsoncpp',
400        'skia_lib.gyp:skia_lib',
401        'tools.gyp:picture_renderer',
402        'tools.gyp:picture_utils',
403      ],
404      'conditions': [
405        ['skia_android_framework == 1', {
406          'libraries': [ '-lskia' ],
407        }],
408      ],
409    },
410    {
411      'target_name': 'dump_record',
412      'type': 'executable',
413      'sources': [
414        '../tools/dump_record.cpp',
415        '../tools/DumpRecord.cpp',
416        '../tools/LazyDecodeBitmap.cpp',
417      ],
418      'include_dirs': [
419        '../src/core/',
420        '../src/images',
421        '../src/lazy',
422      ],
423      'dependencies': [
424        'timer',
425        'flags.gyp:flags',
426        'skia_lib.gyp:skia_lib',
427      ],
428    },
429    {
430      'target_name': 'picture_renderer',
431      'type': 'static_library',
432      'sources': [
433        '../tools/image_expectations.h',
434        '../tools/image_expectations.cpp',
435        '../tools/LazyDecodeBitmap.cpp',
436        '../tools/PictureRenderer.h',
437        '../tools/PictureRenderer.cpp',
438        '../tools/PictureRenderingFlags.h',
439        '../tools/PictureRenderingFlags.cpp',
440        '../tools/CopyTilesRenderer.h',
441        '../tools/CopyTilesRenderer.cpp',
442        '../src/pipe/utils/SamplePipeControllers.h',
443        '../src/pipe/utils/SamplePipeControllers.cpp',
444      ],
445      'include_dirs': [
446        '../src/core',
447        '../src/images',
448        '../src/lazy',
449        '../src/pipe/utils/',
450        '../src/utils/',
451      ],
452      'direct_dependent_settings': {
453        'include_dirs': [
454          # needed for JSON headers used within image_expectations.h
455          '../third_party/externals/jsoncpp-chromium/overrides/include/',
456          '../third_party/externals/jsoncpp/include/',
457        ],
458      },
459      'dependencies': [
460        'flags.gyp:flags',
461        'jsoncpp.gyp:jsoncpp',
462        'skia_lib.gyp:skia_lib',
463        'tools.gyp:picture_utils',
464      ],
465      'conditions': [
466        ['skia_gpu == 1',
467          {
468            'include_dirs' : [
469              '../src/gpu',
470            ],
471            'dependencies': [
472              'gputest.gyp:skgputest',
473            ],
474            'export_dependent_settings': [
475                'gputest.gyp:skgputest',
476            ],
477          },
478        ],
479      ],
480    },
481    {
482      'target_name': 'render_pdfs',
483      'type': 'executable',
484      'sources': [
485        '../tools/render_pdfs_main.cpp',
486      ],
487      'include_dirs': [
488        '../src/core',
489        '../src/pipe/utils/',
490        '../src/utils/',
491      ],
492      'dependencies': [
493        'flags.gyp:flags',
494        'pdf.gyp:pdf',
495        'skia_lib.gyp:skia_lib',
496        'tools.gyp:picture_utils',
497        'tools.gyp:proc_stats',
498      ],
499      'conditions': [
500        ['skia_win_debuggers_path and skia_os == "win"',
501          {
502            'dependencies': [
503              'tools.gyp:win_dbghelp',
504            ],
505          },
506        ],
507        # VS static libraries don't have a linker option. We must set a global
508        # project linker option, or add it to each executable.
509        ['skia_win_debuggers_path and skia_os == "win" and '
510         'skia_arch_width == 64',
511          {
512            'msvs_settings': {
513              'VCLinkerTool': {
514                'AdditionalDependencies': [
515                  '<(skia_win_debuggers_path)/x64/DbgHelp.lib',
516                ],
517              },
518            },
519          },
520        ],
521        ['skia_win_debuggers_path and skia_os == "win" and '
522         'skia_arch_width == 32',
523          {
524            'msvs_settings': {
525              'VCLinkerTool': {
526                'AdditionalDependencies': [
527                  '<(skia_win_debuggers_path)/DbgHelp.lib',
528                ],
529              },
530            },
531          },
532        ],
533      ],
534    },
535    {
536      'target_name': 'picture_utils',
537      'type': 'static_library',
538      'sources': [
539        '../tools/picture_utils.cpp',
540        '../tools/picture_utils.h',
541      ],
542      'dependencies': [
543        'skia_lib.gyp:skia_lib',
544      ],
545      'direct_dependent_settings': {
546        'include_dirs': [
547          '../tools/',
548        ],
549      },
550    },
551    {
552      'target_name': 'pinspect',
553      'type': 'executable',
554      'sources': [
555        '../tools/pinspect.cpp',
556      ],
557      'dependencies': [
558        'flags.gyp:flags',
559        'skia_lib.gyp:skia_lib',
560        'tools.gyp:picture_renderer',
561      ],
562    },
563    {
564      'target_name': 'imgconv',
565      'type': 'executable',
566      'sources': [
567        '../tools/imgconv.cpp',
568      ],
569      'dependencies': [
570        'flags.gyp:flags',
571        'skia_lib.gyp:skia_lib',
572      ],
573    },
574    {
575      'target_name': 'filter',
576      'type': 'executable',
577      'include_dirs' : [
578        '../src/core',
579        '../src/utils/debugger',
580      ],
581      'sources': [
582        '../tools/filtermain.cpp',
583        '../src/utils/debugger/SkDrawCommand.h',
584        '../src/utils/debugger/SkDrawCommand.cpp',
585        '../src/utils/debugger/SkDebugCanvas.h',
586        '../src/utils/debugger/SkDebugCanvas.cpp',
587        '../src/utils/debugger/SkObjectParser.h',
588        '../src/utils/debugger/SkObjectParser.cpp',
589      ],
590      'dependencies': [
591        'skia_lib.gyp:skia_lib',
592        'tools.gyp:picture_utils',
593      ],
594    },
595    {
596      'target_name': 'test_image_decoder',
597      'type': 'executable',
598      'sources': [
599        '../tools/test_image_decoder.cpp',
600      ],
601      'dependencies': [
602        'skia_lib.gyp:skia_lib',
603      ],
604    },
605    {
606      'target_name': 'proc_stats',
607      'type': 'static_library',
608      'sources': [
609        '../tools/ProcStats.h',
610        '../tools/ProcStats.cpp',
611      ],
612      'direct_dependent_settings': {
613        'include_dirs': [ '../tools', ],
614      },
615    },
616    {
617      'target_name': 'test_public_includes',
618      'type': 'static_library',
619      # Ensure that our public headers don't have unused params so that clients
620      # (e.g. Android) that include us can build with these warnings enabled
621      'cflags!': [ '-Wno-unused-parameter' ],
622      'variables': {
623        'includes_to_test': [
624          '<(skia_include_path)/animator',
625          '<(skia_include_path)/c',
626          '<(skia_include_path)/config',
627          '<(skia_include_path)/core',
628          '<(skia_include_path)/effects',
629          '<(skia_include_path)/gpu',
630          '<(skia_include_path)/images',
631          '<(skia_include_path)/pathops',
632          '<(skia_include_path)/pipe',
633          '<(skia_include_path)/ports',
634          '<(skia_include_path)/svg/parser',
635          '<(skia_include_path)/utils',
636          '<(skia_include_path)/views',
637          '<(skia_include_path)/xml',
638        ],
639        'paths_to_ignore': [
640          '<(skia_include_path)/gpu/gl/GrGLConfig_chrome.h',
641          '<(skia_include_path)/ports/SkAtomics_std.h',
642          '<(skia_include_path)/ports/SkAtomics_atomic.h',
643          '<(skia_include_path)/ports/SkAtomics_sync.h',
644          '<(skia_include_path)/ports/SkMutex_pthread.h',
645          '<(skia_include_path)/ports/SkMutex_win.h',
646          '<(skia_include_path)/ports/SkTypeface_mac.h',
647          '<(skia_include_path)/ports/SkTypeface_win.h',
648          '<(skia_include_path)/utils/ios',
649          '<(skia_include_path)/utils/mac',
650          '<(skia_include_path)/utils/win',
651          '<(skia_include_path)/utils/SkDebugUtils.h',
652          '<(skia_include_path)/utils/SkJSONCPP.h',
653          '<(skia_include_path)/views/animated',
654          '<(skia_include_path)/views/SkOSWindow_Android.h',
655          '<(skia_include_path)/views/SkOSWindow_iOS.h',
656          '<(skia_include_path)/views/SkOSWindow_Mac.h',
657          '<(skia_include_path)/views/SkOSWindow_SDL.h',
658          '<(skia_include_path)/views/SkOSWindow_Unix.h',
659          '<(skia_include_path)/views/SkOSWindow_Win.h',
660          '<(skia_include_path)/views/SkWindow.h',
661        ],
662      },
663      'include_dirs': [
664        '<@(includes_to_test)',
665      ],
666      'sources': [
667        # unused_param_test.cpp is generated by the action below.
668        '<(INTERMEDIATE_DIR)/test_public_includes.cpp',
669      ],
670      'actions': [
671        {
672          'action_name': 'generate_includes_cpp',
673          'inputs': [
674            '../tools/generate_includes_cpp.py',
675            '<@(includes_to_test)',
676            # This causes the gyp generator on mac to fail
677            #'<@(paths_to_ignore)',
678          ],
679          'outputs': [
680            '<(INTERMEDIATE_DIR)/test_public_includes.cpp',
681          ],
682          'action': ['python', '../tools/generate_includes_cpp.py',
683                               '--ignore', '<(paths_to_ignore)',
684                               '<@(_outputs)', '<@(includes_to_test)'],
685        },
686      ],
687    },
688  ],
689  'conditions': [
690    ['skia_shared_lib',
691      {
692        'targets': [
693          {
694            'target_name': 'sklua',
695            'product_name': 'skia',
696            'product_prefix': '',
697            'product_dir': '<(PRODUCT_DIR)/',
698            'type': 'shared_library',
699            'sources': [
700              '../src/utils/SkLuaCanvas.cpp',
701              '../src/utils/SkLua.cpp',
702            ],
703            'include_dirs': [
704              # Lua exposes GrReduceClip which in turn requires src/core for SkTLList
705              '../src/gpu/',
706              '../src/core/',
707              '../third_party/lua/src/',
708            ],
709            'dependencies': [
710              'lua.gyp:lua',
711              'pdf.gyp:pdf',
712              'skia_lib.gyp:skia_lib',
713            ],
714            'conditions': [
715              ['skia_os != "win"',
716                {
717                  'ldflags': [
718                    '-Wl,-rpath,\$$ORIGIN,--enable-new-dtags',
719                  ],
720                },
721              ],
722            ],
723          },
724        ],
725      },
726    ],
727    ['skia_win_debuggers_path and skia_os == "win"',
728      {
729        'targets': [
730          {
731            'target_name': 'win_dbghelp',
732            'type': 'static_library',
733            'defines': [
734              'SK_CDB_PATH="<(skia_win_debuggers_path)"',
735            ],
736            'sources': [
737              '../tools/win_dbghelp.h',
738              '../tools/win_dbghelp.cpp',
739            ],
740          },
741        ],
742      },
743    ],
744    ['skia_os == "win"',
745      {
746        'targets': [
747          {
748            'target_name': 'win_lcid',
749            'type': 'executable',
750            'sources': [
751              '../tools/win_lcid.cpp',
752            ],
753          },
754        ],
755      },
756    ],
757    ['skia_os == "mac"',
758      {
759        'targets': [
760          {
761            'target_name': 'create_test_font',
762            'type': 'executable',
763            'sources': [
764              '../tools/create_test_font.cpp',
765            ],
766            'include_dirs': [
767              '../src/core',
768            ],
769            'dependencies': [
770              'flags.gyp:flags',
771              'skia_lib.gyp:skia_lib',
772              'resources',
773            ],
774          },
775        ],
776      },
777    ],
778  ],
779}
780