#!/usr/bin/env python3
# coding=utf-8
#
# Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
# 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
#
#     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 os
from scripts import common_env
Import('env')
Import('env_cfg')
Import('module')

module_path = env_cfg.get_module_dir(module)
obj_path = env_cfg.obj_path
module_libs = env_cfg.get_module_libs(module)
libs = []

env = env.Clone()
env_cfg.append_environs(env, module)
common_env.print_log_env(env, env_cfg.get_module_dir(module))

for lib in module_libs:
    print('lib_name:',lib)
    src_path = module_libs[lib]
    objs = []
    for src in src_path:
        objs += env.SConscript(os.path.join(src, 'SConscript'), {'env':env}, variant_dir = os.path.join('#', obj_path, module_path, src), duplicate = 0)
    libs += env.Library(lib,objs)
Return('libs')
