summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ctor.h20
-rw-r--r--src/task.cc6
-rw-r--r--src/task.h4
-rw-r--r--src/task_ar.cc4
-rw-r--r--src/task_cc.cc22
-rw-r--r--src/task_ld.cc4
-rw-r--r--src/task_so.cc4
-rw-r--r--src/util.cc8
-rw-r--r--src/util.h2
-rw-r--r--test/source_type_test.cc32
10 files changed, 53 insertions, 53 deletions
diff --git a/src/ctor.h b/src/ctor.h
index 2fefac3..dbcfa66 100644
--- a/src/ctor.h
+++ b/src/ctor.h
@@ -26,13 +26,13 @@ enum class target_type
function,
};
-enum class Language
+enum class language
{
- Auto, // Default - deduce language from source extensions
+ automatic, // Default - deduce language from source extensions
- C,
- Cpp,
- Asm,
+ c,
+ cpp,
+ assembler,
};
enum class OutputSystem
@@ -45,16 +45,16 @@ struct Source
{
Source(const char* file) : file(file) {}
Source(const std::string& file) : file(file) {}
- Source(const char* file, Language lang) : file(file), language(lang) {}
- Source(const std::string& file, Language lang) : file(file), language(lang) {}
+ Source(const char* file, ctor::language lang) : file(file), language(lang) {}
+ Source(const std::string& file, ctor::language lang) : file(file), language(lang) {}
Source(const char* file, const char* output) : file(file), output(output) {}
Source(const std::string& file, const std::string& output) : file(file), output(output) {}
- Source(const char* file, Language lang, const char* output) : file(file), language(lang), output(output) {}
- Source(const std::string& file, Language lang, const std::string& output) : file(file), language(lang), output(output) {}
+ Source(const char* file, ctor::language lang, const char* output) : file(file), language(lang), output(output) {}
+ Source(const std::string& file, ctor::language lang, const std::string& output) : file(file), language(lang), output(output) {}
std::string file;
- Language language{Language::Auto};
+ ctor::language language{ctor::language::automatic};
std::string output{};
};
diff --git a/src/task.cc b/src/task.cc
index fa843c7..eba365f 100644
--- a/src/task.cc
+++ b/src/task.cc
@@ -119,7 +119,7 @@ ctor::target_type Task::targetType() const
return target_type;
}
-Language Task::sourceLanguage() const
+ctor::language Task::sourceLanguage() const
{
return source_language;
}
@@ -133,7 +133,7 @@ std::string Task::compiler() const
{
switch(sourceLanguage())
{
- case Language::C:
+ case ctor::language::c:
switch(outputSystem())
{
case OutputSystem::Host:
@@ -141,7 +141,7 @@ std::string Task::compiler() const
case OutputSystem::Build:
return getConfiguration(cfg::build_cc, "/usr/bin/gcc");
}
- case Language::Cpp:
+ case ctor::language::cpp:
switch(outputSystem())
{
case OutputSystem::Host:
diff --git a/src/task.h b/src/task.h
index 1d61665..673df67 100644
--- a/src/task.h
+++ b/src/task.h
@@ -60,7 +60,7 @@ public:
const ctor::BuildConfiguration& buildConfig() const;
ctor::target_type targetType() const;
- ctor::Language sourceLanguage() const;
+ ctor::language sourceLanguage() const;
ctor::OutputSystem outputSystem() const;
std::string compiler() const;
@@ -77,7 +77,7 @@ protected:
std::set<std::shared_ptr<Task>> dependsTasks;
const ctor::BuildConfiguration& config;
ctor::target_type target_type{ctor::target_type::automatic};
- ctor::Language source_language{ctor::Language::Auto};
+ ctor::language source_language{ctor::language::automatic};
ctor::OutputSystem output_system{ctor::OutputSystem::Host};
const ctor::Settings& settings;
std::string sourceDir;
diff --git a/src/task_ar.cc b/src/task_ar.cc
index eaf23e6..528e71a 100644
--- a/src/task_ar.cc
+++ b/src/task_ar.cc
@@ -41,14 +41,14 @@ TaskAR::TaskAR(const BuildConfiguration& config,
flagsFile += ".flags";
target_type = ctor::target_type::static_library;
- source_language = Language::C;
+ source_language = ctor::language::c;
for(const auto& source : config.sources)
{
std::filesystem::path sourceFile(source.file);
// TODO: Use task languages instead
if(sourceFile.extension().string() != ".c")
{
- source_language = Language::Cpp;
+ source_language = ctor::language::cpp;
}
}
}
diff --git a/src/task_cc.cc b/src/task_cc.cc
index 2b1e648..581ca12 100644
--- a/src/task_cc.cc
+++ b/src/task_cc.cc
@@ -34,23 +34,23 @@ TaskCC::TaskCC(const BuildConfiguration& config, const Settings& settings,
target_type = ctor::target_type::object;
source_language = source.language;
- if(source_language == Language::Auto)
+ if(source_language == ctor::language::automatic)
{
source_language = languageFromExtension(sourceFile);
}
switch(source_language)
{
- case Language::C:
+ case ctor::language::c:
base += "_c";
break;
- case Language::Cpp:
+ case ctor::language::cpp:
base += "_cc";
break;
- case Language::Asm:
+ case ctor::language::assembler:
base += "_asm";
break;
- case Language::Auto:
+ case ctor::language::automatic:
assert(0 && "This should never happen");
break;
}
@@ -171,14 +171,14 @@ int TaskCC::runInner()
{
switch(sourceLanguage())
{
- case Language::C:
+ case ctor::language::c:
std::cout << "CC ";
break;
- case Language::Cpp:
+ case ctor::language::cpp:
std::cout << "CXX ";
break;
- case Language::Auto:
- case Language::Asm:
+ case ctor::language::automatic:
+ case ctor::language::assembler:
// Only c/c++ handled by this task type.
break;
}
@@ -260,9 +260,9 @@ std::vector<std::string> TaskCC::flags() const
{
switch(sourceLanguage())
{
- case Language::C:
+ case ctor::language::c:
return config.flags.cflags;
- case Language::Cpp:
+ case ctor::language::cpp:
return config.flags.cxxflags;
default:
std::cerr << "Unknown CC target type\n";
diff --git a/src/task_ld.cc b/src/task_ld.cc
index 9a36bd9..20a4f37 100644
--- a/src/task_ld.cc
+++ b/src/task_ld.cc
@@ -47,13 +47,13 @@ TaskLD::TaskLD(const BuildConfiguration& config,
flagsFile = std::filesystem::path(settings.builddir) / cleanUp(sourceDir) / targetFile().stem();
flagsFile += ".flags";
- source_language = Language::C;
+ source_language = ctor::language::c;
for(const auto& source : config.sources)
{
std::filesystem::path sourceFile(source.file);
if(sourceFile.extension().string() != ".c")
{
- source_language = Language::Cpp;
+ source_language = ctor::language::cpp;
}
}
}
diff --git a/src/task_so.cc b/src/task_so.cc
index 4d154d7..d7c0820 100644
--- a/src/task_so.cc
+++ b/src/task_so.cc
@@ -43,14 +43,14 @@ TaskSO::TaskSO(const BuildConfiguration& config,
flagsFile += ".flags";
target_type = ctor::target_type::dynamic_library;
- source_language = Language::C;
+ source_language = ctor::language::c;
for(const auto& source : config.sources)
{
std::filesystem::path sourceFile(source.file);
// TODO: Use task languages instead
if(sourceFile.extension().string() != ".c")
{
- source_language = Language::Cpp;
+ source_language = ctor::language::cpp;
}
}
}
diff --git a/src/util.cc b/src/util.cc
index 47cb5c4..f25b7eb 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -82,12 +82,12 @@ std::vector<std::string> readDeps(const std::string& depFile)
return output;
}
-Language languageFromExtension(const std::filesystem::path& file)
+ctor::language languageFromExtension(const std::filesystem::path& file)
{
auto ext = file.extension().string();
if(ext == ".c")
{
- return Language::C;
+ return ctor::language::c;
}
if(ext == ".C" ||
@@ -98,14 +98,14 @@ Language languageFromExtension(const std::filesystem::path& file)
ext == ".cp" ||
ext == ".cxx")
{
- return Language::Cpp;
+ return ctor::language::cpp;
}
if(ext == ".s" ||
ext == ".S" ||
ext == ".asm")
{
- return Language::Asm;
+ return ctor::language::assembler;
}
std::cerr << "Could not deduce language from " << file.string() << "\n";
diff --git a/src/util.h b/src/util.h
index 1b41823..d5fccc8 100644
--- a/src/util.h
+++ b/src/util.h
@@ -10,7 +10,7 @@
std::string readFile(const std::string& fileName);
std::vector<std::string> readDeps(const std::string& depFile);
-ctor::Language languageFromExtension(const std::filesystem::path& file);
+ctor::language languageFromExtension(const std::filesystem::path& file);
std::string cleanUp(const std::string& path);
template<typename T>
diff --git a/test/source_type_test.cc b/test/source_type_test.cc
index e64aaee..c12e524 100644
--- a/test/source_type_test.cc
+++ b/test/source_type_test.cc
@@ -1,25 +1,25 @@
#include <ctor.h>
#include <task_cc.h>
-std::ostream& operator<<(std::ostream& stream, const ctor::Language& lang);
+std::ostream& operator<<(std::ostream& stream, const ctor::language& lang);
#include <uunit.h>
-std::ostream& operator<<(std::ostream& stream, const ctor::Language& lang)
+std::ostream& operator<<(std::ostream& stream, const ctor::language& lang)
{
switch(lang)
{
- case ctor::Language::Auto:
- stream << "Language::Auto";
+ case ctor::language::automatic:
+ stream << "ctor::language::automatic";
break;
- case ctor::Language::C:
- stream << "Language::C";
+ case ctor::language::c:
+ stream << "ctor::language::c";
break;
- case ctor::Language::Cpp:
- stream << "Language::Cpp";
+ case ctor::language::cpp:
+ stream << "ctor::language::cpp";
break;
- case ctor::Language::Asm:
- stream << "Language::Asm";
+ case ctor::language::assembler:
+ stream << "ctor::language::assembler";
break;
}
@@ -34,7 +34,7 @@ public:
: TaskCC({}, {}, "build", source)
{}
- ctor::Language language() const
+ ctor::language language() const
{
return source_language;
}
@@ -53,22 +53,22 @@ public:
{
{ // c++
TestableTaskCC task("hello.cc");
- uASSERT_EQUAL(ctor::Language::Cpp, task.language());
+ uASSERT_EQUAL(ctor::language::cpp, task.language());
}
{ // c
TestableTaskCC task("hello.c");
- uASSERT_EQUAL(ctor::Language::C, task.language());
+ uASSERT_EQUAL(ctor::language::c, task.language());
}
{ // asm
TestableTaskCC task("hello.s");
- uASSERT_EQUAL(ctor::Language::Asm, task.language());
+ uASSERT_EQUAL(ctor::language::assembler, task.language());
}
{ // custom/explicit language
- TestableTaskCC task( {"hello.foo", ctor::Language::Asm} );
- uASSERT_EQUAL(ctor::Language::Asm, task.language());
+ TestableTaskCC task( {"hello.foo", ctor::language::assembler} );
+ uASSERT_EQUAL(ctor::language::assembler, task.language());
}
// Note: Failure state will result in exit(1) so cannot be tested