Skip to content

Commit 07bf392

Browse files
authored
Boilerplate (#2)
* .gitattributes * .gitignore * .vimrc * settings * chore: project helper scripts * chore: added project markdown files * LICENSE * chore: CMake updates * CI * .vscode/settings.json * .gitattributes * ci * README.md "related projects" * README.md operating-system badge * README.md * chore: harmonize CMake standards and install targets * chore: standardise helper project identity handling * chore: standardize shell-script color output * chore: canonicalised helper scripts * CMake * CMake
1 parent ea2505b commit 07bf392

10 files changed

Lines changed: 299 additions & 95 deletions

File tree

‎.gitattributes‎

Lines changed: 85 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,85 @@
1-
*.c linguist-language=C
2-
*.cmake linguist-vendored
3-
*.cmd linguist-detectable=false
4-
*.cpp linguist-language=C++
5-
*.cxx linguist-language=C++
6-
*.dsp linguist-detectable=false
7-
*.dsw linguist-detectable=false
8-
*.h linguist-language=C
9-
*.hpp linguist-language=C++
10-
*.html linguist-detectable=false
11-
*.hxx linguist-language=C++
12-
*.sh linguist-detectable=false
13-
*.sln linguist-detectable=false
14-
*.vcxproj linguist-detectable=false
15-
*.vimrc linguist-detectable=false
16-
CMakeLists.txt linguist-vendored
17-
makefile linguist-detectable=false
1+
# .gitattributes — C (GitHub-hosted)
2+
#
3+
# Sources: GitHub Docs (line endings), git-scm gitattributes (diff=cpp),
4+
# gitattributes/gitattributes C++.gitattributes + Common.gitattributes,
5+
# github-linguist overrides.
6+
7+
# Default: detect text, normalize to LF in the repository
8+
* text=auto
9+
10+
# --- Source ---
11+
*.c text diff=cpp
12+
*.h text diff=cpp
13+
*.inc text
14+
*.inl text
15+
16+
# --- Build / config ---
17+
*.am text
18+
*.cmake text
19+
*.m4 text
20+
*.mak text
21+
*.mk text
22+
*akefile text
23+
CMakeLists.txt text
24+
configure text eol=lf
25+
configure.ac text
26+
27+
# --- Scripts ---
28+
*.bash text eol=lf
29+
*.bat text eol=crlf
30+
*.cmd text eol=crlf
31+
*.ps1 text eol=crlf
32+
*.sh text eol=lf
33+
*.zsh text eol=lf
34+
35+
# --- Docs / meta ---
36+
*.adoc text
37+
*.markdown text diff=markdown
38+
*.md text diff=markdown
39+
*.txt text
40+
AUTHORS text
41+
CHANGELOG text
42+
CHANGES text
43+
CONTRIBUTING text
44+
COPYING text
45+
LICENSE text
46+
NEWS text
47+
README text
48+
TODO text
49+
.gitattributes text
50+
.gitignore text
51+
52+
# --- Serialisation ---
53+
*.json text
54+
*.toml text
55+
*.xml text
56+
*.yaml text
57+
*.yml text
58+
59+
# --- Compiled / binary artefacts ---
60+
*.a binary
61+
*.dll binary
62+
*.dylib binary
63+
*.exe binary
64+
*.gch binary
65+
*.lib binary
66+
*.o binary
67+
*.obj binary
68+
*.out binary
69+
*.pch binary
70+
*.so binary
71+
72+
# --- Archives / images (common) ---
73+
*.gif binary
74+
*.gz binary
75+
*.ico binary
76+
*.jpeg binary
77+
*.jpg binary
78+
*.png binary
79+
*.tar binary
80+
*.zip binary
81+
82+
# --- GitHub Linguist ---
83+
# Object / build trees if committed (prefer .gitignore; mark if present)
84+
**/build/** linguist-generated
85+
**/cmake-build-*/** linguist-generated

‎.github/workflows/ci.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ on:
44
push:
55
branches:
66
- master
7+
- dev
78
- boilerplate
9+
- idiomatic
10+
- rc1
11+
- rc2
12+
- rc3
813
pull_request:
914

1015
concurrency:

‎.vscode/settings.json‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"editor.tabSize": 4,
66
},
77
"[c]": {
8+
"editor.defaultFormatter": "ms-vscode.cpptools",
9+
"editor.formatOnSave": true,
810
"editor.insertSpaces": true,
911
"editor.rulers": [ 60, 64, 68, 72, 76 ],
1012
"editor.tabSize": 4,
@@ -14,6 +16,8 @@
1416
"editor.tabSize": 4,
1517
},
1618
"[cpp]": {
19+
"editor.defaultFormatter": "ms-vscode.cpptools",
20+
"editor.formatOnSave": true,
1721
"editor.insertSpaces": true,
1822
"editor.rulers": [ 60, 64, 68, 72, 76 ],
1923
"editor.tabSize": 4,
@@ -49,7 +53,17 @@
4953
"editor.insertSpaces": true,
5054
"editor.tabSize": 2,
5155
},
56+
"C_Cpp.autocompleteAddParentheses": true,
57+
"C_Cpp.clang_format_fallbackStyle": "none",
58+
"C_Cpp.clang_format_style": "file",
59+
"C_Cpp.default.cStandard": "c17",
60+
"C_Cpp.default.cppStandard": "c++17",
61+
"C_Cpp.enhancedColorization": "enabled",
62+
"C_Cpp.errorSquiggles": "enabled",
63+
"C_Cpp.formatting": "clangFormat",
64+
"C_Cpp.intelliSenseEngine": "default",
5265
"cmake.configureOnOpen": false,
66+
"debug.allowBreakpointsEverywhere": true,
5367
"editor.detectIndentation": false,
5468
"editor.insertSpaces": false,
5569
"editor.renderWhitespace": "all",
@@ -128,6 +142,7 @@
128142
"numeric": "cpp",
129143
"optional": "cpp",
130144
"ostream": "cpp",
145+
"print": "cpp",
131146
"queue": "cpp",
132147
"random": "cpp",
133148
"ranges": "cpp",

‎CMakeLists.txt‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,16 @@ set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT
5656

5757
# adhere strictly to C and C++ standards plus extensions. These are actually
5858
# useless since we do not compile anything; they merely state our intention.
59-
set(CMAKE_C_STANDARD 17)
59+
if(NOT CMAKE_C_STANDARD)
60+
61+
set(CMAKE_C_STANDARD 17)
62+
endif()
6063
set(CMAKE_C_STANDARD_REQUIRED ON)
6164
set(CMAKE_C_EXTENSIONS ON) # GNU extensions and POSIX standard
62-
set(CMAKE_CXX_STANDARD 17)
65+
if(NOT CMAKE_CXX_STANDARD)
66+
67+
set(CMAKE_CXX_STANDARD 17)
68+
endif()
6369
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6470
set(CMAKE_CXX_EXTENSIONS ON)
6571

@@ -181,11 +187,11 @@ include(GNUInstallDirs)
181187
# ##########################################################
182188
# tool
183189

184-
add_executable(${PROJECT_NAME}
190+
add_executable(${PROJECT_NAME_LOWER}
185191
main.c
186192
)
187193

188-
target_compile_options(${PROJECT_NAME}
194+
target_compile_options(${PROJECT_NAME_LOWER}
189195
PRIVATE
190196
$<$<OR:$<C_COMPILER_ID:Clang>,$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:GNU>>:
191197
-Werror -Wall -Wextra -pedantic
@@ -199,11 +205,11 @@ target_compile_options(${PROJECT_NAME}
199205
>
200206
)
201207

202-
target_link_libraries(${PROJECT_NAME}
208+
target_link_libraries(${PROJECT_NAME_LOWER}
203209
$<$<STREQUAL:${STLSOFT_INCLUDE_DIR},>:STLSoft::STLSoft>
204210
)
205211

206-
install(TARGETS ${PROJECT_NAME}
212+
install(TARGETS ${PROJECT_NAME_LOWER}
207213
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
208214
)
209215

@@ -227,7 +233,7 @@ endif(BUILD_TESTING)
227233
# ##########################################################
228234
# completion
229235

230-
message(NOTICE "Generating CMake build scripts for ${PROJECT_NAME} ${PROJECT_VERSION}, for C${CMAKE_C_STANDARD} C++${CMAKE_CXX_STANDARD}")
236+
message(NOTICE "Generating CMake build scripts for ${PROJECT_NAME} ${PROJECT_VERSION}, for C${CMAKE_C_STANDARD} C++${CMAKE_CXX_STANDARD}, with build type ${CMAKE_BUILD_TYPE}")
231237

232238

233239
# ############################## end of file ############################# #

‎README.md‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Windows CLI that writes messages to the debugger via **OutputDebugString**
44

55

66
![C](https://img.shields.io/badge/C-00599C?style=flat&logo=c&logoColor=white)
7+
![Windows](https://img.shields.io/badge/OS-Windows-0078D6?style=flat&logo=windows&logoColor=white)
78
[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
89
[![GitHub release](https://img.shields.io/github/v/release/sistools/WriteDebugString.svg)](https://github.com/sistools/WriteDebugString/releases/latest)
910
[![Last Commit](https://img.shields.io/github/last-commit/sistools/WriteDebugString)](https://github.com/sistools/WriteDebugString/commits/master)
@@ -75,10 +76,17 @@ Defect reports, feature requests, and pull requests are welcome on [the **WriteD
7576

7677
### Related projects
7778

78-
Other (similar) projects include:
79-
80-
* [**ReadDebugString**](https://github.com/sistools/ReadDebugString)
81-
* [**realpath**](https://github.com/sistools/realpath)
79+
Other **sistools** projects include:
80+
81+
* [**chomp**](https://github.com/sistools/chomp);
82+
* [**errni**](https://github.com/sistools/errni) (errno on all platforms, and also GetLastError codes on Windows);
83+
* [**lnunique**](https://github.com/sistools/lnunique);
84+
* [**lslocales**](https://github.com/sistools/lslocales);
85+
* [**lstrip**](https://github.com/sistools/lstrip);
86+
* [**mksock**](https://github.com/sistools/mksock) (Unix-only);
87+
* [**ReadDebugString**](https://github.com/sistools/ReadDebugString) (Windows-only);
88+
* [**realpath**](https://github.com/sistools/realpath) (Windows-only);
89+
* [**rstrip**](https://github.com/sistools/rstrip);
8290

8391

8492
### License

‎build_cmake.sh‎

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#! /bin/bash
22

33
ScriptPath=$0
4-
Dir=$(cd $(dirname "$ScriptPath"); pwd)
4+
Dir=$(cd "$(dirname "$ScriptPath")" && pwd)
55
Basename=$(basename "$ScriptPath")
6+
67
CMakeDir=${SIS_CMAKE_BUILD_DIR:-$Dir/_build}
78
if [[ -n "$MSYSTEM" ]]; then
89

@@ -13,11 +14,31 @@ else
1314
DefaultMakeCmd=make
1415
fi
1516
MakeCmd=${SIS_CMAKE_MAKE_COMMAND:-${SIS_CMAKE_COMMAND:-$DefaultMakeCmd}}
17+
ProjectNameFile="$Dir/.sis/project_name.txt"
18+
ProjectName=$(tr -d '[:space:]' < "$ProjectNameFile")
1619

1720
IgnoreRemainingFlagsAndOptions=0
1821
Targets=()
1922

2023

24+
# ##########################################################
25+
# colours
26+
27+
if command -v tput > /dev/null; then
28+
29+
SisClr_Blue=${FG_BLUE:-$(tput setaf 4)}
30+
SisClr_Red=${FG_RED:-$(tput setaf 1)}
31+
SisClr_Bold=${FD_BOLD:-$(tput bold)}
32+
SisClr_None=${FD_NONE:-$(tput sgr0)}
33+
else
34+
35+
SisClr_Blue=
36+
SisClr_Red=
37+
SisClr_Bold=
38+
SisClr_None=
39+
fi
40+
41+
2142
# ##########################################################
2243
# functions
2344

@@ -77,7 +98,7 @@ EOF
7798
;;
7899
*)
79100

80-
>&2 echo "$ScriptPath: unrecognised argument '$1'; use --help for usage"
101+
>&2 echo "$ScriptPath: ${SisClr_Red}${SisClr_Bold}unrecognised argument '$1'${SisClr_None}; use --help for usage"
81102

82103
exit 1
83104
;;
@@ -92,7 +113,7 @@ done
92113

93114
if [ ! -d "$CMakeDir" ]; then
94115

95-
>&2 echo "$ScriptPath: CMake build directory '$CMakeDir' not found so nothing to do; use script 'prepare_cmake.sh' if you wish to prepare CMake artefacts"
116+
>&2 echo "$ScriptPath: ${SisClr_Red}${SisClr_Bold}CMake build directory '$CMakeDir' not found${SisClr_None} so nothing to do; use script 'prepare_cmake.sh' if you wish to prepare CMake artefacts"
96117

97118
exit 1
98119
else
@@ -101,7 +122,7 @@ else
101122

102123
if [ ! -f "$CMakeDir/Makefile" ]; then
103124

104-
>&2 echo "$ScriptPath: CMake build directory '$CMakeDir' does not contain expected file 'Makefile', so a clean cannot be performed. It is recommended that you remove all CMake artefacts using script 'remove_cmake_artefacts.sh' followed by regeneration via 'prepare_cmake.sh'"
125+
>&2 echo "$ScriptPath: ${SisClr_Red}${SisClr_Bold}CMake build directory '$CMakeDir' does not contain expected file 'Makefile'${SisClr_None}, so a clean cannot be performed. It is recommended that you remove all CMake artefacts using script 'remove_cmake_artefacts.sh' followed by regeneration via 'prepare_cmake.sh'"
105126

106127
cd ->/dev/null
107128

@@ -110,10 +131,10 @@ else
110131

111132
if [ -z "$Targets" ]; then
112133

113-
echo "Executing build (via command \`$MakeCmd\`)"
134+
echo "Executing build of ${SisClr_Blue}${SisClr_Bold}${ProjectName}${SisClr_None} (via command \`${SisClr_Blue}${SisClr_Bold}$MakeCmd${SisClr_None}\`)"
114135
else
115136

116-
echo "Executing build (via command \`$MakeCmd\`) with specific target(s) $(join_by , "${Targets[@]}")"
137+
echo "Executing build of ${SisClr_Blue}${SisClr_Bold}${ProjectName}${SisClr_None} (via command \`${SisClr_Blue}${SisClr_Bold}$MakeCmd${SisClr_None}\`) with specific target(s) $(join_by , "${Targets[@]}")"
117138
fi
118139

119140
$MakeCmd ${Targets[*]}
@@ -127,4 +148,3 @@ fi
127148

128149

129150
# ############################## end of file ############################# #
130-

0 commit comments

Comments
 (0)