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

Stop the sulk with GPL2016 on Windows #602

Merged
merged 24 commits into from
Jun 17, 2017
Merged

Conversation

orinem
Copy link
Contributor

@orinem orinem commented Jun 9, 2017

Trying to use stlink with GNAT/GPL2016/GPS was an exercise in frustration on Windows (no, another OS is NOT an option). GPS would sulk trying to flash/debug. However, running st-util then flash/debug would work, but one copy of st-util would crash.

These changes result in an st-util.exe that builds in Visual Studio 2017 (don't complain, it's free for open source development) and does not exhibit the above problems. However, it is far from complete. It requires that libusb be built from source in Visual Studio 2017 and the resulting binaries copying into the build folder. It's beyond my current inclination to make cmake do that. It's likely that a previous version of Visual Studio will work fine with the libusb that is downloaded. I have no time to check that either.

The critical commit is probably f881677. The code was using the wrong function to close a socket and furthermore, subsequent code that used the correct function closed the incorrect socket.

Feel free to cherry pick from these commits (especially ignoring the VS2017 project files that are particularly messy - cmake should be able to make them now).

@xor-gate
Copy link
Member

xor-gate commented Jun 9, 2017

That's great news, I would prefer generating the MSVC 2017 project using CMake. I'm not a big fan of having for every IDE and compiler version different projects. Have you tried this ? I will review your code changes ASAP.

@xor-gate xor-gate self-requested a review June 9, 2017 07:47
@orinem
Copy link
Contributor Author

orinem commented Jun 9, 2017 via email

@xor-gate
Copy link
Member

xor-gate commented Jun 9, 2017

Yeah I know how it works, it costs some effort to get it working. But happily you have it sort of compiling and working.

@orinem
Copy link
Contributor Author

orinem commented Jun 9, 2017

These commits can be ignored: 3206c29, c46b3f0 and 8dae077 - they just clutter up the history. I'd force a rebase, but it's a bit late for that.

@xor-gate
Copy link
Member

xor-gate commented Jun 9, 2017

No problem we just squash them when finished.

@orinem
Copy link
Contributor Author

orinem commented Jun 10, 2017

At this point, the MSVC projects generated by cmake work fine with VS2017 as long as the libusb archive has libs built with VS2017. I suspect everything would be fine on a previous version of VS as well, but haven't tried it.

I downloaded the latest libusb source, built the VS2015 solution using VS2017 (works fine) and copied libusb-1.0.lib from the libusb-1.0.21\Win32\Debug\lib directory into libusb-1.0.21.7z\MS32\static using 7-Zip. Then, I cleaned out the stlink/build directory, copied the modified libusb-1.0.21.7z in to the build directory, ran cmake and build the resulting solution (Debug target). This sequence produced an st-util.exe that I put in my GNAT/2016/bin directory.

Debugging under GNAT/GPS is working fine, so I'll leave this branch alone now.

src/getopt/getopt.h Outdated Show resolved Hide resolved
@orinem
Copy link
Contributor Author

orinem commented Jun 10, 2017 via email

@orinem
Copy link
Contributor Author

orinem commented Jun 10, 2017

I copied the suggested BSD licensed files in for getopt. I also made the links to libusb dynamic for MSVC (it's no longer necessary to modify the libusb archive with this change).

@xor-gate
Copy link
Member

Great, looks good to me. A few things left:

  • Could you write a section about MSVC 2017 usage/compilation in document https://github.com/texane/stlink/blob/master/doc/compiling.md
  • (optional, can be a hassle) Could you try to let it compile with AppVeyor continuous integration with the MSVC 2017 image (I only own Mac and *Nix machines), this should also be able to create builds for releases which are reproducable.
  • There is no way to have the executables static for windows now as you have it pointing to the DLL folder, maybe we should find a way to have it static compiled (which makes distribution easier).

@xor-gate
Copy link
Member

xor-gate commented Jun 10, 2017

@texane can we finally enable AppVeyor Github integration for this project repository? Just like Travis continuous integration. This makes release/artifacts for windows with MSVC/MinGW compiled much easier to maintain for me because I only own Mac and *Nix machines. I would also appreciate if you can give me full permissions on the repository so I will not bother you with trying to get it work.

@xor-gate xor-gate added this to the v1.3.2 milestone Jun 10, 2017
@orinem
Copy link
Contributor Author

orinem commented Jun 10, 2017 via email

@xor-gate
Copy link
Member

Thanks for looking into it! Keep me posted.

@orinem
Copy link
Contributor Author

orinem commented Jun 11, 2017

The existing AppVeyor script fails: "mv: cannot move mingw32' to /MinGW/mingw32': Permission denied" for x86 and "error: 'usleep' is deprecated" for x64.

I did have success from the AppVeyor web UI. This exported appveyor.yml successfully builds the project under VS2017. There are a lot of warnings that should be reviewed, mostly signed/unsigned conversions. Log is attached.

log-2.txt

EDIT:

The formatting messed it up, so I attached it as a file - rename to .yml to use it.

appveyor.txt

@xor-gate
Copy link
Member

Nice work @orinem ! Its possible the mingw32 stuff is broken. Looks good, last note: why are there two unistd.h compat files? Probably we should just keep one under src or in include. When you are finished we can merge!

Copy link
Member

@xor-gate xor-gate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, except we probably just need one unistd.h compat file

@orinem
Copy link
Contributor Author

orinem commented Jun 11, 2017

Two unistd.h files was an accident. I've deleted the extra.

src/getopt/LICENSE.txt Outdated Show resolved Hide resolved
@orinem
Copy link
Contributor Author

orinem commented Jun 13, 2017

The file had "ä" and "Ä" characters in a character set encoding incompatible with UTF8. I resaved the file from vi as utf8 and the latest diff looks OK.

@xor-gate
Copy link
Member

Sorry for my late reply. All set!

@xor-gate xor-gate merged commit 79d9178 into stlink-org:master Jun 17, 2017
@orinem
Copy link
Contributor Author

orinem commented Jun 18, 2017 via email

@xor-gate
Copy link
Member

Sure, since I build and released a windows executable there are many downloads.

@stlink-org stlink-org locked as resolved and limited conversation to collaborators Apr 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants