Patchwork [3/3] Properly include libusb-win32 header.

login
register
about
Submitter Stefan Tauner
Date 2015-01-19 20:39:36
Message ID <1421699976-7852-3-git-send-email-stefan.tauner@alumni.tuwien.ac.at>
Download mbox | patch
Permalink /patch/4276/
State Accepted
Headers show

Comments

Stefan Tauner - 2015-01-19 20:39:36
libusb-win32 is using a different header file name for a while, use
that on Windows builds to make clear that this is currently the
correct header to include.

Hopefully this will change soonish with migrating away from libusb-0.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
---
 Makefile   | 5 +++++
 dediprog.c | 8 ++++++++
 2 files changed, 13 insertions(+)
Carl-Daniel Hailfinger - 2015-01-26 01:54:35
On 19.01.2015 21:39, Stefan Tauner wrote:
> libusb-win32 is using a different header file name for a while, use
> that on Windows builds to make clear that this is currently the
> correct header to include.

Yes, but at http://flashrom.org/Windows we still direct users to the old
libusb-win32 version which uses the old usb.h.
As long as those instructions are in the wiki, this will introduce
additional breakage.


> Hopefully this will change soonish with migrating away from libusb-0.
>
> Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
> ---
>  Makefile   | 5 +++++
>  dediprog.c | 8 ++++++++
>  2 files changed, 13 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 54ebfe4..03670d2 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -843,7 +843,12 @@ endef
>  export LIBPCI_TEST
>  
>  define LIBUSB0_TEST
> +#include "platform.h"
> +#if IS_WINDOWS
> +#include <lusb0_usb.h>
> +#else
>  #include <usb.h>
> +#endif
>  int main(int argc, char **argv)
>  {
>  	(void) argc;

We'd have to fix the wiki at the same time we commit this.

Regards,
Carl-Daniel
Stefan Tauner - 2015-01-26 08:35:26
On Mon, 26 Jan 2015 02:54:35 +0100
Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> wrote:

> On 19.01.2015 21:39, Stefan Tauner wrote:
> > libusb-win32 is using a different header file name for a while, use
> > that on Windows builds to make clear that this is currently the
> > correct header to include.
> 
> Yes, but at http://flashrom.org/Windows we still direct users to the old
> libusb-win32 version which uses the old usb.h.
> As long as those instructions are in the wiki, this will introduce
> additional breakage.

That's because that wiki page is even more outdated than libusb-0. :)

> > Hopefully this will change soonish with migrating away from libusb-0.
> >
> > Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
> > Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
> > ---
> >  Makefile   | 5 +++++
> >  dediprog.c | 8 ++++++++
> >  2 files changed, 13 insertions(+)
> >
> > diff --git a/Makefile b/Makefile
> > index 54ebfe4..03670d2 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -843,7 +843,12 @@ endef
> >  export LIBPCI_TEST
> >  
> >  define LIBUSB0_TEST
> > +#include "platform.h"
> > +#if IS_WINDOWS
> > +#include <lusb0_usb.h>
> > +#else
> >  #include <usb.h>
> > +#endif
> >  int main(int argc, char **argv)
> >  {
> >  	(void) argc;
> 
> We'd have to fix the wiki at the same time we commit this.

The more important question is if it is worth it at all. Under normal
circumstances I'd say no, because we should migrate to libusb-1 ASAP.
In retrospection of our past development I would that say fixing things
that are wrong but easy to fix should be done (immediately), even if
they are obsoleted soon in the best case.

Is it enough to change the download URL for the precompiled libusb and
change the name of usb.h in the description or were there other
build-relevant changes between 1.2.4.0 and 1.2.6.0?
Carl-Daniel Hailfinger - 2015-01-26 09:00:17
On 26.01.2015 09:35, Stefan Tauner wrote:
> On Mon, 26 Jan 2015 02:54:35 +0100
> Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> wrote:
>
>> On 19.01.2015 21:39, Stefan Tauner wrote:
>>> libusb-win32 is using a different header file name for a while, use
>>> that on Windows builds to make clear that this is currently the
>>> correct header to include.
>> Yes, but at http://flashrom.org/Windows we still direct users to the old
>> libusb-win32 version which uses the old usb.h.
>> As long as those instructions are in the wiki, this will introduce
>> additional breakage.
> That's because that wiki page is even more outdated than libusb-0. :)
>
>>> Hopefully this will change soonish with migrating away from libusb-0.
>>>
>>> Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
>>> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
>>> ---
>>>  Makefile   | 5 +++++
>>>  dediprog.c | 8 ++++++++
>>>  2 files changed, 13 insertions(+)
>>>
>>> diff --git a/Makefile b/Makefile
>>> index 54ebfe4..03670d2 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -843,7 +843,12 @@ endef
>>>  export LIBPCI_TEST
>>>  
>>>  define LIBUSB0_TEST
>>> +#include "platform.h"
>>> +#if IS_WINDOWS
>>> +#include <lusb0_usb.h>
>>> +#else
>>>  #include <usb.h>
>>> +#endif
>>>  int main(int argc, char **argv)
>>>  {
>>>  	(void) argc;
>> We'd have to fix the wiki at the same time we commit this.
> The more important question is if it is worth it at all. Under normal
> circumstances I'd say no, because we should migrate to libusb-1 ASAP.
> In retrospection of our past development I would that say fixing things
> that are wrong but easy to fix should be done (immediately), even if
> they are obsoleted soon in the best case.

Agreed.


> Is it enough to change the download URL for the precompiled libusb and
> change the name of usb.h in the description or were there other
> build-relevant changes between 1.2.4.0 and 1.2.6.0?

I tried building natively with libusb-win32 1.2.6.0 and it worked with
your patch. Please adjust both (bin and devel-filter) libusb-win32
version numbers while you're at it.

Regards,
Carl-Daniel
Stefan Tauner - 2015-01-26 22:06:44
On Mon, 26 Jan 2015 10:00:17 +0100
Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> wrote:

> On 26.01.2015 09:35, Stefan Tauner wrote:
> > On Mon, 26 Jan 2015 02:54:35 +0100
> > Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> wrote:
> >
> >> On 19.01.2015 21:39, Stefan Tauner wrote:
> >>> libusb-win32 is using a different header file name for a while, use
> >>> that on Windows builds to make clear that this is currently the
> >>> correct header to include.
> >> Yes, but at http://flashrom.org/Windows we still direct users to the old
> >> libusb-win32 version which uses the old usb.h.
> >> As long as those instructions are in the wiki, this will introduce
> >> additional breakage.
> > That's because that wiki page is even more outdated than libusb-0. :)
> >
> >>> Hopefully this will change soonish with migrating away from libusb-0.
> >>>
> >>> Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
> >>> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
> >>> ---
> >>>  Makefile   | 5 +++++
> >>>  dediprog.c | 8 ++++++++
> >>>  2 files changed, 13 insertions(+)
> >>>
> >>> diff --git a/Makefile b/Makefile
> >>> index 54ebfe4..03670d2 100644
> >>> --- a/Makefile
> >>> +++ b/Makefile
> >>> @@ -843,7 +843,12 @@ endef
> >>>  export LIBPCI_TEST
> >>>  
> >>>  define LIBUSB0_TEST
> >>> +#include "platform.h"
> >>> +#if IS_WINDOWS
> >>> +#include <lusb0_usb.h>
> >>> +#else
> >>>  #include <usb.h>
> >>> +#endif
> >>>  int main(int argc, char **argv)
> >>>  {
> >>>  	(void) argc;
> >> We'd have to fix the wiki at the same time we commit this.
> > The more important question is if it is worth it at all. Under normal
> > circumstances I'd say no, because we should migrate to libusb-1 ASAP.
> > In retrospection of our past development I would that say fixing things
> > that are wrong but easy to fix should be done (immediately), even if
> > they are obsoleted soon in the best case.
> 
> Agreed.
> 
> 
> > Is it enough to change the download URL for the precompiled libusb and
> > change the name of usb.h in the description or were there other
> > build-relevant changes between 1.2.4.0 and 1.2.6.0?
> 
> I tried building natively with libusb-win32 1.2.6.0 and it worked with
> your patch. Please adjust both (bin and devel-filter) libusb-win32
> version numbers while you're at it.

Done, and the patch was committed in r1877. Thanks.

Patch

diff --git a/Makefile b/Makefile
index 54ebfe4..03670d2 100644
--- a/Makefile
+++ b/Makefile
@@ -843,7 +843,12 @@  endef
 export LIBPCI_TEST
 
 define LIBUSB0_TEST
+#include "platform.h"
+#if IS_WINDOWS
+#include <lusb0_usb.h>
+#else
 #include <usb.h>
+#endif
 int main(int argc, char **argv)
 {
 	(void) argc;
diff --git a/dediprog.c b/dediprog.c
index 71a9f8b..4248499 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -17,11 +17,19 @@ 
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include "platform.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <limits.h>
 #include <errno.h>
+
+#if IS_WINDOWS
+#include <lusb0_usb.h>
+#else
 #include <usb.h>
+#endif
+
 #include "flash.h"
 #include "chipdrivers.h"
 #include "programmer.h"