summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.dg8
-rw-r--r--ctor.cc2
-rw-r--r--examples/ctor.cc96
-rw-r--r--examples/subdir/ctor.cc39
-rw-r--r--src/build.cc36
5 files changed, 108 insertions, 73 deletions
diff --git a/Makefile.dg b/Makefile.dg
index 9d8cf09..eb693be 100644
--- a/Makefile.dg
+++ b/Makefile.dg
@@ -111,10 +111,12 @@ SRC = \
OBJ = $(patsubst %.c,%.o,$(patsubst %.cc,%.o,$(patsubst %.cpp,%.o,$(SRC))))
-CXXFLAGS = -DUI_X11 -O3 -g -Wall -Werror -std=c++11 -Idrumgizmo/getoptpp -Idrumgizmo/ -Idrumgizmo/hugin -Idrumgizmo/plugingui/ -Idrumgizmo/src/ -Idrumgizmo/zita-resampler/libs -Idrumgizmo/pugixml/src
-CFLAGS = -O3 -g -Wall -Werror
+CXXFLAGS = -MMD -DUI_X11 -O3 -g -Wall -std=c++11 -Idrumgizmo/getoptpp -Idrumgizmo/ -Idrumgizmo/hugin -Idrumgizmo/plugingui/ -Idrumgizmo/src/ -Idrumgizmo/zita-resampler/libs -Idrumgizmo/pugixml/src
+CFLAGS = -MMD -O3 -g -Wall -Werror
LDFLAGS = -lm -lX11 -lXext -pthread -lsndfile
+DEPS := $(OBJ:.o=.d)
+
%.o: %.c
gcc $(CFLAGS) -c $< -o $@
@@ -126,3 +128,5 @@ plugingui: $(OBJ)
clean:
rm -f plugingui $(OBJ)
+
+-include $(DEPS) \ No newline at end of file
diff --git a/ctor.cc b/ctor.cc
index d795ff9..792e9e8 100644
--- a/ctor.cc
+++ b/ctor.cc
@@ -33,7 +33,7 @@ BuildConfigurations ctorConfigs(const Settings& settings)
.cxxflags = {
"-std=c++20",
"-O3",
- "-g",
+ //"-g",
"-Wall",
"-Werror",
"-Isrc",
diff --git a/examples/ctor.cc b/examples/ctor.cc
index 1a02e90..c41e27c 100644
--- a/examples/ctor.cc
+++ b/examples/ctor.cc
@@ -1,11 +1,11 @@
// -*- c++ -*-
// Distributed under the BSD 2-Clause License.
// See accompanying file LICENSE for details.
-#include "libctor.h"
+#include <libctor.h>
namespace
{
-BuildConfigurations myConfigs()
+BuildConfigurations myConfigs(const Settings&)
{
return
{
@@ -23,39 +23,41 @@ BuildConfigurations myConfigs()
.depends = {
"libplugingui.so",
},
- .cxxflags = {
- "-DUI_X11",
- "-O3",
- "-g",
- "-Wall",
- "-Werror",
- "-std=c++11",
- "-Idrumgizmo/getoptpp",
- "-Idrumgizmo/",
- "-Idrumgizmo/hugin",
- "-Idrumgizmo/plugingui/",
- "-Idrumgizmo/src/",
- "-Idrumgizmo/zita-resampler/libs",
- "-Idrumgizmo/pugixml/src",
+ .flags = {
+ .cxxflags = {
+ "-DUI_X11",
+ "-O3",
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-std=c++11",
+ "-Idrumgizmo/getoptpp",
+ "-Idrumgizmo/",
+ "-Idrumgizmo/hugin",
+ "-Idrumgizmo/plugingui/",
+ "-Idrumgizmo/src/",
+ "-Idrumgizmo/zita-resampler/libs",
+ "-Idrumgizmo/pugixml/src",
+ },
+ .cflags = {
+ "-g",
+ "-O3",
+ "-Wall",
+ "-Werror",
+ },
+ .ldflags = {
+ "-lm",
+ "-lX11",
+ "-lXext",
+ "-lsndfile",
+ "-pthread",
+ },
},
- .cflags = {
- "-g",
- //"-O3",
- "-Wall",
- "-Werror",
- },
- .ldflags = {
- "-lm",
- "-lX11",
- "-lXext",
- "-lsndfile",
- "-pthread",
- }
},
};
}
-BuildConfigurations myConfigs2()
+BuildConfigurations myConfigs2(const Settings&)
{
return
{
@@ -129,23 +131,25 @@ BuildConfigurations myConfigs2()
.depends = {
"src.a",
},
- .cxxflags = {
- "-DUI_X11",
- "-O3",
- "-g",
- "-Wall",
- "-Werror",
- "-std=c++11",
- "-Idrumgizmo/getoptpp",
- "-Idrumgizmo/",
- "-Idrumgizmo/hugin",
- "-Idrumgizmo/plugingui/",
- "-Idrumgizmo/src/",
- "-Idrumgizmo/zita-resampler/libs",
- "-Idrumgizmo/pugixml/src",
+ .flags = {
+ .cxxflags = {
+ "-DUI_X11",
+ "-O3",
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-std=c++11",
+ "-Idrumgizmo/getoptpp",
+ "-Idrumgizmo/",
+ "-Idrumgizmo/hugin",
+ "-Idrumgizmo/plugingui/",
+ "-Idrumgizmo/src/",
+ "-Idrumgizmo/zita-resampler/libs",
+ "-Idrumgizmo/pugixml/src",
+ },
+ .cflags = {},
+ .ldflags = {},
},
- .cflags = {},
- .ldflags = {}
}
};
}
diff --git a/examples/subdir/ctor.cc b/examples/subdir/ctor.cc
index b5f5885..6e28733 100644
--- a/examples/subdir/ctor.cc
+++ b/examples/subdir/ctor.cc
@@ -1,11 +1,11 @@
// -*- c++ -*-
// Distributed under the BSD 2-Clause License.
// See accompanying file LICENSE for details.
-#include "../libctor.h"
+#include <libctor.h>
namespace
{
-BuildConfigurations myConfigs()
+BuildConfigurations myConfigs(const Settings&)
{
return
{
@@ -54,25 +54,28 @@ BuildConfigurations myConfigs()
"../drumgizmo/src/versionstr.cc",
"../drumgizmo/src/zrwrapper.cc",
},
- .cxxflags = {
- "-fPIC",
- "-DUI_X11",
- "-O3",
- "-g",
- "-Wall",
- "-Werror",
- "-std=c++11",
- "-I../drumgizmo/getoptpp",
- "-I../drumgizmo/",
- "-I../drumgizmo/hugin",
- "-I../drumgizmo/plugingui/",
- "-I ../drumgizmo/src/",
- "-I ../drumgizmo/zita-resampler/libs",
- "-I ../drumgizmo/pugixml/src",
+ .flags = {
+ .cxxflags = {
+ "-fPIC",
+ "-DUI_X11",
+ "-O3",
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-std=c++11",
+ "-I../drumgizmo/getoptpp",
+ "-I../drumgizmo/",
+ "-I../drumgizmo/hugin",
+ "-I../drumgizmo/plugingui/",
+ "-I ../drumgizmo/src/",
+ "-I ../drumgizmo/zita-resampler/libs",
+ "-I ../drumgizmo/pugixml/src",
+ },
},
}
};
}
-int a = reg(__FILE__, myConfigs);
}
+
+REG(myConfigs);
diff --git a/src/build.cc b/src/build.cc
index 98952e0..502c67c 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -52,8 +52,13 @@ int build(const Settings& settings,
std::list<std::future<int>> processes;
+ const auto start_interval = 50ms;
+ const auto poll_interval = 10ms;
+ auto last = std::chrono::system_clock::now() - start_interval;
+
// Start all tasks
bool done{false};
+ std::shared_ptr<Task> nextTask{};
while(!done)
{
bool started_one{false};
@@ -65,7 +70,14 @@ int build(const Settings& settings,
break;
}
- auto task = getNextTask(all_tasks, dirtyTasks);
+ if(!nextTask)
+ {
+ nextTask = getNextTask(all_tasks, dirtyTasks);
+ }
+
+ auto task = nextTask;
+ nextTask.reset();
+
if(task == nullptr)
{
if(processes.empty() && !dirtyTasks.empty())
@@ -77,6 +89,16 @@ int build(const Settings& settings,
break;
}
+ auto now = std::chrono::system_clock::now();
+ if(now - last < start_interval)
+ {
+ // Make sure we don't start tasks too close to each other to prevent
+ // straining the disk.
+ std::this_thread::sleep_for(start_interval - (now - last));
+ }
+
+ last = now;
+
processes.emplace_back(
std::async(std::launch::async,
[task]()
@@ -84,9 +106,11 @@ int build(const Settings& settings,
return task->run();
}));
started_one = true;
- // Make sure we don't start tasks on top of each other to prevent
- // straining the disk.
- std::this_thread::sleep_for(50ms);
+
+ //if(!nextTask)
+ //{
+ // nextTask = getNextTask(all_tasks, dirtyTasks);
+ //}
}
for(auto process = processes.begin();
@@ -108,9 +132,9 @@ int build(const Settings& settings,
break;
}
- if(!started_one) // prevent polling too fast if no task is yet ready
+ if(!started_one && nextTask) // prevent polling too fast if no task is yet ready
{
- std::this_thread::sleep_for(10ms);
+ std::this_thread::sleep_for(poll_interval);
}
}