1# Copyright (c) 2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14config("rtti") { 15 if (is_win) { 16 cflags_cc = [ "/GR" ] 17 } else { 18 cflags_cc = [ "-frtti" ] 19 } 20} 21 22config("exceptions") { 23 if (is_win) { 24 # Enables exceptions in the STL. 25 if (!use_custom_libcxx) { 26 defines = [ "_HAS_EXCEPTIONS=1" ] 27 } 28 cflags_cc = [ "/EHsc" ] 29 } else { 30 cflags_cc = [ "-fexceptions" ] 31 } 32} 33 34config("no_exceptions") { 35 if (is_win) { 36 # Disables exceptions in the STL. 37 # libc++ uses the __has_feature macro to control whether to use exceptions, 38 # so defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also 39 # breaks libc++ because it depends on MSVC headers that only provide certain 40 # declarations if _HAS_EXCEPTIONS is 1. Those MSVC headers do not use 41 # exceptions, despite being conditional on _HAS_EXCEPTIONS. 42 if (!use_custom_libcxx) { 43 defines = [ "_HAS_EXCEPTIONS=0" ] 44 } 45 } else { 46 cflags_cc = [ "-fno-exceptions" ] 47 } 48} 49