Skip to content

Commit

Permalink
Reorganised project source directories
Browse files Browse the repository at this point in the history
(Closes #976)
  • Loading branch information
Nightwalker-87 committed Jun 4, 2020
1 parent 8f42f54 commit b9773d0
Show file tree
Hide file tree
Showing 30 changed files with 187 additions and 215 deletions.
60 changes: 28 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,43 +81,41 @@ endif ()
## Define include directories to avoid absolute paths for header defines
include_directories(${LIBUSB_INCLUDE_DIR})

# ====
include_directories(${PROJECT_SOURCE_DIR}/include) ### TODO: Clean this up...
include_directories(${PROJECT_BINARY_DIR}/include/stlink)
include_directories(${PROJECT_SOURCE_DIR}/include/stlink)
include_directories(${PROJECT_SOURCE_DIR}/include/stlink/tools)
# ====
include_directories(${PROJECT_SOURCE_DIR}/inc) # contains top-level header files
include_directories(${PROJECT_BINARY_DIR}/inc) # contains version.h

include_directories(src)
include_directories(src/tools) ### TODO: Clean this up...
include_directories(src/mmap)
include_directories(src/st-flash)
include_directories(src/st-link-lib)

set(STLINK_HEADERS
include/stlink.h
include/stlink/backend.h
include/stlink/chipid.h
include/stlink/commands.h
include/stlink/flash_loader.h
include/stlink/reg.h
src/logging.h
src/md5.h
src/sg.h
src/usb.h
inc/stlink.h
src/backend.h
src/commands.h
src/reg.h
src/st-link-lib/chipid.h
src/st-link-lib/flash_loader.h
src/st-link-lib/logging.h
src/st-link-lib/md5.h
src/st-link-lib/sg.h
src/st-link-lib/usb.h
)

set(STLINK_SOURCE
src/common.c
src/chipid.c
src/flash_loader.c
src/logging.c
src/md5.c
src/sg.c
src/usb.c
src/st-link-lib/chipid.c
src/st-link-lib/flash_loader.c
src/st-link-lib/logging.c
src/st-link-lib/md5.c
src/st-link-lib/sg.c
src/st-link-lib/usb.c
)

if (WIN32 OR MINGW OR MSYS)
include_directories(src/mingw)
set(STLINK_SOURCE "${STLINK_SOURCE};src/mmap.c;src/mingw/mingw.c")
set(STLINK_HEADERS "${STLINK_HEADERS};src/mmap.h;src/mingw/mingw.h")
set(STLINK_SOURCE "${STLINK_SOURCE};src/mmap/mmap.c;src/mingw/mingw.c")
set(STLINK_HEADERS "${STLINK_HEADERS};src/mmap/mmap.h;src/mingw/mingw.h")
endif ()

if (MSVC)
Expand Down Expand Up @@ -221,15 +219,17 @@ install(TARGETS ${STLINK_LIB_STATIC} ARCHIVE DESTINATION ${STLINK_LIBRARY_PATH})
# Build toolset executables
###

set(ST-FLASH_SOURCES src/st-flash/flash.c src/st-flash/flash_opts.c)
set(ST-INFO_SOURCES src/st-info/info.c)
set(ST-UTIL_SOURCES src/st-util/gdb-remote.c src/st-util/gdb-server.c src/st-util/semihosting.c)

if (MSVC)
# Add getopt to sources
set(ST-UTIL_SOURCES "${ST-UTIL_SOURCES};src/getopt/getopt.c")
endif ()

add_executable(st-flash src/tools/flash.c src/tools/flash_opts.c)
add_executable(st-info src/tools/info.c)
add_executable(st-flash ${ST-FLASH_SOURCES})
add_executable(st-info ${ST-INFO_SOURCES})
add_executable(st-util ${ST-UTIL_SOURCES})

if (WIN32 OR APPLE)
Expand Down Expand Up @@ -267,11 +267,7 @@ endif ()
# Additional build tasks
###

# ====
add_subdirectory(include) # contains subordinate CMakeLists for version config and old header includes
### TODO: Clean this up ...
# ====

add_subdirectory(inc) # contains subordinate CMakeLists for version config
add_subdirectory(src/stlink-gui) # contains subordinate CMakeLists to build GUI
add_subdirectory(tests) # contains subordinate CMakeLists to build test executables
add_subdirectory(cmake/packaging) # contains subordinate CMakeLists to build packages
Expand Down
9 changes: 9 additions & 0 deletions inc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
configure_file(
"${PROJECT_SOURCE_DIR}/inc/version.h.in"
"${CMAKE_BINARY_DIR}/inc/version.h"
)

file(GLOB STLINK_HEADERS "src/st-link-lib/*.h" "${CMAKE_BINARY_DIR}/inc/version.h")
install(FILES ${STLINK_HEADERS} DESTINATION ${STLINK_INCLUDE_PATH})
install(FILES ${CMAKE_SOURCE_DIR}/inc/stlink.h DESTINATION ${STLINK_INCLUDE_PATH})
install(FILES ${CMAKE_SOURCE_DIR}/inc/stm32.h DESTINATION ${STLINK_INCLUDE_PATH})
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 0 additions & 9 deletions include/CMakeLists.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#include <sys/stat.h>

#include <stlink.h>
#include "mmap.h"
#include "logging.h"
#include "md5.h"
#include <mmap.h>
#include <logging.h>
#include <md5.h>

#ifndef O_BINARY
#define O_BINARY 0
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/tools/flash.c → src/st-flash/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <sys/types.h>

#include <stlink.h>
#include <flash.h>
#include "flash.h"

static stlink_t *connected_stlink = NULL;

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/tools/flash_opts.c → src/st-flash/flash_opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <stdio.h>
#include <string.h>

#include <flash.h>
#include "flash.h"

static bool starts_with(const char * str, const char * prefix) {
size_t n = strlen(prefix);
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/chipid.c → src/st-link-lib/chipid.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <stlink.h>
#include <chipid.h>
#include "chipid.h"

static const struct stlink_chipid_params devices[] = {
{
Expand Down
File renamed without changes.
Loading

0 comments on commit b9773d0

Please sign in to comment.