• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# coding=utf-8
3
4"""
5* Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
6* Licensed under the Apache License, Version 2.0 (the "License");
7* you may not use this file except in compliance with the License.
8* You may obtain a copy of the License at
9*
10*     http://www.apache.org/licenses/LICENSE-2.0
11*
12* Unless required by applicable law or agreed to in writing, software
13* distributed under the License is distributed on an "AS IS" BASIS,
14* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15* See the License for the specific language governing permissions and
16* limitations under the License.
17*
18* Description: SCons Compile environment init.
19"""
20
21import os
22import sys
23
24from copy import deepcopy
25from scons_utils import scons_usr_string_option
26from scons_utils import scons_pre_check
27from scons_utils import select_added_cfg
28from scons_utils import scons_get_cfg_val
29from scons_utils import condition_str
30from scons_utils import scons_usr_bool_option
31from scons_utils import scons_get_cfg_val
32from scons_utils import traverse_subdir
33
34#Module to be built by default.
35compile_module = ['drv', 'sys', 'at']
36
37#Get settings from menuconfig
38product_soft_ver_str = scons_usr_string_option('CONFIG_TARGET_SOFT_VER')
39log_output_flag = False
40
41#library path for linking
42cur_file_path = os.path.split(os.path.realpath(__file__))[0]
43netcfg_lib_dir = os.path.join(cur_file_path, '..', '..', '..', '..', '..',
44    'huawei', 'hms', 'hilink', 'ohos', 'l0', 'hi3861', 'lib', 'wifi')
45os_lib_path = [
46    os.path.join('build', 'scripts'),
47    os.path.join('build', 'libs'),
48    netcfg_lib_dir,
49    os.path.join('ohos', 'libs'),
50]
51
52#library path for boot linking
53os_boot_path = [
54    os.path.join('build', 'libs'),
55]
56
57"""
58module_dir dictionary. Format as
59module name : relative directory where the module is located
60"""
61module_dir = {
62    'boot': os.path.join('boot', 'flashboot'),
63    'loaderboot': os.path.join('boot', 'loaderboot'),
64    'drv': os.path.join('platform', 'drivers'),
65    'sys': os.path.join('platform', 'system'),
66    'at': os.path.join('components', 'at'),
67    'hilink': os.path.join('components', 'hilink'),
68    #'OHOS': os.path.join('components', 'OHOS', 'kv'),
69}
70
71"""
72proj_lib_cfg dictionary, contains the sub-folders which includes the source code.
73Format as
74    module name : {library name:["folder1", "folder2"]}
75"""
76proj_lib_cfg = {
77    #flashboot
78    'boot':{ #module name
79        'boot': [ #library name
80            'startup', #source code folders
81            os.path.join('drivers', 'lsadc'),
82            os.path.join('drivers', 'flash'),
83            os.path.join('drivers', 'efuse'),
84            os.path.join('drivers', 'gpio'),
85            os.path.join('drivers', 'io'),
86            os.path.join('common', 'nvm'),
87            os.path.join('common', 'partition_table'),
88            os.path.join('..', '..', 'third_party', 'u-boot-v2019.07', 'u-boot-v2019.07', 'lib'),
89            os.path.join('..', 'commonboot', 'efuse'),
90            os.path.join('..', 'commonboot', 'flash'),
91            'lzmaram',
92            'upg',
93            'secure'
94        ]
95    },
96    #loaderboot
97    'loaderboot':{ #module name
98        'loaderboot': [ #library name
99            'startup', #source code folders
100            'common',
101            os.path.join('common', 'nvm'),
102            os.path.join('common', 'partition_table'),
103            os.path.join('drivers', 'lsadc'),
104            os.path.join('drivers', 'efuse'),
105            os.path.join('drivers', 'flash'),
106            os.path.join('..', '..', 'third_party', 'u-boot-v2019.07', 'u-boot-v2019.07', 'lib'),
107            os.path.join('..', 'commonboot', 'efuse'),
108            os.path.join('..', 'commonboot', 'flash'),
109            'secure'
110        ]
111    },
112    #drivers
113    'drv':{
114        'uart' : [
115            'uart'
116        ],
117        'adc' : [
118            'adc'
119        ],
120        'tsensor' : [
121            'tsensor'
122        ],
123    },
124    #system module
125    'sys':{
126        'cfg' : [
127            'cfg'
128        ],
129        'parttab' : [
130            'partition_table'
131        ],
132        'upg' : [
133            'upg'
134        ],
135    },
136    #third parties and components
137    'at':{'at':['src']},
138    'hilink':{'hilink':['.']},
139    #'OHOS':{'OHOS':['src']},
140}
141
142"""
143Base Settings.
144defines:
145    common:
146        Modify common would take effect in each module building process.
147        Insert global defines if needed.
148    others, like coap, at:
149        Insert module defines below, only affects the module compiling.
150
151liteos_inc_path:
152    Separate os header path to avoid the path too deep.
153    common: global setting.
154
155common_inc_path:
156    include path contains the head files, MUST start with '#'.
157    common: global setting.
158
159"""
160proj_environment = {
161    'ar_flags':{
162        'common':['cr']
163    },
164
165    'cc_flags':{
166        'common':[]
167    },
168
169    'link_flags':{
170        'common':['-nostartfiles', '-nostdlib', '-static', '--gc-sections']
171    },
172
173    'link_scripts_flag':{
174        'common':[os.path.join('-Iplatform', 'os', 'Huawei_LiteOS', 'kernel', 'include'),'-Iconfig']
175    },
176
177    'as_flags':{
178        'common':[]
179    },
180
181    'defines':{
182        'common':[
183            ('PRODUCT_USR_SOFT_VER_STR', r'\"%s\"'%product_soft_ver_str),
184            'CYGPKG_POSIX_SIGNALS',
185            '__ECOS__',
186            '__RTOS_',
187            'PRODUCT_CFG_HAVE_FEATURE_SYS_ERR_INFO',
188            '__LITEOS__',
189            'LIB_CONFIGURABLE',
190            'LOSCFG_SHELL',
191            'LOSCFG_CACHE_STATICS', # This option is used to control whether Cache hit ratio statistics are supported.
192            'CUSTOM_AT_COMMAND',
193            'LOS_COMPILE_LDM',
194            'LOS_CONFIG_IPERF3',
195            ('SECUREC_ENABLE_SCANF_FILE', 0),
196        ],
197        'at':['_PRE_WLAN_FEATURE_MFG_TEST'],
198    },
199
200    'opts':{
201        'common':['-mabi=ilp32', '-march=rv32imc', '-falign-functions=2', '-msave-restore',
202            '-fno-optimize-strlen', '-freorder-blocks-algorithm=simple', '-fno-schedule-insns',
203            '-fno-inline-small-functions',
204            '-fno-inline-functions-called-once', '-mtune=size', '-fno-strict-aliasing',
205            '-msmall-data-limit=0', '-nostdinc', '-fno-aggressive-loop-optimizations', '-fno-builtin', '-std=c99',
206            '-Os', '-ffunction-sections', '-fdata-sections', '-fno-exceptions', '-fno-short-enums',
207            '-fno-common', '-Wall', '-Wundef', '-DLOS_COMPILE_LDM',
208            '-fstack-protector-strong', '-freg-struct-return', '-fvisibility=hidden', '-pipe'
209        ],
210
211        'drv':['-Werror', '-fsigned-char'],
212
213        'sys':['-Werror', '-fsigned-char'],
214    },
215
216    'liteos_inc_path':{
217        'common':[
218            os.path.join('kernel', 'include'),
219            os.path.join('kernel', 'base', 'include'),
220            os.path.join('targets', 'hi3861v100', 'include'),
221            os.path.join('targets', 'hi3861v100', 'plat', 'riscv'),
222        ],
223        'drv':[],
224
225        'sys':[
226            os.path.join('kernel', 'extended', 'include'),
227        ],
228
229        'os':[os.path.join('kernel', 'extended', 'include'),],
230
231        'mbedtls':[],
232
233        'at':[
234            os.path.join('targets', 'hi3861v100', 'commons'),
235        ],
236    },
237
238    'common_inc_path':{
239        'common':[
240            os.path.join('#', 'include'),
241            os.path.join('#', 'platform', 'include'),
242            os.path.join('#', 'config'),
243            os.path.join('#', 'config', 'nv'),
244            os.path.join('#', '..', '..', '..', '..', 'utils','native','liteos','include'),
245        ],
246        'drv':[os.path.join('#', 'platform', 'drivers', 'dma'),
247               os.path.join('#', 'platform', 'drivers', 'flash'),
248        ],
249
250        'sys':[
251            os.path.join('#', 'platform', 'system', 'include'),
252            os.path.join('#', 'platform', 'system', 'upg'),
253            os.path.join('#', 'platform', 'drivers', 'flash'),
254        ],
255        'os':[
256        ],
257
258        'mbedtls':[
259            os.path.join('#', 'third_party', 'mbedtls', 'include'),
260            os.path.join('#', 'third_party', 'mbedtls', 'include', 'mbedtls'),
261            os.path.join('#', 'platform', 'drivers', 'cipher'),
262            os.path.join('#', 'third_party', 'lwip_sack', 'include'),
263        ],
264
265        'at':[
266            os.path.join('#', 'platform', 'drivers', 'uart'),
267            os.path.join('#', 'platform', 'system', 'cpup'),
268            os.path.join('#', 'platform', 'at'),
269            os.path.join('#', 'components', 'at', 'src'),
270            os.path.join('#', 'components', 'wifi', 'include'),
271            os.path.join('#', 'components', 'iperf2', 'include'),
272            os.path.join('#', 'config', 'diag'),
273            os.path.join('#', 'third_party', 'lwip_sack', 'include'),
274        ],
275
276        'hilink':[
277            os.path.join('#', 'components', 'hilink', 'include'),
278        ],
279    },
280} # End of proj_environment
281
282# env for makefile
283common_str = ''
284module_str = {}
285fixed_config = {'module':deepcopy(compile_module), 'lib_cfg':deepcopy(proj_lib_cfg), 'env_cfg':deepcopy(proj_environment)}
286
287def set_str_2make(type, macro, macro_val, macro_cfg, env_type = None, env_mod_type = None, depends = None):
288    type_list = ['module', 'lib_cfg', 'env_cfg']
289    global common_str
290    global module_str
291    if type not in type_list:
292        print('[ERROR] type err')
293        sys.exit(1)
294    elif type == 'module':
295        strs = 'ifeq ($(%s), %s)\n'%(macro, macro_val)
296        strs = '%s\tCOMPILE_MODULE += %s\n'%(strs, macro_cfg)
297        #strs = '%s\tLIBS += $(addprefix -l, $(%s_libs))\n'%(strs, macro_cfg)
298        strs = '%sendif\n'%strs
299        common_str = '%s%s'%(common_str, strs)
300    elif type == 'lib_cfg':
301        strs = 'ifeq ($(%s), %s)\n'%(macro, macro_val)
302        for mod in macro_cfg:
303            libs = macro_cfg[mod]
304            str_2_mod = 'ifeq ($(%s), %s)\n'%(macro, macro_val)
305            for lib in libs:
306                src = macro_cfg[mod][lib]
307                str_2_mod = '%s\t%s_srcs += %s\n'%(str_2_mod, lib, ' '.join(src))
308            str_2_mod = '%sendif\n'%(str_2_mod)
309            if mod not in module_str:
310                module_str[mod] = str_2_mod
311            else:
312                org_str = module_str[mod]
313                module_str[mod] = '%s%s'%(org_str, str_2_mod)
314            strs = '%s\t%s_libs += %s\n'%(strs, mod, lib)
315        strs = '%sendif\n'%strs
316        common_str = '%s%s'%(common_str, strs)
317    elif type == 'env_cfg':
318        if env_mod_type == 'common':
319            strs = condition_str(macro, macro_val, macro_cfg, env_type, depends)
320            common_str = '%s%s'%(common_str, strs)
321        elif env_mod_type in module_str:
322            strs = condition_str(macro, macro_val, macro_cfg, env_type, depends, True)
323            org_str = module_str[env_mod_type]
324            module_str[env_mod_type] = '%s%s'%(org_str, strs)
325        else:
326            module_str[env_mod_type] = condition_str(macro, macro_val, macro_cfg, env_type, depends, True)
327
328def set_config(type, macro, macro_val, macro_cfg, env_type = None, env_mod_type = None, depends = None):
329    type_list = ['module', 'lib_cfg', 'env_cfg']
330    if type not in type_list:
331        print('[ERROR] type err')
332        sys.exit(1)
333    elif type == 'module':
334        if scons_get_cfg_val(macro) == macro_val:
335            compile_module.append(macro_cfg)
336    elif type == 'lib_cfg':
337        if scons_get_cfg_val(macro) == macro_val:
338            for mod in macro_cfg:
339                libs = macro_cfg[mod]
340                for lib in libs:
341                    src = macro_cfg[mod][lib]
342                    if lib not in proj_lib_cfg[mod]:
343                        proj_lib_cfg[mod][lib] = src
344                    else:
345                        proj_lib_cfg[mod][lib].extend(src)
346    elif type == 'env_cfg':
347        cfg = select_added_cfg(macro, macro_val, macro_cfg, depends)
348        if cfg is not None:
349            proj_environment[env_type][env_mod_type].extend(cfg)
350
351    set_str_2make(type, macro, macro_val, macro_cfg, env_type, env_mod_type, depends)
352
353# Configrations
354
355set_config('lib_cfg', 'CONFIG_I2C_SUPPORT', 'y', {'drv': {'i2c': ['i2c']}})
356set_config('lib_cfg', 'CONFIG_SPI_SUPPORT', 'y', {'drv': {'spi': ['spi']}})
357set_config('lib_cfg', 'CONFIG_PWM_SUPPORT', 'y', {'drv': {'pwm': ['pwm']}})
358
359set_config('env_cfg', 'CONFIG_I2C_SUPPORT', 'y', ['CONFIG_I2C_SUPPORT'], 'defines', 'common')
360set_config('env_cfg', 'CONFIG_DMA_SUPPORT', 'y', ['CONFIG_DMA_SUPPORT'], 'defines', 'common')
361set_config('env_cfg', 'CONFIG_SPI_SUPPORT', 'y', ['CONFIG_SPI_SUPPORT'], 'defines', 'common')
362set_config('env_cfg', 'CONFIG_PWM_SUPPORT', 'y', ['CONFIG_PWM_SUPPORT'], 'defines', 'common')
363set_config('env_cfg', 'CONFIG_PWM_HOLD_AFTER_REBOOT', 'y', ['CONFIG_PWM_HOLD_AFTER_REBOOT'], 'defines', 'common')
364set_config('env_cfg', 'CONFIG_I2S_SUPPORT', 'y', ['CONFIG_I2S_SUPPORT'], 'defines', 'common')
365set_config('env_cfg', 'CONFIG_COMPRESSION_OTA_SUPPORT', 'y', ['CONFIG_COMPRESSION_OTA_SUPPORT'], 'defines', 'common')
366set_config('env_cfg', 'CONFIG_DUAL_PARTITION_OTA_SUPPORT', 'y', ['CONFIG_DUAL_PARTITION_OTA_SUPPORT'], 'defines', 'common')
367set_config('env_cfg', 'CONFIG_AT_SUPPORT', 'y', ['CONFIG_AT_COMMAND'], 'defines', 'common')
368set_config('env_cfg', 'LOSCFG_DAQ', 'y', ['FEATURE_DAQ'], 'defines', 'common')
369set_config('env_cfg', 'LOSCFG_BACKTRACE', 'y', ['LOS_BACKTRACE'], 'defines', 'common')
370set_config('env_cfg', 'CONFIG_UART0_SUPPORT', 'y', ['CONFIG_UART0_SUPPORT'], 'defines', 'common')
371set_config('env_cfg', 'CONFIG_UART1_SUPPORT', 'y', ['CONFIG_UART1_SUPPORT'], 'defines', 'common')
372set_config('env_cfg', 'CONFIG_UART2_SUPPORT', 'y', ['CONFIG_UART2_SUPPORT'], 'defines', 'common')
373
374set_config('env_cfg', 'CONFIG_TARGET_CHIP_HI3861', 'y', [('PRODUCT_CFG_CHIP_VER_STR', r'\"Hi3861V100\"'), 'CHIP_VER_Hi3861', ('CONFIG_CHIP_PRODUCT_NAME', r'\"Hi3861\"')], 'defines', 'common')
375set_config('env_cfg', 'CONFIG_CHIP_PKT_48K', 'y', ['CONFIG_CHIP_PKT_48K'], 'defines', 'common')
376set_config('env_cfg', 'CONFIG_CHIP_PKT_32K', 'y', ['CONFIG_CHIP_PKT_32K'], 'defines', 'common')
377
378macro = 'LOSCFG_COMPILER_HI3861_ASIC'
379macro_cfg = {
380            'y': ['HI_BOARD_ASIC'],
381            'others': ['HI_BOARD_FPGA']}
382macro_val = list(macro_cfg.keys())
383set_config('env_cfg', macro, macro_val, macro_cfg, 'defines', 'common')
384
385macro = 'LOSCFG_COMPILER_HI3861_FLASH'
386macro_cfg = {
387            'y': ['HI_ON_FLASH'],
388            'others': ['HI_ON_RAM']}
389macro_val = list(macro_cfg.keys())
390set_config('env_cfg', macro, macro_val, macro_cfg, 'defines', 'common')
391
392macro = 'CONFIG_MESH_SUPPORT'
393macro_cfg = {
394            'y': ['CONFIG_MESH_SUPPORT', 'LOS_CONFIG_MESH', 'LOS_CONFIG_MESH_GTK', 'CONFIG_MESH', 'CONFIG_SAE', 'CONFIG_ECC', 'LOS_CONFIG_HOSTAPD_MGMT', 'LOSCFG_APP_MESH', 'LWIP_DEBUG_OPEN', 'LWIP_SMALL_SIZE_MESH=1'],
395            'others': ['LWIP_SMALL_SIZE_MESH=0']}
396macro_val = list(macro_cfg.keys())
397set_config('env_cfg', macro, macro_val, macro_cfg, 'defines', 'common')
398
399set_config('env_cfg', 'CONFIG_LWIP_SMALL_SIZE', 'y', ['CONFIG_LWIP_SMALL_SIZE'], 'defines', 'common')
400set_config('env_cfg', 'CONFIG_LWIP_SMALL_SIZE_MESH', 'y', ['CONFIG_LWIP_SMALL_SIZE_MESH'], 'defines', 'common')
401set_config('env_cfg', 'CONFIG_NETIF_HOSTNAME', 'y', ['CONFIG_NETIF_HOSTNAME'], 'defines', 'common')
402set_config('env_cfg', 'CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER', 'y', ['CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER'], 'defines', 'common')
403set_config('env_cfg', 'CONFIG_DHCPS_GW', 'y', ['CONFIG_DHCPS_GW'], 'defines', 'common')
404set_config('env_cfg', 'CONFIG_UART_DMA_SUPPORT', 'y', ['CONFIG_UART_DMA_SUPPORT'], 'defines', 'common')
405set_config('env_cfg', 'CONFIG_SDIO_SUPPORT', 'y', ['CONFIG_SDIO_SUPPORT'], 'defines', 'common')
406set_config('env_cfg', 'CONFIG_SPI_DMA_SUPPORT', 'y', ['CONFIG_SPI_DMA_SUPPORT'], 'defines', 'common')
407set_config('env_cfg', 'CONFIG_TEE_HUKS_SUPPORT', 'y', ['CONFIG_TEE_HUKS_SUPPORT'], 'defines', 'common')
408set_config('env_cfg', 'CONFIG_TEE_HUKS_DEMO_SUPPORT', 'y', ['CONFIG_TEE_HUKS_DEMO_SUPPORT'], 'defines', 'common')
409set_config('env_cfg', 'CONFIG_FLASH_ENCRYPT_SUPPORT', 'y', ['CONFIG_FLASH_ENCRYPT_SUPPORT'], 'defines', 'common')
410set_config('env_cfg', 'LOSCFG_KASAN', 'y', ['LOSCFG_DEBUG_KASAN'], 'defines', 'common', depends=('LOSCFG_KASAN_EXAMPLES_DEMO', 'y'))
411set_config('env_cfg', 'LOSCFG_KASAN', 'y', ['LOSCFG_DEBUG_KASAN'], 'defines', 'common', depends=('LOSCFG_KASAN_LITEOS_NET_COAP', 'y'))
412
413set_config('env_cfg', 'LOSCFG_BACKTRACE', 'y', ['-fno-omit-frame-pointer'], 'as_flags', 'common')
414
415
416set_config('env_cfg', 'HB_LITEOS_COMPILE_TESTCASE', 'y', ['-DHI1131TEST'], 'link_scripts_flag', 'common')
417set_config('env_cfg', 'LOSCFG_KASAN', 'y', ['-DLOSCFG_DEBUG_KASAN'], 'link_scripts_flag', 'common')
418set_config('env_cfg', 'CONFIG_FLASH_ENCRYPT_SUPPORT', 'y', ['-DCONFIG_FLASH_ENCRYPT_SUPPORT'], 'link_scripts_flag', 'common')
419set_config('env_cfg', 'CONFIG_TEE_HUKS_SUPPORT', 'y', ['-DCONFIG_TEE_HUKS_SUPPORT'], 'link_scripts_flag', 'common')
420set_config('env_cfg', 'CONFIG_TARGET_SIG_RSA_V15', 'y', ['-DCONFIG_TARGET_SIG_RSA_V15'], 'link_scripts_flag', 'common')
421set_config('env_cfg', 'CONFIG_TARGET_SIG_RSA_PSS', 'y', ['-DCONFIG_TARGET_SIG_RSA_PSS'], 'link_scripts_flag', 'common')
422set_config('env_cfg', 'CONFIG_TARGET_SIG_ECC', 'y', ['-DCONFIG_TARGET_SIG_ECC'], 'link_scripts_flag', 'common')
423set_config('env_cfg', 'CONFIG_CHIP_PKT_48K', 'y', ['-DCONFIG_CHIP_PKT_48K'], 'link_scripts_flag', 'common')
424set_config('env_cfg', 'CONFIG_CHIP_PKT_32K', 'y', ['-DCONFIG_CHIP_PKT_32K'], 'link_scripts_flag', 'common')
425
426macro = 'LOSCFG_COMPILER_HI3861_ASIC'
427macro_cfg = {
428            'y': ['-DHI_BOARD_ASIC'],
429            'others': ['-DHI_BOARD_FPGA']}
430macro_val = list(macro_cfg.keys())
431set_config('env_cfg', macro, macro_val, macro_cfg, 'link_scripts_flag', 'common')
432
433macro = 'LOSCFG_COMPILER_HI3861_FLASH'
434macro_cfg = {
435            'y': ['-DHI_ON_FLASH'],
436            'others': ['-DHI_ON_RAM']}
437macro_val = list(macro_cfg.keys())
438set_config('env_cfg', macro, macro_val, macro_cfg, 'link_scripts_flag', 'common')
439
440
441set_config('env_cfg', 'LOSCFG_KERNEL_RUNSTOP', 'y', [os.path.join('kernel', 'extended', 'runstop'),], 'liteos_inc_path', 'common')
442set_config('env_cfg', 'LOSCFG_COMPAT_POSIX', 'y', [os.path.join('components', 'posix', 'include')], 'liteos_inc_path', 'common')
443set_config('env_cfg', 'LOSCFG_COMPAT_LINUX', 'y', [os.path.join('components', 'linux', 'include')], 'liteos_inc_path', 'common')
444set_config('env_cfg', 'LOSCFG_SHELL', 'y', [os.path.join('shell', 'include')], 'liteos_inc_path', 'common')
445set_config('env_cfg', 'LOSCFG_NET_TELNET', 'y', [os.path.join('net', 'telnet', 'include')], 'liteos_inc_path', 'common')
446set_config('env_cfg', 'LOSCFG_LIB_LIBC', 'y',
447            [os.path.join('components', 'lib', 'libc', 'hw', 'include'),
448            os.path.join('components', 'lib', 'libc', 'musl', 'include'),
449            os.path.join('components', 'lib', 'libc', 'musl', 'arch', 'generic'),
450            os.path.join('components', 'lib', 'libc', 'musl', 'arch', 'riscv32'),
451            os.path.join('components', 'lib', 'libc', 'nuttx', 'include'),
452            os.path.join('components', 'lib', 'libsec', 'include'),
453            os.path.join('targets', 'hi3861v100', 'config'),
454            os.path.join('targets', 'hi3861v100', 'user'),
455            os.path.join('targets', 'hi3861v100', 'plat'),
456            os.path.join('targets', 'hi3861v100', 'extend', 'include'),
457            os.path.join('arch'),
458            ], 'liteos_inc_path', 'common')
459
460set_config('env_cfg', 'LOSCFG_NET_LWIP_SACK', 'y', [os.path.join('#', 'third_party', 'lwip_sack', 'include'),], 'common_inc_path', 'common')
461
462set_config('env_cfg', 'LOSCFG_BACKTRACE', 'y', ['-fno-omit-frame-pointer'], 'opts', 'common')
463set_config('env_cfg', 'LOSCFG_KASAN', 'y', ['-fsanitize=kernel-address', '-fasan-shadow-offset=1835008', '--param asan-stack=1', '-fsanitize=bounds-strict'], 'opts', 'common', depends=('LOSCFG_KASAN_EXAMPLES_DEMO', 'y'))
464set_config('env_cfg', 'LOSCFG_KASAN', 'y', ['-fsanitize=kernel-address', '-fasan-shadow-offset=1835008', '--param asan-stack=1', '-fsanitize=bounds-strict'], 'opts', 'common', depends=('LOSCFG_KASAN_LITEOS_NET_COAP', 'y'))
465
466# -------------------------------hilink support-------------------------------
467if scons_usr_bool_option('CONFIG_HILINK') == 'y':
468    os_lib_path.append(os.path.join('components', 'hilink', 'lib'))
469set_config('module', 'CONFIG_HILINK', 'y', 'hilink')
470set_config('env_cfg', 'CONFIG_HILINK', 'y', ['CONFIG_HILINK'], 'defines', 'common')
471
472def get_fixed_config(type = 'all'):
473    if type == 'all':
474        return fixed_config
475    elif type in ['module', 'lib_cfg', 'env_cfg']:
476        return fixed_config[type]
477    else:
478        print('[ERROR] type err!')
479
480def get_make_str(module = 'common'):
481    if module == 'common':
482        return common_str
483    elif module in module_str:
484        return module_str[module]
485    else:
486        print('[INFO] %s not exists module config for makefile!'%module)
487
488def get_str_dict():
489    return (common_str, module_str)
490
491def get_proj_env():
492    return proj_environment
493
494def get_proj_env_value(env_name, module):
495    if module in proj_environment[env_name].keys():
496        return proj_environment[env_name].get(module)
497    else:
498        return None
499
500def set_proj_env_value_by_macro(env_name, module, env_value, macro='', macro_value=''):
501    pass
502
503def print_log_env(env, cwd_path):
504    if log_output_flag is False:
505        return
506    print('----------------------------enter real:', os.path.realpath(str(cwd_path)))
507    print('CPPPATH:', env['CPPPATH'])
508    print('DEFINES:', env['CPPDEFINES'])
509    print('CC:', env['CC'])
510
511def insert_module(module):
512    compile_module.append(module)
513
514def insert_module_dir(name, path):
515    module_dir[name] = path
516
517def insert_lib_cfg(name, cfg):
518    proj_lib_cfg[name] = cfg
519
520def insert_env_defs(name, defs):
521    proj_environment['defines'][name] = defs
522
523def insert_os_include(name, includes):
524    proj_environment['liteos_inc_path'][name] = includes
525
526def insert_common_include(name, includes):
527    proj_environment['common_inc_path'][name] = includes
528
529def insert_ar_flags(name, flags):
530    proj_environment['ar_flags']['common'].extend(flags)
531
532def insert_as_flags(name, flags):
533    proj_environment['as_flags']['common'].extend(flags)
534
535def insert_ld_flags(name, flags):
536    proj_environment['link_flags']['common'].extend(flags)
537
538def insert_cc_flags(name, flags):
539    proj_environment['opts'][name] = flags
540
541def set_factory_mode():
542    proj_environment['defines']['common'].append('CONFIG_FACTORY_TEST_MODE')
543