| @@ -30,8 +30,7 @@ compile_command_info compile_file_plan::generate_compile_command(build_env_ref e | |||
| } | |||
| fs::path compile_file_plan::calc_object_file_path(const build_env& env) const noexcept { | |||
| // `relpath` is just the path from the root of the source directory to the source file. | |||
| auto relpath = fs::relative(_source.path, _source.basis_path); | |||
| auto relpath = _source.relative_path(); | |||
| // The full output directory is prefixed by `_subdir` | |||
| auto ret = env.output_root / _subdir / relpath; | |||
| ret.replace_filename(relpath.filename().string() + env.toolchain.object_suffix()); | |||
| @@ -86,8 +86,7 @@ library_plan library_plan::create(const library_root& lib, | |||
| // Pick a subdir based on app/test | |||
| const auto subdir_base = is_test ? params.out_subdir / "test" : params.out_subdir; | |||
| // Put test/app executables in a further subdirectory based on the source file path | |||
| const auto subdir | |||
| = subdir_base / fs::relative(source.path.parent_path(), lib.src_source_root().path); | |||
| const auto subdir = subdir_base / source.relative_path().parent_path(); | |||
| // Pick compile rules based on app/test | |||
| auto rules = is_test ? test_rules : compile_rules; | |||
| // Pick input libs based on app/test | |||
| @@ -17,11 +17,22 @@ enum class source_kind { | |||
| std::optional<source_kind> infer_source_kind(path_ref) noexcept; | |||
| struct source_file { | |||
| fs::path path; | |||
| fs::path basis_path; | |||
| /** | |||
| * The actual path to the file | |||
| */ | |||
| fs::path path; | |||
| /** | |||
| * The path to source root that contains the file in question | |||
| */ | |||
| fs::path basis_path; | |||
| /** | |||
| * The kind of the source file | |||
| */ | |||
| source_kind kind; | |||
| static std::optional<source_file> from_path(path_ref path, path_ref base_path) noexcept; | |||
| fs::path relative_path() const noexcept { return fs::relative(path, basis_path); } | |||
| }; | |||
| using source_list = std::vector<source_file>; | |||