-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.gn
129 lines (111 loc) · 4.06 KB
/
BUILD.gn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
import("//build_overrides/pigweed.gni")
import("$dir_pw_arduino_build/arduino.gni")
import("$dir_pw_build/python.gni")
import("$dir_pw_build/python_dist.gni")
import("$dir_pw_build/python_venv.gni")
import("$dir_pw_tokenizer/database.gni")
import("$dir_pw_unit_test/test.gni")
# NOTE: All the `deps` listed in `//BUILD.gn` must either be instantiated with a
# toolchain, e.g. `":my_host_target(//path/to/host:toolchain)"`, or listed
# within an `if (current_toolchain != default_toolchain)` statement.
# It also prevents the default toolchain from parsing any unnecessary BUILD.gn
# files.
# Lists all the targets build by default with e.g. `ninja -C out`.
group("default") {
deps = [
":docs",
":examples",
":host",
":python.lint",
":python.tests",
]
}
group("docs") {
deps = [ ]
}
# Group all targets that run on host only, e.g. tests, utils.
group("host") {
deps = [ ":run_tests(//targets/host:host_debug_tests)" ]
}
# In-tree Python packages
_sample_project_python_packages = [ "//tools:tools" ]
# This group contains all the python packages that should be tested and linted.
pw_python_group("python") {
python_deps = _sample_project_python_packages
}
_all_python_packages =
_sample_project_python_packages
# The default venv for Python actions in GN
# Set this gn arg in a declare_args block in this file 'BUILD.gn' or in '.gn' to
# use this venv.
#
# pw_build_PYTHON_BUILD_VENV = "//:sample_project_build_venv"
#
pw_python_venv("sample_project_build_venv") {
path = "$root_build_dir/python-venv"
constraints = pw_build_PIP_CONSTRAINTS
requirements = pw_build_PIP_REQUIREMENTS
# Ensure all third party Python dependencies are installed into this venv.
# This works by checking the setup.cfg files for all packages listed here and
# installing the packages listed in the [options].install_requires field.
source_packages = _all_python_packages
}
# This template collects all python packages and their dependencies into a
# single super Python package for installation into the bootstrapped virtual
# environment.
pw_python_distribution("sample_project_python_distribution") {
packages = _all_python_packages
generate_setup_cfg = {
name = "sample-project-tools"
version = "0.0.1"
append_date_to_version = true
include_default_pyproject_file = true
}
}
# Install the sample-project-tools super Python package into the bootstrapped
# Python venv.
pw_python_pip_install("pip_install_sample_project_tools") {
packages = [ ":sample_project_python_distribution" ]
}
group("examples") {
deps = []
# mimxrt595_evk examples.
deps += [
"//examples/01_bluetooth:bluetooth(//targets/mimxrt595_evk_freertos:mimxrt595_evk_freertos_debug)",
"//examples/02_usb_fastboot:usb_fastboot(//targets/mimxrt595_evk_freertos:mimxrt595_evk_freertos_debug)",
]
}
# TODO: b/301306292 - Removing this causes a duplicate toolchain to be
# generated if any tests are present in the test group. Figure out why, and set
# up a more scalable solution.
if (current_toolchain != default_toolchain) {
# All the tests that should run as part of the build.
pw_test_group("tests") {
group_deps = [
# Uncomment this to automatically run the example unit test.
# "//examples/02_unit_testing:tests",
]
}
group("run_tests") {
if (pw_unit_test_AUTOMATIC_RUNNER == "") {
# Without a test runner defined, build the tests but don't run them.
deps = [ ":tests" ]
} else {
# With a test runner, build and run tests.
deps = [ ":tests.run" ]
}
}
}