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

Build settings #929

Merged
merged 15 commits into from
Apr 19, 2020
Merged

Build settings #929

merged 15 commits into from
Apr 19, 2020

Conversation

Nightwalker-87
Copy link
Member

@Nightwalker-87 Nightwalker-87 commented Apr 16, 2020

  • Added new build configs for Travis CI
  • Refactoring for cmake modules & settings
  • Updated Travis build script
  • GUI-Build on UNIX-based systems if GTK3 is detected
  • [doc] Updated package requirements (GUI)
  • Added CMAKEFLAGS and install target
  • Updated CHANGELOG for upcoming release

Should see some testing if compilation also works well unter mac and win in real-world conditions. So far I did some runs on a debian bullseye system. GUI works well. Focus should be on correct package creation when reviewing and anything else that catches your eye of course.

The 3rd test (flash.c) still fails, as I haven't found the root of the problem yet.

Further I plan some more changes to the project structure, but I am waiting with this until several other issues have been addressed towards our upcoming release. Otherwise we would just run into unnecessary merge conflicts.

- Added new build configs for Travis
- Refactoring for cmake modules
- Updated Travis build script
- Makefile: binary build for Windows
- Updated travis CI build config
- Refactoring of cmake build config
- Alligned coding style for GUI
- Whitespace cleanup for GUI
- Moved source code for GUI
- Updated old project references
- Alligned code style in /tests
- Added note on OS support to README.md
Copy link
Collaborator

@chenguokai chenguokai left a comment

Choose a reason for hiding this comment

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

Edit: I made a mistake, the error is not caused for lack of gtk (cannot recognize gtk even if gtk3 is installed is still one possible issue here)

cmake fails at line 153:

-- The C compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Git: /usr/bin/git (found version "2.21.1 (Apple Git-122.3)") 
-- Performing Test C_SUPPORTS_STD_GNU11
-- Performing Test C_SUPPORTS_STD_GNU11 - Success
-- Performing Test C_SUPPORTS_WALL
-- Performing Test C_SUPPORTS_WALL - Success
-- Performing Test C_SUPPORTS_WEXTRA
-- Performing Test C_SUPPORTS_WEXTRA - Success
-- Performing Test C_SUPPORTS_WSHADOW
-- Performing Test C_SUPPORTS_WSHADOW - Success
-- Performing Test C_SUPPORTS_D_FORTIFY_SOURCE_2
-- Performing Test C_SUPPORTS_D_FORTIFY_SOURCE_2 - Success
-- Performing Test C_SUPPORTS_FSTRICT_ALIASING
-- Performing Test C_SUPPORTS_FSTRICT_ALIASING - Success
-- Performing Test C_SUPPORTS_WUNDEF
-- Performing Test C_SUPPORTS_WUNDEF - Success
-- Performing Test C_SUPPORTS_WFORMAT
-- Performing Test C_SUPPORTS_WFORMAT - Success
-- Performing Test C_SUPPORTS_WFORMAT_SECURITY
-- Performing Test C_SUPPORTS_WFORMAT_SECURITY - Success
-- Performing Test C_SUPPORTS_WMAYBE_UNINITIALIZED
-- Performing Test C_SUPPORTS_WMAYBE_UNINITIALIZED - Failed
-- Performing Test C_SUPPORTS_WMISSING_VARIABLE_DECLARATIONS
-- Performing Test C_SUPPORTS_WMISSING_VARIABLE_DECLARATIONS - Success
-- Performing Test C_SUPPORTS_WSHORTEN_64_TO_32
-- Performing Test C_SUPPORTS_WSHORTEN_64_TO_32 - Success
-- Performing Test C_SUPPORTS_WIMPLICIT_FUNCTION_DECLARATION
-- Performing Test C_SUPPORTS_WIMPLICIT_FUNCTION_DECLARATION - Success
-- Performing Test C_SUPPORTS_WREDUNDANT_DECLS
-- Performing Test C_SUPPORTS_WREDUNDANT_DECLS - Success
-- Performing Test C_SUPPORTS_FPIC
-- Performing Test C_SUPPORTS_FPIC - Success
-- Performing Test C_SUPPORTS_O2
-- Performing Test C_SUPPORTS_O2 - Success
-- Performing Test C_SUPPORTS_WERROR
-- Performing Test C_SUPPORTS_WERROR - Success
-- Found Libusb: /opt/local/lib/libusb-1.0.a  
-- Looking for sys/mman.h
-- Looking for sys/mman.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for __stack_chk_fail in ssp
-- Looking for __stack_chk_fail in ssp - not found
-- STLINK_LIB_SHARED: stlink
-- PROJECT_VERSION_MAJOR: 
-- VERSION: ..
CMake Error at CMakeLists.txt:153 (set_target_properties):
  set_target_properties called with incorrect number of arguments.


-- gtk not found!
-- Manpage generation disabled
-- Configuring incomplete, errors occurred!
See also "/Users/cgk/Downloads/stlink-build-settings/build/Release/CMakeFiles/CMakeOutput.log".
See also "/Users/cgk/Downloads/stlink-build-settings/build/Release/CMakeFiles/CMakeError.log".
make: *** [build/Release] Error 1

This problem occurs only when I build with from the zip file downloaded on the web interface. The build succeed with a git cloned one. Maybe we should add a doc for this or (if possible) throw a warning in cmake.

Original wrong idea

My local test failed for lack of gtk.
I suggest do not enable gtk-based GUI by default, at least for macOS.
GTK is not native in macOS. Also, GTK on macOS only officially support macOS 10.10 and later(In practice, gtk3 builds on 10.7 and later), which would force me to drop support for support starting from 10.6.

If the GUI is set to optional, a GUI variant can be added to MacPorts Portfile, which will provide the interface for 10.7 and later.

@Nightwalker-87
Copy link
Member Author

This may be an undiscovered older problem...

We can make gtk3 an requirement for installations via brew and Macports which then would allow mac users to make use of this feature as well. As far as I can see there is no mention related to the GUI for macOS in our project documentation at all. To me it is not necessary to provide an additional package for the gui on linux either. So my suggestion on this is to include the gui into the main package and to install it by default if gtk can be retrieved automatically from a repo and skip it if this is not possible (e.g. on stand alone installations).

@Nightwalker-87
Copy link
Member Author

CMake Error at CMakeLists.txt:153 (set_target_properties):
set_target_properties called with incorrect number of arguments.

This should not fail really. I think it is a problem with reading the project version number when git is not present. That would also explain why this only happens when downloading the zip archive.

@Nightwalker-87
Copy link
Member Author

@chenguokai: I found that some necessary cases were not addressed in the workflow of the version.cmake module. Please retry.

@chenguokai
Copy link
Collaborator

Build succeeded without git, nice work!

But I still cannot figure out why cmake failed to recognize either gtk2 or gtk3 which has been installed by MacPorts. Confirmed that both headers and binary dynamic libs are present.

@Nightwalker-87
Copy link
Member Author

One reason for that seems to be in /CMakeLists.txt:

if (NOT APPLE AND NOT WIN32 AND NOT CMAKE_CROSSCOMPILING)
    find_package(PkgConfig)
    pkg_check_modules(gtk gtk+-3.0)
endif ()

Thus macOS is always excluded from GUI builds and the detection in /src/stlink-gui/CMakeLists.txt does not help as gtk_FOUND has not seen any result from the previous check:

if (NOT gtk_FOUND)
    message(STATUS "gtk not found!")
    return()                         # no GTK present => no GUI build
endif ()

- Added gtk-package to travis build config
- Added gtk to version_support.md (GUI)
- Minor correction for CHANGELOG.md
- README: Removed reference to OpenBSD
- Added info on GTK3 libs & versioning
- Updated compiling instructions for macOS
@Nightwalker-87
Copy link
Member Author

@chenguokai: Here are some more improvements: We query for GTK3 on all unix-based systems. If cmake does not find it, there will be no compilation for the GUI. I've updated the related documentation as well, so have a short look at that first. Hence I expect the GUI to compile flawlessly on macOS now, if there is no mistake.
Please give it another try.

@grevaillot and @chenguokai you may finally review this now. I'm not planning any extra work on this PR apart from necessary fixes, if needed.

@chenguokai
Copy link
Collaborator

Works so well!

@Nightwalker-87 Nightwalker-87 requested review from slyshykO and martonmiklos and removed request for martonmiklos April 19, 2020 15:52
@martonmiklos
Copy link
Collaborator

Managed to build it under 18.04 Ubuntu.

@Nightwalker-87 Nightwalker-87 removed the request for review from slyshykO April 19, 2020 20:32
@Nightwalker-87 Nightwalker-87 merged commit cb3a2b6 into develop Apr 19, 2020
@Nightwalker-87 Nightwalker-87 deleted the build-settings branch April 19, 2020 20:35
@stlink-org stlink-org locked as resolved and limited conversation to collaborators May 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

make test target broken
5 participants