util: Add tool to generate cros_ec_commands.h
Add a rule to generate a new cros_ec_commands.h when ec_commands.h is modified. The rule is checked when buildall is invoked. At Presubmit stage, check a cros_ec_commands.h exists if ec_commands.h is modified. The CL author is responsible to upstream that file. BUG=chromium:945948 BRANCH=none Cq-Depend: chromium:1558853 TEST=Check manually cros_ec_commands.h is generated with make build_cros_ec_commands Check no bread crumbs are left-over when the rule fails. Check checkpatch triggers when it finds an invalid syntax in the output file. Check ../../repohooks/pre-upload.py returns a meaningful error when cros_ec_commands.h file is not present. Change-Id: Ibc8ed7165914d39b5f0bd41643932a8514768925 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1559380 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Brian Norris <briannorris@chromium.org>
This commit is contained in:
parent
d3ce30103e
commit
5c931074f5
|
@ -164,7 +164,7 @@ build_boards: | $(FAILED_BOARDS_DIR)
|
|||
$(MAKE) try_build_boards
|
||||
|
||||
.PHONY: buildall
|
||||
buildall: build_boards
|
||||
buildall: build_boards build_cros_ec_commands
|
||||
$(MAKE) build_cts
|
||||
$(MAKE) buildfuzztests
|
||||
$(MAKE) runtests
|
||||
|
@ -758,6 +758,12 @@ stats: build_boards
|
|||
$(call cmd_stats,RO)
|
||||
$(call cmd_stats,RW)
|
||||
|
||||
.PHONY: build_cros_ec_commands
|
||||
build_cros_ec_commands: build/kernel/include/linux/mfd/cros_ec_commands.h
|
||||
|
||||
build/kernel/include/linux/mfd/cros_ec_commands.h: include/ec_commands.h
|
||||
util/make_linux_ec_commands_h.sh $< $@
|
||||
|
||||
.SECONDARY:
|
||||
|
||||
-include $(deps)
|
||||
|
|
|
@ -12,6 +12,7 @@ checkpatch_check: --no-tree --ignore=MSLEEP,VOLATILE,SPDX_LICENSE_TAG
|
|||
kerneldoc_check: --include_regex=\bec_commands\.h$
|
||||
|
||||
[Hook Scripts]
|
||||
presubmit_check = util/presubmit_check.sh 2>&1
|
||||
config_option_check = util/config_option_check.py 2>&1
|
||||
host_command_check = util/host_command_check.sh 2>&1
|
||||
presubmit_check = util/presubmit_check.sh
|
||||
config_option_check = util/config_option_check.py
|
||||
host_command_check = util/host_command_check.sh
|
||||
ec_commands_h = util/linux_ec_commands_h_check.sh
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2019 The Chromium OS Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
set -e
|
||||
|
||||
ec_commands_file_in="include/ec_commands.h"
|
||||
ec_commands_file_out="build/kernel/include/linux/mfd/cros_ec_commands.h"
|
||||
|
||||
# Check if ec_commands.h has changed.
|
||||
echo ${PRESUBMIT_FILES} | grep -q "${ec_commands_file_in}" || exit 0
|
||||
|
||||
if [ ! -f "${ec_commands_file_out}" ]; then
|
||||
echo "A new cros_ec_commands.h must be generated."
|
||||
echo 'Please run "make buildall" or "make build_cros_ec_commands"'.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${ec_commands_file_out}" -ot "${ec_commands_file_in}" ]; then
|
||||
echo "cros_ec_commands.h is out of date."
|
||||
echo 'Please run "make buildall" or "make build_cros_ec_commands"'.
|
||||
exit 1
|
||||
fi
|
|
@ -0,0 +1,70 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2019 The Chromium OS Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# Generate a kernel include file from ec_commands.h.
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
Generate an ec_commands.h file suitable for upstreaming to kernel.org.
|
||||
Syntax:
|
||||
$0 source_ec_commands.h target_cros_ec_commands.h
|
||||
|
||||
source_ec_commands.h: source file, usually include/ec_commands.h
|
||||
target_cros_ec_commands.h: target file that will be upstreamed.
|
||||
EOF
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
in="$1"
|
||||
out="$2"
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
out_dir="$(dirname "${out}")"
|
||||
mkdir -p "${out_dir}"
|
||||
tmp="$(mktemp -p "${out_dir}" cros_ec_XXX.h)"
|
||||
cp "${in}" "${tmp}"
|
||||
|
||||
cleanup() {
|
||||
rm -f "${tmp}"*
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
# Replace license
|
||||
patch "${tmp}" << EOF
|
||||
@@ -1,6 +1,11 @@
|
||||
-/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
|
||||
- * Use of this source code is governed by a BSD-style license that can be
|
||||
- * found in the LICENSE file.
|
||||
+/* SPDX-License-Identifier: GPL-2.0 */
|
||||
+/*
|
||||
+ * Host communication command constants for ChromeOS EC
|
||||
+ *
|
||||
+ * Copyright (C) 2012 Google, Inc
|
||||
+ *
|
||||
+ * NOTE: This file is auto-generated from ChromeOS EC Open Source code from
|
||||
+ * https://chromium.googlesource.com/chromiumos/platform/ec/+/master/include/ec_commands.h
|
||||
*/
|
||||
|
||||
/* Host communication command constants for Chrome EC */
|
||||
EOF
|
||||
|
||||
# Change header guards
|
||||
sed -i "s/__CROS_EC_EC_COMMANDS_H/__CROS_EC_COMMANDS_H/" "${tmp}"
|
||||
|
||||
# Remove non kernel code to prevent checkpatch warnings and simplify the .h.
|
||||
unifdef -x2 -m -UCONFIG_HOSTCMD_ALIGNED -U__ACPI__ -D__KERNEL__ -U__cplusplus \
|
||||
-UCHROMIUM_EC "${tmp}"
|
||||
|
||||
# Check kernel checkpatch passes.
|
||||
"${CROS_WORKON_SRCROOT}/src/repohooks/checkpatch.pl" -f "${tmp}"
|
||||
|
||||
cp "${tmp}" "${out}"
|
Loading…
Reference in New Issue