From d55f17ed396a3ad6de1036499d1277b6c2160ac0 Mon Sep 17 00:00:00 2001 From: rwx1229113 Date: Thu, 31 Jul 2025 14:04:56 +0300 Subject: [PATCH] Fix for Windows file copying: dll and exe extentions, destination directory. source_fallback entries removed as they not needed since previous commit --- ui2abc/gn/command/gen_sdk.py | 30 +++++++++++++++----------- ui2abc/gn/sdk_config.json | 42 +++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/ui2abc/gn/command/gen_sdk.py b/ui2abc/gn/command/gen_sdk.py index e3c58ba1d..f9bb97ea2 100755 --- a/ui2abc/gn/command/gen_sdk.py +++ b/ui2abc/gn/command/gen_sdk.py @@ -39,28 +39,25 @@ def validate_out_root(out_root, compiler_type): return out_root -def copy_files(config, src_base, dist_base, out_root, compiler_type): +def copy_files(config, src_base, dist_base, out_root, compiler_type, substitutions): """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, compiler_type) destination = replace_out_root(mapping['destination'], out_root, compiler_type) + if substitutions: + for key, val in substitutions.items(): + source = source.replace(key, val) + destination = destination.replace(key, val) + # Build full paths source = os.path.join(src_base, source) destination = os.path.join(dist_base, destination) - # Check if the source path exists, otherwise try fallback 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, 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}") - continue - else: - continue + print(f"Source path does not exist: {source}") + continue # Create the destination directory if it doesn't exist dest_dir = os.path.dirname(destination) if os.path.isfile(source) else destination @@ -92,6 +89,8 @@ def main(): parser.add_argument('--current-cpu', required=True, help='current CPU') args = parser.parse_args() + print(f"gen_sdk: current-cpu={args.current_cpu} current-os={args.current_os} out-root={args.out_root}") + # Load the configuration config = load_config(args.config) @@ -99,8 +98,15 @@ def main(): out_root = validate_out_root(args.out_root, compiler_type) + substitutions = config.get('substitutions') + + if substitutions: + substitutions = substitutions.get(args.current_os) + if not substitutions: + raise Exception(f'Substitutions not found for current_os "{args.current_os}".') + # Copy files or directories - copy_files(config, args.src, args.dist, out_root, compiler_type) + copy_files(config, args.src, args.dist, out_root, compiler_type, substitutions) # Create package.json to pass SDK validation content = """{ diff --git a/ui2abc/gn/sdk_config.json b/ui2abc/gn/sdk_config.json index c61196177..8630b8b93 100644 --- a/ui2abc/gn/sdk_config.json +++ b/ui2abc/gn/sdk_config.json @@ -1,24 +1,35 @@ { + + "substitutions": { + "linux": + { + "$host_tools": "linux_host_tools", + "$.exe": "", + "$.lib": ".so" + }, + "mingw": + { + "$host_tools": "windows_host_tools", + "$.exe": ".exe", + "$.lib": ".dll" + } + }, "file_mappings": [ { - "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/$compiler_type/arkcompiler/ets_frontend/es2panda$.exe", + "destination": "$host_tools/bin/es2panda$.exe" }, { - "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/$compiler_type/arkcompiler/ets_frontend/libes2panda_public$.lib", + "destination": "$host_tools/lib/libes2panda-public$.lib" }, { - "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/$compiler_type/arkcompiler/runtime_core/ark_link$.exe", + "destination": "$host_tools/bin/ark_link$.exe" }, { - "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" + "source": "$out_root/$compiler_type/arkcompiler/runtime_core/libarktsbase$.lib", + "destination": "$host_tools/lib/libarktsbase$.lib" }, { "source": "arkcompiler/runtime_core/static_core/plugins/ets/stdlib/escompat", @@ -30,21 +41,18 @@ }, { "source": "arkcompiler/ets_frontend/ets2panda/public/es2panda_lib.h", - "destination": "linux_host_tools/include/tools/es2panda/public/es2panda_lib.h" + "destination": "$host_tools/include/tools/es2panda/public/es2panda_lib.h" }, { "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" + "destination": "$host_tools/include/tools/es2panda/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/$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" } ] -- Gitee