初始化:添加本地配置文件

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
This commit is contained in:
qzh
2025-08-31 15:42:43 +08:00
commit b1d0ef0d0d
12 changed files with 554 additions and 0 deletions

47
SConstruct Normal file
View File

@@ -0,0 +1,47 @@
import os
from SCons.Script import *
# 确保 build 目录存在
BUILD_DIR = 'build'
if not os.path.exists(BUILD_DIR):
os.makedirs(BUILD_DIR)
# 导入配置修改为导入algo.py
from algo import *
# 初始化构建环境
env = Environment(
tools=['default'],
CC=CC,
CXX=CXX,
AS=AS,
AR=AR,
LINK=LINK,
CCFLAGS=CFLAGS,
CXXFLAGS=CFLAGS,
ASFLAGS=AFLAGS,
LINKFLAGS=LFLAGS,
CPPPATH=['inc'], # 仅使用项目内的头文件目录
)
# 递归构建源码(SConscript 负责收集编译文件)
src_objs = env.SConscript('SConscript', exports='env')
# 链接生成 elf 文件(输出到 build 目录)
elf_target = os.path.join(BUILD_DIR, TARGET_NAME)
elf_file = env.Program(elf_target, src_objs)
# 后处理:生成 bin、asm 等文件
post_commands = env.Command(
os.path.join(BUILD_DIR, 'post_actions'), # 虚拟目标,确保命令执行
elf_file,
POST_ACTION
)
# 关联默认构建目标(执行 scons 时默认编译+后处理)
Default(elf_file)
Default(post_commands)
# 清理规则(删除 build 目录及内容)
Clean(elf_file, BUILD_DIR)