You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/09/14 06:33:35 UTC
[nuttx] branch master updated (7c422381ca -> a0cc455922)
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
from 7c422381ca net/tcp: Set SO_ERROR for poll error in setup
new d0ca0d422e tools: defconfig supports the include command
new a0cc455922 tools: add support for merge_config
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
Documentation/quickstart/configuring.rst | 26 ++++++++
tools/configure.sh | 31 ++++-----
tools/merge_config.py | 69 +++++++++++++++++++
tools/process_config.sh | 111 +++++++++++++++++++++++++++++++
4 files changed, 222 insertions(+), 15 deletions(-)
create mode 100755 tools/merge_config.py
create mode 100755 tools/process_config.sh
[nuttx] 02/02: tools: add support for merge_config
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit a0cc455922db30f85c9669efdd6ec9e918933d56
Author: yinshengkai <yi...@xiaomi.com>
AuthorDate: Mon Sep 11 20:34:31 2023 +0800
tools: add support for merge_config
Usage example:
./tools/merge_config.py -o defconfig .config1 .config2
Signed-off-by: yinshengkai <yi...@xiaomi.com>
---
Documentation/quickstart/configuring.rst | 10 +++++
tools/merge_config.py | 69 ++++++++++++++++++++++++++++++++
2 files changed, 79 insertions(+)
diff --git a/Documentation/quickstart/configuring.rst b/Documentation/quickstart/configuring.rst
index 0cf176549a..4ff36999c8 100644
--- a/Documentation/quickstart/configuring.rst
+++ b/Documentation/quickstart/configuring.rst
@@ -140,3 +140,13 @@ The default header file search path includes:
CONFIG_XXX2=y
#include "configs/system.config"
#include "configs/net.config"
+
+Merge configuration
+--------------------------
+
+Multiple config fragments can be merged manually using the tools/merge_config.py script.
+
+.. code-block:: console
+
+ $ cd nuttx
+ $ ./tools/merge_config.py -o defconfig .config1 .config2
diff --git a/tools/merge_config.py b/tools/merge_config.py
new file mode 100755
index 0000000000..6dc2fc762a
--- /dev/null
+++ b/tools/merge_config.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python3
+############################################################################
+# tools/merge_config.py
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership. The
+# ASF licenses this file to you 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
+#
+# http://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 argparse
+import os
+
+try:
+ from kconfiglib import Kconfig
+except ModuleNotFoundError:
+ print("Please execute the following command to install dependencies:")
+ print("pip install kconfiglib")
+ exit()
+
+script_path = os.path.split(os.path.realpath(__file__))[0]
+topdir = os.path.join(script_path, "..")
+kconfig_path = os.path.join(topdir, "Kconfig")
+
+# Set environment variables
+
+os.environ["BINDIR"] = os.path.join(topdir)
+os.environ["APPSDIR"] = os.path.join(topdir, "../apps")
+os.environ["APPSBINDIR"] = os.path.join(topdir, "../apps")
+
+
+def merge_configs(output_file, input_files):
+ kconf = Kconfig(kconfig_path, suppress_traceback=True)
+
+ kconf.warn_assign_undef = True
+ kconf.warn_assign_override = False
+ kconf.warn_assign_redun = False
+
+ for input_file in input_files:
+ print(kconf.load_config(input_file, replace=False))
+
+ # Save the merged configuration to the output file
+
+ kconf.write_min_config(output_file)
+ print(f"Configuration successfully merged to {output_file}")
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description="Merge Kconfig configuration files")
+ parser.add_argument(
+ "-o", "--output", required=True, help="Output merged configuration file"
+ )
+ parser.add_argument(
+ "input_files", nargs="+", help="List of input configuration files"
+ )
+ args = parser.parse_args()
+
+ merge_configs(args.output, args.input_files)
[nuttx] 01/02: tools: defconfig supports the include command
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit d0ca0d422e9197c0973d68f422cdcad84820edf5
Author: yinshengkai <yi...@xiaomi.com>
AuthorDate: Mon Sep 11 17:18:06 2023 +0800
tools: defconfig supports the include command
We support search directory structure as follows:
Current directory
stm32/configs/common
stm32/common/configs
Signed-off-by: yinshengkai <yi...@xiaomi.com>
---
Documentation/quickstart/configuring.rst | 16 +++++
tools/configure.sh | 31 ++++-----
tools/process_config.sh | 111 +++++++++++++++++++++++++++++++
3 files changed, 143 insertions(+), 15 deletions(-)
diff --git a/Documentation/quickstart/configuring.rst b/Documentation/quickstart/configuring.rst
index 1ccd0d63db..0cf176549a 100644
--- a/Documentation/quickstart/configuring.rst
+++ b/Documentation/quickstart/configuring.rst
@@ -124,3 +124,19 @@ This is also useful to script configuration changes that you perform often:
kconfig-tweak --disable CONFIG_DEBUG_NOOPT
kconfig-tweak --disable CONFIG_SYSLOG_TIMESTAMP
make oldconfig
+
+Reference configuration
+--------------------------
+
+Defconfig supports the use of #include statements to reference other configuration files.
+The default header file search path includes:
+ ${current directory}
+ ${boards}/configs/comnon
+ ${boards}/common/configs
+
+.. code-block::
+
+ CONFIG_XXX1=y
+ CONFIG_XXX2=y
+ #include "configs/system.config"
+ #include "configs/net.config"
diff --git a/tools/configure.sh b/tools/configure.sh
index 04344a28b1..caf960474d 100755
--- a/tools/configure.sh
+++ b/tools/configure.sh
@@ -203,6 +203,22 @@ if [ -r ${dest_config} ]; then
fi
fi
+# Okay... Everything looks good. Setup the configuration
+
+echo " Copy files"
+ln -sf ${src_makedefs} ${dest_makedefs} || \
+ { echo "Failed to symlink ${src_makedefs}" ; exit 8 ; }
+${TOPDIR}/tools/process_config.sh -I ${configpath}/../../common/configs \
+ -I ${configpath}/../common -o ${dest_config} ${src_config}
+install -m 644 ${src_config} "${backup_config}" || \
+ { echo "Failed to backup ${src_config}" ; exit 10 ; }
+
+# Install any optional files
+
+for opt in ${OPTFILES}; do
+ test -f ${configpath}/${opt} && install ${configpath}/${opt} "${TOPDIR}/"
+done
+
# Extract values needed from the defconfig file. We need:
# (1) The CONFIG_WINDOWS_NATIVE setting to know it this is target for a
# native Windows
@@ -271,21 +287,6 @@ if [ ! -z "${appdir}" -a ! -d "${TOPDIR}/${posappdir}" ]; then
exit 7
fi
-# Okay... Everything looks good. Setup the configuration
-
-echo " Copy files"
-ln -sf ${src_makedefs} ${dest_makedefs} || \
- { echo "Failed to symlink ${src_makedefs}" ; exit 8 ; }
-install -m 644 ${src_config} "${dest_config}" || \
- { echo "Failed to copy ${src_config}" ; exit 9 ; }
-install -m 644 ${src_config} "${backup_config}" || \
- { echo "Failed to backup ${src_config}" ; exit 10 ; }
-
-# Install any optional files
-
-for opt in ${OPTFILES}; do
- test -f ${configpath}/${opt} && install ${configpath}/${opt} "${TOPDIR}/"
-done
# If we did not use the CONFIG_APPS_DIR that was in the defconfig config file,
# then append the correct application information to the tail of the .config
diff --git a/tools/process_config.sh b/tools/process_config.sh
new file mode 100755
index 0000000000..a08f680db2
--- /dev/null
+++ b/tools/process_config.sh
@@ -0,0 +1,111 @@
+#!/usr/bin/env bash
+# tools/process_config.sh
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership. The
+# ASF licenses this file to you 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
+#
+# http://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.
+#
+
+process_file() {
+ local output_file="$1"
+ local input_file="$2"
+ local include_paths=("${!3}")
+
+ while IFS= read -r line || [ -n "$line" ]
+ do
+ if [[ $line == \#include* ]]; then
+ local include_file=$(echo $line | sed -E 's/#include [<"](.+)[">]/\1/')
+ local found=false
+
+ # Check current directory first
+
+ if [ -f $include_file ]; then
+ process_file $output_file $include_file include_paths[@]
+ found=true
+ else
+ # Then check in the include paths
+
+ for path in "${include_paths[@]}"; do
+ local full_path="$path/$include_file"
+ if [ -f $full_path ]; then
+ process_file $output_file $full_path include_paths[@]
+ found=true
+ break
+ fi
+ done
+ fi
+
+ # Configuration file not found
+
+ if [ "$found" = false ]; then
+ echo "ERROR: Can't find \"$include_file\" in current directory or search paths."
+ rm $output_file
+ exit 1
+ fi
+ else
+ echo "$line" >> $output_file
+ fi
+ done < "$input_file"
+}
+
+usage() {
+ echo "Usage: $0 [OPTIONS] [INPUT_FILE]"
+ echo " -h display this help"
+ echo " -I include path, can be specified multiple times"
+ echo " -o output file"
+ echo " [INPUT_FILE] the file to be processed"
+}
+
+while [[ $# -gt 0 ]]
+do
+ key="$1"
+
+ case $key in
+ -I)
+ INCLUDE_PATHS+=("$2")
+ shift
+ shift
+ ;;
+ -o)
+ OUTPUT_FILE="$2"
+ shift
+ shift
+ ;;
+ *)
+ if [ -z "$INPUT_FILE" ]; then
+ INPUT_FILE="$1"
+ shift
+ else
+ echo "Error: Multiple input files specified"
+ usage
+ exit 1
+ fi
+ ;;
+ esac
+done
+
+if [ -z "$INPUT_FILE" ]; then
+ echo "Error: Input file not specified"
+ usage
+ exit 1
+fi
+
+if [ -z "$OUTPUT_FILE" ]; then
+ echo "Error: Output file not specified"
+ usage
+ exit 1
+fi
+
+echo "" > $OUTPUT_FILE
+process_file "$OUTPUT_FILE" "$INPUT_FILE" INCLUDE_PATHS[@]