Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add standalone libftdi1 library #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Matheus-Garbelini
Copy link

@Matheus-Garbelini Matheus-Garbelini commented Feb 4, 2021

Dear @l29ah thanks a lot for maintaining this library. Here's another big PR for usability:
I'm making an attempt to make the library more mainstream to use by adding a static build of libftdi1, libusb and libconfuse included as a whole archive to libmpsse (libmpsse-static.a). This means that the user only needs to link -lpthread and -ludev and should be ready to go.

I've updated the readme with the new build instruction, but you just have to run build.sh. Let me know your feedback.
Here's the main changed I did to source code files:

  • Removed the latency_timer range from libftdi to allow ft2232h devices to be used with "0" ms latency timer.
  • Changed config.h to mpsse_config.h. This avoids conflict with other projects which already uses config.h for something else.
  • Modified configure.ac to use the static libftdi library.
  • Updated the CI file (.travis.yml) to use ./build.sh instead

MISC

How to generate libftdi1-static.a

  • Clone repositories libusb and libconfuse-2.5 and compile them to get their static libraries:

  • Configure libftdi as follows adding the correct path to each library static libraries and header folders:

cmake -B build -DLIBUSB_LIBRARIES=`pwd`/libusb-1.0.a \
-DLIBUSB_INCLUDE_DIR=`pwd`/libusb/libusb \
-DCONFUSE_LIBRARY=`pwd`/libconfuse.a \
-DCONFUSE_INCLUDE_DIR=`pwd`/confuse-2.5/src \
-DFTDIPP=ON \
-DCMAKE_BUILD_TYPE=Release

make -C build ftdi1-static
  1. Use ar -x libftdi1.a && ar -x libconfuse.a && ar -x libusb.a to extract all object files
  2. Use ar -qc libftdi1-static.a *.o to create ftdi static library
  3. Copy the generated libftdi1-static.a to libmpsse src folder.

# How to generate libftdi1-static.a Clone repositories `libusb` and `libconfuse-2.5` and compile them to get their static libraries

# Configure libftdi as follows adding the correct path to each library static libraries and header folders
cmake -B build -DLIBUSB_LIBRARIES=`pwd`/libusb-1.0.a \
-DLIBUSB_INCLUDE_DIR=`pwd`/libusb/libusb \
-DCONFUSE_LIBRARY=`pwd`/libconfuse.a \
-DCONFUSE_INCLUDE_DIR=`pwd`/confuse-2.5/src \
-DFTDIPP=ON \
-DCMAKE_BUILD_TYPE=Release

# Compile the static library
```bash
make -C build ftdi1-static
```
# 1. Use `ar -x libftdi1.a && ar -x libconfuse.a && ar -x libusb-1.0.a` to extract all object files
# 2. Use `ar -qc libftdi1-static.a *.o` to create ftdi static library
# 3. Copy the generated libftdi1-static.a to libmpsse src folder.
@l29ah
Copy link
Owner

l29ah commented May 18, 2021

Sorry i didn't notice your PR.
You shouldn't commit generated files into the repo. Also the commits must be atomic, so git bisect and other workflows make sense.

@Matheus-Garbelini
Copy link
Author

Matheus-Garbelini commented May 20, 2021

thanks, @l29ah and noted.

  • I can solve the issue with generated file by including all steps to generate the static libraries on build.sh. I wonder if you prefer to include libftdi and linconfuse-2.5 as submodules or simply handle everything by cloning them on build.sh?
  • I'll do a force push with the atomic commit then.
  • I see a lot of formatting was changed due to VSCode, do you have the clang-format file to enforce the correct automatic formatting for this repo?

Do you have some feedback on the code changes itself?

@l29ah
Copy link
Owner

l29ah commented May 20, 2021

I prefer the build system to take the dependencies from the running system, as it does now.

No, and i would prefer not to touch the formatting for some time to maintain compatibility with people's patches to the original libmpsse, even though the current style is horrible.

@l29ah
Copy link
Owner

l29ah commented May 20, 2021

And i probably can't even tell what "the code changes itself" are among the automatically generated stuff and questionable scripts.

@Matheus-Garbelini
Copy link
Author

Matheus-Garbelini commented May 20, 2021

@l29ah thanks for the feedback and sorry for the trouble.
I'll fix this PR when I get the chance. Since you prefer to link with system dependencies, would a build script which generates both the normal library and the standalone be an acceptable solution for the final PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants