tools+csdk: 恢复脱敏后脚本的可运行性——resume_android.ps1 的 adb 改为探测已知安装位置、resume_rev.ps1 对临时分析脚本加存在性守卫、legacy demo 两个 C 程序的日志/快照路径改用 getenv("TEMP") 运行时解析(原硬编码本机路径本就不可移植)
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <libusb.h>
|
#include <libusb.h>
|
||||||
|
|
||||||
@@ -340,7 +341,16 @@ static int init_camera(void) {
|
|||||||
int WINAPI WinMain(HINSTANCE inst, HINSTANCE hprev, LPSTR cmd, int show) {
|
int WINAPI WinMain(HINSTANCE inst, HINSTANCE hprev, LPSTR cmd, int show) {
|
||||||
(void)hprev; (void)cmd; (void)show;
|
(void)hprev; (void)cmd; (void)show;
|
||||||
|
|
||||||
g_log = fopen("%TEMP%/opencode/demo_log.txt", "w");
|
/* Log/snapshot under %TEMP%, resolved at runtime (the original archived
|
||||||
|
version hard-coded a per-machine absolute path that breaks elsewhere). */
|
||||||
|
static char logpath[MAX_PATH], bmppath[MAX_PATH];
|
||||||
|
const char *tmp = getenv("TEMP");
|
||||||
|
if (!tmp || !*tmp) tmp = ".";
|
||||||
|
snprintf(logpath, sizeof(logpath) - 1, "%s\\mag160c_demo_log.txt", tmp);
|
||||||
|
logpath[sizeof(logpath) - 1] = 0;
|
||||||
|
snprintf(bmppath, sizeof(bmppath) - 1, "%s\\mag160c_render_test.bmp", tmp);
|
||||||
|
bmppath[sizeof(bmppath) - 1] = 0;
|
||||||
|
g_log = fopen(logpath, "w");
|
||||||
if (g_log) { fprintf(g_log, "demo start\n"); fflush(g_log); }
|
if (g_log) { fprintf(g_log, "demo start\n"); fflush(g_log); }
|
||||||
|
|
||||||
libusb_init(&g_usb);
|
libusb_init(&g_usb);
|
||||||
@@ -468,7 +478,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE hprev, LPSTR cmd, int show) {
|
|||||||
}
|
}
|
||||||
render(g_frame);
|
render(g_frame);
|
||||||
if ((g_frame_count % 200) == 0) {
|
if ((g_frame_count % 200) == 0) {
|
||||||
FILE *tf = fopen("%TEMP%/opencode/render_test.bmp", "wb");
|
FILE *tf = fopen(bmppath, "wb");
|
||||||
if (tf) { fwrite(g_bmp, 1, sizeof(g_bmp), tf); fclose(tf); }
|
if (tf) { fwrite(g_bmp, 1, sizeof(g_bmp), tf); fclose(tf); }
|
||||||
}
|
}
|
||||||
DWORD now = GetTickCount();
|
DWORD now = GetTickCount();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* ---- libusb-win32 (libusb0) API ---------------------------------------- */
|
/* ---- libusb-win32 (libusb0) API ---------------------------------------- */
|
||||||
typedef struct usb_bus {
|
typedef struct usb_bus {
|
||||||
@@ -319,7 +320,12 @@ static int init_camera(void) {
|
|||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE inst, HINSTANCE hprev, LPSTR cmd, int show) {
|
int WINAPI WinMain(HINSTANCE inst, HINSTANCE hprev, LPSTR cmd, int show) {
|
||||||
(void)hprev; (void)cmd; (void)show;
|
(void)hprev; (void)cmd; (void)show;
|
||||||
g_log = fopen("%TEMP%/opencode/demo_usb0_log.txt", "w");
|
static char logpath[MAX_PATH];
|
||||||
|
const char *tmp = getenv("TEMP");
|
||||||
|
if (!tmp || !*tmp) tmp = ".";
|
||||||
|
snprintf(logpath, sizeof(logpath) - 1, "%s\\mag160c_demo_usb0_log.txt", tmp);
|
||||||
|
logpath[sizeof(logpath) - 1] = 0;
|
||||||
|
g_log = fopen(logpath, "w");
|
||||||
if (g_log) { fprintf(g_log, "demo start\n"); fflush(g_log); }
|
if (g_log) { fprintf(g_log, "demo start\n"); fflush(g_log); }
|
||||||
|
|
||||||
HMODULE l0 = LoadLibraryA("libusb0.dll");
|
HMODULE l0 = LoadLibraryA("libusb0.dll");
|
||||||
|
|||||||
@@ -9,7 +9,15 @@ Write-Host "Gradle: 工程wrapper android\gradlew.bat (JDK 21: C:\Tools\jdk-21)"
|
|||||||
Write-Host "SDK: $(Test-Path "$env:LOCALAPPDATA\Android\Sdk\platform-tools\adb.exe")"
|
Write-Host "SDK: $(Test-Path "$env:LOCALAPPDATA\Android\Sdk\platform-tools\adb.exe")"
|
||||||
|
|
||||||
Write-Host "=== 2. 设备 ==="
|
Write-Host "=== 2. 设备 ==="
|
||||||
adb devices
|
# adb: PATH first, then the known SDK install locations
|
||||||
|
$adb = Get-Command adb -ErrorAction SilentlyContinue
|
||||||
|
if (-not $adb) {
|
||||||
|
foreach ($cand in @("C:\Tools\android-sdk\platform-tools\adb.exe",
|
||||||
|
"$env:LOCALAPPDATA\Android\Sdk\platform-tools\adb.exe")) {
|
||||||
|
if (Test-Path $cand) { $adb = $cand; break }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($adb) { & $adb devices } else { Write-Host "!!! adb 未找到(确认 Android SDK platform-tools 已安装)" }
|
||||||
|
|
||||||
Write-Host "=== 3. 构建 ==="
|
Write-Host "=== 3. 构建 ==="
|
||||||
Push-Location $andr
|
Push-Location $andr
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ if (-not (Test-Path "$pairsDir\pair_000.raw")) {
|
|||||||
} else { Write-Host "官方数据已存在, 跳过" }
|
} else { Write-Host "官方数据已存在, 跳过" }
|
||||||
|
|
||||||
Write-Host "=== 8. 对比 ==="
|
Write-Host "=== 8. 对比 ==="
|
||||||
python "%TEMP%\compare_live.py"
|
# compare_live.py was an ad-hoc analysis helper of the original session and is
|
||||||
|
# not shipped with the repo (临时分析脚本不入库); the step is skipped gracefully.
|
||||||
|
if (Test-Path "$env:TEMP\compare_live.py") {
|
||||||
|
python "$env:TEMP\compare_live.py"
|
||||||
|
} else {
|
||||||
|
Write-Host "跳过: %TEMP%\compare_live.py 不存在(一次性分析脚本,重新生成后再跑)"
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host "=== 完成。下一步见 analysis\session_state.md ==="
|
Write-Host "=== 完成。下一步见 analysis\session_state.md ==="
|
||||||
|
|||||||
Reference in New Issue
Block a user