Skip to content

Stop the sulk with GPL2016 on Windows - #602

Merged
xor-gate merged 24 commits into
stlink-org:masterfrom
orinem:master
Jun 17, 2017
Merged

xor-gate merged 24 commits into
stlink-org:masterfrom
orinem:master

Conversation

@orinem

@orinem orinem commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

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

xor-gate commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

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

orinem commented Jun 9, 2017 via email

Copy link
Copy Markdown
Contributor Author

@xor-gate

xor-gate commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

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

orinem commented Jun 9, 2017

Copy link
Copy Markdown
Contributor Author

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

xor-gate commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

No problem we just squash them when finished.

@orinem

orinem commented Jun 10, 2017

Copy link
Copy Markdown
Contributor Author

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.

Comment thread src/getopt/getopt.h Outdated
@orinem

orinem commented Jun 10, 2017 via email

Copy link
Copy Markdown
Contributor Author

@orinem

orinem commented Jun 10, 2017

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor

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

xor-gate commented Jun 10, 2017 •

Copy link
Copy Markdown
Contributor

@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

orinem commented Jun 10, 2017 via email

Copy link
Copy Markdown
Contributor Author

@xor-gate

Copy link
Copy Markdown
Contributor

Thanks for looking into it! Keep me posted.

@orinem

orinem commented Jun 11, 2017 •

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor

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!

@xor-gate xor-gate left a comment

Copy link
Copy Markdown
Contributor

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

orinem commented Jun 11, 2017

Copy link
Copy Markdown
Contributor Author

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

Comment thread src/getopt/LICENSE.txt Outdated
@orinem

orinem commented Jun 13, 2017

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor

Sorry for my late reply. All set!

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

orinem commented Jun 18, 2017 via email

Copy link
Copy Markdown
Contributor Author

@xor-gate

Copy link
Copy Markdown
Contributor

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.

4 participants