-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinstall.cpp
More file actions
43 lines (37 loc) · 1.17 KB
/
install.cpp
File metadata and controls
43 lines (37 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <cstdlib>
#include <filesystem>
#include <thread>
#include <gsl/narrow>
#include <spdlog/spdlog.h>
#include "cppship/cmd/build.h"
#include "cppship/cmd/install.h"
#include "cppship/core/manifest.h"
#include "cppship/util/fs.h"
#include "cppship/util/log.h"
#include "cppship/util/repo.h"
using namespace cppship;
int cmd::run_install([[maybe_unused]] const InstallOptions& options)
{
// TODO: fix me
#ifdef _WINNDOWS
throw Error { "install is not supported in Windows" };
#else
const int result = run_build({ .profile = options.profile });
if (result != 0) {
return EXIT_FAILURE;
}
BuildContext ctx(options.profile);
Manifest manifest(ctx.metafile);
const auto bin_file = ctx.profile_dir / manifest.name();
if (!fs::exists(bin_file)) {
warn("no binary to install");
return EXIT_SUCCESS;
}
const auto root = fs::path(options.root);
const auto dst = root / "bin" / manifest.name();
cppship::create_if_not_exist(dst.parent_path());
status("install", "{} to {}", bin_file.string(), dst.string());
fs::copy_file(bin_file, dst, fs::copy_options::overwrite_existing);
return EXIT_SUCCESS;
#endif
}