diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..453ed1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +cache/ +build/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..453ed1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +cache/ +build/ diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000..dc5df86 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,2 @@ +FROM ubuntu:16.04 +RUN apt-get update diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..453ed1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +cache/ +build/ diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000..dc5df86 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,2 @@ +FROM ubuntu:16.04 +RUN apt-get update diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..5f07058 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,25 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Build Tools +RUN apt-get install -y g++ gcc gdb flex bison make +RUN apt-get install -y clang clang-tidy clang-format +RUN apt-get install -y mingw-w64-common mingw-w64-tools mingw-w64 mingw-w64-i686-dev mingw-w64-x86-64-dev +RUN apt-get install -y git curl wget cmake + +# Libraries +# RUN apt-get install -y libcppunit-1.12-1 libcppunit-doc +# RUN apt-get install libqt4-dev libqt4-core libqt4-gui libqt4-sql libqt4-webkit +# RUN apt-get install graphviz doxygen libqttestrunner1c2a qdevelop + + +# RUN mkdir -p /home/jenkins +# RUN mkdir -p /var/lib/jenkins +# RUN echo -e "\n192.168.1.116 jenkins.localdomain\n" > /etc/hosts +# ADD slave.py /var/lib/jenkins/slave.py +# WORKDIR /home/jenkins +# ENV JENKINS_URL "http://jenkins.localdomain" +# ENV JENKINS_SLAVE_ADDRESS "" +# ENV JENKINS_USER "jryland" +# CMD [ "python", "-u", "/var/lib/jenkins/slave.py" ] + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..453ed1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +cache/ +build/ diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000..dc5df86 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,2 @@ +FROM ubuntu:16.04 +RUN apt-get update diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..5f07058 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,25 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Build Tools +RUN apt-get install -y g++ gcc gdb flex bison make +RUN apt-get install -y clang clang-tidy clang-format +RUN apt-get install -y mingw-w64-common mingw-w64-tools mingw-w64 mingw-w64-i686-dev mingw-w64-x86-64-dev +RUN apt-get install -y git curl wget cmake + +# Libraries +# RUN apt-get install -y libcppunit-1.12-1 libcppunit-doc +# RUN apt-get install libqt4-dev libqt4-core libqt4-gui libqt4-sql libqt4-webkit +# RUN apt-get install graphviz doxygen libqttestrunner1c2a qdevelop + + +# RUN mkdir -p /home/jenkins +# RUN mkdir -p /var/lib/jenkins +# RUN echo -e "\n192.168.1.116 jenkins.localdomain\n" > /etc/hosts +# ADD slave.py /var/lib/jenkins/slave.py +# WORKDIR /home/jenkins +# ENV JENKINS_URL "http://jenkins.localdomain" +# ENV JENKINS_SLAVE_ADDRESS "" +# ENV JENKINS_USER "jryland" +# CMD [ "python", "-u", "/var/lib/jenkins/slave.py" ] + diff --git a/Dockerfile.lint b/Dockerfile.lint new file mode 100644 index 0000000..ebe5235 --- /dev/null +++ b/Dockerfile.lint @@ -0,0 +1,6 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Linting Tools +RUN apt-get install -y clang clang-tidy clang-format make git python3 + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..453ed1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +cache/ +build/ diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000..dc5df86 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,2 @@ +FROM ubuntu:16.04 +RUN apt-get update diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..5f07058 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,25 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Build Tools +RUN apt-get install -y g++ gcc gdb flex bison make +RUN apt-get install -y clang clang-tidy clang-format +RUN apt-get install -y mingw-w64-common mingw-w64-tools mingw-w64 mingw-w64-i686-dev mingw-w64-x86-64-dev +RUN apt-get install -y git curl wget cmake + +# Libraries +# RUN apt-get install -y libcppunit-1.12-1 libcppunit-doc +# RUN apt-get install libqt4-dev libqt4-core libqt4-gui libqt4-sql libqt4-webkit +# RUN apt-get install graphviz doxygen libqttestrunner1c2a qdevelop + + +# RUN mkdir -p /home/jenkins +# RUN mkdir -p /var/lib/jenkins +# RUN echo -e "\n192.168.1.116 jenkins.localdomain\n" > /etc/hosts +# ADD slave.py /var/lib/jenkins/slave.py +# WORKDIR /home/jenkins +# ENV JENKINS_URL "http://jenkins.localdomain" +# ENV JENKINS_SLAVE_ADDRESS "" +# ENV JENKINS_USER "jryland" +# CMD [ "python", "-u", "/var/lib/jenkins/slave.py" ] + diff --git a/Dockerfile.lint b/Dockerfile.lint new file mode 100644 index 0000000..ebe5235 --- /dev/null +++ b/Dockerfile.lint @@ -0,0 +1,6 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Linting Tools +RUN apt-get install -y clang clang-tidy clang-format make git python3 + diff --git a/Makefile b/Makefile index 80f74c4..663d57e 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,66 @@ +SOURCES = Test.cpp -all: - mkdir -p build - x86_64-linux-gnu-g++ Test.cpp -o build/hello-linux-64 - x86_64-w64-mingw32-g++ Test.cpp -o build/hello-win64.exe - x86_64-apple-darwin19-c++ Test.cpp -o build/hello-macosx.bin +BUILD_DIR = build +CXXFLAGS = -std=c++14 -test: - mkdir -p build - echo "Blah" > build/tests.xml +UNAME := $(shell uname) +# LINUX version +ifeq ($(UNAME), Linux) +TARGETS := $(BUILD_DIR)/hello-linux-64 $(BUILD_DIR)/hello-win64.exe $(BUILD_DIR)/hello-macosx.bin +endif + +# WINDOWS version +ifeq ($(UNAME), MINGW64_NT-10.0) +TARGETS := $(BUILD_DIR)/hello-win64.exe +endif + +all: $(TARGETS) + @echo "all..." + @echo $(UNAME) + +.PRECIOUS: $(BUILD_DIR)/ $(BUILD_DIR)%/ + +$(BUILD_DIR)/: + @echo "dir1..." + @mkdir -p $@ + +$(BUILD_DIR)%/: + @echo "dir2..." + @mkdir -p $@ + +.SECONDEXPANSION: + +$(BUILD_DIR)/hello-linux-64: Test.cpp $$(@D)/ + @echo "Building Linux binary..." + @x86_64-linux-gnu-g++ $< -o $@ + +$(BUILD_DIR)/hello-win64.exe: Test.cpp $$(@D)/ + @echo "Building Windows binary..." + @x86_64-w64-mingw32-g++ $< -o $@ + +$(BUILD_DIR)/hello-macosx.bin: Test.cpp $$(@D)/ + @echo "Building MacOSX binary..." + @x86_64-apple-darwin19-c++ $< -o $@ + +tidy: $(BUILD_DIR)/tidy.xml + +$(BUILD_DIR)/tidy.xml: $$(@D)/ + @chmod u+x ./clang-tidy-to-junit.py + @clang-tidy -checks='c*,l*,m*' $(SOURCES) -- $(CXXFLAGS) | ./clang-tidy-to-junit.py $(PWD)/ > $@ + +test: $(BUILD_DIR)/tests.xml + +$(BUILD_DIR)/tests.xml: $$(@D)/ + @echo '' > $@ + @echo '' >> $@ + @echo '' >> $@ + publish: - echo "Publish..." + @echo "Publish..." diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..453ed1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +cache/ +build/ diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000..dc5df86 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,2 @@ +FROM ubuntu:16.04 +RUN apt-get update diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..5f07058 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,25 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Build Tools +RUN apt-get install -y g++ gcc gdb flex bison make +RUN apt-get install -y clang clang-tidy clang-format +RUN apt-get install -y mingw-w64-common mingw-w64-tools mingw-w64 mingw-w64-i686-dev mingw-w64-x86-64-dev +RUN apt-get install -y git curl wget cmake + +# Libraries +# RUN apt-get install -y libcppunit-1.12-1 libcppunit-doc +# RUN apt-get install libqt4-dev libqt4-core libqt4-gui libqt4-sql libqt4-webkit +# RUN apt-get install graphviz doxygen libqttestrunner1c2a qdevelop + + +# RUN mkdir -p /home/jenkins +# RUN mkdir -p /var/lib/jenkins +# RUN echo -e "\n192.168.1.116 jenkins.localdomain\n" > /etc/hosts +# ADD slave.py /var/lib/jenkins/slave.py +# WORKDIR /home/jenkins +# ENV JENKINS_URL "http://jenkins.localdomain" +# ENV JENKINS_SLAVE_ADDRESS "" +# ENV JENKINS_USER "jryland" +# CMD [ "python", "-u", "/var/lib/jenkins/slave.py" ] + diff --git a/Dockerfile.lint b/Dockerfile.lint new file mode 100644 index 0000000..ebe5235 --- /dev/null +++ b/Dockerfile.lint @@ -0,0 +1,6 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Linting Tools +RUN apt-get install -y clang clang-tidy clang-format make git python3 + diff --git a/Makefile b/Makefile index 80f74c4..663d57e 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,66 @@ +SOURCES = Test.cpp -all: - mkdir -p build - x86_64-linux-gnu-g++ Test.cpp -o build/hello-linux-64 - x86_64-w64-mingw32-g++ Test.cpp -o build/hello-win64.exe - x86_64-apple-darwin19-c++ Test.cpp -o build/hello-macosx.bin +BUILD_DIR = build +CXXFLAGS = -std=c++14 -test: - mkdir -p build - echo "Blah" > build/tests.xml +UNAME := $(shell uname) +# LINUX version +ifeq ($(UNAME), Linux) +TARGETS := $(BUILD_DIR)/hello-linux-64 $(BUILD_DIR)/hello-win64.exe $(BUILD_DIR)/hello-macosx.bin +endif + +# WINDOWS version +ifeq ($(UNAME), MINGW64_NT-10.0) +TARGETS := $(BUILD_DIR)/hello-win64.exe +endif + +all: $(TARGETS) + @echo "all..." + @echo $(UNAME) + +.PRECIOUS: $(BUILD_DIR)/ $(BUILD_DIR)%/ + +$(BUILD_DIR)/: + @echo "dir1..." + @mkdir -p $@ + +$(BUILD_DIR)%/: + @echo "dir2..." + @mkdir -p $@ + +.SECONDEXPANSION: + +$(BUILD_DIR)/hello-linux-64: Test.cpp $$(@D)/ + @echo "Building Linux binary..." + @x86_64-linux-gnu-g++ $< -o $@ + +$(BUILD_DIR)/hello-win64.exe: Test.cpp $$(@D)/ + @echo "Building Windows binary..." + @x86_64-w64-mingw32-g++ $< -o $@ + +$(BUILD_DIR)/hello-macosx.bin: Test.cpp $$(@D)/ + @echo "Building MacOSX binary..." + @x86_64-apple-darwin19-c++ $< -o $@ + +tidy: $(BUILD_DIR)/tidy.xml + +$(BUILD_DIR)/tidy.xml: $$(@D)/ + @chmod u+x ./clang-tidy-to-junit.py + @clang-tidy -checks='c*,l*,m*' $(SOURCES) -- $(CXXFLAGS) | ./clang-tidy-to-junit.py $(PWD)/ > $@ + +test: $(BUILD_DIR)/tests.xml + +$(BUILD_DIR)/tests.xml: $$(@D)/ + @echo '' > $@ + @echo '' >> $@ + @echo '' >> $@ + publish: - echo "Publish..." + @echo "Publish..." diff --git a/Setup.md b/Setup.md new file mode 100644 index 0000000..f2f3457 --- /dev/null +++ b/Setup.md @@ -0,0 +1,23 @@ + + +Instructions here are pretty good: + + https://github.com/jgitver/jgitver-maven-plugin/wiki/automatic-builds-for-maven%2C-jenkins-and-gitbucket + + +On Windows Client: + + Edit (as Administrator) C:\Windows\System32\drivers\etc\hosts + and add the following: + + 192.168.1.116 gitbucket.localdomain + 192.168.1.116 jenkins.localdomain + +On MacOSX Clients: + + sudo vi /etc/hosts + + and add as above + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..453ed1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +cache/ +build/ diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000..dc5df86 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,2 @@ +FROM ubuntu:16.04 +RUN apt-get update diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..5f07058 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,25 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Build Tools +RUN apt-get install -y g++ gcc gdb flex bison make +RUN apt-get install -y clang clang-tidy clang-format +RUN apt-get install -y mingw-w64-common mingw-w64-tools mingw-w64 mingw-w64-i686-dev mingw-w64-x86-64-dev +RUN apt-get install -y git curl wget cmake + +# Libraries +# RUN apt-get install -y libcppunit-1.12-1 libcppunit-doc +# RUN apt-get install libqt4-dev libqt4-core libqt4-gui libqt4-sql libqt4-webkit +# RUN apt-get install graphviz doxygen libqttestrunner1c2a qdevelop + + +# RUN mkdir -p /home/jenkins +# RUN mkdir -p /var/lib/jenkins +# RUN echo -e "\n192.168.1.116 jenkins.localdomain\n" > /etc/hosts +# ADD slave.py /var/lib/jenkins/slave.py +# WORKDIR /home/jenkins +# ENV JENKINS_URL "http://jenkins.localdomain" +# ENV JENKINS_SLAVE_ADDRESS "" +# ENV JENKINS_USER "jryland" +# CMD [ "python", "-u", "/var/lib/jenkins/slave.py" ] + diff --git a/Dockerfile.lint b/Dockerfile.lint new file mode 100644 index 0000000..ebe5235 --- /dev/null +++ b/Dockerfile.lint @@ -0,0 +1,6 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Linting Tools +RUN apt-get install -y clang clang-tidy clang-format make git python3 + diff --git a/Makefile b/Makefile index 80f74c4..663d57e 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,66 @@ +SOURCES = Test.cpp -all: - mkdir -p build - x86_64-linux-gnu-g++ Test.cpp -o build/hello-linux-64 - x86_64-w64-mingw32-g++ Test.cpp -o build/hello-win64.exe - x86_64-apple-darwin19-c++ Test.cpp -o build/hello-macosx.bin +BUILD_DIR = build +CXXFLAGS = -std=c++14 -test: - mkdir -p build - echo "Blah" > build/tests.xml +UNAME := $(shell uname) +# LINUX version +ifeq ($(UNAME), Linux) +TARGETS := $(BUILD_DIR)/hello-linux-64 $(BUILD_DIR)/hello-win64.exe $(BUILD_DIR)/hello-macosx.bin +endif + +# WINDOWS version +ifeq ($(UNAME), MINGW64_NT-10.0) +TARGETS := $(BUILD_DIR)/hello-win64.exe +endif + +all: $(TARGETS) + @echo "all..." + @echo $(UNAME) + +.PRECIOUS: $(BUILD_DIR)/ $(BUILD_DIR)%/ + +$(BUILD_DIR)/: + @echo "dir1..." + @mkdir -p $@ + +$(BUILD_DIR)%/: + @echo "dir2..." + @mkdir -p $@ + +.SECONDEXPANSION: + +$(BUILD_DIR)/hello-linux-64: Test.cpp $$(@D)/ + @echo "Building Linux binary..." + @x86_64-linux-gnu-g++ $< -o $@ + +$(BUILD_DIR)/hello-win64.exe: Test.cpp $$(@D)/ + @echo "Building Windows binary..." + @x86_64-w64-mingw32-g++ $< -o $@ + +$(BUILD_DIR)/hello-macosx.bin: Test.cpp $$(@D)/ + @echo "Building MacOSX binary..." + @x86_64-apple-darwin19-c++ $< -o $@ + +tidy: $(BUILD_DIR)/tidy.xml + +$(BUILD_DIR)/tidy.xml: $$(@D)/ + @chmod u+x ./clang-tidy-to-junit.py + @clang-tidy -checks='c*,l*,m*' $(SOURCES) -- $(CXXFLAGS) | ./clang-tidy-to-junit.py $(PWD)/ > $@ + +test: $(BUILD_DIR)/tests.xml + +$(BUILD_DIR)/tests.xml: $$(@D)/ + @echo '' > $@ + @echo '' >> $@ + @echo '' >> $@ + publish: - echo "Publish..." + @echo "Publish..." diff --git a/Setup.md b/Setup.md new file mode 100644 index 0000000..f2f3457 --- /dev/null +++ b/Setup.md @@ -0,0 +1,23 @@ + + +Instructions here are pretty good: + + https://github.com/jgitver/jgitver-maven-plugin/wiki/automatic-builds-for-maven%2C-jenkins-and-gitbucket + + +On Windows Client: + + Edit (as Administrator) C:\Windows\System32\drivers\etc\hosts + and add the following: + + 192.168.1.116 gitbucket.localdomain + 192.168.1.116 jenkins.localdomain + +On MacOSX Clients: + + sudo vi /etc/hosts + + and add as above + + + diff --git a/Test.cpp b/Test.cpp index 6ed636d..66b4f84 100644 --- a/Test.cpp +++ b/Test.cpp @@ -1,6 +1,9 @@ + #include + int main() { printf("hello\n"); } + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..453ed1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +cache/ +build/ diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000..dc5df86 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,2 @@ +FROM ubuntu:16.04 +RUN apt-get update diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..5f07058 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,25 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Build Tools +RUN apt-get install -y g++ gcc gdb flex bison make +RUN apt-get install -y clang clang-tidy clang-format +RUN apt-get install -y mingw-w64-common mingw-w64-tools mingw-w64 mingw-w64-i686-dev mingw-w64-x86-64-dev +RUN apt-get install -y git curl wget cmake + +# Libraries +# RUN apt-get install -y libcppunit-1.12-1 libcppunit-doc +# RUN apt-get install libqt4-dev libqt4-core libqt4-gui libqt4-sql libqt4-webkit +# RUN apt-get install graphviz doxygen libqttestrunner1c2a qdevelop + + +# RUN mkdir -p /home/jenkins +# RUN mkdir -p /var/lib/jenkins +# RUN echo -e "\n192.168.1.116 jenkins.localdomain\n" > /etc/hosts +# ADD slave.py /var/lib/jenkins/slave.py +# WORKDIR /home/jenkins +# ENV JENKINS_URL "http://jenkins.localdomain" +# ENV JENKINS_SLAVE_ADDRESS "" +# ENV JENKINS_USER "jryland" +# CMD [ "python", "-u", "/var/lib/jenkins/slave.py" ] + diff --git a/Dockerfile.lint b/Dockerfile.lint new file mode 100644 index 0000000..ebe5235 --- /dev/null +++ b/Dockerfile.lint @@ -0,0 +1,6 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Linting Tools +RUN apt-get install -y clang clang-tidy clang-format make git python3 + diff --git a/Makefile b/Makefile index 80f74c4..663d57e 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,66 @@ +SOURCES = Test.cpp -all: - mkdir -p build - x86_64-linux-gnu-g++ Test.cpp -o build/hello-linux-64 - x86_64-w64-mingw32-g++ Test.cpp -o build/hello-win64.exe - x86_64-apple-darwin19-c++ Test.cpp -o build/hello-macosx.bin +BUILD_DIR = build +CXXFLAGS = -std=c++14 -test: - mkdir -p build - echo "Blah" > build/tests.xml +UNAME := $(shell uname) +# LINUX version +ifeq ($(UNAME), Linux) +TARGETS := $(BUILD_DIR)/hello-linux-64 $(BUILD_DIR)/hello-win64.exe $(BUILD_DIR)/hello-macosx.bin +endif + +# WINDOWS version +ifeq ($(UNAME), MINGW64_NT-10.0) +TARGETS := $(BUILD_DIR)/hello-win64.exe +endif + +all: $(TARGETS) + @echo "all..." + @echo $(UNAME) + +.PRECIOUS: $(BUILD_DIR)/ $(BUILD_DIR)%/ + +$(BUILD_DIR)/: + @echo "dir1..." + @mkdir -p $@ + +$(BUILD_DIR)%/: + @echo "dir2..." + @mkdir -p $@ + +.SECONDEXPANSION: + +$(BUILD_DIR)/hello-linux-64: Test.cpp $$(@D)/ + @echo "Building Linux binary..." + @x86_64-linux-gnu-g++ $< -o $@ + +$(BUILD_DIR)/hello-win64.exe: Test.cpp $$(@D)/ + @echo "Building Windows binary..." + @x86_64-w64-mingw32-g++ $< -o $@ + +$(BUILD_DIR)/hello-macosx.bin: Test.cpp $$(@D)/ + @echo "Building MacOSX binary..." + @x86_64-apple-darwin19-c++ $< -o $@ + +tidy: $(BUILD_DIR)/tidy.xml + +$(BUILD_DIR)/tidy.xml: $$(@D)/ + @chmod u+x ./clang-tidy-to-junit.py + @clang-tidy -checks='c*,l*,m*' $(SOURCES) -- $(CXXFLAGS) | ./clang-tidy-to-junit.py $(PWD)/ > $@ + +test: $(BUILD_DIR)/tests.xml + +$(BUILD_DIR)/tests.xml: $$(@D)/ + @echo '' > $@ + @echo '' >> $@ + @echo '' >> $@ + publish: - echo "Publish..." + @echo "Publish..." diff --git a/Setup.md b/Setup.md new file mode 100644 index 0000000..f2f3457 --- /dev/null +++ b/Setup.md @@ -0,0 +1,23 @@ + + +Instructions here are pretty good: + + https://github.com/jgitver/jgitver-maven-plugin/wiki/automatic-builds-for-maven%2C-jenkins-and-gitbucket + + +On Windows Client: + + Edit (as Administrator) C:\Windows\System32\drivers\etc\hosts + and add the following: + + 192.168.1.116 gitbucket.localdomain + 192.168.1.116 jenkins.localdomain + +On MacOSX Clients: + + sudo vi /etc/hosts + + and add as above + + + diff --git a/Test.cpp b/Test.cpp index 6ed636d..66b4f84 100644 --- a/Test.cpp +++ b/Test.cpp @@ -1,6 +1,9 @@ + #include + int main() { printf("hello\n"); } + diff --git a/build.sh b/build.sh deleted file mode 100755 index 13674d2..0000000 --- a/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -export PATH=/home/jryland/CrossCompilers/osxcross/target/bin:$PATH -make - diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..453ed1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +cache/ +build/ diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000..dc5df86 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,2 @@ +FROM ubuntu:16.04 +RUN apt-get update diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..5f07058 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,25 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Build Tools +RUN apt-get install -y g++ gcc gdb flex bison make +RUN apt-get install -y clang clang-tidy clang-format +RUN apt-get install -y mingw-w64-common mingw-w64-tools mingw-w64 mingw-w64-i686-dev mingw-w64-x86-64-dev +RUN apt-get install -y git curl wget cmake + +# Libraries +# RUN apt-get install -y libcppunit-1.12-1 libcppunit-doc +# RUN apt-get install libqt4-dev libqt4-core libqt4-gui libqt4-sql libqt4-webkit +# RUN apt-get install graphviz doxygen libqttestrunner1c2a qdevelop + + +# RUN mkdir -p /home/jenkins +# RUN mkdir -p /var/lib/jenkins +# RUN echo -e "\n192.168.1.116 jenkins.localdomain\n" > /etc/hosts +# ADD slave.py /var/lib/jenkins/slave.py +# WORKDIR /home/jenkins +# ENV JENKINS_URL "http://jenkins.localdomain" +# ENV JENKINS_SLAVE_ADDRESS "" +# ENV JENKINS_USER "jryland" +# CMD [ "python", "-u", "/var/lib/jenkins/slave.py" ] + diff --git a/Dockerfile.lint b/Dockerfile.lint new file mode 100644 index 0000000..ebe5235 --- /dev/null +++ b/Dockerfile.lint @@ -0,0 +1,6 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Linting Tools +RUN apt-get install -y clang clang-tidy clang-format make git python3 + diff --git a/Makefile b/Makefile index 80f74c4..663d57e 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,66 @@ +SOURCES = Test.cpp -all: - mkdir -p build - x86_64-linux-gnu-g++ Test.cpp -o build/hello-linux-64 - x86_64-w64-mingw32-g++ Test.cpp -o build/hello-win64.exe - x86_64-apple-darwin19-c++ Test.cpp -o build/hello-macosx.bin +BUILD_DIR = build +CXXFLAGS = -std=c++14 -test: - mkdir -p build - echo "Blah" > build/tests.xml +UNAME := $(shell uname) +# LINUX version +ifeq ($(UNAME), Linux) +TARGETS := $(BUILD_DIR)/hello-linux-64 $(BUILD_DIR)/hello-win64.exe $(BUILD_DIR)/hello-macosx.bin +endif + +# WINDOWS version +ifeq ($(UNAME), MINGW64_NT-10.0) +TARGETS := $(BUILD_DIR)/hello-win64.exe +endif + +all: $(TARGETS) + @echo "all..." + @echo $(UNAME) + +.PRECIOUS: $(BUILD_DIR)/ $(BUILD_DIR)%/ + +$(BUILD_DIR)/: + @echo "dir1..." + @mkdir -p $@ + +$(BUILD_DIR)%/: + @echo "dir2..." + @mkdir -p $@ + +.SECONDEXPANSION: + +$(BUILD_DIR)/hello-linux-64: Test.cpp $$(@D)/ + @echo "Building Linux binary..." + @x86_64-linux-gnu-g++ $< -o $@ + +$(BUILD_DIR)/hello-win64.exe: Test.cpp $$(@D)/ + @echo "Building Windows binary..." + @x86_64-w64-mingw32-g++ $< -o $@ + +$(BUILD_DIR)/hello-macosx.bin: Test.cpp $$(@D)/ + @echo "Building MacOSX binary..." + @x86_64-apple-darwin19-c++ $< -o $@ + +tidy: $(BUILD_DIR)/tidy.xml + +$(BUILD_DIR)/tidy.xml: $$(@D)/ + @chmod u+x ./clang-tidy-to-junit.py + @clang-tidy -checks='c*,l*,m*' $(SOURCES) -- $(CXXFLAGS) | ./clang-tidy-to-junit.py $(PWD)/ > $@ + +test: $(BUILD_DIR)/tests.xml + +$(BUILD_DIR)/tests.xml: $$(@D)/ + @echo '' > $@ + @echo '' >> $@ + @echo '' >> $@ + publish: - echo "Publish..." + @echo "Publish..." diff --git a/Setup.md b/Setup.md new file mode 100644 index 0000000..f2f3457 --- /dev/null +++ b/Setup.md @@ -0,0 +1,23 @@ + + +Instructions here are pretty good: + + https://github.com/jgitver/jgitver-maven-plugin/wiki/automatic-builds-for-maven%2C-jenkins-and-gitbucket + + +On Windows Client: + + Edit (as Administrator) C:\Windows\System32\drivers\etc\hosts + and add the following: + + 192.168.1.116 gitbucket.localdomain + 192.168.1.116 jenkins.localdomain + +On MacOSX Clients: + + sudo vi /etc/hosts + + and add as above + + + diff --git a/Test.cpp b/Test.cpp index 6ed636d..66b4f84 100644 --- a/Test.cpp +++ b/Test.cpp @@ -1,6 +1,9 @@ + #include + int main() { printf("hello\n"); } + diff --git a/build.sh b/build.sh deleted file mode 100755 index 13674d2..0000000 --- a/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -export PATH=/home/jryland/CrossCompilers/osxcross/target/bin:$PATH -make - diff --git a/clang-tidy-to-junit.py b/clang-tidy-to-junit.py new file mode 100755 index 0000000..a3496a6 --- /dev/null +++ b/clang-tidy-to-junit.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 + +import sys +import collections +import re +import logging +import itertools +from xml.sax.saxutils import escape + +# Create a `ErrorDescription` tuple with all the information we want to keep. +ErrorDescription = collections.namedtuple( + 'ErrorDescription', 'file line column error error_identifier description') + + +class ClangTidyConverter: + # All the errors encountered. + errors = [] + + # Parses the error. + # Group 1: file path + # Group 2: line + # Group 3: column + # Group 4: error message + # Group 5: error identifier + error_regex = re.compile( + r"^([\w\/\.\-\ ]+):(\d+):(\d+): (.+) (\[[\w\-,\.]+\])$") + + # This identifies the main error line (it has a [the-warning-type] at the end) + # We only create a new error when we encounter one of those. + main_error_identifier = re.compile(r'\[[\w\-,\.]+\]$') + + def __init__(self, basename): + self.basename = basename + + def print_junit_file(self, output_file): + # Write the header. + output_file.write(""" +""".format(error_count=len(self.errors))) + + sorted_errors = sorted(self.errors, key=lambda x: x.file) + + # Iterate through the errors, grouped by file. + for file, errorIterator in itertools.groupby(sorted_errors, key=lambda x: x.file): + errors = list(errorIterator) + error_count = len(errors) + + # Each file gets a test-suite + output_file.write("""\n \n""" + .format(error_count=error_count, file=file)) + for error in errors: + # Write each error as a test case. + output_file.write(""" + + +{htmldata} + + """.format(id="[{}/{}] {}".format(error.line, error.column, error.error_identifier), message=escape(error.error), + htmldata=escape(error.description))) + output_file.write("\n \n") + output_file.write("\n") + + def process_error(self, error_array): + if len(error_array) == 0: + return + + result = self.error_regex.match(error_array[0]) + if result is None: + logging.warning( + 'Could not match error_array to regex: %s', error_array) + return + + # We remove the `basename` from the `file_path` to make prettier filenames in the JUnit file. + file_path = result.group(1).replace(self.basename, "") + error = ErrorDescription(file_path, int(result.group(2)), int( + result.group(3)), result.group(4), result.group(5), "\n".join(error_array[1:])) + self.errors.append(error) + + def convert(self, input_file, output_file): + # Collect all lines related to one error. + current_error = [] + for line in input_file: + # If the line starts with a `/`, it is a line about a file. + if line[0] == '/': + # Look if it is the start of a error + if self.main_error_identifier.search(line, re.M): + # If so, process any `current_error` we might have + self.process_error(current_error) + # Initialize `current_error` with the first line of the error. + current_error = [line] + else: + # Otherwise, append the line to the error. + current_error.append(line) + elif len(current_error) > 0: + # If the line didn't start with a `/` and we have a `current_error`, we simply append + # the line as additional information. + current_error.append(line) + else: + pass + + # If we still have any current_error after we read all the lines, + # process it. + if len(current_error) > 0: + self.process_error(current_error) + + # Print the junit file. + self.print_junit_file(output_file) + + +if __name__ == "__main__": + if len(sys.argv) < 2: + logging.error("Usage: %s base-filename-path", sys.argv[0]) + logging.error( + " base-filename-path: Removed from the filenames to make nicer paths.") + sys.exit(1) + converter = ClangTidyConverter(sys.argv[1]) + converter.convert(sys.stdin, sys.stdout) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..453ed1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +cache/ +build/ diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000..dc5df86 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,2 @@ +FROM ubuntu:16.04 +RUN apt-get update diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..5f07058 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,25 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Build Tools +RUN apt-get install -y g++ gcc gdb flex bison make +RUN apt-get install -y clang clang-tidy clang-format +RUN apt-get install -y mingw-w64-common mingw-w64-tools mingw-w64 mingw-w64-i686-dev mingw-w64-x86-64-dev +RUN apt-get install -y git curl wget cmake + +# Libraries +# RUN apt-get install -y libcppunit-1.12-1 libcppunit-doc +# RUN apt-get install libqt4-dev libqt4-core libqt4-gui libqt4-sql libqt4-webkit +# RUN apt-get install graphviz doxygen libqttestrunner1c2a qdevelop + + +# RUN mkdir -p /home/jenkins +# RUN mkdir -p /var/lib/jenkins +# RUN echo -e "\n192.168.1.116 jenkins.localdomain\n" > /etc/hosts +# ADD slave.py /var/lib/jenkins/slave.py +# WORKDIR /home/jenkins +# ENV JENKINS_URL "http://jenkins.localdomain" +# ENV JENKINS_SLAVE_ADDRESS "" +# ENV JENKINS_USER "jryland" +# CMD [ "python", "-u", "/var/lib/jenkins/slave.py" ] + diff --git a/Dockerfile.lint b/Dockerfile.lint new file mode 100644 index 0000000..ebe5235 --- /dev/null +++ b/Dockerfile.lint @@ -0,0 +1,6 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Linting Tools +RUN apt-get install -y clang clang-tidy clang-format make git python3 + diff --git a/Makefile b/Makefile index 80f74c4..663d57e 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,66 @@ +SOURCES = Test.cpp -all: - mkdir -p build - x86_64-linux-gnu-g++ Test.cpp -o build/hello-linux-64 - x86_64-w64-mingw32-g++ Test.cpp -o build/hello-win64.exe - x86_64-apple-darwin19-c++ Test.cpp -o build/hello-macosx.bin +BUILD_DIR = build +CXXFLAGS = -std=c++14 -test: - mkdir -p build - echo "Blah" > build/tests.xml +UNAME := $(shell uname) +# LINUX version +ifeq ($(UNAME), Linux) +TARGETS := $(BUILD_DIR)/hello-linux-64 $(BUILD_DIR)/hello-win64.exe $(BUILD_DIR)/hello-macosx.bin +endif + +# WINDOWS version +ifeq ($(UNAME), MINGW64_NT-10.0) +TARGETS := $(BUILD_DIR)/hello-win64.exe +endif + +all: $(TARGETS) + @echo "all..." + @echo $(UNAME) + +.PRECIOUS: $(BUILD_DIR)/ $(BUILD_DIR)%/ + +$(BUILD_DIR)/: + @echo "dir1..." + @mkdir -p $@ + +$(BUILD_DIR)%/: + @echo "dir2..." + @mkdir -p $@ + +.SECONDEXPANSION: + +$(BUILD_DIR)/hello-linux-64: Test.cpp $$(@D)/ + @echo "Building Linux binary..." + @x86_64-linux-gnu-g++ $< -o $@ + +$(BUILD_DIR)/hello-win64.exe: Test.cpp $$(@D)/ + @echo "Building Windows binary..." + @x86_64-w64-mingw32-g++ $< -o $@ + +$(BUILD_DIR)/hello-macosx.bin: Test.cpp $$(@D)/ + @echo "Building MacOSX binary..." + @x86_64-apple-darwin19-c++ $< -o $@ + +tidy: $(BUILD_DIR)/tidy.xml + +$(BUILD_DIR)/tidy.xml: $$(@D)/ + @chmod u+x ./clang-tidy-to-junit.py + @clang-tidy -checks='c*,l*,m*' $(SOURCES) -- $(CXXFLAGS) | ./clang-tidy-to-junit.py $(PWD)/ > $@ + +test: $(BUILD_DIR)/tests.xml + +$(BUILD_DIR)/tests.xml: $$(@D)/ + @echo '' > $@ + @echo '' >> $@ + @echo '' >> $@ + publish: - echo "Publish..." + @echo "Publish..." diff --git a/Setup.md b/Setup.md new file mode 100644 index 0000000..f2f3457 --- /dev/null +++ b/Setup.md @@ -0,0 +1,23 @@ + + +Instructions here are pretty good: + + https://github.com/jgitver/jgitver-maven-plugin/wiki/automatic-builds-for-maven%2C-jenkins-and-gitbucket + + +On Windows Client: + + Edit (as Administrator) C:\Windows\System32\drivers\etc\hosts + and add the following: + + 192.168.1.116 gitbucket.localdomain + 192.168.1.116 jenkins.localdomain + +On MacOSX Clients: + + sudo vi /etc/hosts + + and add as above + + + diff --git a/Test.cpp b/Test.cpp index 6ed636d..66b4f84 100644 --- a/Test.cpp +++ b/Test.cpp @@ -1,6 +1,9 @@ + #include + int main() { printf("hello\n"); } + diff --git a/build.sh b/build.sh deleted file mode 100755 index 13674d2..0000000 --- a/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -export PATH=/home/jryland/CrossCompilers/osxcross/target/bin:$PATH -make - diff --git a/clang-tidy-to-junit.py b/clang-tidy-to-junit.py new file mode 100755 index 0000000..a3496a6 --- /dev/null +++ b/clang-tidy-to-junit.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 + +import sys +import collections +import re +import logging +import itertools +from xml.sax.saxutils import escape + +# Create a `ErrorDescription` tuple with all the information we want to keep. +ErrorDescription = collections.namedtuple( + 'ErrorDescription', 'file line column error error_identifier description') + + +class ClangTidyConverter: + # All the errors encountered. + errors = [] + + # Parses the error. + # Group 1: file path + # Group 2: line + # Group 3: column + # Group 4: error message + # Group 5: error identifier + error_regex = re.compile( + r"^([\w\/\.\-\ ]+):(\d+):(\d+): (.+) (\[[\w\-,\.]+\])$") + + # This identifies the main error line (it has a [the-warning-type] at the end) + # We only create a new error when we encounter one of those. + main_error_identifier = re.compile(r'\[[\w\-,\.]+\]$') + + def __init__(self, basename): + self.basename = basename + + def print_junit_file(self, output_file): + # Write the header. + output_file.write(""" +""".format(error_count=len(self.errors))) + + sorted_errors = sorted(self.errors, key=lambda x: x.file) + + # Iterate through the errors, grouped by file. + for file, errorIterator in itertools.groupby(sorted_errors, key=lambda x: x.file): + errors = list(errorIterator) + error_count = len(errors) + + # Each file gets a test-suite + output_file.write("""\n \n""" + .format(error_count=error_count, file=file)) + for error in errors: + # Write each error as a test case. + output_file.write(""" + + +{htmldata} + + """.format(id="[{}/{}] {}".format(error.line, error.column, error.error_identifier), message=escape(error.error), + htmldata=escape(error.description))) + output_file.write("\n \n") + output_file.write("\n") + + def process_error(self, error_array): + if len(error_array) == 0: + return + + result = self.error_regex.match(error_array[0]) + if result is None: + logging.warning( + 'Could not match error_array to regex: %s', error_array) + return + + # We remove the `basename` from the `file_path` to make prettier filenames in the JUnit file. + file_path = result.group(1).replace(self.basename, "") + error = ErrorDescription(file_path, int(result.group(2)), int( + result.group(3)), result.group(4), result.group(5), "\n".join(error_array[1:])) + self.errors.append(error) + + def convert(self, input_file, output_file): + # Collect all lines related to one error. + current_error = [] + for line in input_file: + # If the line starts with a `/`, it is a line about a file. + if line[0] == '/': + # Look if it is the start of a error + if self.main_error_identifier.search(line, re.M): + # If so, process any `current_error` we might have + self.process_error(current_error) + # Initialize `current_error` with the first line of the error. + current_error = [line] + else: + # Otherwise, append the line to the error. + current_error.append(line) + elif len(current_error) > 0: + # If the line didn't start with a `/` and we have a `current_error`, we simply append + # the line as additional information. + current_error.append(line) + else: + pass + + # If we still have any current_error after we read all the lines, + # process it. + if len(current_error) > 0: + self.process_error(current_error) + + # Print the junit file. + self.print_junit_file(output_file) + + +if __name__ == "__main__": + if len(sys.argv) < 2: + logging.error("Usage: %s base-filename-path", sys.argv[0]) + logging.error( + " base-filename-path: Removed from the filenames to make nicer paths.") + sys.exit(1) + converter = ClangTidyConverter(sys.argv[1]) + converter.convert(sys.stdin, sys.stdout) diff --git a/run-tidy.sh b/run-tidy.sh new file mode 100644 index 0000000..63ba4fa --- /dev/null +++ b/run-tidy.sh @@ -0,0 +1,6 @@ +#!/bin/bash + + +cat "$build_dir/clang-tidy-output" | ./clang-tidy-to-junit.py /srv/Jenkins/source-root-directory >"$build_dir/junit.xml" + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..453ed1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +cache/ +build/ diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000..dc5df86 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,2 @@ +FROM ubuntu:16.04 +RUN apt-get update diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..5f07058 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,25 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Build Tools +RUN apt-get install -y g++ gcc gdb flex bison make +RUN apt-get install -y clang clang-tidy clang-format +RUN apt-get install -y mingw-w64-common mingw-w64-tools mingw-w64 mingw-w64-i686-dev mingw-w64-x86-64-dev +RUN apt-get install -y git curl wget cmake + +# Libraries +# RUN apt-get install -y libcppunit-1.12-1 libcppunit-doc +# RUN apt-get install libqt4-dev libqt4-core libqt4-gui libqt4-sql libqt4-webkit +# RUN apt-get install graphviz doxygen libqttestrunner1c2a qdevelop + + +# RUN mkdir -p /home/jenkins +# RUN mkdir -p /var/lib/jenkins +# RUN echo -e "\n192.168.1.116 jenkins.localdomain\n" > /etc/hosts +# ADD slave.py /var/lib/jenkins/slave.py +# WORKDIR /home/jenkins +# ENV JENKINS_URL "http://jenkins.localdomain" +# ENV JENKINS_SLAVE_ADDRESS "" +# ENV JENKINS_USER "jryland" +# CMD [ "python", "-u", "/var/lib/jenkins/slave.py" ] + diff --git a/Dockerfile.lint b/Dockerfile.lint new file mode 100644 index 0000000..ebe5235 --- /dev/null +++ b/Dockerfile.lint @@ -0,0 +1,6 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Linting Tools +RUN apt-get install -y clang clang-tidy clang-format make git python3 + diff --git a/Makefile b/Makefile index 80f74c4..663d57e 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,66 @@ +SOURCES = Test.cpp -all: - mkdir -p build - x86_64-linux-gnu-g++ Test.cpp -o build/hello-linux-64 - x86_64-w64-mingw32-g++ Test.cpp -o build/hello-win64.exe - x86_64-apple-darwin19-c++ Test.cpp -o build/hello-macosx.bin +BUILD_DIR = build +CXXFLAGS = -std=c++14 -test: - mkdir -p build - echo "Blah" > build/tests.xml +UNAME := $(shell uname) +# LINUX version +ifeq ($(UNAME), Linux) +TARGETS := $(BUILD_DIR)/hello-linux-64 $(BUILD_DIR)/hello-win64.exe $(BUILD_DIR)/hello-macosx.bin +endif + +# WINDOWS version +ifeq ($(UNAME), MINGW64_NT-10.0) +TARGETS := $(BUILD_DIR)/hello-win64.exe +endif + +all: $(TARGETS) + @echo "all..." + @echo $(UNAME) + +.PRECIOUS: $(BUILD_DIR)/ $(BUILD_DIR)%/ + +$(BUILD_DIR)/: + @echo "dir1..." + @mkdir -p $@ + +$(BUILD_DIR)%/: + @echo "dir2..." + @mkdir -p $@ + +.SECONDEXPANSION: + +$(BUILD_DIR)/hello-linux-64: Test.cpp $$(@D)/ + @echo "Building Linux binary..." + @x86_64-linux-gnu-g++ $< -o $@ + +$(BUILD_DIR)/hello-win64.exe: Test.cpp $$(@D)/ + @echo "Building Windows binary..." + @x86_64-w64-mingw32-g++ $< -o $@ + +$(BUILD_DIR)/hello-macosx.bin: Test.cpp $$(@D)/ + @echo "Building MacOSX binary..." + @x86_64-apple-darwin19-c++ $< -o $@ + +tidy: $(BUILD_DIR)/tidy.xml + +$(BUILD_DIR)/tidy.xml: $$(@D)/ + @chmod u+x ./clang-tidy-to-junit.py + @clang-tidy -checks='c*,l*,m*' $(SOURCES) -- $(CXXFLAGS) | ./clang-tidy-to-junit.py $(PWD)/ > $@ + +test: $(BUILD_DIR)/tests.xml + +$(BUILD_DIR)/tests.xml: $$(@D)/ + @echo '' > $@ + @echo '' >> $@ + @echo '' >> $@ + publish: - echo "Publish..." + @echo "Publish..." diff --git a/Setup.md b/Setup.md new file mode 100644 index 0000000..f2f3457 --- /dev/null +++ b/Setup.md @@ -0,0 +1,23 @@ + + +Instructions here are pretty good: + + https://github.com/jgitver/jgitver-maven-plugin/wiki/automatic-builds-for-maven%2C-jenkins-and-gitbucket + + +On Windows Client: + + Edit (as Administrator) C:\Windows\System32\drivers\etc\hosts + and add the following: + + 192.168.1.116 gitbucket.localdomain + 192.168.1.116 jenkins.localdomain + +On MacOSX Clients: + + sudo vi /etc/hosts + + and add as above + + + diff --git a/Test.cpp b/Test.cpp index 6ed636d..66b4f84 100644 --- a/Test.cpp +++ b/Test.cpp @@ -1,6 +1,9 @@ + #include + int main() { printf("hello\n"); } + diff --git a/build.sh b/build.sh deleted file mode 100755 index 13674d2..0000000 --- a/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -export PATH=/home/jryland/CrossCompilers/osxcross/target/bin:$PATH -make - diff --git a/clang-tidy-to-junit.py b/clang-tidy-to-junit.py new file mode 100755 index 0000000..a3496a6 --- /dev/null +++ b/clang-tidy-to-junit.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 + +import sys +import collections +import re +import logging +import itertools +from xml.sax.saxutils import escape + +# Create a `ErrorDescription` tuple with all the information we want to keep. +ErrorDescription = collections.namedtuple( + 'ErrorDescription', 'file line column error error_identifier description') + + +class ClangTidyConverter: + # All the errors encountered. + errors = [] + + # Parses the error. + # Group 1: file path + # Group 2: line + # Group 3: column + # Group 4: error message + # Group 5: error identifier + error_regex = re.compile( + r"^([\w\/\.\-\ ]+):(\d+):(\d+): (.+) (\[[\w\-,\.]+\])$") + + # This identifies the main error line (it has a [the-warning-type] at the end) + # We only create a new error when we encounter one of those. + main_error_identifier = re.compile(r'\[[\w\-,\.]+\]$') + + def __init__(self, basename): + self.basename = basename + + def print_junit_file(self, output_file): + # Write the header. + output_file.write(""" +""".format(error_count=len(self.errors))) + + sorted_errors = sorted(self.errors, key=lambda x: x.file) + + # Iterate through the errors, grouped by file. + for file, errorIterator in itertools.groupby(sorted_errors, key=lambda x: x.file): + errors = list(errorIterator) + error_count = len(errors) + + # Each file gets a test-suite + output_file.write("""\n \n""" + .format(error_count=error_count, file=file)) + for error in errors: + # Write each error as a test case. + output_file.write(""" + + +{htmldata} + + """.format(id="[{}/{}] {}".format(error.line, error.column, error.error_identifier), message=escape(error.error), + htmldata=escape(error.description))) + output_file.write("\n \n") + output_file.write("\n") + + def process_error(self, error_array): + if len(error_array) == 0: + return + + result = self.error_regex.match(error_array[0]) + if result is None: + logging.warning( + 'Could not match error_array to regex: %s', error_array) + return + + # We remove the `basename` from the `file_path` to make prettier filenames in the JUnit file. + file_path = result.group(1).replace(self.basename, "") + error = ErrorDescription(file_path, int(result.group(2)), int( + result.group(3)), result.group(4), result.group(5), "\n".join(error_array[1:])) + self.errors.append(error) + + def convert(self, input_file, output_file): + # Collect all lines related to one error. + current_error = [] + for line in input_file: + # If the line starts with a `/`, it is a line about a file. + if line[0] == '/': + # Look if it is the start of a error + if self.main_error_identifier.search(line, re.M): + # If so, process any `current_error` we might have + self.process_error(current_error) + # Initialize `current_error` with the first line of the error. + current_error = [line] + else: + # Otherwise, append the line to the error. + current_error.append(line) + elif len(current_error) > 0: + # If the line didn't start with a `/` and we have a `current_error`, we simply append + # the line as additional information. + current_error.append(line) + else: + pass + + # If we still have any current_error after we read all the lines, + # process it. + if len(current_error) > 0: + self.process_error(current_error) + + # Print the junit file. + self.print_junit_file(output_file) + + +if __name__ == "__main__": + if len(sys.argv) < 2: + logging.error("Usage: %s base-filename-path", sys.argv[0]) + logging.error( + " base-filename-path: Removed from the filenames to make nicer paths.") + sys.exit(1) + converter = ClangTidyConverter(sys.argv[1]) + converter.convert(sys.stdin, sys.stdout) diff --git a/run-tidy.sh b/run-tidy.sh new file mode 100644 index 0000000..63ba4fa --- /dev/null +++ b/run-tidy.sh @@ -0,0 +1,6 @@ +#!/bin/bash + + +cat "$build_dir/clang-tidy-output" | ./clang-tidy-to-junit.py /srv/Jenkins/source-root-directory >"$build_dir/junit.xml" + + diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..d43aad9 --- /dev/null +++ b/setup.sh @@ -0,0 +1,6 @@ +#!/bin/bash + + +curl https://raw.githubusercontent.com/PSPDFKit-labs/clang-tidy-to-junit/master/clang-tidy-to-junit.py -o clang-tidy-to-junit.py + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..453ed1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +cache/ +build/ diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000..dc5df86 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,2 @@ +FROM ubuntu:16.04 +RUN apt-get update diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..5f07058 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,25 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Build Tools +RUN apt-get install -y g++ gcc gdb flex bison make +RUN apt-get install -y clang clang-tidy clang-format +RUN apt-get install -y mingw-w64-common mingw-w64-tools mingw-w64 mingw-w64-i686-dev mingw-w64-x86-64-dev +RUN apt-get install -y git curl wget cmake + +# Libraries +# RUN apt-get install -y libcppunit-1.12-1 libcppunit-doc +# RUN apt-get install libqt4-dev libqt4-core libqt4-gui libqt4-sql libqt4-webkit +# RUN apt-get install graphviz doxygen libqttestrunner1c2a qdevelop + + +# RUN mkdir -p /home/jenkins +# RUN mkdir -p /var/lib/jenkins +# RUN echo -e "\n192.168.1.116 jenkins.localdomain\n" > /etc/hosts +# ADD slave.py /var/lib/jenkins/slave.py +# WORKDIR /home/jenkins +# ENV JENKINS_URL "http://jenkins.localdomain" +# ENV JENKINS_SLAVE_ADDRESS "" +# ENV JENKINS_USER "jryland" +# CMD [ "python", "-u", "/var/lib/jenkins/slave.py" ] + diff --git a/Dockerfile.lint b/Dockerfile.lint new file mode 100644 index 0000000..ebe5235 --- /dev/null +++ b/Dockerfile.lint @@ -0,0 +1,6 @@ +FROM ubuntu:16.04 +RUN apt-get update + +# Install Linting Tools +RUN apt-get install -y clang clang-tidy clang-format make git python3 + diff --git a/Makefile b/Makefile index 80f74c4..663d57e 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,66 @@ +SOURCES = Test.cpp -all: - mkdir -p build - x86_64-linux-gnu-g++ Test.cpp -o build/hello-linux-64 - x86_64-w64-mingw32-g++ Test.cpp -o build/hello-win64.exe - x86_64-apple-darwin19-c++ Test.cpp -o build/hello-macosx.bin +BUILD_DIR = build +CXXFLAGS = -std=c++14 -test: - mkdir -p build - echo "Blah" > build/tests.xml +UNAME := $(shell uname) +# LINUX version +ifeq ($(UNAME), Linux) +TARGETS := $(BUILD_DIR)/hello-linux-64 $(BUILD_DIR)/hello-win64.exe $(BUILD_DIR)/hello-macosx.bin +endif + +# WINDOWS version +ifeq ($(UNAME), MINGW64_NT-10.0) +TARGETS := $(BUILD_DIR)/hello-win64.exe +endif + +all: $(TARGETS) + @echo "all..." + @echo $(UNAME) + +.PRECIOUS: $(BUILD_DIR)/ $(BUILD_DIR)%/ + +$(BUILD_DIR)/: + @echo "dir1..." + @mkdir -p $@ + +$(BUILD_DIR)%/: + @echo "dir2..." + @mkdir -p $@ + +.SECONDEXPANSION: + +$(BUILD_DIR)/hello-linux-64: Test.cpp $$(@D)/ + @echo "Building Linux binary..." + @x86_64-linux-gnu-g++ $< -o $@ + +$(BUILD_DIR)/hello-win64.exe: Test.cpp $$(@D)/ + @echo "Building Windows binary..." + @x86_64-w64-mingw32-g++ $< -o $@ + +$(BUILD_DIR)/hello-macosx.bin: Test.cpp $$(@D)/ + @echo "Building MacOSX binary..." + @x86_64-apple-darwin19-c++ $< -o $@ + +tidy: $(BUILD_DIR)/tidy.xml + +$(BUILD_DIR)/tidy.xml: $$(@D)/ + @chmod u+x ./clang-tidy-to-junit.py + @clang-tidy -checks='c*,l*,m*' $(SOURCES) -- $(CXXFLAGS) | ./clang-tidy-to-junit.py $(PWD)/ > $@ + +test: $(BUILD_DIR)/tests.xml + +$(BUILD_DIR)/tests.xml: $$(@D)/ + @echo '' > $@ + @echo '' >> $@ + @echo '' >> $@ + publish: - echo "Publish..." + @echo "Publish..." diff --git a/Setup.md b/Setup.md new file mode 100644 index 0000000..f2f3457 --- /dev/null +++ b/Setup.md @@ -0,0 +1,23 @@ + + +Instructions here are pretty good: + + https://github.com/jgitver/jgitver-maven-plugin/wiki/automatic-builds-for-maven%2C-jenkins-and-gitbucket + + +On Windows Client: + + Edit (as Administrator) C:\Windows\System32\drivers\etc\hosts + and add the following: + + 192.168.1.116 gitbucket.localdomain + 192.168.1.116 jenkins.localdomain + +On MacOSX Clients: + + sudo vi /etc/hosts + + and add as above + + + diff --git a/Test.cpp b/Test.cpp index 6ed636d..66b4f84 100644 --- a/Test.cpp +++ b/Test.cpp @@ -1,6 +1,9 @@ + #include + int main() { printf("hello\n"); } + diff --git a/build.sh b/build.sh deleted file mode 100755 index 13674d2..0000000 --- a/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -export PATH=/home/jryland/CrossCompilers/osxcross/target/bin:$PATH -make - diff --git a/clang-tidy-to-junit.py b/clang-tidy-to-junit.py new file mode 100755 index 0000000..a3496a6 --- /dev/null +++ b/clang-tidy-to-junit.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 + +import sys +import collections +import re +import logging +import itertools +from xml.sax.saxutils import escape + +# Create a `ErrorDescription` tuple with all the information we want to keep. +ErrorDescription = collections.namedtuple( + 'ErrorDescription', 'file line column error error_identifier description') + + +class ClangTidyConverter: + # All the errors encountered. + errors = [] + + # Parses the error. + # Group 1: file path + # Group 2: line + # Group 3: column + # Group 4: error message + # Group 5: error identifier + error_regex = re.compile( + r"^([\w\/\.\-\ ]+):(\d+):(\d+): (.+) (\[[\w\-,\.]+\])$") + + # This identifies the main error line (it has a [the-warning-type] at the end) + # We only create a new error when we encounter one of those. + main_error_identifier = re.compile(r'\[[\w\-,\.]+\]$') + + def __init__(self, basename): + self.basename = basename + + def print_junit_file(self, output_file): + # Write the header. + output_file.write(""" +""".format(error_count=len(self.errors))) + + sorted_errors = sorted(self.errors, key=lambda x: x.file) + + # Iterate through the errors, grouped by file. + for file, errorIterator in itertools.groupby(sorted_errors, key=lambda x: x.file): + errors = list(errorIterator) + error_count = len(errors) + + # Each file gets a test-suite + output_file.write("""\n \n""" + .format(error_count=error_count, file=file)) + for error in errors: + # Write each error as a test case. + output_file.write(""" + + +{htmldata} + + """.format(id="[{}/{}] {}".format(error.line, error.column, error.error_identifier), message=escape(error.error), + htmldata=escape(error.description))) + output_file.write("\n \n") + output_file.write("\n") + + def process_error(self, error_array): + if len(error_array) == 0: + return + + result = self.error_regex.match(error_array[0]) + if result is None: + logging.warning( + 'Could not match error_array to regex: %s', error_array) + return + + # We remove the `basename` from the `file_path` to make prettier filenames in the JUnit file. + file_path = result.group(1).replace(self.basename, "") + error = ErrorDescription(file_path, int(result.group(2)), int( + result.group(3)), result.group(4), result.group(5), "\n".join(error_array[1:])) + self.errors.append(error) + + def convert(self, input_file, output_file): + # Collect all lines related to one error. + current_error = [] + for line in input_file: + # If the line starts with a `/`, it is a line about a file. + if line[0] == '/': + # Look if it is the start of a error + if self.main_error_identifier.search(line, re.M): + # If so, process any `current_error` we might have + self.process_error(current_error) + # Initialize `current_error` with the first line of the error. + current_error = [line] + else: + # Otherwise, append the line to the error. + current_error.append(line) + elif len(current_error) > 0: + # If the line didn't start with a `/` and we have a `current_error`, we simply append + # the line as additional information. + current_error.append(line) + else: + pass + + # If we still have any current_error after we read all the lines, + # process it. + if len(current_error) > 0: + self.process_error(current_error) + + # Print the junit file. + self.print_junit_file(output_file) + + +if __name__ == "__main__": + if len(sys.argv) < 2: + logging.error("Usage: %s base-filename-path", sys.argv[0]) + logging.error( + " base-filename-path: Removed from the filenames to make nicer paths.") + sys.exit(1) + converter = ClangTidyConverter(sys.argv[1]) + converter.convert(sys.stdin, sys.stdout) diff --git a/run-tidy.sh b/run-tidy.sh new file mode 100644 index 0000000..63ba4fa --- /dev/null +++ b/run-tidy.sh @@ -0,0 +1,6 @@ +#!/bin/bash + + +cat "$build_dir/clang-tidy-output" | ./clang-tidy-to-junit.py /srv/Jenkins/source-root-directory >"$build_dir/junit.xml" + + diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..d43aad9 --- /dev/null +++ b/setup.sh @@ -0,0 +1,6 @@ +#!/bin/bash + + +curl https://raw.githubusercontent.com/PSPDFKit-labs/clang-tidy-to-junit/master/clang-tidy-to-junit.py -o clang-tidy-to-junit.py + + diff --git a/windows-setup.sh b/windows-setup.sh new file mode 100644 index 0000000..10399ea --- /dev/null +++ b/windows-setup.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +mkdir -p cache +cd cache + +PYTHON_INSTALL=python-3.8.0.exe +if [ ! -f ${PYTHON_INSTALL} ] +then + curl https://www.python.org/ftp/python/3.8.0/${PYTHON_INSTALL} -o ${PYTHON_INSTALL} +fi +chmod u+x ${PYTHON_INSTALL} +cmd //C ${PYTHON_INSTALL} + + +CLANG_INSTALL=LLVM-9.0.0-win64.exe +if [ ! -f ${CLANG_INSTALL} ] +then + curl http://releases.llvm.org/9.0.0/${CLANG_INSTALL} -o ${CLANG_INSTALL} +fi +chmod u+x ${CLANG_INSTALL} +cmd //C ${CLANG_INSTALL} + + +MINGW_INSTALL=mingw-w64-install.exe +if [ ! -f ${MINGW_INSTALL} ] +then + curl https://nchc.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/${MINGW_INSTALL} -o ${MINGW_INSTALL} +fi +chmod u+x ${MINGW_INSTALL} +cmd //C ${MINGW_INSTALL} + + +TIDY_TO_JUNIT=clang-tidy-to-junit.py +if [ ! -f ${TIDY_TO_JUNIT} ] +then + curl https://raw.githubusercontent.com/PSPDFKit-labs/clang-tidy-to-junit/master/${TIDY_TO_JUNIT} -o ${TIDY_TO_JUNIT} +fi + +