diff --git a/.gitignore b/.gitignore index 2e791b6..159f7e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,24 @@ build tmp .vscode/ -.idea/ \ No newline at end of file +.idea/ + +### CMake ### +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +### CMake Patch ### +# External projects +*-prefix/ +build.ninja + +.ninja_log diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..196a479 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.16) + +project(ci-scripts LANGUAGES NONE) + +set(TOOLS + "kitware/cmake" + "mozilla/sccache" + "muesli/duf" + ) + +foreach (item IN ITEMS ${TOOLS}) + string(REPLACE "/" ";" RLIST ${item}) + list(GET RLIST 1 TOOL) + add_custom_target( + ${TOOL} + COMMAND ${CMAKE_COMMAND} -DGH_REPO=${item} -P ${CMAKE_SOURCE_DIR}/update.cmake + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + VERBATIM + ) + list(APPEND all_tools ${TOOL}) +endforeach () + +add_custom_target( + update_all ALL + COMMENT "Update all tools" + DEPENDS ${all_tools} + VERBATIM +) \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 8753824..0000000 --- a/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -all : cmake sccache lazygit - -cmake: - cmake -DTOOL=cmake -DREPO=kitware -P update.cmake - -sccache: - cmake -DTOOL=sccache -DREPO=mozilla -P update.cmake - -lazygit: - cmake -DTOOL=lazygit -DREPO=jesseduffield -P update.cmake \ No newline at end of file diff --git a/install-duf.sh b/install-duf.sh new file mode 100644 index 0000000..68b16d4 --- /dev/null +++ b/install-duf.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -eu + +wget "https://github.com/muesli/duf/releases/download/v0.6.2/duf_0.6.2_linux_amd64.deb" -nv -O /tmp/duf.deb +dpkg -i /tmp/duf.deb diff --git a/templates/install-duf.sh.in b/templates/install-duf.sh.in new file mode 100644 index 0000000..3fd08ee --- /dev/null +++ b/templates/install-duf.sh.in @@ -0,0 +1,5 @@ +#!/bin/bash +set -eu + +wget "https://github.com/muesli/duf/releases/download/v@VERSION@/duf_@VERSION@_linux_amd64.deb" -nv -O /tmp/duf.deb +dpkg -i /tmp/duf.deb \ No newline at end of file diff --git a/update.cmake b/update.cmake index 8713ddc..746c5b9 100644 --- a/update.cmake +++ b/update.cmake @@ -1,6 +1,15 @@ -message("TOOL \"${TOOL}\" REPO \"${REPO}\"") +macro(mgs text) + execute_process(COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --green --bold ${text}) +endmacro() -SET(URL "https://api.github.com/repos/${REPO}/${TOOL}/releases/latest") + +string(REPLACE "/" ";" RLIST "${GH_REPO}") +list(GET RLIST 0 OWNER) +list(GET RLIST 1 TOOL) + +mgs("TOOL \"${TOOL}\" OWNER \"${OWNER}\"") + +SET(URL "https://api.github.com/repos/${OWNER}/${TOOL}/releases/latest") execute_process(COMMAND curl -s -L ${URL} OUTPUT_VARIABLE VERSION_JSON) string(JSON VERSION_DIRTY GET ${VERSION_JSON} tag_name) @@ -8,5 +17,5 @@ string(JSON VERSION_DIRTY GET ${VERSION_JSON} tag_name) string(REGEX REPLACE [^0-9\\.] "" VERSION "${VERSION_DIRTY}") string(REPLACE "." "_" VERSION_UNDERSCORE ${VERSION}) -message("Latest VERSION ${VERSION}") +mgs("Latest VERSION ${VERSION}") configure_file("${CMAKE_CURRENT_LIST_DIR}/templates/install-${TOOL}.sh.in" "${CMAKE_CURRENT_LIST_DIR}/install-${TOOL}.sh" @ONLY) \ No newline at end of file