Skip to content

Commit 0a0e494

Browse files
authored
Merge pull request #45 from saxbophone/develop
v0.11.0: New CLI
2 parents 8798431 + dbf19df commit 0a0e494

File tree

13 files changed

+419
-393
lines changed

13 files changed

+419
-393
lines changed

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
*.hex
3030
# Custom named executables
3131
sxp_test
32-
sxp_prepare
33-
sxp_generate
34-
sxp_render
32+
sxp
3533

3634
# Debug files
3735
*.dSYM/
@@ -41,5 +39,6 @@ CMakeCache.txt
4139
CMakeFiles/
4240
Testing/
4341
Makefile
44-
*.cmake
42+
cmake_install.cmake
43+
CTestTestfile.cmake
4544
install_manifest.txt

CMakeLists.txt

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
cmake_minimum_required(VERSION 3.0)
33
enable_language(C CXX)
44

5-
project(saxbospiral VERSION 0.10.0 LANGUAGES C)
5+
project(saxbospiral VERSION 0.11.0 LANGUAGES C)
66
set(CMAKE_C_STANDARD 99)
77
set(CMAKE_C_STANDARD_REQUIRED ON)
88
set(
@@ -36,8 +36,15 @@ if(NOT CMAKE_BUILD_TYPE EQUAL CMAKE_C_FLAGS_RELEASE)
3636
enable_c_compiler_flag_if_supported("-Werror")
3737
endif()
3838

39+
# dependencies
40+
# add custom dependencies directory
41+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
42+
# libpng
3943
find_package(PNG REQUIRED)
4044
include_directories(${PNG_INCLUDE_DIR})
45+
# Argtable
46+
find_package(Argtable REQUIRED)
47+
include_directories(${ARGTABLE_INCLUDE_DIR})
4148

4249
# C source files
4350
file(
@@ -55,14 +62,10 @@ add_library(saxbospiral ${LIB_SAXBOSPIRAL_SOURCES})
5562
# Link libsaxbospiral with libpng so we get libpng symbols
5663
target_link_libraries(saxbospiral ${PNG_LIBRARY})
5764

58-
add_executable(sxp_prepare prepare.c)
59-
add_executable(sxp_generate generate.c)
60-
add_executable(sxp_render render.c)
65+
add_executable(sxp sxp.c)
6166
add_executable(sxp_test tests.c)
6267

63-
target_link_libraries(sxp_prepare saxbospiral ${PNG_LIBRARY})
64-
target_link_libraries(sxp_generate saxbospiral ${PNG_LIBRARY})
65-
target_link_libraries(sxp_render saxbospiral ${PNG_LIBRARY})
68+
target_link_libraries(sxp saxbospiral ${PNG_LIBRARY} ${ARGTABLE_LIBRARY})
6669
target_link_libraries(sxp_test saxbospiral ${PNG_LIBRARY})
6770

6871
install(
@@ -82,13 +85,7 @@ install(
8285
DESTINATION include/saxbospiral/render_backends
8386
)
8487

85-
install(
86-
PROGRAMS
87-
sxp_prepare
88-
sxp_generate
89-
sxp_render
90-
DESTINATION bin
91-
)
88+
install(PROGRAMS sxp DESTINATION bin)
9289

9390
enable_testing()
9491
add_test(unit_tests sxp_test)
@@ -98,12 +95,12 @@ find_program(COMMAND_INTERPRETER bash)
9895
if(COMMAND_INTERPRETER)
9996
add_test(
10097
NAME func_test COMMAND ${COMMAND_INTERPRETER}
101-
# each script needs to know the path to each executable it runs
102-
"func_test.sh" sxp_prepare sxp_generate sxp_render "saxbospiral ${SAXBOSPIRAL_VERSION_STRING}"
98+
# each script needs to know the path to the sxp cli executable
99+
"func_test.sh" sxp "saxbospiral ${SAXBOSPIRAL_VERSION_STRING}"
103100
)
104101
add_custom_target(
105102
build_logo ${COMMAND_INTERPRETER}
106-
"build_logo.sh" sxp_prepare sxp_generate sxp_render "saxbospiral.png" "saxbospiral ${SAXBOSPIRAL_VERSION_STRING}"
103+
"build_logo.sh" sxp "saxbospiral.png" "saxbospiral ${SAXBOSPIRAL_VERSION_STRING}"
107104
)
108105
else()
109106
# warn about skipping of functional test script

build_logo.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#!/bin/bash
22
#
33
# Script for updating the project logo
4-
# The paths of the prepare, generate and render commands are
5-
# passed as the first 3 arguments. The 4th argument is the
6-
# file to write the PNG output to and the 5th is the message
7-
# to use for the logo data (of format "saxbospiral vX.Y.Z")
4+
# The first argument is the path to the sxp cli program.
5+
# The second argument is the file to write the PNG output to.
6+
# The third is the message to use for the logo data
7+
# (of format "saxbospiral vX.Y.Z").
88
#
99
echo "Generating logo";
10-
echo -n "$5" > temp.hex && \
11-
./"$1" temp.hex temp.sxp && \
12-
./"$2" temp.sxp && \
13-
./"$3" temp.sxp "$4" && \
10+
echo -n "$3" > temp.hex && \
11+
./"$1" -pg -i temp.hex -o temp.sxp && \
12+
./"$1" -r -i temp.sxp -o "$2"
1413
rm temp.hex temp.sxp;

cmake/Modules/FindArgtable.cmake

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# https://raw.githubusercontent.com/cinemast/libjson-rpc-cpp/master/cmake/FindArgtable.cmake
2+
# - Try to find ARGTABLE
3+
# Once done this will define
4+
#
5+
# ARGTABLE_FOUND - system has ARGTABLE
6+
# ARGTABLE_INCLUDE_DIRS - the ARGTABLE include directory
7+
# ARGTABLE_LIBRARIES - Link these to use ARGTABLE
8+
9+
find_path(
10+
ARGTABLE_INCLUDE_DIR
11+
NAMES argtable2.h
12+
DOC "argtable include dir"
13+
)
14+
15+
find_library(
16+
ARGTABLE_LIBRARY
17+
NAMES argtable2
18+
DOC "argtable library"
19+
)
20+
21+
set(ARGTABLE_INCLUDE_DIRS ${ARGTABLE_INCLUDE_DIR})
22+
set(ARGTABLE_LIBRARIES ${ARGTABLE_LIBRARY})
23+
24+
# debug library on windows
25+
# same naming convention as in qt (appending debug library with d)
26+
# boost is using the same "hack" as us with "optimized" and "debug"
27+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
28+
find_library(
29+
ARGTABLE_LIBRARY_DEBUG
30+
NAMES argtable2d
31+
DOC "argtable debug library"
32+
)
33+
34+
set(ARGTABLE_LIBRARIES optimized ${ARGTABLE_LIBRARIES} debug ${ARGTABLE_LIBRARY_DEBUG})
35+
36+
endif()
37+
38+
# handle the QUIETLY and REQUIRED arguments and set JSONCPP_FOUND to TRUE
39+
# if all listed variables are TRUE, hide their existence from configuration view
40+
include(FindPackageHandleStandardArgs)
41+
find_package_handle_standard_args(
42+
argtable DEFAULT_MSG ARGTABLE_INCLUDE_DIR ARGTABLE_LIBRARY
43+
)
44+
mark_as_advanced(ARGTABLE_INCLUDE_DIR ARGTABLE_LIBRARY)

func_test.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
#
33
# Functional test script.
44
# Generates a new logo and compares with the current one.
5-
# The paths of the prepare, generate and render commands are
6-
# passed as the first 3 arguments. The 4th argument is the
7-
# message to use for the file (see build_logo.sh)
5+
# The first argument is the path to the sxp cli program.
6+
# The second argument is the message to use for the file (see build_logo.sh)
87
#
9-
./build_logo.sh "$1" "$2" "$3" "test_saxbospiral.png" "$4" && \
8+
./build_logo.sh "$1" "test_saxbospiral.png" "$2" && \
109
diff "saxbospiral.png" "test_saxbospiral.png" && \
1110
rm "test_saxbospiral.png";

generate.c

Lines changed: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)