summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2022-07-15 11:14:14 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2022-07-16 14:33:01 +0200
commit523bb702ec416e77ecf2eab91021c7b044f4aec0 (patch)
tree0a09c1674ab3bcb94ab5427dc9466a579b13fafd
parentae1871ca0ffcac3e8bd337f8d8bb4e7fd6c59295 (diff)
Build with clangclang
-rw-r--r--Jenkinsfile39
-rwxr-xr-xbootstrap.sh13
-rw-r--r--src/bootstrap.cc7
-rw-r--r--src/configure.cc23
-rw-r--r--src/rebuild.h2
-rw-r--r--src/task.h1
-rw-r--r--src/tasks.h4
-rw-r--r--src/unittest.h2
8 files changed, 78 insertions, 13 deletions
diff --git a/Jenkinsfile b/Jenkinsfile
index b483ac3..3e269dd 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -2,18 +2,45 @@ pipeline {
agent { label 'c++20' }
stages {
- stage('Build') {
+ stage('Clean') {
steps {
- echo 'Building...'
- sh 'rm -Rf build'
+ echo 'Cleaning workspace ...'
+ sh 'rm -Rf build build-gcc build-clang'
+ }
+ }
+ stage('Build-gcc') {
+ steps {
+ echo 'Building (gcc) ...'
sh './bootstrap.sh'
}
}
- stage('Test') {
+ stage('Test-gcc') {
+ steps {
+ echo 'Testing (gcc) ...'
+ sh './ctor check'
+ }
+ post {
+ always {
+ sh 'mv build build-gcc'
+ }
+ }
+ }
+ stage('Build-clang') {
+ steps {
+ echo 'Building (clang) ...'
+ sh 'CXX=clang++-15 ./bootstrap.sh'
+ }
+ }
+ stage('Test-clang') {
steps {
- echo 'Testing...'
+ echo 'Testing (clang) ...'
sh './ctor check'
}
+ post {
+ always {
+ sh 'mv build build-clang'
+ }
+ }
}
}
@@ -21,7 +48,7 @@ pipeline {
always {
xunit(thresholds: [ skipped(failureThreshold: '0'),
failed(failureThreshold: '0') ],
- tools: [ CppUnit(pattern: 'build/test/*.xml') ])
+ tools: [ CppUnit(pattern: 'build-*/test/*.xml') ])
}
}
} \ No newline at end of file
diff --git a/bootstrap.sh b/bootstrap.sh
index a5c11ac..abe8012 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,7 +1,16 @@
#!/bin/sh
+: ${CXX:=g++}
+CXX=$(which $CXX)
+$CXX -std=c++20 /dev/null -c -o /dev/null 2> /dev/null 1> /dev/null
+if [ $? != 0 ]
+then
+ echo "Set CXX to a compiler supporting c++20."
+ exit 1
+fi
+
echo "Bootstrapping..."
-g++ -std=c++20 -Wall -O3 -Isrc -pthread src/bootstrap.cc ctor.cc test/ctor.cc -o ctor && \
+$CXX -std=c++20 -Wall -O3 -Isrc -pthread src/bootstrap.cc ctor.cc test/ctor.cc -o ctor && \
./ctor && \
-g++ -std=c++20 -Wall -O3 -Isrc -pthread ctor.cc test/ctor.cc -Lbuild -lctor -o ctor && \
+$CXX -std=c++20 -Wall -O3 -Isrc -pthread ctor.cc test/ctor.cc -Lbuild -lctor -o ctor && \
./ctor configure --ctor-includedir=src --ctor-libdir=build && \
echo "Done. Now run ./ctor to (re)build."
diff --git a/src/bootstrap.cc b/src/bootstrap.cc
index 9a3c321..7abd9cf 100644
--- a/src/bootstrap.cc
+++ b/src/bootstrap.cc
@@ -3,6 +3,7 @@
// See accompanying file LICENSE for details.
#include <iostream>
#include <array>
+#include <cstdlib>
#define BOOTSTRAP
@@ -35,6 +36,12 @@ bool hasConfiguration(const std::string& key)
const std::string& getConfiguration(const std::string& key,
const std::string& defaultValue)
{
+ if(key == cfg::host_cxx && std::getenv("CXX"))
+ {
+ static std::string s = std::getenv("CXX");
+ return s;
+ }
+
return defaultValue;
}
diff --git a/src/configure.cc b/src/configure.cc
index a81f8ad..e006aa0 100644
--- a/src/configure.cc
+++ b/src/configure.cc
@@ -32,6 +32,7 @@ namespace ctor
{
std::optional<std::string> includedir;
std::optional<std::string> libdir;
+std::map<std::string, std::string> conf_values;
}
bool hasConfiguration(const std::string& key)
@@ -46,6 +47,11 @@ bool hasConfiguration(const std::string& key)
return true;
}
+ if(ctor::conf_values.find(key) != ctor::conf_values.end())
+ {
+ return true;
+ }
+
const auto& c = configuration();
return c.tools.find(key) != c.tools.end();
}
@@ -63,6 +69,11 @@ const std::string& getConfiguration(const std::string& key,
return *ctor::libdir;
}
+ if(ctor::conf_values.find(key) != ctor::conf_values.end())
+ {
+ return ctor::conf_values[key];
+ }
+
const auto& c = configuration();
if(hasConfiguration(key))
{
@@ -376,6 +387,18 @@ int regenerateCache(const Settings& default_settings,
std::string build_ar = locate(build_arch, ar_prog);
std::string build_ld = locate(build_arch, ld_prog);
+ // Store current values for execution in this execution context.
+ if(!ctor_includedir.empty())
+ {
+ ctor::conf_values[cfg::ctor_includedir] = ctor_includedir;
+ }
+ if(!ctor_libdir.empty())
+ {
+ ctor::conf_values[cfg::ctor_libdir] = ctor_libdir;
+ }
+ ctor::conf_values[cfg::host_cxx] = host_cxx;
+ ctor::conf_values[cfg::build_cxx] = build_cxx;
+
std::cout << "Writing results to: " << configurationFile.string() << "\n";
{
std::ofstream istr(configurationFile);
diff --git a/src/rebuild.h b/src/rebuild.h
index f1255c6..94cda2d 100644
--- a/src/rebuild.h
+++ b/src/rebuild.h
@@ -8,8 +8,6 @@
#include "libctor.h"
-class Settings;
-
struct BuildConfigurationEntry
{
const char* file;
diff --git a/src/task.h b/src/task.h
index be3995f..d64889a 100644
--- a/src/task.h
+++ b/src/task.h
@@ -28,6 +28,7 @@ class Task
public:
Task(const BuildConfiguration& config, const Settings& settings,
const std::string& sourceDir);
+ virtual ~Task() = default;
int registerDepTasks(const std::set<std::shared_ptr<Task>>& tasks);
virtual int registerDepTasksInner(const std::set<std::shared_ptr<Task>>& tasks) { return 0; }
diff --git a/src/tasks.h b/src/tasks.h
index c547432..403a954 100644
--- a/src/tasks.h
+++ b/src/tasks.h
@@ -10,8 +10,8 @@
#include "task.h"
-class BuildConfiguration;
-class Settings;
+struct BuildConfiguration;
+struct Settings;
struct Target
{
diff --git a/src/unittest.h b/src/unittest.h
index 8dee33c..5118689 100644
--- a/src/unittest.h
+++ b/src/unittest.h
@@ -7,7 +7,7 @@
#include <memory>
class Task;
-class Settings;
+struct Settings;
int runUnitTests(std::set<std::shared_ptr<Task>>& tasks,
const Settings& settings);