cd E:\Work\_wasm\smart-wasm-project


 emcc src/math_utils.cpp src/smart_json_wrapper.cpp src/main.cpp `
>> -I./src `
>> -g4 `
>> -O0 `
>> --source-map-base http://localhost:8000/ `
>> -s WASM=1 `
>> -s EXPORTED_FUNCTIONS='["_smart_process_json","_smart_get_function_list","_smart_get_function_info","_smart_test_match","_smart_get_version","_smart_free_string","_malloc","_free","_main"]' `
>> -s EXPORTED_RUNTIME_METHODS='["UTF8ToString","stringToUTF8","ccall","cwrap","HEAPU8", "HEAPU16", "HEAPU32", "HEAP8", "HEAP16", "HEAP32", "HEAPF32", "HEAPF64"]' `
>> -s MODULARIZE=1 `
>> -s EXPORT_NAME='createSmartMathModule' `
>> -s ALLOW_MEMORY_GROWTH=1 `
>> -s ASSERTIONS=2 `
>> -s STACK_OVERFLOW_CHECK=2 `
>> -o public/wasm/smart_math.js







# 检查最新编译时间
$jsFile = Get-Item "public/wasm/smart_math.js" -ErrorAction SilentlyContinue
if ($jsFile) {
    Write-Host "smart_math.js 最后修改时间: $($jsFile.LastWriteTime)" -ForegroundColor Yellow
}

# 如果文件太旧或有问题，重新编译
Write-Host "重新编译..." -ForegroundColor Cyan
emcc src/math_utils.cpp src/smart_json_wrapper.cpp src/main.cpp `
    -I./src `
    -Os `
    -s WASM=1 `
    -s EXPORTED_FUNCTIONS='["_smart_process_json","_smart_get_function_list","_smart_get_function_info","_smart_test_match","_smart_get_version","_smart_free_string","_malloc","_free","_main"]' `
    -s EXPORTED_RUNTIME_METHODS='["UTF8ToString"]' `
    -s MODULARIZE=1 `
    -s EXPORT_NAME='SmartMathModule' `
    -s ALLOW_MEMORY_GROWTH=1 `
    -o public/wasm/smart_simple.js


emcc src/math_utils.cpp src/smart_json_wrapper.cpp src/main.cpp `
    -I./src `
    -Os `
    -s WASM=1 `
    -s EXPORTED_FUNCTIONS='["_smart_process_json","_smart_get_function_list","_smart_get_function_info","_smart_test_match","_smart_get_version","_smart_free_string","_malloc","_free","_main"]' `
    -s EXPORTED_RUNTIME_METHODS='["UTF8ToString","stringToUTF8","ccall","cwrap","HEAPU8", "HEAPU16", "HEAPU32", "HEAP8", "HEAP16", "HEAP32", "HEAPF32", "HEAPF64"]' `
    -s MODULARIZE=1 `
    -s EXPORT_NAME='createSmartMathModule' `
    -s ALLOW_MEMORY_GROWTH=1 `
    -o public/wasm/smart_math.js




# 开发调试版本 - 包含完整的调试信息
emcc src/math_utils.cpp src/smart_json_wrapper.cpp src/main.cpp `
    -I./src `
    -gsource-map `
    -O0 `
    -s WASM=1 `
    -s WASM_BIGINT=1 `
    -s USE_PTHREADS=0 `
    -s FILESYSTEM=0 `
    -s EXPORTED_FUNCTIONS='["_smart_process_json","_smart_get_function_list","_smart_get_function_info","_smart_test_match","_smart_get_version","_smart_free_string","_malloc","_free","_main"]' `
    -s EXPORTED_RUNTIME_METHODS='["UTF8ToString","stringToUTF8","ccall","cwrap","HEAPU8","HEAPU16","HEAPU32","HEAP8","HEAP16","HEAP32","HEAPF32","HEAPF64","writeArrayToMemory","writeAsciiToMemory"]' `
    -s MODULARIZE=1 `
    -s EXPORT_NAME='createSmartMathModule' `
    -s ALLOW_MEMORY_GROWTH=1 `
    -s INITIAL_MEMORY=16777216 `
    -s MAXIMUM_MEMORY=268435456 `
    -s ASSERTIONS=2 `
    -s STACK_OVERFLOW_CHECK=2 `
    -s SAFE_HEAP=1 `
    -s DEMANGLE_SUPPORT=1 `
    -s ERROR_ON_UNDEFINED_SYMBOLS=0 `
    -s STANDALONE_WASM=0 `
    -s ENVIRONMENT='web,worker' `
    -o public/wasm/smart_math_debug.js




    PS E:\Work\_wasm\smart-wasm-project> 
    
    emcc src/math_utils.cpp src/smart_json_wrapper.cpp src/main.cpp -I./src -g4 -O0 --source-map-base http://localhost:8000/ -s WASM=1 -s EXPORTED_FUNCTIONS='["_smart_process_json","_smart_get_function_list","_smart_get_function_info","_smart_test_match","_smart_get_version","_smart_free_string","_malloc","_free","_main"]' -s EXPORTED_RUNTIME_METHODS='["UTF8ToString","stringToUTF8","ccall","cwrap","HEAPU8", "HEAPU16", "HEAPU32", "HEAP8", "HEAP16", "HEAP32", "HEAPF32", "HEAPF64"]' -s MODULARIZE=1 -s EXPORT_NAME='createSmartMathModule' -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=2 -s STACK_OVERFLOW_CHECK=2 -o public/wasm/smart_math.js



emcc: warning: please replace -g4 with -gsource-map [-Wdeprecated]
PS E:\Work\_wasm\smart-wasm-project> python -m http.server 8080