[M120 Migration] Implement ewk_view_is_video_playing api
[platform/framework/web/chromium-efl.git] / build / rust / BUILD.gn
1 # Copyright 2021 The Chromium Authors
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/buildflag_header.gni")
6 import("//build/config/rust.gni")
7
8 if (toolchain_has_rust) {
9   config("edition_2021") {
10     rustflags = [ "--edition=2021" ]
11   }
12
13   config("edition_2018") {
14     rustflags = [ "--edition=2018" ]
15   }
16
17   config("edition_2015") {
18     rustflags = [ "--edition=2015" ]
19   }
20
21   if (enable_cxx) {
22     # The required dependencies for cxx-generated bindings, that must be included
23     # on the C++ side.
24     static_library("cxx_cppdeps") {
25       sources = [
26         "//third_party/rust/cxx/v1/crate/include/cxx.h",
27         "//third_party/rust/cxx/v1/crate/src/cxx.cc",
28       ]
29
30       defines = [ "RUST_CXX_NO_EXCEPTIONS" ]
31
32       # We cannot depend on base/base_export.h because base depends on us.
33       if (is_component_build) {
34         if (is_win) {
35           defines += [ "CXX_RS_EXPORT=__declspec(dllexport)" ]
36         } else {
37           defines +=
38               [ "CXX_RS_EXPORT=__attribute__((visibility(\"default\")))" ]
39         }
40       } else {
41         defines += [ "CXX_RS_EXPORT=" ]
42       }
43
44       # Depending on the C++ bindings side of cxx then requires also depending
45       # on the Rust bindings, since one calls the other. And the Rust bindings
46       # require the Rust standard library.
47       deps = [ ":cxx_rustdeps" ]
48     }
49
50     # The required dependencies for cxx-generated bindings, that must be included
51     # on the Rust side.
52     group("cxx_rustdeps") {
53       public_deps = [ "//third_party/rust/cxx/v1:lib" ]
54     }
55   }
56 }
57
58 # Enables code behind #[cfg(test)]. This should only be used for targets where
59 # testonly=true.
60 config("test") {
61   rustflags = [
62     "--cfg",
63     "test",
64   ]
65 }
66
67 # TODO(crbug.com/gn/104): GN rust_proc_macro targets are missing this
68 # command line flag, for the proc_macro crate which is provided by rustc for
69 # compiling proc-macros.
70 config("proc_macro_extern") {
71   rustflags = [
72     "--extern",
73     "proc_macro",
74   ]
75 }
76
77 # Forbids unsafe code in crates with this config.
78 config("forbid_unsafe") {
79   rustflags = [ "-Funsafe_code" ]
80 }
81
82 config("panic_immediate_abort") {
83   visibility = [ "//build/rust/std/rules:*" ]
84   if (is_official_build) {
85     rustflags = [
86       "--cfg",
87       "feature=\"panic_immediate_abort\"",
88     ]
89   }
90 }