Skip to content

Commit df06190

Browse files
committed
add pure ai generated pptt parser and aml generator
1 parent 85b549b commit df06190

File tree

30 files changed

+7584
-1
lines changed

30 files changed

+7584
-1
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build and upload AML artifacts
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
name: Configure, build and prepare artifacts
11+
runs-on: ubuntu-latest
12+
outputs:
13+
platforms: ${{ steps.prepare.outputs.platforms }}
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Install build dependencies
19+
run: |
20+
sudo apt-get update
21+
sudo apt-get install -y build-essential cmake ninja-build zip python3 python3-pip
22+
23+
- name: Configure CMake
24+
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
25+
26+
- name: Build
27+
run: cmake --build build -- -j$(nproc)
28+
29+
- name: Collect AMLs and create per-platform zips
30+
id: prepare
31+
run: |
32+
set -euo pipefail
33+
mkdir -p artifacts
34+
platforms=()
35+
36+
for dir in build/*/builtin; do
37+
if [ -d "$dir" ]; then
38+
shopt -s nullglob
39+
aml_files=("$dir"/*.aml)
40+
if [ ${#aml_files[@]} -gt 0 ]; then
41+
platform=$(basename "$(dirname "$dir")")
42+
echo "Packaging $platform..."
43+
zip -j "artifacts/${platform}.zip" "$dir"/*.aml || true
44+
platforms+=("$platform")
45+
fi
46+
shopt -u nullglob
47+
fi
48+
done
49+
50+
# Convert platforms array to JSON
51+
PLATFORMS_JSON=$(python3 - <<'PY'
52+
import json,sys
53+
print(json.dumps(sys.argv[1:]))
54+
PY
55+
${platforms[@]:-})
56+
57+
echo "Found platforms: $PLATFORMS_JSON"
58+
echo "platforms=$PLATFORMS_JSON" >> $GITHUB_OUTPUT
59+
60+
upload:
61+
name: Upload platform artifacts
62+
needs: build
63+
runs-on: ubuntu-latest
64+
strategy:
65+
fail-fast: false
66+
matrix:
67+
platform: ${{ fromJson(needs.build.outputs.platforms) }}
68+
steps:
69+
- name: Ensure artifacts exist
70+
run: |
71+
ls -al artifacts || true
72+
73+
- name: Upload artifact for platform
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: ${{ matrix.platform }}
77+
path: artifacts/${{ matrix.platform }}.zip

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.aml
2+
*.o
3+
*.dts
4+
*.dtb
5+
*.pyc
6+
7+
build/
8+
.vscode/
9+
__pycache__/

CMakeLists.txt

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(acpi-table-generator C)
3+
4+
set(CMAKE_C_STANDARD 11)
5+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -O2")
6+
7+
# 查找 iasl 工具
8+
find_program(IASL_EXECUTABLE iasl)
9+
if(IASL_EXECUTABLE)
10+
message(STATUS "找到 iasl: ${IASL_EXECUTABLE}")
11+
set(IASL_AVAILABLE TRUE)
12+
else()
13+
message(WARNING "未找到 iasl 工具,将跳过 DSL 反编译步骤")
14+
set(IASL_AVAILABLE FALSE)
15+
endif()
16+
17+
# 扫描 include 目录下的所有子目录
18+
file(GLOB PLATFORM_DIRS "${CMAKE_SOURCE_DIR}/include/*")
19+
20+
# 为每个平台创建独立的构建目标
21+
foreach(PLATFORM_DIR ${PLATFORM_DIRS})
22+
if(IS_DIRECTORY ${PLATFORM_DIR})
23+
# 提取平台名称(如 sm8550, sm8850)
24+
get_filename_component(PLATFORM_NAME ${PLATFORM_DIR} NAME)
25+
26+
# 跳过 common 目录(它包含通用定义,不是平台)
27+
if(PLATFORM_NAME STREQUAL "common")
28+
continue()
29+
endif()
30+
31+
message(STATUS "配置平台: ${PLATFORM_NAME}")
32+
33+
# 创建该平台的可执行文件目标
34+
set(TARGET_NAME pptt_generator_${PLATFORM_NAME})
35+
add_executable(${TARGET_NAME} src/pptt.c)
36+
37+
# 设置该目标的包含目录
38+
target_include_directories(${TARGET_NAME} PRIVATE
39+
${CMAKE_SOURCE_DIR}/include
40+
${PLATFORM_DIR}
41+
)
42+
43+
# 设置平台输出目录(在构建目录下)
44+
set(PLATFORM_OUTPUT_DIR "${CMAKE_BINARY_DIR}/${PLATFORM_NAME}")
45+
set(PLATFORM_BUILTIN_DIR "${PLATFORM_OUTPUT_DIR}/builtin")
46+
set(PLATFORM_SRC_DIR "${PLATFORM_OUTPUT_DIR}/src")
47+
48+
# 添加自定义命令:运行生成器并输出到指定目录
49+
add_custom_command(
50+
TARGET ${TARGET_NAME} POST_BUILD
51+
# 创建目录结构
52+
COMMAND ${CMAKE_COMMAND} -E make_directory ${PLATFORM_BUILTIN_DIR}
53+
COMMAND ${CMAKE_COMMAND} -E make_directory ${PLATFORM_SRC_DIR}
54+
# 运行生成器
55+
COMMAND ${TARGET_NAME}
56+
# 复制 AML 到 builtin 目录
57+
COMMAND ${CMAKE_COMMAND} -E copy PPTT.aml ${PLATFORM_BUILTIN_DIR}/PPTT.aml
58+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
59+
COMMENT "生成 ${PLATFORM_NAME} 的 PPTT.aml 到 ${PLATFORM_BUILTIN_DIR}"
60+
)
61+
62+
# 如果 iasl 可用,添加反编译步骤
63+
if(IASL_AVAILABLE)
64+
add_custom_command(
65+
TARGET ${TARGET_NAME} POST_BUILD
66+
COMMAND ${IASL_EXECUTABLE} -d ${PLATFORM_BUILTIN_DIR}/PPTT.aml > /dev/null 2>&1 || true
67+
COMMAND ${CMAKE_COMMAND} -E rename ${PLATFORM_BUILTIN_DIR}/PPTT.dsl ${PLATFORM_SRC_DIR}/PPTT.dsl
68+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
69+
COMMENT "反编译 ${PLATFORM_NAME} 的 PPTT.aml 到 DSL"
70+
)
71+
endif()
72+
73+
# 添加安装规则(可选)
74+
install(FILES ${PLATFORM_BUILTIN_DIR}/PPTT.aml
75+
DESTINATION ${PLATFORM_NAME}/builtin)
76+
if(IASL_AVAILABLE AND EXISTS ${PLATFORM_SRC_DIR}/PPTT.dsl)
77+
install(FILES ${PLATFORM_SRC_DIR}/PPTT.dsl
78+
DESTINATION ${PLATFORM_NAME}/src)
79+
endif()
80+
endif()
81+
endforeach()
82+
83+
# 创建一个 all 目标来构建所有平台
84+
add_custom_target(build_all_platforms ALL)
85+
foreach(PLATFORM_DIR ${PLATFORM_DIRS})
86+
if(IS_DIRECTORY ${PLATFORM_DIR})
87+
get_filename_component(PLATFORM_NAME ${PLATFORM_DIR} NAME)
88+
# 跳过 common 目录
89+
if(NOT PLATFORM_NAME STREQUAL "common")
90+
add_dependencies(build_all_platforms pptt_generator_${PLATFORM_NAME})
91+
endif()
92+
endif()
93+
endforeach()
94+
95+
# 添加清理目标
96+
add_custom_target(clean_output
97+
COMMAND ${CMAKE_COMMAND} -E echo "清理所有输出文件"
98+
COMMENT "清理所有输出文件"
99+
)
100+
101+
# 打印配置信息
102+
message(STATUS "源代码目录: ${CMAKE_SOURCE_DIR}")
103+
message(STATUS "构建目录: ${CMAKE_BINARY_DIR}")
104+
message(STATUS "AML 文件输出到: build/<平台名>/builtin/PPTT.aml")
105+
if(IASL_AVAILABLE)
106+
message(STATUS "DSL 文件输出到: build/<平台名>/src/PPTT.dsl")
107+
endif()

0 commit comments

Comments
 (0)