blob: 189bf7e8fcdab6275b5187cd797a160ffef1f676 [file] [log] [blame]
# Copyright 2022 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/pi_pico.gni")
import("//build_overrides/pigweed.gni")
import("$dir_pw_build/target_types.gni")
declare_args() {
PICO_SDK_VERSION_MAJOR = 1
PICO_SDK_VERSION_MINOR = 3
PICO_SDK_VERSION_REVISION = 0
}
# GN-ism: To reference earlier args, this needs to be in a separate block.
declare_args() {
PICO_SDK_VERSION_STRING = "${PICO_SDK_VERSION_MAJOR}.${PICO_SDK_VERSION_MINOR}.${PICO_SDK_VERSION_REVISION}"
}
template("generate_version_header") {
assert(defined(invoker.version_major))
assert(defined(invoker.version_minor))
assert(defined(invoker.version_revision))
assert(defined(invoker.version_string))
_generated_header_dir = "${target_gen_dir}/${target_name}_include"
_generated_header_path = "${_generated_header_dir}/pico/version.h"
config("${target_name}.public_include_dirs") {
include_dirs = [ "${_generated_header_dir}" ]
}
generated_file("${target_name}.generated_header") {
outputs = [ "${_generated_header_path}" ]
_lines = [
"// ---------------------------------------",
"// THIS FILE IS AUTOGENERATED; DO NOT EDIT",
"// ---------------------------------------",
"",
"#ifndef _PICO_VERSION_H",
"#define _PICO_VERSION_H",
"",
"#define PICO_SDK_VERSION_MAJOR ${invoker.version_major}",
"#define PICO_SDK_VERSION_MINOR ${invoker.version_minor}",
"#define PICO_SDK_VERSION_REVISION ${invoker.version_revision}",
"#define PICO_SDK_VERSION_STRING \"${invoker.version_string}\"",
"",
"#endif",
]
# Join with newline.
_NEWLINE_CHAR = "$0x0A"
contents = string_join(_NEWLINE_CHAR, _lines)
}
pw_source_set("${target_name}") {
remove_configs = [ "$dir_pw_build:strict_warnings" ]
public_configs = [ ":${target_name}.public_include_dirs" ]
deps = [ ":${target_name}.generated_header" ]
public = [ "${_generated_header_path}" ]
forward_variables_from(invoker,
"*",
[
"version_major",
"version_minor",
"version_revision",
"version_string",
])
}
}