From cab40fbdf5aee035ece0e271bb0c74d184854448 Mon Sep 17 00:00:00 2001 From: Zhuo Yang Date: Wed, 11 Sep 2024 22:03:33 +0800 Subject: [PATCH] fix: consider -fuse-ld --- ofCmakeConfig | 11 ++++++----- wmakelog2cmakelists.py | 13 ++++++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ofCmakeConfig b/ofCmakeConfig index 532c416..848afd1 100755 --- a/ofCmakeConfig +++ b/ofCmakeConfig @@ -1,10 +1,11 @@ #!/bin/bash -if [ ! -f "log.wmake" ] -then - echo "wmake > log.wmake" - wmake $@ >log.wmake 2>&1 -fi +wclean && wmake $@ > log.wmake 2>&1 +# if [ ! -f "log.wmake" ] +# then +# echo "wmake > log.wmake" +# wmake $@ >log.wmake 2>&1 +# fi # Find the Python executable in the system PYTHON_EXEC=$(which python3) diff --git a/wmakelog2cmakelists.py b/wmakelog2cmakelists.py index 9fb0a47..23d6928 100644 --- a/wmakelog2cmakelists.py +++ b/wmakelog2cmakelists.py @@ -56,8 +56,15 @@ def parse_wmake_log(log_file): # Determine if it's a compile or link statement if '-Xlinker' in line or '-Wl,' in line: # Link statement + # Handle -fuse-ld + useld = re.search(r'(-fuse-ld=\S+)', line) + if useld: + link_options.append(f'{useld.group(1)}') + print(link_options) + # Handle output file output_file = re.search(r'-o\s+(\S+)', line).group(1) - lib_matches = re.findall(r'-l(\S+)', line) + # Handle libraries + lib_matches = re.findall(r' -l(\S+)', line) for lib in lib_matches: if lib not in link_libraries: link_libraries.append(lib) @@ -93,8 +100,8 @@ def parse_wmake_log(log_file): objstr = f'add_library({objname} STATIC {" ".join(source_files)})' # Handle the issue of link and target having the same name - link_libraries = [lib if lib != objname else f'lib{ - lib}.so' for lib in link_libraries] + link_libraries = [lib if lib != objname else f'lib{lib}.so' + for lib in link_libraries] # Create CMakeLists.txt content cmake_content = f"""cmake_minimum_required(VERSION 3.10)