Files
se-algo/SConscript
qzh b1d0ef0d0d 初始化:添加本地配置文件
new file:   .gitignore
	new file:   .vscode/settings.json
	new file:   LICENSE
	new file:   README.md
	new file:   SConscript
	new file:   SConstruct
	new file:   algo.py
	new file:   inc/type.h
	new file:   inc/zuc256.h
	new file:   run.sh
	new file:   src/main.c
	new file:   src/zuc256.c
2025-08-31 15:44:27 +08:00

41 lines
929 B
Python

import os
from SCons.Script import *
# 导入环境
Import('env')
# 项目根目录
CWD = os.getcwd()
# 收集源码(.c 和 .S 文件)
sources = Glob(os.path.join(CWD, 'src/*.c')) + Glob(os.path.join(CWD, 'src/*.S'))
# 编译选项
cpppath = [
CWD,
os.path.join(CWD, 'inc'), # 仅使用项目内的头文件目录
]
# 确保 build 目录存在
BUILD_DIR = 'build'
if not os.path.exists(BUILD_DIR):
os.makedirs(BUILD_DIR)
# 逐个编译源码生成目标文件(输出到 build 目录)
objs = []
for src in sources:
src_path = str(src) # 转换为字符串路径
obj_name = os.path.basename(src_path).replace('.c', '.o').replace('.S', '.o')
obj_path = os.path.join(CWD, BUILD_DIR, obj_name)
obj = env.Object(
target=obj_path,
source=src_path,
CPPPATH=cpppath,
)
objs.append(obj)
# 返回目标文件列表,给 SConstruct 链接用
Return('objs')