diff --git a/pythonfmu/builder.py b/pythonfmu/builder.py index a96d51b..de0186b 100644 --- a/pythonfmu/builder.py +++ b/pythonfmu/builder.py @@ -66,6 +66,7 @@ def build_FMU( dest: FilePath = ".", project_files: Iterable[FilePath] = set(), documentation_folder: Optional[FilePath] = None, + binary_files : Optional[FilePath] = None, **options, ) -> Path: script_file = Path(script_file) @@ -164,7 +165,7 @@ def build_FMU( src_binaries.rglob("*.so"), src_binaries.rglob("*.dylib"), ): - relative_f = f.relative_to(src_binaries) + relative_f = f.relative_to(src_binaries) arcname = ( binaries / relative_f.parent @@ -172,6 +173,22 @@ def build_FMU( ) zip_fmu.write(f, arcname=arcname) + if binary_files is not None: + binary_file = Path(binary_files) + if binary_file.is_file(): + with open(binary_file,'r') as bf: + bfs = bf.readlines() + bfs = [line.rstrip() for line in bfs] + + for f in bfs: + f = Path(f) + arcname = ( + binaries + / get_platform() + / f.name + ) + zip_fmu.write(f, arcname=arcname) + # Add the documentation folder if documentation_folder is not None: documentation = Path("documentation") @@ -217,6 +234,13 @@ def create_command_parser(parser: argparse.ArgumentParser): default=None ) + parser.add_argument( + "--binary_file", + dest="binary_files", + help="will copy the files list in the binary file in binary folder enabling better portability", + default=None + ) + for option in FMI2_MODEL_OPTIONS: action = "store_false" if option.value else "store_true" parser.add_argument( diff --git a/pythonfmu/pythonfmu-export/src/CMakeLists.txt b/pythonfmu/pythonfmu-export/src/CMakeLists.txt index b2314d5..5275926 100644 --- a/pythonfmu/pythonfmu-export/src/CMakeLists.txt +++ b/pythonfmu/pythonfmu-export/src/CMakeLists.txt @@ -17,6 +17,9 @@ set(sources pythonfmu/PySlaveInstance.cpp ) +SET (CMAKE_SHARED_LINKER_FLAGS + "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN'") + add_library(pythonfmu-export ${sources} ${headers}) target_compile_features(pythonfmu-export PUBLIC "cxx_std_17")