From 6bf253da76797a3e1f654b572ffb7e336aaf8143 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Sun, 13 Nov 2022 19:32:15 -0800 Subject: [PATCH 1/6] fix: dev: update version hdr, add version arg, allow git version str * add version script to tox build Signed-off-by: Stephen L Arnold --- cccc/cccc_ver.h | 6 +++--- cccc/ccccmain.cc | 29 ++++++++++++++++++++++------- release.sh | 5 ++++- tox.ini | 2 ++ 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/cccc/cccc_ver.h b/cccc/cccc_ver.h index 367dc40..2d39e9d 100644 --- a/cccc/cccc_ver.h +++ b/cccc/cccc_ver.h @@ -1,3 +1,3 @@ -// This version built on kepler at 20210219-220832 -#define CCCC_VERSION 3.1.6 -#define CCCC_VERSION_STRING "3.1.6" +// This version built on lorentz at 20221113-185650 +#define CCCC_VERSION 3.2.0 +#define CCCC_VERSION_STRING "3.2.0" diff --git a/cccc/ccccmain.cc b/cccc/ccccmain.cc index c2c5098..ff0c260 100644 --- a/cccc/ccccmain.cc +++ b/cccc/ccccmain.cc @@ -44,6 +44,12 @@ #include "ALexer.h" #endif +#if defined(VERSION_FORMAT_DEV) +#define VERSION_INFO CCCC_VERSION_DEV +#else +#define VERSION_INFO CCCC_VERSION_STRING +#endif + #define NEW_PAGE "\f\n" CCCC_Project *prj=NULL; @@ -157,6 +163,11 @@ void Main::HandleArgs(int argc, char **argv) PrintUsage(cout); exit(0); } + else if(next_arg=="--version") + { + version(argv[0]); + exit(0); + } else { // the options below this point are all of the form --opt=val, @@ -603,20 +614,22 @@ void Main::PrintCredits(ostream& os) { // the principal purpose of the constructor is to set up the // two lots of boilerplate text that this class requires - string version_string="Version "; - version_string.append(CCCC_VERSION_STRING); + string version_string="CCCC version "; + version_string.append(VERSION_INFO); const char *credit_strings[] = { "CCCC - a code counter for C and C++", "===================================", "", - "A program to analyse C and C++ source code and report on", - "some simple software metrics", version_string.c_str(), - "Copyright Tim Littlefair, 1995, 1996, 1997, 1998, 1999, 2000", - "with contributions from Bill McLean, Herman Hueni, Lynn Wilson ", - "Peter Bell, Thomas Hieber and Kenneth H. Cox.", + "", + "A program to analyse C and C++ source code and report on", + "some simple software metrics.", + "", + "Copyright Tim Littlefair, 1995, 1996, 1997, 1998, 1999, 2000, 2022", + "with contributions from Bill McLean, Herman Hueni, Lynn Wilson ", + "Peter Bell, Thomas Hieber, Kenneth H. Cox, and Stephen Arnold.", "", "The development of this program was heavily dependent on", "the Purdue Compiler Construction Tool Set (PCCTS) ", @@ -664,6 +677,8 @@ void Main::DescribeOutput() } } +void version(const char *prog) { std::cout << VERSION_INFO << '\n'; } + /* ** the usage message is printed on cerr if unexpected options are found, ** and on cout if option --help is found. diff --git a/release.sh b/release.sh index 784118a..46ba71a 100755 --- a/release.sh +++ b/release.sh @@ -16,9 +16,12 @@ if [[ $1 == "--version" ]]; then elif [[ -n $VERSION ]]; then RELEASE_VERSION="${VERSION}" else - RELEASE_VERSION=$(git describe --tags) + RELEASE_VERSION=$(git describe --tags | cut -d- -f1) fi +RELEASE_VERSION_GIT=$(git describe --tags --dirty --always) + echo "// This version built on ${UNAME_N} at ${DATE}" > cccc/cccc_ver.h echo "#define CCCC_VERSION ${RELEASE_VERSION}" >> cccc/cccc_ver.h echo "#define CCCC_VERSION_STRING \"${RELEASE_VERSION}\"" >> cccc/cccc_ver.h +echo "#define CCCC_VERSION_DEV \"${RELEASE_VERSION_GIT}\"" >> cccc/cccc_ver.h diff --git a/tox.ini b/tox.ini index 78f59fc..90a3182 100644 --- a/tox.ini +++ b/tox.ini @@ -16,6 +16,7 @@ setenv = CXX = {env:CXX:g++} CCC = {env:CXX:g++} LD = {env:CXX:g++} + VERSION = {env:VERSION:3.2.0} passenv = pythonLocation @@ -50,6 +51,7 @@ deps = lint: beautysh commands = + {build,clang}: bash release.sh --version {env:VERSION} {build,clang}: bash -c 'make -j1 CCC=$CXX CC=$CC cccc' {build,clang}: bash -c 'make -j1 CCC=$CXX test 2>&1 | tail -n5' lint: bash -c 'cpplint --output=gsed {toxinidir}/cccc/*' From 2da953c1f3275a9806710992992abcab0f37924e Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 16 Nov 2022 13:38:09 -0800 Subject: [PATCH 2/6] chg: dev: let make generate the version file from git * update cccc (posix) makefiles to generate version header (requires bash or cmd.exe and git commands) * optional: define VERSION_FORMAT_DEV in CPPFLAGS to use full dev version string * delete and remove cccc_ver.h and release.sh files from git tracking Signed-off-by: Stephen L Arnold --- .gitignore | 1 + Makefile | 4 ++-- cccc/cccc_ver.h | 3 --- cccc/ccccmain.cc | 5 +++-- cccc/posixgcc.mak | 35 ++++++++++++++++++++++++++++++++++- cccc/rules.mak | 16 +++++++++++++--- release.sh | 27 --------------------------- tox.ini | 10 ++++++---- 8 files changed, 59 insertions(+), 42 deletions(-) delete mode 100644 cccc/cccc_ver.h delete mode 100755 release.sh diff --git a/.gitignore b/.gitignore index caa242f..eac1ba6 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ cccc/Jtokens.h cccc/cccc.cpp cccc/java.cpp cccc/parser.dlg +cccc/cccc_ver.h # generated test output test/.cccc/* diff --git a/Makefile b/Makefile index 5604c6a..c0a06dc 100644 --- a/Makefile +++ b/Makefile @@ -71,10 +71,10 @@ docs : Doxyfile.html_cfg $(CCCCSRC) $(DOCS)/.keep_dir @echo "API docs now in $(DOCS)/html" clean : - rm -rf cccc/*.o cccc/cccc $(GENSRC) pccts/bin/* + rm -f cccc/cccc_ver.h cccc/*.o cccc/cccc pccts/bin/* reallyclean : clean - rm -rf ccccout/* doxygen/html test/.cccc $(TESTOBJ) + rm -rf ccccout/* doxygen/html test/.cccc $(TESTOBJ) $(GENSRC) make -C pccts clean clobber : reallyclean diff --git a/cccc/cccc_ver.h b/cccc/cccc_ver.h deleted file mode 100644 index 2d39e9d..0000000 --- a/cccc/cccc_ver.h +++ /dev/null @@ -1,3 +0,0 @@ -// This version built on lorentz at 20221113-185650 -#define CCCC_VERSION 3.2.0 -#define CCCC_VERSION_STRING "3.2.0" diff --git a/cccc/ccccmain.cc b/cccc/ccccmain.cc index ff0c260..206a731 100644 --- a/cccc/ccccmain.cc +++ b/cccc/ccccmain.cc @@ -112,6 +112,7 @@ class Main void HandleReportOption(const string&); void PrintCredits(ostream& os); void PrintUsage(ostream& os); + void Version(const char *prog); int ParseFiles(); int DumpDatabase(); int LoadDatabase(); @@ -165,7 +166,7 @@ void Main::HandleArgs(int argc, char **argv) } else if(next_arg=="--version") { - version(argv[0]); + Version(argv[0]); exit(0); } else @@ -677,7 +678,7 @@ void Main::DescribeOutput() } } -void version(const char *prog) { std::cout << VERSION_INFO << '\n'; } +void Main::Version(const char *prog) { std::cout << VERSION_INFO << '\n'; } /* ** the usage message is printed on cerr if unexpected options are found, diff --git a/cccc/posixgcc.mak b/cccc/posixgcc.mak index f558724..3e5e741 100644 --- a/cccc/posixgcc.mak +++ b/cccc/posixgcc.mak @@ -16,6 +16,39 @@ ## See rules.mak for discussion of the meaning of the make variables ## which this file defines +# generate build/version info +ifeq ($(SHELL), cmd.exe) +BUILD_DATE := $(shell python -c "from datetime import datetime; print(datetime.utcnow().strftime('%d/%m/%Y, %H:%M'))" +BUILD_MACHINE := $(shell echo %username%)@$(shell hostname) +else +BUILD_DATE := $(shell date -u +"%d/%m/%Y, %H:%M") +BUILD_MACHINE := $(shell whoami)@$(shell hostname) +endif + +version := $(subst -, ,$(shell git describe --long --dirty --tags)) +COMMIT := $(strip $(word 3, $(version))) +COMMITS_PAST := $(strip $(word 2, $(version))) +DIRTY := $(strip $(word 4, $(version))) + +ifneq ($(COMMITS_PAST), 0) +BUILD_INFO_COMMITS := .$(COMMITS_PAST) +endif + +ifneq ($(DIRTY),) +BUILD_INFO_DIRTY :=+ +endif + +BUILD_INFO := $(COMMIT)$(BUILD_INFO_COMMITS)$(BUILD_INFO_DIRTY) +VERSION_TAG :=$(strip $(word 1, $(version))) + +VERSION_DEV := $(VERSION_TAG)-$(BUILD_INFO) +VERSION_SEM := $(VERSION_TAG)$(BUILD_INFO_COMMITS) + +$(info Build Time: $(BUILD_DATE)) +$(info Build Host: $(BUILD_MACHINE)) +$(info Build Version: $(VERSION_SEM)) +$(info Build Version Dev: $(VERSION_DEV)) + # support for debugging ifeq "$(DEBUG)" "true" DEBUG_FLAGS = -g @@ -28,7 +61,7 @@ PATHSEP=/ CCC ?= g++ INCLUDES = -I../pccts/h -I. -CCC_OPTS = -c $(CFLAGS) $(DEBUG_FLAGS) $(INCLUDES) -std=c++98 -x c++ +CCC_OPTS = -c $(CFLAGS) $(DEBUG_FLAGS) $(CPPFLAGS) $(INCLUDES) -std=c++98 -x c++ C_OFLAG = -o LD_OPTS = $(LDFLAGS) $(DEBUG_LFLAGS) LD_OFLAG = -o diff --git a/cccc/rules.mak b/cccc/rules.mak index 3fee067..14dd14a 100644 --- a/cccc/rules.mak +++ b/cccc/rules.mak @@ -130,7 +130,17 @@ USR_OBJ = \ ALL_OBJ = $(SPAWN_OBJ) $(USR_OBJ) $(PCCTS_OBJ) - +cccc_ver.h: rules.mak + @echo "Generating $@" + @echo #ifndef CCCC_VER_H_ > $@ + @echo #define CCCC_VER_H_ >> $@ + @echo "#define BUILD_TIME \"$(BUILD_DATE)\"" >> $@ + @echo "#define BUILD_HOST \"$(BUILD_MACHINE)\"" >> $@ + @echo "#define CCCC_VERSION_STRING \"$(VERSION_SEM)\"" >> $@ + @echo "#define CCCC_VERSION_DEV \"$(VERSION_DEV)\"" >> $@ + @echo #endif >> $@ + +cccc.cpp : cccc_ver.h all: $(CCCC_EXE) @@ -138,7 +148,7 @@ all: $(CCCC_EXE) $(CCCC_EXE): $(USR_G) $(ANLTR_SPAWN) $(DLG_SPAWN) $(USR_H) $(USR_C) $(ALL_OBJ) $(CCC) $(ALL_OBJ) $(LD_OPTS) $(LD_EXTRA_LIBS) $(LD_OFLAG)$(CCCC_EXE) -.SUFFIXES: .cc .$(OBJEXT) .cpp .cxx .g .g_info +.SUFFIXES: .cc .$(OBJEXT) .cpp .cxx .g .g_info .h ## ANTLR can give us some very useful documentation including a ## cross reference of the rules and a list of first token sets @@ -148,7 +158,7 @@ $(CCCC_EXE): $(USR_G) $(ANLTR_SPAWN) $(DLG_SPAWN) $(USR_H) $(USR_C) $(ALL_OBJ) $(ANTLR) $(AFLAGS) -gc -gx -pa $< > $*.1st $(ANTLR) $(AFLAGS) -gc -gx -cr $< > $*.xrf -ccccmain.$(OBJEXT) : ccccmain.cc +ccccmain.$(OBJEXT) : ccccmain.cc $(CCC) $(CCC_OPTS) $(LANG_DEFINES) ccccmain.cc diff --git a/release.sh b/release.sh deleted file mode 100755 index 46ba71a..0000000 --- a/release.sh +++ /dev/null @@ -1,27 +0,0 @@ -#! /usr/bin/env bash -# release.sh -# set the release version in the header file before building -# - -set -e - -PATH=/usr/bin:/bin:/usr/sbin:/sbin -export LC_ALL=C - -DATE=$(date +%Y%m%d-%H%M%S) -UNAME_N=$(uname -n) - -if [[ $1 == "--version" ]]; then - RELEASE_VERSION="${2}" -elif [[ -n $VERSION ]]; then - RELEASE_VERSION="${VERSION}" -else - RELEASE_VERSION=$(git describe --tags | cut -d- -f1) -fi - -RELEASE_VERSION_GIT=$(git describe --tags --dirty --always) - -echo "// This version built on ${UNAME_N} at ${DATE}" > cccc/cccc_ver.h -echo "#define CCCC_VERSION ${RELEASE_VERSION}" >> cccc/cccc_ver.h -echo "#define CCCC_VERSION_STRING \"${RELEASE_VERSION}\"" >> cccc/cccc_ver.h -echo "#define CCCC_VERSION_DEV \"${RELEASE_VERSION_GIT}\"" >> cccc/cccc_ver.h diff --git a/tox.ini b/tox.ini index 90a3182..ba980e0 100644 --- a/tox.ini +++ b/tox.ini @@ -16,7 +16,7 @@ setenv = CXX = {env:CXX:g++} CCC = {env:CXX:g++} LD = {env:CXX:g++} - VERSION = {env:VERSION:3.2.0} + CPPFLAGS = {env:CPPFLAGS:-DVERSION_FORMAT_DEV} passenv = pythonLocation @@ -51,9 +51,11 @@ deps = lint: beautysh commands = - {build,clang}: bash release.sh --version {env:VERSION} - {build,clang}: bash -c 'make -j1 CCC=$CXX CC=$CC cccc' + #{build,clang}: bash release.sh + {build,clang}: bash -c 'make -j4 CXX=$CXX CC=$CC mini' + {build,clang}: bash -c 'make -j4 CCC=$CXX CC=$CC cccc' {build,clang}: bash -c 'make -j1 CCC=$CXX test 2>&1 | tail -n5' + {build,clang}: bash -c './cccc/cccc --version' lint: bash -c 'cpplint --output=gsed {toxinidir}/cccc/*' changes: bash -c 'gitchangelog {posargs} > CHANGELOG.md' - clean: bash -c 'make reallyclean' + clean: bash -c 'make clean' From cf4557b40525c77017f2612b5ebd337d3106050e Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 16 Nov 2022 14:39:43 -0800 Subject: [PATCH 3/6] chg: dev: tune up make/bat and workflows with version var * note the --version N.N arg is now required for build_msvc.bat Signed-off-by: Stephen L Arnold --- .github/workflows/ci.yml | 10 +++++++++- .github/workflows/smoke.yml | 18 +++++++++++++++--- build_msvc.bat | 8 ++++---- cccc/posixgcc.mak | 33 --------------------------------- cccc/rules.mak | 35 ++++++++++++++++++++++++++++++++++- debian/rules | 3 ++- 6 files changed, 64 insertions(+), 43 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f2c507..1041c93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,6 +60,14 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Get version + id: get_version + run: | + echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV + echo ${{ env.VERSION }} - name: Install and setup MSYS2 mingw if: runner.os == 'Windows' && matrix.compiler == 'mingw-w64' @@ -81,7 +89,7 @@ jobs: - name: Build and test windows MSVC if: runner.os == 'Windows' && matrix.compiler == 'cl' run: | - .\build_msvc.bat --clean + .\build_msvc.bat --version ${{ env.VERSION }} - name: Install and setup Linux packages if: runner.os == 'Linux' diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index d80d4af..38ed9ba 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -20,6 +20,14 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Get version + id: get_version + run: | + echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV + echo ${{ env.VERSION }} - name: Add 64-bit mingw-w64 to the PATH run: | @@ -31,18 +39,22 @@ jobs: run: make cccc - name: run test - run: make test + run: | + make test + ./cccc/cccc --version windows: runs-on: windows-2019 steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Enable Developer Command Prompt uses: ilammy/msvc-dev-cmd@v1 - name: Build run: | - .\build_msvc.bat --clean - .\cccc.exe + .\build_msvc.bat --version ${{ env.VERSION }} + .\cccc.exe --version diff --git a/build_msvc.bat b/build_msvc.bat index 46b234c..12df01c 100755 --- a/build_msvc.bat +++ b/build_msvc.bat @@ -17,10 +17,10 @@ REM for cccc.exe install set BIN_DIR="%PREFIX%"\\bin set arg1=%1 - if "%arg1%"=="--version" ( - echo // This version built on %HOSTNAME% at %DATE% > cccc\cccc_ver.h - echo #define CCCC_VERSION %2 >> cccc\cccc_ver.h + echo #define BUILD_HOST %HOSTNAME% > cccc\cccc_ver.h + echo #define BUILD_TIME %DATE% >> cccc\cccc_ver.h + echo #define CCCC_VERSION_DEV %2 >> cccc\cccc_ver.h echo #define CCCC_VERSION_STRING "%2" >> cccc\cccc_ver.h set arg1=--clean ) @@ -28,11 +28,11 @@ if "%arg1%"=="--installer" ( goto :buildInstaller ) - if "%arg1%"=="--clean" ( for %%d in ( pccts\dlg pccts\antlr cccc ) do ( if exist %%d\*.obj del %%d\*.obj if exist %%d\*.exe del %%d\*.exe + if exist %%d\cccc_ver.h del %%d\cccc_ver.h ) if exist pccts\bin rmdir /s /q pccts\bin mkdir pccts\bin diff --git a/cccc/posixgcc.mak b/cccc/posixgcc.mak index 3e5e741..f150e23 100644 --- a/cccc/posixgcc.mak +++ b/cccc/posixgcc.mak @@ -16,39 +16,6 @@ ## See rules.mak for discussion of the meaning of the make variables ## which this file defines -# generate build/version info -ifeq ($(SHELL), cmd.exe) -BUILD_DATE := $(shell python -c "from datetime import datetime; print(datetime.utcnow().strftime('%d/%m/%Y, %H:%M'))" -BUILD_MACHINE := $(shell echo %username%)@$(shell hostname) -else -BUILD_DATE := $(shell date -u +"%d/%m/%Y, %H:%M") -BUILD_MACHINE := $(shell whoami)@$(shell hostname) -endif - -version := $(subst -, ,$(shell git describe --long --dirty --tags)) -COMMIT := $(strip $(word 3, $(version))) -COMMITS_PAST := $(strip $(word 2, $(version))) -DIRTY := $(strip $(word 4, $(version))) - -ifneq ($(COMMITS_PAST), 0) -BUILD_INFO_COMMITS := .$(COMMITS_PAST) -endif - -ifneq ($(DIRTY),) -BUILD_INFO_DIRTY :=+ -endif - -BUILD_INFO := $(COMMIT)$(BUILD_INFO_COMMITS)$(BUILD_INFO_DIRTY) -VERSION_TAG :=$(strip $(word 1, $(version))) - -VERSION_DEV := $(VERSION_TAG)-$(BUILD_INFO) -VERSION_SEM := $(VERSION_TAG)$(BUILD_INFO_COMMITS) - -$(info Build Time: $(BUILD_DATE)) -$(info Build Host: $(BUILD_MACHINE)) -$(info Build Version: $(VERSION_SEM)) -$(info Build Version Dev: $(VERSION_DEV)) - # support for debugging ifeq "$(DEBUG)" "true" DEBUG_FLAGS = -g diff --git a/cccc/rules.mak b/cccc/rules.mak index 14dd14a..e290815 100644 --- a/cccc/rules.mak +++ b/cccc/rules.mak @@ -15,7 +15,40 @@ ## makes including GNU Make. The way I have dealt with this ## is to exclude use of preprocessor features from this file ## while using them freely in the platform-specific files. -## + +# generate build/version info +ifeq ($(SHELL), cmd.exe) +BUILD_DATE := $(shell python -c "from datetime import datetime; print(datetime.utcnow().strftime('%d/%m/%Y, %H:%M'))" +BUILD_MACHINE := $(shell echo %username%)@$(shell hostname) +else +BUILD_DATE := $(shell date -u +"%d/%m/%Y, %H:%M") +BUILD_MACHINE := $(shell whoami)@$(shell hostname) +endif + +version := $(subst -, ,$(shell git describe --long --dirty --tags)) +COMMIT := $(strip $(word 3, $(version))) +COMMITS_PAST := $(strip $(word 2, $(version))) +DIRTY := $(strip $(word 4, $(version))) + +ifneq ($(COMMITS_PAST), 0) +BUILD_INFO_COMMITS := .$(COMMITS_PAST) +endif + +ifneq ($(DIRTY),) +BUILD_INFO_DIRTY :=+ +endif + +BUILD_INFO := $(COMMIT)$(BUILD_INFO_COMMITS)$(BUILD_INFO_DIRTY) +VERSION_TAG :=$(strip $(word 1, $(version))) + +VERSION_DEV := $(VERSION_TAG)-$(BUILD_INFO) +VERSION_SEM := $(VERSION_TAG)$(BUILD_INFO_COMMITS) + +$(info Build Time: $(BUILD_DATE)) +$(info Build Host: $(BUILD_MACHINE)) +$(info Build Version: $(VERSION_SEM)) +$(info Build Version Dev: $(VERSION_DEV)) + ## The following make variables must be defined before entering this ## file: ## diff --git a/debian/rules b/debian/rules index a711ea9..c579a0d 100755 --- a/debian/rules +++ b/debian/rules @@ -22,6 +22,7 @@ CFLAGS += -c -I/usr/include/pccts -x c++ buildflags := CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" override_dh_auto_build: + $(MAKE) -C cccc -f rules.mak cccc_ver.h $(MAKE) -C cccc -f posixgcc.mak $(buildflags) \ PCCTS_H=/usr/include/pccts PCCTS_BIN=/usr/bin $(CROSS) @@ -37,7 +38,7 @@ override_dh_auto_clean: -rm -rf test/.cccc test/*.xml test/*.html test/*.db override_dh_auto_install: - # The default 'make install' uses su! + # The default makefile has no install target override_dh_installdocs: dh_installdocs 'cccc/CCCC User Guide.html' From 264ee5daf8d25839109c5162ba20728e6e84bd1a Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 16 Nov 2022 15:53:42 -0800 Subject: [PATCH 4/6] chg: dev: make sure everybody has a version, fix msvc bat file * add git dep for build-deb-action container versioning * remove exrtraneous make step in debian/rules, add explicit target * remove erroneous cleaning of version file from batch file * add gh-describe action and pass version to batch file * give mingw some fetch-depth or install git in specific runner envs * convert readme to rst (needs render check) Signed-off-by: Stephen L Arnold --- .github/workflows/ci.yml | 12 +++--- .github/workflows/debs.yml | 1 + .github/workflows/release.yml | 1 + .github/workflows/smoke.yml | 15 +++---- README.md => README.rst | 78 +++++++++++++++++++++++++---------- build_msvc.bat | 1 - debian/docs | 2 +- debian/rules | 3 +- 8 files changed, 71 insertions(+), 42 deletions(-) rename README.md => README.rst (76%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1041c93..5b05cda 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,18 +63,16 @@ jobs: with: fetch-depth: 0 - - name: Get version - id: get_version - run: | - echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV - echo ${{ env.VERSION }} + - name: Git describe + id: ghd + uses: proudust/gh-describe@v1 - name: Install and setup MSYS2 mingw if: runner.os == 'Windows' && matrix.compiler == 'mingw-w64' uses: msys2/setup-msys2@v2 with: msystem: MINGW64 - install: mingw-w64-x86_64-toolchain make gcc diffutils + install: mingw-w64-x86_64-toolchain make gcc diffutils git - name: Build and test windows mingw if: runner.os == 'Windows' && matrix.compiler == 'mingw-w64' @@ -89,7 +87,7 @@ jobs: - name: Build and test windows MSVC if: runner.os == 'Windows' && matrix.compiler == 'cl' run: | - .\build_msvc.bat --version ${{ env.VERSION }} + .\build_msvc.bat --version ${{ steps.ghd.outputs.describe }} - name: Install and setup Linux packages if: runner.os == 'Linux' diff --git a/.github/workflows/debs.yml b/.github/workflows/debs.yml index c2029a1..6d5f65d 100644 --- a/.github/workflows/debs.yml +++ b/.github/workflows/debs.yml @@ -48,6 +48,7 @@ jobs: with: docker-image: "debian:${{ matrix.dist }}-slim" buildpackage-opts: --build=binary --no-sign + extra-build-deps: git - name: Upload deb files uses: actions/upload-artifact@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1e4fb1a..7d595fd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,6 +48,7 @@ jobs: with: docker-image: "debian:${{ matrix.dist }}-slim" buildpackage-opts: --build=binary --no-sign + extra-build-deps: git - name: Upload deb files uses: actions/upload-artifact@v3 diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index 38ed9ba..b741f7e 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -23,12 +23,6 @@ jobs: with: fetch-depth: 0 - - name: Get version - id: get_version - run: | - echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV - echo ${{ env.VERSION }} - - name: Add 64-bit mingw-w64 to the PATH run: | echo "c:/msys64/bin;c:/msys64/mingw64/bin" >> $GITHUB_PATH @@ -41,20 +35,21 @@ jobs: - name: run test run: | make test - ./cccc/cccc --version windows: runs-on: windows-2019 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 + + - name: Git describe + id: ghd + uses: proudust/gh-describe@v1 - name: Enable Developer Command Prompt uses: ilammy/msvc-dev-cmd@v1 - name: Build run: | - .\build_msvc.bat --version ${{ env.VERSION }} + .\build_msvc.bat --version ${{ steps.ghd.outputs.describe }} .\cccc.exe --version diff --git a/README.md b/README.rst similarity index 76% rename from README.md rename to README.rst index 05ffed9..34a67bd 100644 --- a/README.md +++ b/README.rst @@ -1,17 +1,14 @@ README for CCCC versions 3.2.x ============================== -[![Github CI](https://github.com/sarnold/cccc/actions/workflows/ci.yml/badge.svg)](https://github.com/sarnold/cccc/actions/workflows/ci.yml) -[![Conda CI](https://github.com/sarnold/cccc/actions/workflows/conda.yml/badge.svg)](https://github.com/sarnold/cccc/actions/workflows/conda.yml) -[![Debian packages](https://github.com/sarnold/cccc/actions/workflows/debs.yml/badge.svg)](https://github.com/sarnold/cccc/actions/workflows/debs.yml) -[![Release CI](https://github.com/sarnold/cccc/actions/workflows/release.yml/badge.svg)](https://github.com/sarnold/cccc/actions/workflows/release.yml) +|ci| |conda| |debs| |release| -[![CCCC License](https://img.shields.io/badge/license-GPL2-green.svg?dummy)](https://github.com/sarnold/cccc/blob/master/cccc/COPYING) -![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/sarnold/cccc?include_prereleases) -[![Github Issues](https://img.shields.io/github/issues/sarnold/cccc)](https://github.com/sarnold/cccc/issues?q=is:issue+is:open) +|tag| |license| |issues| -[![Conda Version](https://img.shields.io/conda/vn/conda-forge/cccc.svg)](https://anaconda.org/conda-forge/cccc) -[![Conda Platforms](https://img.shields.io/conda/pn/conda-forge/cccc.svg)](https://anaconda.org/conda-forge/cccc) +|vconda| |pconda| + +What is it? +----------- This is a maintenance update of the last (sourceforge) release of the program CCCC (C and C++ Code Counter). This software performs analysis and reports @@ -21,12 +18,22 @@ Ada95, which were supported in previous versions are presently not supported new site for CCCC development is: https://github.com/sarnold/cccc and for current documentation see: http://sarnold.github.io/cccc/ -* [Github Action](https://github.com/marketplace/actions/cccc-action) - Now available as a github action! -* [Quick Install](https://github.com/sarnold/cccc/blob/master/README_install.rst) - Quick start install instructions -* [User Guide](http://sarnold.github.io/cccc/CCCC_User_Guide.html) - User guide (updated) -* [Release Notes](https://github.com/sarnold/cccc/blob/master/CHANGELOG.md) - Autogenerated changelog for github releases (with a little SVN history for context) -* [Software API docs](http://sarnold.github.io/cccc/api/html/index.html) - Software API documentation with design diagrams, etc -* [Complexity Metrics](http://sarnold.github.io/cccc/metrics/cccc.html) - Source code metrics for a source code metrics tool... ;) +* `Github Action`_ - Now available as a github action! +* `Quick Install`_ - Quick start install instructions +* `User Guide`_ - User guide (updated) +* `Release Notes`_ - Autogenerated changelog for github releases (with a little SVN history for context) +* `Software API docs`_ - Software API documentation with design diagrams, etc +* `Complexity Metrics`_ - Source code metrics for a source code metrics tool... ;) + +.. _Github Action: https://github.com/marketplace/actions/cccc-action +.. _Quick Install: https://github.com/sarnold/cccc/blob/master/README_install.rst +.. _User Guide: http://sarnold.github.io/cccc/CCCC_User_Guide.html +.. _Release Notes: https://github.com/sarnold/cccc/blob/master/CHANGELOG.md +.. _Software API docs: http://sarnold.github.io/cccc/api/html/index.html +.. _Complexity Metrics: http://sarnold.github.io/cccc/metrics/cccc.html + +Background +---------- CCCC is a command line tool, originally implemented for Linux and other POSIX-style platforms, but also buildable on the Win32 platform. Files @@ -67,6 +74,9 @@ to which you have and whether it is installed at the default position in the filesystem). On Linux and similar platforms the shell script build_posixgcc.sh should still work. +Historical +---------- + As of the last upstream release (ver 3.1.4) the reference build tool for the Win32 platform is the freely distributed Microsoft Visual C++ Toolkit 2003. As this toolkit does not contain a 'make' style program the script @@ -125,7 +135,10 @@ domain with no restrictions, other than the pious hope that should anyone base a derivative work on it I will be given due credit. The current version is released under the GNU Public License (including the bundled PCCTS source). -The upcoming 3.1.5 release will be a maintenance release to clean up the build and +Notes from the maintainer +------------------------- + +The initial 3.1.5 release was a maintenance release to clean up the build and makefile config (enabling parallel make) and fix a build error with recent gcc. The pccts build target "mini" builds only the tools required to build cccc, while the make target "pccts" builds the complete toolset, and "all" will build @@ -137,10 +150,8 @@ of (expensive) commercial engineering tools. It has a simple CLI and other support like Jenkins plugins. Use it to find out your own complexity metrics. You might be surprised... -The above updates by Stephen L Arnold. - Notes from the original author -============================== +------------------------------ CCCC was originally developed as a proof-of-concept tool for some ideas relating to software metrics which I was investigating as an academic @@ -169,13 +180,38 @@ available for the forseeable future from https://github.com/sarnold/cccc as well as the original home at http://cccc.sourceforge.net +.. |ci| image:: https://github.com/sarnold/cccc/actions/workflows/ci.yml/badge.svg + :target: https://github.com/sarnold/cccc/actions/workflows/ci.yml + :alt: CI Status +.. |conda| image:: https://github.com/sarnold/cccc/actions/workflows/conda.yml/badge.svg + :target: https://github.com/sarnold/cccc/actions/workflows/conda.yml + :alt: Conda Status +.. |debs| image:: https://github.com/sarnold/cccc/actions/workflows/debs.yml/badge.svg + :target: https://github.com/sarnold/cccc/actions/workflows/release.yml + :alt: Debian packages +.. |release| image:: https://github.com/sarnold/cccc/actions/workflows/release.yml/badge.svg + :target: https://github.com/sarnold/cccc/actions/workflows/release.yml + :alt: Release Status +.. |license| image:: https://img.shields.io/badge/license-GPL2-green.svg?dummy + :target: https://github.com/sarnold/cccc/blob/master/cccc/COPYING + :alt: License +.. |tag| image:: https://img.shields.io/github/v/tag/sarnold/cccc?include_prereleases + :target: https://github.com/sarnold/cccc/releases + :alt: GitHub tag (latest SemVer pre-release) +.. |issues| image:: https://img.shields.io/github/issues/sarnold/cccc + :target: https://github.com/sarnold/cccc/issues?q=is:issue+is:open + :alt: Issues +.. |vconda| image:: https://img.shields.io/conda/vn/conda-forge/cccc.svg + :target: https://anaconda.org/conda-forge/cccc + :alt: Conda Version - - +.. |pconda| image:: https://img.shields.io/conda/pn/conda-forge/cccc.svg + :target: https://anaconda.org/conda-forge/cccc + :alt: Conda Platforms diff --git a/build_msvc.bat b/build_msvc.bat index 12df01c..94d1052 100755 --- a/build_msvc.bat +++ b/build_msvc.bat @@ -32,7 +32,6 @@ if "%arg1%"=="--clean" ( for %%d in ( pccts\dlg pccts\antlr cccc ) do ( if exist %%d\*.obj del %%d\*.obj if exist %%d\*.exe del %%d\*.exe - if exist %%d\cccc_ver.h del %%d\cccc_ver.h ) if exist pccts\bin rmdir /s /q pccts\bin mkdir pccts\bin diff --git a/debian/docs b/debian/docs index b43bf86..a1320b1 100644 --- a/debian/docs +++ b/debian/docs @@ -1 +1 @@ -README.md +README.rst diff --git a/debian/rules b/debian/rules index c579a0d..cad141b 100755 --- a/debian/rules +++ b/debian/rules @@ -22,9 +22,8 @@ CFLAGS += -c -I/usr/include/pccts -x c++ buildflags := CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" override_dh_auto_build: - $(MAKE) -C cccc -f rules.mak cccc_ver.h $(MAKE) -C cccc -f posixgcc.mak $(buildflags) \ - PCCTS_H=/usr/include/pccts PCCTS_BIN=/usr/bin $(CROSS) + PCCTS_H=/usr/include/pccts PCCTS_BIN=/usr/bin $(CROSS) cccc override_dh_auto_test: ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) From bc7d1a4d83a34edf322b2156611434d828addb7f Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 16 Nov 2022 21:41:00 -0800 Subject: [PATCH 5/6] fix: dev: still more msvc bat cleanup, update workflow/tox files * setup python and use tox in smoke.yml, add mising exclude in ci.yml * need to skip missing installer section in build_msvc.bat * set default parallel make args to 1, higher is iffy in gh ci Signed-off-by: Stephen L Arnold --- .github/workflows/ci.yml | 2 +- .github/workflows/smoke.yml | 14 ++++++++++---- Makefile | 8 +++++--- build_msvc.bat | 8 ++------ tox.ini | 6 +++--- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b05cda..ac543a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,7 +81,7 @@ jobs: make - name: Install and setup msvc prompt - if: runner.os == 'Windows' + if: runner.os == 'Windows' && matrix.compiler == 'cl' uses: ilammy/msvc-dev-cmd@v1 - name: Build and test windows MSVC diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index b741f7e..85b7c34 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -29,12 +29,18 @@ jobs: which gcc if: startsWith(matrix.os, 'win') - - name: build - run: make cccc + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Add requirements + run: | + python -m pip install --upgrade pip + pip install tox - - name: run test + - name: Build and test run: | - make test + tox -e build windows: runs-on: windows-2019 diff --git a/Makefile b/Makefile index c0a06dc..51ea866 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ LD ?= g++ DOX = doxygen CCCC = ./cccc/cccc CCCOPTS = --lang=c++ -CCCCSRC = ./cccc/*.cc ./cccc/*.h +CCCCSRC = ./cccc/*.cc ./cccc/*.cpp ./cccc/*.h GENSRC = cccc/CLexer.cpp \ cccc/CLexer.h \ cccc/CParser.cpp \ @@ -71,11 +71,13 @@ docs : Doxyfile.html_cfg $(CCCCSRC) $(DOCS)/.keep_dir @echo "API docs now in $(DOCS)/html" clean : - rm -f cccc/cccc_ver.h cccc/*.o cccc/cccc pccts/bin/* + rm -f cccc/*.o cccc/cccc reallyclean : clean - rm -rf ccccout/* doxygen/html test/.cccc $(TESTOBJ) $(GENSRC) + rm -f pccts/bin/* $(TESTOBJ) $(GENSRC) + rm -rf ccccout/ doxygen/ test/.cccc make -C pccts clean clobber : reallyclean + rm -f cccc/cccc_ver.h make -C pccts scrub diff --git a/build_msvc.bat b/build_msvc.bat index 94d1052..70a8a9f 100755 --- a/build_msvc.bat +++ b/build_msvc.bat @@ -144,8 +144,10 @@ call run_test java prn13 call run_test java prn14 call run_test java prn15 call run_test java prn16 +echo All tests passed cd .. endlocal +if not exist "c:\Program Files\My Inno Setup Extensions\iscc.exe" goto :end rem The visual C++ addin can't be built using MS Visual C++ Toolkit 2003 rem because it doesn't provide MFC header files and libraries @@ -184,10 +186,4 @@ echo Please rerun the script with the argument --clean to build these binaries. goto :end - :end - - - - - diff --git a/tox.ini b/tox.ini index ba980e0..2d676ec 100644 --- a/tox.ini +++ b/tox.ini @@ -52,10 +52,10 @@ deps = commands = #{build,clang}: bash release.sh - {build,clang}: bash -c 'make -j4 CXX=$CXX CC=$CC mini' - {build,clang}: bash -c 'make -j4 CCC=$CXX CC=$CC cccc' + {build,clang}: bash -c 'make -j{posargs:1} CXX=$CXX CC=$CC mini' + {build,clang}: bash -c 'make -j{posargs:1} CCC=$CXX CC=$CC cccc' {build,clang}: bash -c 'make -j1 CCC=$CXX test 2>&1 | tail -n5' {build,clang}: bash -c './cccc/cccc --version' lint: bash -c 'cpplint --output=gsed {toxinidir}/cccc/*' changes: bash -c 'gitchangelog {posargs} > CHANGELOG.md' - clean: bash -c 'make clean' + clean: bash -c 'make {posargs:clean}' From 7fdfc5a5ca4e53bd520061e230dceb5762b72eb1 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Mon, 5 Dec 2022 22:03:14 -0800 Subject: [PATCH 6/6] chg: add simple dist target, add source tarball to makefile/release * sdist removes dependency on pccts using (pre)generated source files Signed-off-by: Stephen L Arnold --- .github/workflows/release.yml | 8 +++++++- .gitignore | 1 + Makefile | 11 +++++++++-- tox.ini | 8 +++++--- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7d595fd..98616de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,7 +66,7 @@ jobs: id: get_version run: | echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV - echo ${{ env.VERSION }} + echo ${VERSION } - uses: actions/checkout@v3 with: @@ -75,6 +75,11 @@ jobs: # download all artifacts to project dir - uses: actions/download-artifact@v3 + - name: Generate source release + run: | + make cccc dist + ls dist + - name: Generate changes file uses: sarnold/gitchangelog-action@v1 with: @@ -93,3 +98,4 @@ jobs: prerelease: false files: | packages/*.deb + dist/*.gz diff --git a/.gitignore b/.gitignore index eac1ba6..ac23742 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ cccc/cccc +dist/ doxygen/* ccccout/* pccts/bin/* diff --git a/Makefile b/Makefile index 51ea866..795bf8a 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ GENSRC = cccc/CLexer.cpp \ cccc/java.cpp \ cccc/parser.dlg -.PHONY : all mini pccts cccc test +.PHONY : all mini pccts cccc test dist clean all : mini cccc test @@ -70,12 +70,19 @@ docs : Doxyfile.html_cfg $(CCCCSRC) $(DOCS)/.keep_dir $(DOX) Doxyfile.html_cfg @echo "API docs now in $(DOCS)/html" +# dist target requires VERSION set in build environment +dist : clean + mkdir -p dist/cccc-$(VERSION) + cp *.rst *.md build* LICENSE tox.ini Makefile dist/cccc-$(VERSION)/ + cp -r cccc conda test dist/cccc-$(VERSION)/ + tar -czf dist/cccc-$(VERSION).tar.gz -C dist cccc-$(VERSION) + clean : rm -f cccc/*.o cccc/cccc reallyclean : clean rm -f pccts/bin/* $(TESTOBJ) $(GENSRC) - rm -rf ccccout/ doxygen/ test/.cccc + rm -rf ccccout/ doxygen/ test/.cccc dist/ make -C pccts clean clobber : reallyclean diff --git a/tox.ini b/tox.ini index 2d676ec..1f544f4 100644 --- a/tox.ini +++ b/tox.ini @@ -39,9 +39,10 @@ passenv = XDG_* GITHUB* PIP_DOWNLOAD_CACHE + VERSION whitelist_externals = - {build,clang,lint,clean,changes}: bash + {build,clang,lint,clean,changes,sdist}: bash deps = {build,clang,lint,clean}: pip>=19.0.1 @@ -54,8 +55,9 @@ commands = #{build,clang}: bash release.sh {build,clang}: bash -c 'make -j{posargs:1} CXX=$CXX CC=$CC mini' {build,clang}: bash -c 'make -j{posargs:1} CCC=$CXX CC=$CC cccc' - {build,clang}: bash -c 'make -j1 CCC=$CXX test 2>&1 | tail -n5' - {build,clang}: bash -c './cccc/cccc --version' + {build,clang}: bash -c 'make -j1 CCC=$CXX test 2>&1 | tail -n5' + {build,clang}: bash -c './cccc/cccc --version' lint: bash -c 'cpplint --output=gsed {toxinidir}/cccc/*' + sdist: bash -c 'make dist' changes: bash -c 'gitchangelog {posargs} > CHANGELOG.md' clean: bash -c 'make {posargs:clean}'