diff --git a/ui2abc/BUILD.gn b/ui2abc/BUILD.gn index 3e071255be7a8e0f3545e0b5b50cd45e92d7bb9d..90f7f90f517c4a9cd80650201c26466a8354fd28 100644 --- a/ui2abc/BUILD.gn +++ b/ui2abc/BUILD.gn @@ -12,6 +12,7 @@ # limitations under the License. import("//build/ohos.gni") +import("//build/config/components/ets_frontend/ets2abc_config.gni") import("//foundation/arkui/ace_engine/frameworks/bridge/arkts_frontend/koala_mirror/gn/npm_util.gni") koala_root = ".." @@ -21,7 +22,6 @@ host_arch = "${host_os}-${host_cpu}" libarkts_root = "./libarkts" build_root = "//build" -toolchain_linux = "$build_root/toolchain/linux:clang_x64" npm_cmd("fast_arktsc_build") { outputs = [ @@ -64,15 +64,17 @@ action("ui2abc_panda_sdk") { "$target_out_dir/panda-sdk" ] - external_deps = [ - "ets_frontend:libes2panda_public(${toolchain_linux})", - ] + external_deps = [ets2abc_build_deps] + external_deps += [static_linker_build_deps] + external_deps += [ "ets_frontend:libes2panda_public(${host_toolchain})" ] args = [ "--config", rebase_path("gn/sdk_config.json"), "--src", rebase_path("//"), "--dist", rebase_path("./build/sdk"), - "--out-root", rebase_path(root_out_dir) + "--out-root", rebase_path(root_out_dir), + "--current-os", current_os, + "--current-cpu", current_cpu ] } diff --git a/ui2abc/gn/command/gen_sdk.py b/ui2abc/gn/command/gen_sdk.py index fca31821fa8492182587e6a6872b9d4d7e5f4758..e3c58ba1d121a15c6c1afc05a6f0cb54fd677473 100755 --- a/ui2abc/gn/command/gen_sdk.py +++ b/ui2abc/gn/command/gen_sdk.py @@ -23,16 +23,28 @@ def load_config(config_file): config = json.load(f) return config -def replace_out_root(value, out_root): +def get_compiler_type(os, cpu): + if (os == 'mingw' and cpu == 'x86_64'): + return 'mingw_x86_64' + return 'clang_x64' + +def replace_out_root(value, out_root, compiler_type): """Replace $out_root in the string with the actual value.""" - return value.replace("$out_root", out_root) + return value.replace("$out_root", out_root).replace("$compiler_type", compiler_type) + +def validate_out_root(out_root, compiler_type): + head_out_root, tail_out_root = os.path.split(out_root) + if (tail_out_root == compiler_type): + return head_out_root + return out_root + -def copy_files(config, src_base, dist_base, out_root): +def copy_files(config, src_base, dist_base, out_root, compiler_type): """Copy files or directories based on the configuration.""" for mapping in config['file_mappings']: # Replace $out_root - source = replace_out_root(mapping['source'], out_root) - destination = replace_out_root(mapping['destination'], out_root) + source = replace_out_root(mapping['source'], out_root, compiler_type) + destination = replace_out_root(mapping['destination'], out_root, compiler_type) # Build full paths source = os.path.join(src_base, source) @@ -42,7 +54,7 @@ def copy_files(config, src_base, dist_base, out_root): if not os.path.exists(source): print(f"Source path does not exist (will try to fallback): {source}") if mapping['source_fallback']: - source_fallback = replace_out_root(mapping['source_fallback'], out_root) + source_fallback = replace_out_root(mapping['source_fallback'], out_root, compiler_type) source = os.path.join(src_base, source_fallback) if not os.path.exists(source): print(f"Fallback source path does not exist: {source}") @@ -76,13 +88,19 @@ def main(): parser.add_argument("--src", required=True, help="Base source path.") parser.add_argument("--dist", required=True, help="Base destination path.") parser.add_argument("--out-root", required=True, help="Relative out directory to src, used to replace $out_root.") + parser.add_argument('--current-os', required=True, help='current OS') + parser.add_argument('--current-cpu', required=True, help='current CPU') args = parser.parse_args() # Load the configuration config = load_config(args.config) + compiler_type = get_compiler_type(args.current_os, args.current_cpu) + + out_root = validate_out_root(args.out_root, compiler_type) + # Copy files or directories - copy_files(config, args.src, args.dist, args.out_root) + copy_files(config, args.src, args.dist, out_root, compiler_type) # Create package.json to pass SDK validation content = """{ diff --git a/ui2abc/gn/sdk_config.json b/ui2abc/gn/sdk_config.json index 3a2c8af7cf80725f56dc7a61b7fe5171d4f3fbd8..c61196177ee1c53e28acd5ab873198a597805bd3 100644 --- a/ui2abc/gn/sdk_config.json +++ b/ui2abc/gn/sdk_config.json @@ -1,22 +1,22 @@ { "file_mappings": [ { - "source": "$out_root/clang_x64/arkcompiler/ets_frontend/es2panda", + "source": "$out_root/$compiler_type/arkcompiler/ets_frontend/es2panda", "source_fallback": "$out_root/arkcompiler/ets_frontend/es2panda", "destination": "linux_host_tools/bin/es2panda" }, { - "source": "$out_root/clang_x64/arkcompiler/ets_frontend/libes2panda_public.so", + "source": "$out_root/$compiler_type/arkcompiler/ets_frontend/libes2panda_public.so", "source_fallback": "$out_root/arkcompiler/ets_frontend/libes2panda_public.so", "destination": "linux_host_tools/lib/libes2panda-public.so" }, { - "source": "$out_root/clang_x64/arkcompiler/runtime_core/ark_link", + "source": "$out_root/$compiler_type/arkcompiler/runtime_core/ark_link", "source_fallback": "$out_root/arkcompiler/runtime_core/ark_link", "destination": "linux_host_tools/bin/ark_link" }, { - "source": "$out_root/clang_x64/arkcompiler/runtime_core/libarktsbase.so", + "source": "$out_root/$compiler_type/arkcompiler/runtime_core/libarktsbase.so", "source_fallback": "$out_root/arkcompiler/runtime_core/libarktsbase.so", "destination": "linux_host_tools/lib/libarktsbase.so" }, @@ -33,17 +33,17 @@ "destination": "linux_host_tools/include/tools/es2panda/public/es2panda_lib.h" }, { - "source": "$out_root/clang_x64/gen/arkcompiler/ets_frontend/ets2panda/generated/es2panda_lib", + "source": "$out_root/$compiler_type/gen/arkcompiler/ets_frontend/ets2panda/generated/es2panda_lib", "source_fallback": "$out_root/gen/arkcompiler/ets_frontend/ets2panda/generated/es2panda_lib", "destination": "linux_host_tools/include/tools/es2panda/generated/es2panda_lib" }, { - "source": "$out_root/clang_x64/gen/arkcompiler/ets_frontend/ets2panda/generated/es2panda_lib", + "source": "$out_root/$compiler_type/gen/arkcompiler/ets_frontend/ets2panda/generated/es2panda_lib", "source_fallback": "$out_root/gen/arkcompiler/ets_frontend/ets2panda/generated/es2panda_lib", "destination": "ohos_arm64/include/tools/es2panda/generated/es2panda_lib" }, { - "source": "$out_root/clang_x64/gen/arkcompiler/runtime_core/static_core/plugins/ets/etsstdlib.abc", + "source": "$out_root/$compiler_type/gen/arkcompiler/runtime_core/static_core/plugins/ets/etsstdlib.abc", "source_fallback": "$out_root/gen/arkcompiler/runtime_core/static_core/plugins/ets/etsstdlib.abc", "destination": "ets/etsstdlib.abc" } diff --git a/ui2abc/libarkts/BUILD.gn b/ui2abc/libarkts/BUILD.gn index 573d147ce54ea3c46a21627d08b77a90ca203980..e28858f69fef4c18f4f96b354522a8fb10f4b1db 100644 --- a/ui2abc/libarkts/BUILD.gn +++ b/ui2abc/libarkts/BUILD.gn @@ -226,8 +226,7 @@ npm_cmd("es2panda.js") { "$target_out_dir/es2panda.js" ] deps = [ - ":es2panda_copy_lib", - "$ui2abc_root:ui2abc_panda_sdk" + ":es2panda_copy_lib" ] project_path = rebase_path(".") run_tasks = [ "compile:koala:interop", "compile:js" ]