diff --git a/arch/BUILD.gn b/arch/BUILD.gn index 6367bf1a..7e0ec408 100644 --- a/arch/BUILD.gn +++ b/arch/BUILD.gn @@ -29,53 +29,24 @@ import("//kernel/liteos_m/liteos.gni") -group("arch") { - if ("$board_cpu" == "cortex-m3") { - deps = [ "arm/cortex-m3/gcc/:arch" ] - } else if ("$board_cpu" == "cortex-m4") { - deps = [ "arm/cortex-m4/gcc/:arch" ] - } else if ("$board_cpu" == "cortex-m7") { - deps = [ "arm/cortex-m7/gcc/:arch" ] - } else if ("$board_cpu" == "cortex-m33") { - if (defined(LOSCFG_SECURE_TRUSTZONE)) { - deps = [ "arm/cortex-m33/gcc/TZ:arch" ] - } else { - deps = [ "arm/cortex-m33/gcc/NTZ:arch" ] - } - } else if ("$board_cpu" == "ck802" || "$board_cpu" == "e802") { - deps = [ "csky/v2/gcc:arch" ] - } else if ("$board_cpu" == "") { - if ("$board_arch" == "rv32imac" || "$board_arch" == "rv32imafdc") { - deps = [ "risc-v/riscv32/gcc:arch" ] - } else if ("$board" == "esp32") { - deps = [ "xtensa/lx6/gcc:arch" ] - } - } +config("arch_config") { + include_dirs = [ "include" ] } -config("public") { - include_dirs = [ "include" ] - if (defined(LOSCFG_ARCH_ARM)) { - include_dirs += [ "arm/include" ] - if (defined(LOSCFG_ARCH_CORTEX_M3)) { - include_dirs += [ "arm/cortex-m3/gcc" ] - } else if (defined(LOSCFG_ARCH_CORTEX_M4)) { - include_dirs += [ "arm/cortex-m4/gcc" ] - } else if (defined(LOSCFG_ARCH_CORTEX_M7)) { - include_dirs += [ "arm/cortex-m7/gcc" ] - } else if (defined(LOSCFG_ARCH_CORTEX_M33)) { - if (defined(LOSCFG_TRUSTZONE)) { - include_dirs += [ "arm/cortex-m33/gcc/TZ/non_secure" ] - } else { - include_dirs += [ "arm/cortex-m33/gcc/NTZ" ] - } +module_group("arch") { + modules = [] + if ("$board_cpu" == "arm9" || "$board_cpu" == "cortex-m3" || + "$board_cpu" == "cortex-m4" || "$board_cpu" == "cortex-m7" || + "$board_cpu" == "cortex-m33") { + modules += [ "arm" ] + } else if ("$board_cpu" == "ck802" || "$board_cpu" == "e802") { + modules += [ "csky" ] + } else if ("$board_cpu" == "") { + if ("$board_arch" == "rv32imac" || "$board_arch" == "rv32imafdc") { + modules += [ "risc-v" ] + } else if ("$board" == "esp32") { + modules += [ "xtensa" ] } - } else if (defined(LOSCFG_ARCH_RISCV32)) { - include_dirs += [ "risc-v/riscv32/gcc" ] - include_dirs += [ "risc-v/riscv32/gcc/asm" ] - } else if (defined(LOSCFG_ARCH_CSKY)) { - include_dirs += [ "csky/v2/gcc" ] - } else if (defined(LOSCFG_ARCH_XTENSA)) { - include_dirs += [ "xtensa/lx6/gcc" ] } + configs = [ ":arch_config" ] } diff --git a/arch/arm/BUILD.gn b/arch/arm/BUILD.gn new file mode 100644 index 00000000..035e1992 --- /dev/null +++ b/arch/arm/BUILD.gn @@ -0,0 +1,39 @@ +# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import("//kernel/liteos_m/liteos.gni") + +config("arm_config") { + include_dirs = [ "include" ] +} + +module_group("arm") { + modules = [ "$board_cpu/gcc" ] + configs = [ ":arm_config" ] +} diff --git a/arch/arm/arm9/gcc/BUILD.gn b/arch/arm/arm9/gcc/BUILD.gn index 105d00dc..53f7ee35 100644 --- a/arch/arm/arm9/gcc/BUILD.gn +++ b/arch/arm/arm9/gcc/BUILD.gn @@ -40,3 +40,7 @@ kernel_module(module_name) { "reset_vector.S", ] } + +config("public") { + include_dirs = [ "." ] +} diff --git a/arch/arm/cortex-m33/gcc/BUILD.gn b/arch/arm/cortex-m33/gcc/BUILD.gn new file mode 100644 index 00000000..d56b64f4 --- /dev/null +++ b/arch/arm/cortex-m33/gcc/BUILD.gn @@ -0,0 +1,38 @@ +# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import("//kernel/liteos_m/liteos.gni") + +module_group("gcc") { + if (defined(LOSCFG_SECURE_TRUSTZONE)) { + modules = [ "TZ" ] + } else { + modules = [ "NTZ" ] + } +} diff --git a/arch/arm/cortex-m33/gcc/NTZ/BUILD.gn b/arch/arm/cortex-m33/gcc/NTZ/BUILD.gn index a0ecc6b3..341a1838 100644 --- a/arch/arm/cortex-m33/gcc/NTZ/BUILD.gn +++ b/arch/arm/cortex-m33/gcc/NTZ/BUILD.gn @@ -39,3 +39,7 @@ kernel_module(module_name) { "los_timer.c", ] } + +config("public") { + include_dirs = [ "." ] +} diff --git a/arch/arm/cortex-m33/gcc/TZ/BUILD.gn b/arch/arm/cortex-m33/gcc/TZ/BUILD.gn index 7299844a..a3d9e829 100644 --- a/arch/arm/cortex-m33/gcc/TZ/BUILD.gn +++ b/arch/arm/cortex-m33/gcc/TZ/BUILD.gn @@ -45,3 +45,7 @@ kernel_module(module_name) { "secure", ] } + +config("public") { + include_dirs = [ "non_secure" ] +} diff --git a/arch/arm/cortex-m4/gcc/BUILD.gn b/arch/arm/cortex-m4/gcc/BUILD.gn index a22e6003..88498e54 100644 --- a/arch/arm/cortex-m4/gcc/BUILD.gn +++ b/arch/arm/cortex-m4/gcc/BUILD.gn @@ -40,3 +40,7 @@ kernel_module(module_name) { "los_timer.c", ] } + +config("public") { + include_dirs = [ "." ] +} diff --git a/arch/arm/cortex-m7/gcc/BUILD.gn b/arch/arm/cortex-m7/gcc/BUILD.gn index a22e6003..88498e54 100644 --- a/arch/arm/cortex-m7/gcc/BUILD.gn +++ b/arch/arm/cortex-m7/gcc/BUILD.gn @@ -40,3 +40,7 @@ kernel_module(module_name) { "los_timer.c", ] } + +config("public") { + include_dirs = [ "." ] +} diff --git a/arch/csky/BUILD.gn b/arch/csky/BUILD.gn new file mode 100644 index 00000000..d0884ff5 --- /dev/null +++ b/arch/csky/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import("//kernel/liteos_m/liteos.gni") + +module_group("csky") { + modules = [ "v2/gcc" ] +} diff --git a/arch/csky/v2/gcc/BUILD.gn b/arch/csky/v2/gcc/BUILD.gn index a0ecc6b3..341a1838 100755 --- a/arch/csky/v2/gcc/BUILD.gn +++ b/arch/csky/v2/gcc/BUILD.gn @@ -39,3 +39,7 @@ kernel_module(module_name) { "los_timer.c", ] } + +config("public") { + include_dirs = [ "." ] +} diff --git a/arch/risc-v/BUILD.gn b/arch/risc-v/BUILD.gn new file mode 100644 index 00000000..b3f66792 --- /dev/null +++ b/arch/risc-v/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import("//kernel/liteos_m/liteos.gni") + +module_group("risc-v") { + modules = [ "riscv32/gcc" ] +} diff --git a/arch/risc-v/riscv32/gcc/BUILD.gn b/arch/risc-v/riscv32/gcc/BUILD.gn index 9fa6c4ce..62306c91 100644 --- a/arch/risc-v/riscv32/gcc/BUILD.gn +++ b/arch/risc-v/riscv32/gcc/BUILD.gn @@ -38,6 +38,11 @@ kernel_module(module_name) { "los_interrupt.c", "los_timer.c", ] - - include_dirs = [ "asm" ] +} + +config("public") { + include_dirs = [ + ".", + "asm", + ] } diff --git a/arch/xtensa/BUILD.gn b/arch/xtensa/BUILD.gn new file mode 100644 index 00000000..761b381e --- /dev/null +++ b/arch/xtensa/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import("//kernel/liteos_m/liteos.gni") + +module_group("xtensa") { + modules = [ "lx6/gcc" ] +} diff --git a/arch/xtensa/lx6/gcc/BUILD.gn b/arch/xtensa/lx6/gcc/BUILD.gn index 9bd87108..6188099d 100644 --- a/arch/xtensa/lx6/gcc/BUILD.gn +++ b/arch/xtensa/lx6/gcc/BUILD.gn @@ -40,3 +40,7 @@ kernel_module(module_name) { "los_window.S", ] } + +config("public") { + include_dirs = [ "." ] +} diff --git a/liteos.gni b/liteos.gni index fc618f94..faf7560c 100644 --- a/liteos.gni +++ b/liteos.gni @@ -54,7 +54,7 @@ template("kernel_module") { auto_config = true } - cmd = "if grep -q '^\s*config\s*(\s*\"public\"\s*)\s*{\s*\$' $build_gn; then echo true; else echo false; fi" + cmd = "if grep -q '^\s*\(config\s*(\s*\"public\"\s*)\|module_group\s*(\s*\"\S*\"\s*)\)\s*{\s*\$' $build_gn; then echo true; else echo false; fi" has_public_config = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") if (!has_public_config && defined(auto_config)) { @@ -65,7 +65,7 @@ template("kernel_module") { current_dir_name = get_path_info(rebase_path("."), "file") if (target_name != current_dir_name) { - cmd = "if grep -q '^\s*group\s*(\s*\"$current_dir_name\"\s*)\s*{\s*\$' $build_gn; then echo true; else echo false; fi" + cmd = "if grep -q '^\s*\(module_group\|group\)\s*(\s*\"$current_dir_name\"\s*)\s*{\s*\$' $build_gn; then echo true; else echo false; fi" has_current_dir_group = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") if (!has_current_dir_group && defined(auto_config)) { @@ -142,8 +142,9 @@ set_defaults("kernel_module") { "$LITEOSTOPDIR:los_config", ] visibility = [ - "$LITEOSTOPDIR/*", - "..:*", + "$LITEOSTOPDIR:*", ":*", + "..:*", + "../..:*", ] }