mirror of
https://github.com/ModOrganizer2/mob.git
synced 2026-07-27 14:07:05 -07:00
prebuilt usvfs
fixed url::filename() not handling much
This commit is contained in:
@@ -21,6 +21,7 @@ lz4 = true
|
||||
openssl = true
|
||||
pyqt = true
|
||||
python = true
|
||||
usvfs = true
|
||||
|
||||
[versions]
|
||||
vs = 16
|
||||
|
||||
+2
-1
@@ -48,7 +48,8 @@ static bool_map g_prebuilt =
|
||||
{"lz4", false},
|
||||
{"openssl", false},
|
||||
{"pyqt", false},
|
||||
{"python", false}
|
||||
{"python", false},
|
||||
{"usvfs", false}
|
||||
};
|
||||
|
||||
static string_map g_versions =
|
||||
|
||||
+25
-3
@@ -46,12 +46,34 @@ bool url::empty() const
|
||||
|
||||
std::string url::filename() const
|
||||
{
|
||||
const auto pos = s_.find_last_of("/");
|
||||
std::string path;
|
||||
|
||||
{
|
||||
auto* h = curl_url();
|
||||
guard g([&]{ curl_url_cleanup(h); });
|
||||
|
||||
auto r = curl_url_set(h, CURLUPART_URL, s_.c_str(), 0);
|
||||
|
||||
if (r != CURLUE_OK)
|
||||
gcx().bail_out(context::net, "bad url '" + s_ + "'");
|
||||
|
||||
char* buffer = nullptr;
|
||||
r = curl_url_get(h, CURLUPART_PATH, &buffer, 0);
|
||||
|
||||
if (r != CURLUE_OK)
|
||||
gcx().bail_out(context::net, "bad url '" + s_ + "'");
|
||||
|
||||
guard g2([&]{ curl_free(buffer); });
|
||||
|
||||
path = buffer;
|
||||
}
|
||||
|
||||
const auto pos = path.find_last_of("/");
|
||||
|
||||
if (pos == std::string::npos)
|
||||
return s_;
|
||||
return path;
|
||||
else
|
||||
return s_.substr(pos + 1);
|
||||
return path.substr(pos + 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -537,6 +537,17 @@ protected:
|
||||
void do_fetch() override;
|
||||
void do_build_and_install() override;
|
||||
void do_clean_for_rebuild() override;
|
||||
|
||||
private:
|
||||
void fetch_prebuilt();
|
||||
void fetch_from_source();
|
||||
void build_and_install_prebuilt();
|
||||
void build_and_install_from_source();
|
||||
|
||||
void download_from_appveyor(arch a);
|
||||
void copy_prebuilt(arch a);
|
||||
|
||||
std::string prebuilt_directory_name(arch a);
|
||||
};
|
||||
|
||||
|
||||
|
||||
+113
-2
@@ -16,7 +16,7 @@ const std::string& usvfs::version()
|
||||
|
||||
bool usvfs::prebuilt()
|
||||
{
|
||||
return false;
|
||||
return prebuilt::by_name("usvfs");
|
||||
}
|
||||
|
||||
fs::path usvfs::source_path()
|
||||
@@ -26,12 +26,43 @@ fs::path usvfs::source_path()
|
||||
|
||||
void usvfs::do_clean_for_rebuild()
|
||||
{
|
||||
if (prebuilt())
|
||||
return;
|
||||
|
||||
op::delete_directory(cx(), source_path() / "bin", op::optional);
|
||||
op::delete_directory(cx(), source_path() / "lib", op::optional);
|
||||
op::delete_directory(cx(), source_path() / "vsbuild" / "Release", op::optional);
|
||||
}
|
||||
|
||||
void usvfs::do_fetch()
|
||||
{
|
||||
if (prebuilt())
|
||||
fetch_prebuilt();
|
||||
else
|
||||
fetch_from_source();
|
||||
}
|
||||
|
||||
void usvfs::do_build_and_install()
|
||||
{
|
||||
if (prebuilt())
|
||||
build_and_install_prebuilt();
|
||||
else
|
||||
build_and_install_from_source();
|
||||
}
|
||||
|
||||
void usvfs::fetch_prebuilt()
|
||||
{
|
||||
download_from_appveyor(arch::x64);
|
||||
download_from_appveyor(arch::x86);
|
||||
}
|
||||
|
||||
void usvfs::build_and_install_prebuilt()
|
||||
{
|
||||
copy_prebuilt(arch::x86);
|
||||
copy_prebuilt(arch::x64);
|
||||
}
|
||||
|
||||
void usvfs::fetch_from_source()
|
||||
{
|
||||
run_tool(git_clone()
|
||||
.url(make_github_url(conf::mo_org(), "usvfs"))
|
||||
@@ -39,7 +70,7 @@ void usvfs::do_fetch()
|
||||
.output(source_path()));
|
||||
}
|
||||
|
||||
void usvfs::do_build_and_install()
|
||||
void usvfs::build_and_install_from_source()
|
||||
{
|
||||
// usvfs doesn't use "Win32" for 32-bit, it uses "x86"
|
||||
//
|
||||
@@ -57,4 +88,84 @@ void usvfs::do_build_and_install()
|
||||
.solution(source_path() / "vsbuild" / "usvfs.sln"));
|
||||
}
|
||||
|
||||
void usvfs::download_from_appveyor(arch a)
|
||||
{
|
||||
std::string arch_s;
|
||||
const std::string dir = prebuilt_directory_name(a);
|
||||
|
||||
switch (a)
|
||||
{
|
||||
case arch::x86:
|
||||
arch_s = "x86";
|
||||
break;
|
||||
|
||||
case arch::x64:
|
||||
arch_s = "x64";
|
||||
break;
|
||||
|
||||
case arch::dont_care:
|
||||
default:
|
||||
cx().bail_out(context::generic, "bad arch");
|
||||
}
|
||||
|
||||
auto dl = [&](std::string filename)
|
||||
{
|
||||
const auto u = make_appveyor_artifact_url(a, "usvfs", filename);
|
||||
|
||||
return run_tool(downloader()
|
||||
.url(u)
|
||||
.file(paths::build() / dir / u.filename()));
|
||||
};
|
||||
|
||||
parallel(
|
||||
{
|
||||
{"usvfs", [&]{ dl("lib/usvfs_" + arch_s + ".pdb"); }},
|
||||
{"usvfs", [&]{ dl("lib/usvfs_" + arch_s + ".dll"); }},
|
||||
{"usvfs", [&]{ dl("lib/usvfs_" + arch_s + ".lib"); }},
|
||||
{"usvfs", [&]{ dl("bin/usvfs_proxy_" + arch_s + ".exe"); }},
|
||||
{"usvfs", [&]{ dl("bin/usvfs_proxy_" + arch_s + ".pdb"); }}
|
||||
});
|
||||
}
|
||||
|
||||
void usvfs::copy_prebuilt(arch a)
|
||||
{
|
||||
const std::string dir = prebuilt_directory_name(a);
|
||||
|
||||
op::copy_glob_to_dir_if_better(cx(),
|
||||
paths::build() / dir / "*.pdb",
|
||||
paths::install_pdbs(),
|
||||
op::copy_files);
|
||||
|
||||
op::copy_glob_to_dir_if_better(cx(),
|
||||
paths::build() / dir / "*.lib",
|
||||
paths::install_libs(),
|
||||
op::copy_files);
|
||||
|
||||
op::copy_glob_to_dir_if_better(cx(),
|
||||
paths::build() / dir / "*.dll",
|
||||
paths::install_bin(),
|
||||
op::copy_files);
|
||||
|
||||
op::copy_glob_to_dir_if_better(cx(),
|
||||
paths::build() / dir / "*.exe",
|
||||
paths::install_bin(),
|
||||
op::copy_files);
|
||||
}
|
||||
|
||||
std::string usvfs::prebuilt_directory_name(arch a)
|
||||
{
|
||||
switch (a)
|
||||
{
|
||||
case arch::x86:
|
||||
return "usvfs_bin_32";
|
||||
|
||||
case arch::x64:
|
||||
return "usvfs_bin";
|
||||
|
||||
case arch::dont_care:
|
||||
default:
|
||||
cx().bail_out(context::generic, "bad arch");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -21,6 +21,30 @@ url make_prebuilt_url(const std::string& filename)
|
||||
"releases/download/1.1/" + filename;
|
||||
}
|
||||
|
||||
url make_appveyor_artifact_url(
|
||||
arch a, const std::string& project, const std::string& filename)
|
||||
{
|
||||
std::string arch_s;
|
||||
|
||||
switch (a)
|
||||
{
|
||||
case arch::x86:
|
||||
arch_s = "x86";
|
||||
break;
|
||||
|
||||
case arch::x64:
|
||||
arch_s = "x64";
|
||||
break;
|
||||
|
||||
case arch::dont_care:
|
||||
default:
|
||||
gcx().bail_out(context::generic, "bad arch");
|
||||
}
|
||||
|
||||
return
|
||||
"https://ci.appveyor.com/api/projects/Modorganizer2/" +
|
||||
project + "/artifacts/" + filename + "?job=Platform:%20" + arch_s;
|
||||
}
|
||||
|
||||
std::string replace_all(
|
||||
std::string s, const std::string& from, const std::string& to)
|
||||
|
||||
+12
-9
@@ -163,8 +163,20 @@ private:
|
||||
};
|
||||
|
||||
|
||||
enum class arch
|
||||
{
|
||||
x86 = 1,
|
||||
x64,
|
||||
dont_care,
|
||||
|
||||
def = x64
|
||||
};
|
||||
|
||||
|
||||
url make_github_url(const std::string& org, const std::string& repo);
|
||||
url make_prebuilt_url(const std::string& filename);
|
||||
url make_appveyor_artifact_url(
|
||||
arch a, const std::string& project, const std::string& filename);
|
||||
|
||||
std::string replace_all(
|
||||
std::string s, const std::string& from, const std::string& to);
|
||||
@@ -207,15 +219,6 @@ void for_each_line(std::string_view s, F&& f)
|
||||
}
|
||||
|
||||
|
||||
enum class arch
|
||||
{
|
||||
x86 = 1,
|
||||
x64,
|
||||
dont_care,
|
||||
|
||||
def = x64
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class repeat_iterator
|
||||
|
||||
Reference in New Issue
Block a user