Skip to content

Commit 26a9cf0

Browse files
authored
[Android] Escape backslashes and quotation marks (#2546)
This commit escapes the backslashes and quotation marks in Android package build.
1 parent 78b6e1f commit 26a9cf0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

android/mlc4j/prepare_libs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""The build script for mlc4j (MLC LLM and tvm4j)"""
22

33
import argparse
4+
import json
45
import os
56
import subprocess
67
import sys
@@ -93,7 +94,9 @@ def main(mlc_llm_source_dir: Path):
9394
if "TVM_SOURCE_DIR" in os.environ:
9495
logger.info('Set TVM_SOURCE_DIR to "%s"', os.environ["TVM_SOURCE_DIR"])
9596
with open("config.cmake", "w", encoding="utf-8") as file:
96-
print("set(TVM_SOURCE_DIR %s)" % os.environ["TVM_SOURCE_DIR"], file=file)
97+
# We use "json.dumps" to escape backslashes and quotation marks
98+
tvm_source_dir_str_with_escape = json.dumps(os.environ["TVM_SOURCE_DIR"])
99+
print("set(TVM_SOURCE_DIR %s)" % tvm_source_dir_str_with_escape, file=file)
97100

98101
# - Run cmake, build and install
99102
run_cmake(mlc_llm_source_dir / "android" / "mlc4j")

0 commit comments

Comments
 (0)