swig / cccl

Unix cc compiler to Microsoft's cl compiler wrapper
GNU General Public License v3.0
123 stars 36 forks source link

Implement "print-search-dirs" argument #16

Open falhumai96 opened 2 years ago

falhumai96 commented 2 years ago

Implement print-search-dirs argument to list (currently) install "binary" script and the search libraries (required by libtool when building shared libraries (https://git.savannah.gnu.org/cgit/libtool.git/tree/m4/libtool.m4?id=33615a45a6926666f95da8a0dc28fc9a8c62d117#n2320)). This argument requires the presence of a Windows <-> Unix path tool to be present to be used to convert, for e.g., LIB environment variable with Windows libraries search paths to its equivalent in the Unix system it is running on (e.g. Cygwin with native Windows or Linux with Wine). It can be either guessed from the current Unix system or set using the CCCL_WINPATH_BIN environment variable.

The operations of print-search-dirs require the manipulation of Windows paths, namely separating the Windows path prefix from the path, to shorten the Unix version of the path, and parsing the Windows path prefix from the path is a bit tedious. So, I relied on Python's pathlib's PureWindowsPath (and also PurePosixPath for manipulating Unix paths) to resolve this issue without implementing this functionality in pure Bash scripting. However, I would have to add a Python requirement to the script as well, with CCCL_PYTHON_BIN environment variable to set it to a custom Python installation path or resolved from the PATH environment variable. Though recent versions of Linux or Cygwin installation already comes with Python (even native Windows Python should work in this case), and Python is being as available by default as Perl. Also, the library I require, which is pathlib, is already part of the standard library of recent Python versions.