# Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.

{
  'variables': {
    'chromium_code': 1,
    'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/owcr',
    'framework_name': 'Open WeClassRoom Framework',
    # For some reason we don't get the 'use_sysroot' default from common.gypi so
    # set it here as well.
    'use_sysroot%': 0,
  },
  'includes': [
    # Bring in the source file lists.
    'common.gypi',
  ],
  'targets': [
    {
      'target_name': 'test_client',
      'type': 'executable',
      'mac_bundle': 1,
      'msvs_guid': '520558B9-674C-4FCD-BB77-BB78603C34AD',
      'dependencies': [
        'demo_ext'
      ],
      'defines': [

      ],
      'include_dirs': [
        '.',
      ],
      'sources': [
        'test/extension_manager_impl.h',
      ],
      'conditions': [
        ['OS=="win"', {
          'msvs_settings': {
            'VCLinkerTool': {
              # Set /SUBSYSTEM:WINDOWS.
              'SubSystem': '2',
            },
            'VCManifestTool': {
              'AdditionalManifestFiles': [
                'test/test_client.exe.manifest',
              ],
            },
          },
          'link_settings': {
            'libraries': [
              '-luser32.lib',
            ],
          },
          'sources': [
            'test/extension_manager_impl.cc',
            'test/test_client_main_win.cc'
          ],
        }],
        ['OS=="mac"', {
          'make_global_settings': [
           ['CC', '/usr/bin/clang'],
           ['CXX', '/usr/bin/clang++'],
        ],
        'defines': [
          'OS_POSIX',
          'OS_MACOSX',
        ],
        'xcode_settings': {
        'ALWAYS_SEARCH_USER_PATHS': 'NO',
        #'i386', 'x86_64'
        'ARCHS': [ 'x86_64' ],
        'MACOSX_DEPLOYMENT_TARGET': '10.10',
        'CC': 'clang',
        'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
        'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x',
        # libstdc++, c++11, libc++
        'CLANG_CXX_LIBRARY': 'libc++',
        'GCC_ENABLE_OBJC_GC': 'unsupported',
        #'LIBRARY_SEARCH_PATHS': [],
        'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
        'GCC_SYMBOLS_PRIVATE_EXTERN': 'NO',
        'DEBUG_INFORMATION_FORMAT': 'dwarf-with-dsym',
        #'DEPLOYMENT_POSTPROCESSING': 'YES',
        'OTHER_CFLAGS': [
          #'-fno-eliminate-unused-debug-symbols',
          '-mmacosx-version-min=10.10',
          # compile use oc++
          '-x objective-c++',
        ],
        }, # xcode_settings
        'link_settings': {
          'libraries': [
          ],
        },
        'libraries': [],
        'sources': [     
          'test/extension_manager_impl_mac.cc',
          'test/test_client_main_mac.cc',
        ],
        'mac_framework_dirs': [],
        'configurations': {
          'Debug': {
            'xcode_settings': {
              # 'GCC_DEBUGGING_SYMBOLS': 'full',
              # 'STRIP_INSTALLED_PRODUCT': 'YES',
              # 'GCC_OPTIMIZATION_LEVEL': '0',
              # 'OTHER_CFLAGS': ['-g',],
              # 'OTHER_CXXFLAGS': ['-g',],
            }, # xcode_settings
          }, # Debug
          'Release': {
            # 'xcode_settings': {
            # 'GCC_OPTIMIZATION_LEVEL': 's',
            # }, # xcode_settings
          }, # Release
        }, # configurations
      }], # Mac
      ],
    },
    {
      'target_name': 'demo_ext',
      'type': 'shared_library',
      #'mac_bundle': 1,  #create framework,otherwise create dylib
      'msvs_guid': '75E35635-58B8-4357-A618-9A9B571BF6DE',
      'dependencies': [
        'lib_jsoncpp'
      ],
      'defines': [
        'EXTENSION_IMPLEMENT',
      ],
      'include_dirs': [
        '.',
        './lib',
        'public',
        'third_party',
        'third_party/jsoncpp/include',
      ],
      'sources': [
        'lib/extension_export.h',
        'lib/main_entry.h',
        'public/iextension.h',
        'public/iextension_api_delegate.h',
        'public/iextension_manager.h',
        'public/iextension_media_listener.h',
        'public/iextension_mediaapply_delegate.h',
        'public/iextension_mediastream_delegate.h',
        'public/iextension_network_delegate.h',
        'public/iextension_pages_delegate.h',
        'public/iextension_report_delegate.h',
        'public/iextension_thread_delegate.h',
        'lib/main_entry.cc',
        'lib/extension_context.cc',
        'lib/extension_context.h',
        'lib/extension_impl.cc',
        'lib/extension_impl.h',
        'lib/event_notify_template.h',
        'lib/demo_extension_engine.cc',
        'lib/demo_extension_engine.h',
        'lib/demo_extension_engine_methods.cc',
        'lib/common/lock.cc',
        'lib/common/lock.h',
      ],
      'conditions': [
        ['OS=="win"', {
          'defines': [
            'WIN32',
          ],
          'msvs_settings':{
            'VCCLCompilerTool': {
                'RuntimeTypeInfo': 'true',
            },
            'AdditionalDependencies': [
                'libboost_atomic-vc141-mt-s-x32-1_66.lib',
                'libboost_container-vc141-mt-s-x32-1_66.lib',
                'libboost_context-vc141-mt-s-x32-1_66.lib',
                'libboost_date_time-vc141-mt-s-x32-1_66.lib',
                'libboost_exception-vc141-mt-s-x32-1_66.lib',
                'libboost_filesystem-vc141-mt-s-x32-1_66.lib',
                'libboost_iostreams-vc141-mt-s-x32-1_66.lib',
                'libboost_log-vc141-mt-s-x32-1_66.lib',
                'libboost_signals-vc141-mt-s-x32-1_66.lib',
                'libboost_system-vc141-mt-s-x32-1_66.lib',
                'libboost_thread-vc141-mt-s-x32-1_66.lib',
                'libboost_timer-vc141-mt-s-x32-1_66.lib',
                'TALGuid_s.lib',
              ],
          },
          'link_settings': {
            'libraries': [
              '-lcomctl32.lib',
              '-lshlwapi.lib',
              '-lrpcrt4.lib',
              '-lopengl32.lib',
              '-lglu32.lib'
            ],
            'libraries': [
              '-lshell32.lib',
              '-luser32.lib'
            ],
            'library_dirs': [
            ],
          },
          'sources': [
            'lib/common/lock_win.cc',
          ],
          'msvs_disabled_warnings': [
            4267
          ],
        }],
        ['OS=="mac"', {
          'make_global_settings': [
            ['CC', '/usr/bin/clang'],
            ['CXX', '/usr/bin/clang++'],
          ],
          'defines': [
            'OS_POSIX',
            'OS_MACOSX',
          ],
          'include_dirs': [],
          'xcode_settings': {
            'ALWAYS_SEARCH_USER_PATHS': 'NO',
            #'i386', 'x86_64'
            'ARCHS': [ 'x86_64' ],
            'MACOSX_DEPLOYMENT_TARGET': '10.10',
            'CC': 'clang',
            'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
            'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x',
            # libstdc++, c++11, libc++
            'CLANG_CXX_LIBRARY': 'libc++',
            'GCC_ENABLE_OBJC_GC': 'unsupported',
            'LIBRARY_SEARCH_PATHS': [
              '$(SDKROOT)/System/Library/Frameworks',
              '$(PROJECT_DIR)/third_party/scribble/lib',
            ],
            'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
            'GCC_SYMBOLS_PRIVATE_EXTERN': 'NO',
            'DEBUG_INFORMATION_FORMAT': 'dwarf-with-dsym',
            #'DEPLOYMENT_POSTPROCESSING': 'YES',
            'OTHER_CFLAGS':[
              #'-fno-eliminate-unused-debug-symbols',
              '-mmacosx-version-min=10.10',
              # compile use oc++
              '-x objective-c++',
            ],
            'OTHER_LDFLAGS':[
                '-Wl,-search_paths_first',
                '-Wl,-ObjC',
              ],
          }, # xcode_settings
          'link_settings': {
            'libraries': [
              '$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
              #'$(SDKROOT)/System/Library/Frameworks/CoreGraphics.framework',
            ],
          },
          'libraries': [],
          'mac_framework_dirs': [],
          'sources': [
            'lib/common/lock_mac.mm',
          ],
          'configurations': {
            'Debug': {
              'xcode_settings': {
                # 'GCC_DEBUGGING_SYMBOLS': 'full',
                # 'STRIP_INSTALLED_PRODUCT': 'YES',
                # 'GCC_OPTIMIZATION_LEVEL': '0',
                # 'OTHER_CFLAGS': ['-g',],
                # 'OTHER_CXXFLAGS': ['-g',],
              }, # xcode_settings
            }, # Debug
            'Release': {
              'xcode_settings': {
                # 'GCC_OPTIMIZATION_LEVEL': 's',
              }, # xcode_settings
            }, # Release
          }, # configurations
      }], # Mac
      ],
    },
    {
      'target_name': 'lib_jsoncpp',
      'type': 'static_library',
      #'mac_bundle': 1,
      'msvs_guid': 'A0FC4935-8D40-4624-8D84-5A8714419A12',
      'dependencies': [
      ],
      'defines': [
        'WIN32'
      ],
      'include_dirs': [
        'third_party/jsoncpp/include',
        'third_party/jsoncpp/src',
      ],
      'sources': [
        'third_party/jsoncpp/src/json_reader.cpp',
        'third_party/jsoncpp/src/json_tool.h',
        'third_party/jsoncpp/src/json_value.cpp',
        'third_party/jsoncpp/src/json_valueiterator.inl',
        'third_party/jsoncpp/src/json_writer.cpp',
        'third_party/jsoncpp/src/version.h.in',
      ],
      'conditions': [
        ['OS=="win"', {
          'defines': [
            'WIN32'
          ],
          'msvs_settings': {
            'VCLinkerTool': {
              # Set /SUBSYSTEM:WINDOWS.
              'SubSystem': '2',
            },
            'VCManifestTool': {
              'AdditionalManifestFiles': [],
            },
          },
          'link_settings': {
            'libraries': [
              '-luser32.lib',
            ],
          },
          'sources': [],
        }],# Windows
        ['OS=="mac"', {
          'make_global_settings': [
           ['CC', '/usr/bin/clang'],
           ['CXX', '/usr/bin/clang++'],
        ],
        'defines': [
          'OS_POSIX',
          'OS_MACOSX',
        ],
        'xcode_settings': {
                  'ALWAYS_SEARCH_USER_PATHS': 'NO',
        #'i386', 'x86_64'
        'ARCHS': [ 'x86_64' ],
        'MACOSX_DEPLOYMENT_TARGET': '10.10',
        'CC': 'clang',
        'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
        'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x',
        # libstdc++, c++11, libc++
        'CLANG_CXX_LIBRARY': 'libc++',
        'GCC_ENABLE_OBJC_GC': 'unsupported',
        #'LIBRARY_SEARCH_PATHS': [],
        'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
        'GCC_SYMBOLS_PRIVATE_EXTERN': 'NO',
        'DEBUG_INFORMATION_FORMAT': 'dwarf-with-dsym',
        #'DEPLOYMENT_POSTPROCESSING': 'YES',
        'OTHER_CFLAGS': [
          #'-fno-eliminate-unused-debug-symbols',
          '-mmacosx-version-min=10.10',
          # compile use oc++
          '-x objective-c++',
        ],
        }, # xcode_settings
        'link_settings': {
          'libraries': [
          ],
        },
        'libraries': [],
        'mac_framework_dirs': [],
        'configurations': {
          'Debug': {
            'xcode_settings': {
              'GCC_DEBUGGING_SYMBOLS': 'full',
              'STRIP_INSTALLED_PRODUCT': 'YES',
              'GCC_OPTIMIZATION_LEVEL': '0',
              'OTHER_CFLAGS': ['-g',],
              'OTHER_CXXFLAGS': ['-g',],
            }, # xcode_settings
          }, # Debug
          'Release': {
            'xcode_settings': {
            'GCC_OPTIMIZATION_LEVEL': 's',
            }, # xcode_settings
          }, # Release
        }, # configurations
      }], # Mac
    ],
    },
  ],
}
