Update Containerfiles, start CLI tool.

+ Containerfiles: default to using g++.  Most of the dev machines aren't
  working with clang yet; until this is sorted out, they'll need to use
  g++.
+ Add script to determine if the git-tree is tagged.
+ Add basic CMake skeleton and start CLI tool.
This commit is contained in:
Kyle Isom 2023-10-18 21:05:56 -07:00
parent f7c146b3a0
commit 19fa0c147d
13 changed files with 282 additions and 4 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
build
cmake-build-*
TAGS
tags
core*

52
CMakeLists.txt Normal file
View File

@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 3.25)
project(sc3dev
VERSION 0.0.1
LANGUAGES CXX
HOMEPAGE_URL "https://git.wntrmute.dev/sc/sc3dev"
DESCRIPTION "")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILES ON)
find_package(scsl REQUIRED)
include(CTest)
enable_testing()
# compile options:
# -Wall Default to all errors.
# -Wextra And a few extra.
# -Werror And require them to be fixed to build.
# -Wno-unused-function This is a library. Not every function is used here.
# -Wno-unused-parameter Some functions have parameters defined for compatibility,
# and aren't used in the implementation.
add_compile_options(
"-static"
"-Wall"
"-Wextra"
"-Werror"
"-Wno-unused-function"
"-Wno-unused-parameter"
"-g"
"$<$<CONFIG:RELEASE>:-O2>"
)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options("-stdlib=libc++")
else ()
# nothing special for gcc at the moment
endif ()
set(HEADERS)
set(SOURCES)
include_directories(SYSTEM include)
### THE REAL TARGETS ###
add_executable(${PROJECT_NAME}-packager src/packager.cc ${SOURCES} ${HEADERS})
target_link_libraries(${PROJECT_NAME}-packager ${SCSL_LIBRARIES})
### INCLUDES ###
#include(cmake/docs.cmake)
#include(cmake/install.cmake)
#include(cmake/packaging.cmake)

View File

@ -1,9 +1,7 @@
FROM docker.io/library/ubuntu:jammy
LABEL maintainer="K. Isom <kyle@imap.cc>"
ARG DEBIAN_FRONTEND=noninteractive
ARG AUTOMATED_MODE=yes
ARG USE_CLANG=yes
ENV TZ=America/Los_Angeles
# prepare build

View File

@ -1,7 +1,6 @@
FROM docker.io/library/alpine:3.18
LABEL maintainer="K. Isom <kyle@imap.cc>"
ARG AUTOMATED_MODE=yes
ARG USE_CLANG=yes
ENV TZ=America/Los_Angeles
# prepare build

View File

@ -2,7 +2,6 @@ FROM docker.io/library/debian:12.2
LABEL maintainer="K. Isom <kyle@imap.cc>"
ARG DEBIAN_FRONTEND=noninteractive
ARG AUTOMATED_MODE=yes
ARG USE_CLANG=yes
ENV TZ=America/Los_Angeles
# prepare build

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 K. Isom <coder@kyleisom.net>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@ -16,6 +16,7 @@ used across shimmering clarity projects.
systems.
- `install-development-tools.sh` installs the tools needed to build and
package projects.
- `is-current-tag.sh` determines if the current commit is tagged.
- `validate-container.sh` attempts to clone a few repos and build/test
them, validating that the image contains the correct tools to build
them.

53
cmake/docs.cmake Normal file
View File

@ -0,0 +1,53 @@
# Doxygen support for scsl.
set(DISABLE_DOXYGEN OFF CACHE BOOL "Don't use Doxygen for documentation.")
set(DISABLE_SCDOC OFF CACHE BOOL "Don't use scdoc to generate man pages.")
add_custom_target(manpages)
### Generate man pages from markdown ###
# md2man uses scdoc to produce a man page from a markdown document.
if (LINUX and not DISABLE_SCDOC)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man
DESTINATION share)
macro(md2man source)
block()
set(SOURCE_MANPAGE)
set(SOURCE_SECTION)
string(REGEX REPLACE "^.+/([^/]+)\.md$" "\\1" SOURCE_MANPAGE ${source})
string(REGEX REPLACE "^.+/[^/]+\.([0-9])\.md$" "\\1" SOURCE_SECTION ${source})
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man/man${SOURCE_SECTION})
configure_file(${source} ${SOURCE_MANPAGE}.scdoc)
add_custom_command(TARGET manpages
COMMAND scdoc < ${SOURCE_MANPAGE}.scdoc > man/man${SOURCE_SECTION}/${SOURCE_MANPAGE})
endblock()
endmacro()
md2man(docs/lib${PROJECT_NAME}.7.md)
endif ()
### Build documentation with Doxygen ###
if (not DISABLE_DOXYGEN)
find_package(Doxygen)
if (${DOXYGEN_FOUND})
# prefer scdocs for manpages.
set(DOXYGEN_GENERATE_MAN NO)
set(DOXYGEN_GENERATE_LATEX YES)
set(DOXYGEN_EXTRACT_ALL YES)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE "docs/mainpage.md")
message(STATUS "Doxygen found, building docs.")
doxygen_add_docs(${PROJECT_NAME}_docs
${HEADER_FILES}
${SOURCE_FILES}
USE_STAMP_FILE)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_docs)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
${CMAKE_CURRENT_BINARY_DIR}/latex
DESTINATION share/doc/${PROJECT_NAME}/doxygen)
add_dependencies(${PROJECT_NAME}_docs manpages)
endif () # DOXYGEN_FOUND?
endif () # DISABLE_DOXYGEN?

27
cmake/install.cmake Normal file
View File

@ -0,0 +1,27 @@
### Install ###
include(CMakePackageConfigHelpers)
### library packaging for CMake and pkgconfig to find built targets.
write_basic_package_version_file(
${PROJECT_NAME}Config.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY SameMajorVersion
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
### set up installation targets.
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib)
install(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
DESTINATION lib/pkgconfig)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION share/${PROJECT_CMAKE_CONFIG_NAME}/cmake)

39
cmake/packaging.cmake Normal file
View File

@ -0,0 +1,39 @@
### Packaging ###
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_VENDOR "K. Isom")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_DESCRIPTION})
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_FILE_NAME
${PROJECT_NAME}-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_ARCH}${CMAKE_HOST_SYSTEM_PROCESSOR})
# Debian settings
set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_VENDOR})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CPACK_PACKAGE_DESCRIPTION})
set(CPACK_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
set(CPACK_PACKAGE_DEPENDS)
set(CPACK_DEBIAN_PACKAGE_SECTION devel)
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON)
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
if (LINUX)
set(CPACK_GENERATOR "DEB;STGZ;TGZ")
elseif (APPLE)
set(CPACK_GENERATOR "productbuild")
elseif (MSVC OR MSYS OR MINGW)
set(CPACK_GENERATOR "NSIS;ZIP")
else ()
set(CPACK_GENERATOR "ZIP")
endif ()
set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
set(CPACK_SOURCE_IGNORE_FILES
/.git
/.*build.*)
include (CPack)
add_custom_target(package_docs DEPENDS ${PROJECT_NAME}_docs package package_source)

13
cmake/testing.cmake Normal file
View File

@ -0,0 +1,13 @@
### TESTS ###
set(TEST_SOURCES) # common test source code
macro(generate_test name)
add_executable(test_${name} test_${name}.cc ${TEST_SOURCES} ${ARGN})
target_link_libraries(${name} ${PROJECT_NAME})
add_test(${name} ${name})
endmacro()
### ADD TESTS HERE ###
generate_test(${PROJECT_NAME}_test)

28
is-current-tag.sh Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env sh
#########################################################################
# @author : kyle (kyle@imap.cc) #
# @file : is-current-tag.sh #
# @created : Wednesday Oct 18, 2023 18:36:55 PDT #
# #
# @description : determines if the current git commit is a tagged #
# commit. #
# #
# This is used for determining whether this is a current release, and #
# build artifacts should be generated. #
#########################################################################
if [ ! -z "$(git status -s)" ]
then
echo "[-] work tree is dirty - not proceeding."
exit 0
fi
if [ -z "$(git tag --contains $(git rev-parse --verify HEAD))" ]
then
echo "[-] current HEAD isn't tagged."
exit 0
fi
# we are in a tagged commit

41
src/packager.cc Normal file
View File

@ -0,0 +1,41 @@
///
/// \file packager.cc
/// \author K. Isom <kyle@imap.cc>
/// \date 2023-10-18
/// \brief Packaging tools for shimmering-clarity.
///
#include <iostream>
#include <string>
#include <scsl/Commander.h>
#include <scsl/Flag.h>
static struct {
scsl::Flags *flags;
std::string owner;
std::string distribution;
std::string component;
std::string password;
std::string username;
std::string version;
} config;
int
main(int argc, char *argv[])
{
config.flags = new scsl::Flags("sc3dev-packager", "package tooling for shimmering clarity");
config.flags->Register("--component", "main", "Debian package component");
config.flags->Register("--distribution", "ubuntu", "Debian package distribution");
config.flags->Register("--owner", "sc", "package repository owner");
auto status = config.flags->Parse(argc, argv);
if (status != scsl::Flags::ParseStatus::OK) {
std::cerr << "failed to parse flags: "
<< scsl::Flags::ParseStatusToString(status)
<< "\n";
exit(1);
}
}