Skip to content

Commit

Permalink
Deprecate autotools and load version from TRAVIS_TAG, git command or …
Browse files Browse the repository at this point in the history
…local .version file
  • Loading branch information
xor-gate committed Jun 18, 2016
1 parent 2563f43 commit 226e315
Show file tree
Hide file tree
Showing 19 changed files with 353 additions and 572 deletions.
21 changes: 6 additions & 15 deletions .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,15 @@ ls -1 /usr/bin/clang*
ls -1 /usr/bin/scan-build*
echo "----"

if [ "$TRAVIS_OS_NAME" != "osx" ]; then
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
sudo apt-get update -qq || true
sudo apt-get install -qq -y --no-install-recommends libusb-1.0.0-dev libgtk-3-dev
else
brew install libusb
fi

if [ "$BUILD_SYSTEM" == "cmake" ]; then
mkdir build
cd build
cmake ..
make
else
./autogen.sh
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
./configure
else
./configure --with-gtk-gui
fi
make
fi
echo "=== Building Debug"
mkdir -p build/Debug && cd build/Debug && cmake -DCMAKE_BUILD_TYPE=Debug ../../ && make && make package && cd -

echo "=== Building Release"
mkdir -p build/Release && cd build/Release && cmake -DCMAKE_BUILD_TYPE=Release ../../ && make && make package && cd -
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ language: c
addons:
apt:
sources:
# - llvm-toolchain-precise-3.8
- ubuntu-toolchain-r-test
packages:
- clang
# - clang-3.8
- g++-5
- gcc-5
- clang
script:
- ./.travis.sh
matrix:
include:
- os: linux
compiler: clang-3.8
env: "BUILD_SYSTEM=cmake"
compiler: clang
# - os: linux
# compiler: clang-3.8
- os: linux
compiler: gcc-5
env: "BUILD_SYSTEM=cmake"
- os: osx
compiler: clang
env: "BUILD_SYSTEM=cmake"
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.0.0-dev
2 changes: 0 additions & 2 deletions ACKNOWLEDGMENTS

This file was deleted.

19 changes: 0 additions & 19 deletions AUTHORS

This file was deleted.

72 changes: 66 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,51 @@
project(stlink C)
cmake_minimum_required(VERSION 2.8.7)

project(stlink C)
include(CheckCCompilerFlag)
find_package(PkgConfig)

if (POLICY CMP0042)
# Newer cmake on MacOS should use @rpath
cmake_policy (SET CMP0042 NEW)
endif ()

set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake/modules")

# Determine package version.
find_package (Git QUIET)
if (DEFINED ENV{TRAVIS_TAG} AND NOT "$ENV{TRAVIS_TAG}" STREQUAL "")
set (STLINK_PACKAGE_VERSION "$ENV{TRAVIS_TAG}")
elseif (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Working off a git repo, using git versioning

# Check if HEAD is pointing to a tag
execute_process (
COMMAND "${GIT_EXECUTABLE}" describe --always
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
OUTPUT_VARIABLE STLINK_PACKAGE_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)

# If the sources have been changed locally, add -dirty to the version.
execute_process (
COMMAND "${GIT_EXECUTABLE}" diff --quiet
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
RESULT_VARIABLE res)

if (res EQUAL 1)
set (STLINK_PACKAGE_VERSION "${STLINK_PACKAGE_VERSION}-dirty")
endif()
elseif (EXISTS ${PROJECT_SOURCE_DIR}/.version)
# If git is not available (e.g. when building from source package)
# we can extract the package version from .version file.
file (STRINGS .version STLINK_PACKAGE_VERSION)
else ()
set (STLINK_PACKAGE_VERSION "Unknown")
endif()

find_package(LibUSB REQUIRED)
pkg_check_modules(gtk gtk+-3.0)
if (NOT APPLE)
find_package(PkgConfig)
pkg_check_modules(gtk gtk+-3.0)
endif ()

function(add_cflag_if_supported flag)
string(REPLACE "-" "_" flagclean ${flag})
Expand Down Expand Up @@ -39,14 +77,21 @@ add_cflag_if_supported("-Wredundant-decls")
add_cflag_if_supported("-Wundef")
add_cflag_if_supported("-fPIC")

if (CMAKE_BUILD_TYPE STREQUAL "")
set (CMAKE_BUILD_TYPE "Debug")
endif ()

if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
include(CTest)
add_cflag_if_supported("-ggdb")
add_cflag_if_supported("-O0")
#set (STLINK_PACKAGE_VERSION "${STLINK_PACKAGE_VERSION}-debug")
elseif()
add_cflag_if_supported("-O2")
endif()

message("Building ${PROJECT_NAME} ${STLINK_PACKAGE_VERSION}")

set(STLINK_HEADERS
include/stlink.h
include/stlink/usb.h
Expand Down Expand Up @@ -108,20 +153,22 @@ if(NOT MINGW)
RUNTIME DESTINATION bin)
endif()

if(gtk_FOUND)
if (NOT APPLE AND gtk_FOUND)
include_directories(SYSTEM ${gtk_INCLUDE_DIRS})
set(GUI_SOURCES src/tools/gui/stlink-gui.c
src/tools/gui/stlink-gui.h)

# TODO REMOVE whole stlink-gui-local target, fixup auto-search of ui file in implementation
add_executable(stlink-gui-local ${GUI_SOURCES})
set_target_properties(stlink-gui-local PROPERTIES
COMPILE_FLAGS -DSTLINK_UI_DIR=\\"${CMAKE_CURRENT_SOURCE_DIR}/gui\\")
target_link_libraries(stlink-gui-local stlink ${gtk_LDFLAGS})

set(INSTALLED_UI_DIR ${CMAKE_INSTALL_PREFIX}/share)
set(INSTALLED_UI_DIR share/stlink)
add_executable(stlink-gui ${GUI_SOURCES})
# TODO REMOVE, fixup auto-search of ui file in implementation
set_target_properties(stlink-gui PROPERTIES
COMPILE_FLAGS -DSTLINK_UI_DIR=\\"${INSTALLED_UI_DIR}\\")
COMPILE_FLAGS -DSTLINK_UI_DIR=\\"${CMAKE_INSTALL_PREFIX}/${INSTALLED_UI_DIR}\\")
target_link_libraries(stlink-gui stlink ${gtk_LDFLAGS})

install(TARGETS stlink-gui
Expand All @@ -131,3 +178,16 @@ if(gtk_FOUND)
endif()

add_subdirectory(tests)

set (CPACK_PACKAGE_NAME ${PROJECT_NAME})
set (CPACK_PACKAGE_VERSION ${STLINK_PACKAGE_VERSION})
set (CPACK_SOURCE_GENERATOR "TBZ2;ZIP")
set (CPACK_SOURCE_IGNORE_FILES "/build/;/.git/;~$;${CPACK_SOURCE_IGNORE_FILES}")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${STLINK_PACKAGE_VERSION}")
if (APPLE)
set(CPACK_GENERATOR "ZIP")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/dist/osx")
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/dist/osx")
endif ()
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
include (CPack)
27 changes: 0 additions & 27 deletions COPYING

This file was deleted.

9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Stlink ChangeLog
================

v2.0.0
======

Ongoing development

Major changes:

* Deprecation of autotools (autoconf, automake)

v1.2.0
======

Expand Down
59 changes: 0 additions & 59 deletions Makefile.am

This file was deleted.

Empty file removed NEWS
Empty file.
Loading

0 comments on commit 226e315

Please sign in to comment.