#include <dds/build/plan/archive.hpp> | #include <dds/build/plan/archive.hpp> | ||||
#include <dds/build/plan/exe.hpp> | #include <dds/build/plan/exe.hpp> | ||||
#include <dds/library.hpp> | |||||
#include <dds/library/library.hpp> | |||||
#include <dds/usage_reqs.hpp> | #include <dds/usage_reqs.hpp> | ||||
#include <dds/util/fs.hpp> | #include <dds/util/fs.hpp> | ||||
namespace dds { | namespace dds { | ||||
struct library_build_params { | |||||
fs::path out_subdir; | |||||
bool build_tests = false; | |||||
bool build_apps = false; | |||||
bool enable_warnings = false; | |||||
// Extras for compiling tests: | |||||
std::vector<fs::path> test_include_dirs; | |||||
std::vector<fs::path> test_link_files; | |||||
}; | |||||
class library_plan { | class library_plan { | ||||
std::string _name; | std::string _name; | ||||
fs::path _source_root; | fs::path _source_root; |
#pragma once | |||||
#include <dds/build/plan/compile_file.hpp> | |||||
#include <dds/build/source_dir.hpp> | |||||
#include <dds/library_manifest.hpp> | |||||
#include <dds/source.hpp> | |||||
#include <string> | |||||
namespace dds { | |||||
struct library_ident { | |||||
std::string namespace_; | |||||
std::string name; | |||||
}; | |||||
class library { | |||||
fs::path _path; | |||||
source_list _sources; | |||||
library_manifest _man; | |||||
library(path_ref dir, source_list&& src, library_manifest&& man) | |||||
: _path(dir) | |||||
, _sources(std::move(src)) | |||||
, _man(std::move(man)) {} | |||||
public: | |||||
static library from_directory(path_ref); | |||||
auto& manifest() const noexcept { return _man; } | |||||
source_directory src_dir() const noexcept { return source_directory{path() / "src"}; } | |||||
source_directory include_dir() const noexcept { return source_directory{path() / "include"}; } | |||||
path_ref path() const noexcept { return _path; } | |||||
fs::path public_include_dir() const noexcept; | |||||
fs::path private_include_dir() const noexcept; | |||||
const source_list& all_sources() const noexcept { return _sources; } | |||||
shared_compile_file_rules base_compile_rules() const noexcept; | |||||
}; | |||||
struct library_build_params { | |||||
fs::path out_subdir; | |||||
bool build_tests = false; | |||||
bool build_apps = false; | |||||
bool enable_warnings = false; | |||||
// Extras for compiling tests: | |||||
std::vector<fs::path> test_include_dirs; | |||||
std::vector<fs::path> test_link_files; | |||||
}; | |||||
std::vector<library> collect_libraries(path_ref where); | |||||
} // namespace dds |
#include <dds/library.hpp> | |||||
#include <dds/library/library.hpp> | |||||
#include <dds/build/plan/compile_file.hpp> | #include <dds/build/plan/compile_file.hpp> | ||||
#include <dds/build/source_dir.hpp> | #include <dds/build/source_dir.hpp> |
#pragma once | |||||
#include <dds/build/plan/compile_file.hpp> | |||||
#include <dds/build/source_dir.hpp> | |||||
#include <dds/library/manifest.hpp> | |||||
#include <dds/source.hpp> | |||||
#include <string> | |||||
namespace dds { | |||||
/** | |||||
* Represents a library that exists on the filesystem | |||||
*/ | |||||
class library { | |||||
// The path containing the source directories for this library | |||||
fs::path _path; | |||||
// The sources that are part of this library | |||||
source_list _sources; | |||||
// The library manifest associated with this library (may be generated) | |||||
library_manifest _man; | |||||
// Private constructor. Use named constructor `from_directory`, which will build | |||||
// the construct arguments approperiately | |||||
library(path_ref dir, source_list&& src, library_manifest&& man) | |||||
: _path(dir) | |||||
, _sources(std::move(src)) | |||||
, _man(std::move(man)) {} | |||||
public: | |||||
/** | |||||
* Create a library object that refers to the library contained at the given | |||||
* directory path. This will load the sources and manifest properly and | |||||
* return the resulting library object. | |||||
*/ | |||||
static library from_directory(path_ref); | |||||
/** | |||||
* Obtain the manifest for this library | |||||
*/ | |||||
const library_manifest& manifest() const noexcept { return _man; } | |||||
/** | |||||
* The `src/` directory for this library. | |||||
*/ | |||||
source_directory src_dir() const noexcept { return source_directory{path() / "src"}; } | |||||
/** | |||||
* The `include/` directory for this library | |||||
*/ | |||||
source_directory include_dir() const noexcept { return source_directory{path() / "include"}; } | |||||
/** | |||||
* The root path for this library (parent of `src/` and `include/`, if present) | |||||
*/ | |||||
path_ref path() const noexcept { return _path; } | |||||
/** | |||||
* The directory that should be considered the "public" include directory. | |||||
* Dependees that want to use this library should add this to their #include | |||||
* search path. | |||||
*/ | |||||
fs::path public_include_dir() const noexcept; | |||||
/** | |||||
* The directory that contains the "private" heders for this libary. This | |||||
* directory should be added to the search path of the library when it is | |||||
* being built, but NOT to the search path of the dependees. | |||||
*/ | |||||
fs::path private_include_dir() const noexcept; | |||||
/** | |||||
* Get the sources that this library contains | |||||
*/ | |||||
const source_list& all_sources() const noexcept { return _sources; } | |||||
/** | |||||
* Generate a compile rules object that should be used when compiling | |||||
* this library. | |||||
*/ | |||||
shared_compile_file_rules base_compile_rules() const noexcept; | |||||
}; | |||||
/** | |||||
* Given the root source directory of a project/package/sdist, collect all of | |||||
* the libraries that it contains. There may be a library directly in `where`, | |||||
* but there might also be libraries in `where/libs`. This function will find | |||||
* them all. | |||||
*/ | |||||
std::vector<library> collect_libraries(path_ref where); | |||||
} // namespace dds |
#include "./library_manifest.hpp" | |||||
#include "./manifest.hpp" | |||||
#include <dds/util/algo.hpp> | #include <dds/util/algo.hpp> | ||||
#include <range/v3/view/transform.hpp> | #include <range/v3/view/transform.hpp> |
#pragma once | |||||
#include <dds/util/fs.hpp> | |||||
#include <libman/library.hpp> | |||||
#include <vector> | |||||
namespace dds { | |||||
/** | |||||
* Represents the contents of a `library.dds`. This is somewhat a stripped-down | |||||
* version of lm::library, to only represent exactly the parts that we want to | |||||
* offer via `library.dds`. | |||||
*/ | |||||
struct library_manifest { | |||||
/// The name of the library | |||||
std::string name; | |||||
/// The libraries that the owning library "uses" | |||||
std::vector<lm::usage> uses; | |||||
/// The libraries that the owning library must be linked with | |||||
std::vector<lm::usage> links; | |||||
/** | |||||
* Load the library manifest from an existing file | |||||
*/ | |||||
static library_manifest load_from_file(const fs::path&); | |||||
}; | |||||
} // namespace dds |
#pragma once | |||||
#include <dds/util/fs.hpp> | |||||
#include <libman/library.hpp> | |||||
#include <vector> | |||||
namespace dds { | |||||
struct library_manifest { | |||||
std::string name; | |||||
std::vector<lm::usage> uses; | |||||
std::vector<lm::usage> links; | |||||
static library_manifest load_from_file(const fs::path&); | |||||
}; | |||||
} // namespace dds |