diff --git a/.drone.yml b/.drone.yml index e450f13..6cbd32c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -19,7 +19,7 @@ pipeline: - apt-get update -q - apt-get install -qy -t xenial g++-5 - apt-get install -qy cmake pkg-config - - apt-get install -qy libconfig++-dev libxdg-basedir-dev + - apt-get install -qy libconfig++-dev libxdg-basedir-dev asciidoc - rm -rf build && mkdir -p build && cd build - cmake -DCMAKE_INSTALL_PREFIX=/usr .. - make VERBOSE=1 @@ -37,7 +37,7 @@ pipeline: - rm /etc/apt/apt.conf.d/docker-clean - apt-get update -q - apt-get install -qy g++-6 cmake pkg-config - - apt-get install -qy libconfig++-dev libxdg-basedir-dev + - apt-get install -qy libconfig++-dev libxdg-basedir-dev asciidoc - apt-get install -qy dpkg-dev d-shlibs rpm file wget - rm -rf build && mkdir -p build && cd build - cmake -DCMAKE_INSTALL_PREFIX=/usr .. @@ -66,7 +66,7 @@ pipeline: - apt-get update -q - apt-get install -qy -t xenial g++-7 - apt-get install -qy cmake pkg-config - - apt-get install -qy libconfig++-dev libxdg-basedir-dev + - apt-get install -qy libconfig++-dev libxdg-basedir-dev asciidoc - rm -rf build && mkdir -p build && cd build - cmake -DCMAKE_INSTALL_PREFIX=/usr .. - make VERBOSE=1 @@ -93,7 +93,7 @@ pipeline: - apt-get update -q - apt-get install -qy -t xenial g++-8 - apt-get install -qy cmake pkg-config - - apt-get install -qy libconfig++-dev libxdg-basedir-dev + - apt-get install -qy libconfig++-dev libxdg-basedir-dev asciidoc - rm -rf build && mkdir -p build && cd build - cmake -DCMAKE_INSTALL_PREFIX=/usr .. - make VERBOSE=1 @@ -113,7 +113,7 @@ pipeline: - rm /etc/apt/apt.conf.d/docker-clean - apt-get update -q - apt-get install -qy clang cmake pkg-config - - apt-get install -qy libconfig++-dev libxdg-basedir-dev + - apt-get install -qy libconfig++-dev libxdg-basedir-dev asciidoc - rm -rf build && mkdir -p build && cd build - cmake -DCMAKE_INSTALL_PREFIX=/usr .. - make VERBOSE=1 @@ -136,7 +136,7 @@ pipeline: - apt-get update -q - apt-get install -qy -t stretch-backports clang-5.0 - apt-get install -qy cmake pkg-config - - apt-get install -qy libconfig++-dev libxdg-basedir-dev + - apt-get install -qy libconfig++-dev libxdg-basedir-dev asciidoc - rm -rf build && mkdir -p build && cd build - cmake -DCMAKE_INSTALL_PREFIX=/usr .. - make VERBOSE=1 @@ -159,7 +159,7 @@ pipeline: - apt-get update -q - apt-get install -qy -t stretch-backports clang-6.0 - apt-get install -qy cmake pkg-config - - apt-get install -qy libconfig++-dev libxdg-basedir-dev + - apt-get install -qy libconfig++-dev libxdg-basedir-dev asciidoc - rm -rf build && mkdir -p build && cd build - cmake -DCMAKE_INSTALL_PREFIX=/usr .. - make VERBOSE=1 diff --git a/CMakeLists.txt b/CMakeLists.txt index ef753cd..e14fceb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_FLAGS_DEBUG - "${CMAKE_CXX_FLAGS_DEBUG} -Wall -pedantic -Wextra -g -Og -fno-omit-frame-pointer") + "${CMAKE_CXX_FLAGS_DEBUG} -Wpedantic -Wall -Wextra -g -Og -fno-omit-frame-pointer") include_directories(${PROJECT_BINARY_DIR}) include_directories(${LIBXDG_BASEDIR_INCLUDE_DIRS}) @@ -36,3 +36,13 @@ target_link_libraries(${CMAKE_PROJECT_NAME} "-lstdc++fs") install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES README.md DESTINATION ${CMAKE_INSTALL_DOCDIR}) + +add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.1" + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" + DEPENDS "${CMAKE_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.1.adoc" + COMMAND ${CMAKE_SOURCE_DIR}/build_manpage.sh + ARGS ${PROJECT_VERSION}) +add_custom_target(run ALL + DEPENDS "${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.1") +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.1 + DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) diff --git a/README.md b/README.md index 046dfad..428dd0c 100644 --- a/README.md +++ b/README.md @@ -7,40 +7,7 @@ newer than the source file, the compilation is skipped. ## Usage -Use `#!/usr/bin/env compilescript` as shebang and write the compiler arguments -in the second line with the prefix: `//compilescript:`. - -You can delete old cache files with `--cleanup`. - -### Example - -```C++ -#!/usr/bin/env compilescript -//compilescript: -Wall -pedantic -Wextra - -#include - -using std::cout; - -int main(int argc, char *argv[]) -{ - cout << "Hello world!\n"; - cout << argv[1] << '\n'; -} -``` - -## Configuration - -The configuration file is in `${XDG_CONFIG_HOME}/compilescript.cfg`. It will be -generated on first run. - -### Example config - -```CFG -compiler = "g++"; -clean_after_hours = 720; -cache_dir = "/home/user/.cache/compilescript"; -``` +Have a look at the [manpage](https://schlomp.space/tastytea/compilescript/src/branch/master/compilescript.1.adoc). ## Install diff --git a/build_manpage.sh b/build_manpage.sh new file mode 100755 index 0000000..fcf5497 --- /dev/null +++ b/build_manpage.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +name="compilescript" + +if [ -n "${1}" ]; then + dir="$(dirname ${0})" + cp -vf "${dir}/${name}.1.adoc" . + sed -Ei "s/(Revision: +)[0-9]+\.[0-9]\.[0-9]/\1${1}/" "${name}.1.adoc" + a2x --doctype manpage --format manpage --no-xmllint "${name}.1.adoc" +else + echo "usage: ${0} VERSION" >&2 +fi diff --git a/compilescript.1.adoc b/compilescript.1.adoc new file mode 100644 index 0000000..b10f179 --- /dev/null +++ b/compilescript.1.adoc @@ -0,0 +1,79 @@ += compilescript(1) +:Author: tastytea +:Email: tastytea@tastytea.de +:Date: 2019-01-25 +:Revision: 0.0.0 +:man source: compilescript +:man version: {revision} +:man manual: General Commands Manual + +== NAME + +compilescript - allows you to execute files from compiled languages as scripts. + +== SYNOPSIS + +*compilescript* [_file_|_--cleanup_] [_arguments_] + +== DESCRIPTION + +compilescript allows you to execute files from compiled languages as scripts. +By default it uses g++. + +It compiles the source file, stores the binary in +`${XDG_CACHE_HOME}/compilescript/` and executes it. If the binary in cache is +newer than the source file, the compilation is skipped. + +Use `#!/usr/bin/env compilescript` as shebang and write the compiler arguments +in the second line with the prefix: `//compilescript:`. + +The configuration file is in `${XDG_CONFIG_HOME}/compilescript.cfg`. It will be +generated on first run. + +== OPTIONS + +[format="csv",frame="none",grid="none",cols="2"] +|====== +*--cleanup*,Delete old cache files. +|====== + +== EXAMPLE + +=== Example script + +[source,cpp] +---- +#!/usr/bin/env compilescript +//compilescript: -Wall -pedantic -Wextra + +#include + +using std::cout; + +int main(int argc, char *argv[]) +{ + cout << "Hello world!\n"; + cout << argv[1] << '\n'; +} +---- + +=== Example config + +[source,conf] +---- +compiler = "g++"; +clean_after_hours = 720; +cache_dir = "/home/user/.cache/compilescript"; +---- + +== FILES + +* Configuration file: `${XDG_CONFIG_HOME}/compilescript.cfg` +* Cache: `${XDG_CACHE_HOME}/compilescript/` + +`${XDG_CONFIG_HOME}` is usually `~/.config` and `${XDG_DATA_HOME}` is usually +`~/.cache` + +== REPORTING BUGS + +Bugtracker: https://schlomp.space/tastytea/compilescript/issues