Skip to content

Commit

Permalink
Remove gamebryo and nuget specific stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Jul 12, 2024
1 parent be85939 commit 33ac57f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 138 deletions.
26 changes: 3 additions & 23 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,9 @@ namespace mob {
.add_task<mo>("modorganizer-nxmhandler")
.add_task<mo>("modorganizer-helper")
.add_task<mo>("githubpp")
.add_task<mo>("modorganizer-game_gamebryo")
.add_task<mo>({"modorganizer-bsapacker", "bsa_packer"})
.add_task<mo>("modorganizer-preview_bsa");

// the gamebryo flag must be set for all game plugins that inherit from
// the gamebryo classes; this will merge the .ts file from gamebryo with
// the one from the specific plugin
add_task<parallel_tasks>()
.add_task<mo>("modorganizer-game_oblivion", mo::gamebryo)
.add_task<mo>("modorganizer-game_nehrim", mo::gamebryo)
.add_task<mo>("modorganizer-game_fallout3", mo::gamebryo)
.add_task<mo>("modorganizer-game_fallout4", mo::gamebryo)
.add_task<mo>("modorganizer-game_fallout4vr", mo::gamebryo)
.add_task<mo>("modorganizer-game_fallout76", mo::gamebryo)
.add_task<mo>("modorganizer-game_falloutnv", mo::gamebryo)
.add_task<mo>("modorganizer-game_morrowind", mo::gamebryo)
.add_task<mo>("modorganizer-game_skyrim", mo::gamebryo)
.add_task<mo>("modorganizer-game_skyrimse", mo::gamebryo)
.add_task<mo>("modorganizer-game_skyrimvr", mo::gamebryo)
.add_task<mo>("modorganizer-game_starfield", mo::gamebryo)
.add_task<mo>("modorganizer-game_ttw", mo::gamebryo)
.add_task<mo>("modorganizer-game_enderal", mo::gamebryo)
.add_task<mo>("modorganizer-game_enderalse", mo::gamebryo);
.add_task<mo>("modorganizer-preview_bsa")
.add_task<mo>("modorganizer-game_bethesda");

add_task<parallel_tasks>()
.add_task<mo>({"modorganizer-tool_inieditor", "inieditor"})
Expand All @@ -109,7 +89,7 @@ namespace mob {
.add_task<mo>("modorganizer-installer_quick")
.add_task<mo>("modorganizer-installer_fomod")
.add_task<mo>("modorganizer-installer_fomod_csharp")
.add_task<mo>("modorganizer-installer_omod", mo::nuget)
.add_task<mo>("modorganizer-installer_omod")
.add_task<mo>("modorganizer-installer_wizard")
.add_task<mo>("modorganizer-bsa_extractor")
.add_task<mo>("modorganizer-plugin_python");
Expand Down
29 changes: 6 additions & 23 deletions src/tasks/modorganizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ namespace mob::tasks {
g.init_repo();
}

modorganizer::modorganizer(std::string long_name, flags f)
: modorganizer(std::vector<std::string>{long_name}, f)
modorganizer::modorganizer(std::string long_name)
: modorganizer(std::vector<std::string>{long_name})
{
}

modorganizer::modorganizer(std::vector<const char*> names, flags f)
: modorganizer(std::vector<std::string>(names.begin(), names.end()), f)
modorganizer::modorganizer(std::vector<const char*> names)
: modorganizer(std::vector<std::string>(names.begin(), names.end()))
{
}

modorganizer::modorganizer(std::vector<std::string> names, flags f)
: task(make_names(names)), repo_(names[0]), flags_(f)
modorganizer::modorganizer(std::vector<std::string> names)
: task(make_names(names)), repo_(names[0])
{
if (names.size() > 1) {
project_ = names[1];
Expand All @@ -80,16 +80,6 @@ namespace mob::tasks {
}
}

bool modorganizer::is_gamebryo_plugin() const
{
return is_set(flags_, gamebryo);
}

bool modorganizer::is_nuget_plugin() const
{
return is_set(flags_, nuget);
}

fs::path modorganizer::source_path() const
{
// something like build/modorganizer_super/uibase
Expand Down Expand Up @@ -187,13 +177,6 @@ namespace mob::tasks {
// run cmake
run_tool(create_cmake_tool());

// run restore for nuget
//
// until https://gitlab.kitware.com/cmake/cmake/-/issues/20646 is resolved,
// we need a manual way of running the msbuild -t:restore
if (is_nuget_plugin())
run_tool(create_msbuild_tool().targets({"restore"}));

// run msbuild
run_tool(create_msbuild_tool());
}
Expand Down
35 changes: 4 additions & 31 deletions src/tasks/tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,34 +216,13 @@ namespace mob::tasks {
cmake::ops o = cmake::generate,
config config = config::relwithdebinfo);

// flags for some MO projects
enum flags {
noflags = 0x00,

// gamebryo project, used by the translations task because these
// projects have multiple .ts files that have to be merged
gamebryo = 0x01,

// project that uses nuget, cmake doesn't support those right now, so
// `msbuild -t:restore` has to be run manually
nuget = 0x02,
};

// some mo tasks have more than one name, mostly because the transifex slugs
// are different than the names on github; the std::string and const char*
// overloads are because they're constructed from initializer lists and it's
// more convenient that way
modorganizer(std::string name, flags f = noflags);
modorganizer(std::vector<std::string> names, flags f = noflags);
modorganizer(std::vector<const char*> names, flags f = noflags);

// whether this project has the gamebryo flag on
//
bool is_gamebryo_plugin() const;

// whether this project has the nuget flag on
//
bool is_nuget_plugin() const;
modorganizer(std::string name);
modorganizer(std::vector<std::string> names);
modorganizer(std::vector<const char*> names);

// url to the git repo
//
Expand Down Expand Up @@ -271,7 +250,6 @@ namespace mob::tasks {
private:
std::string repo_;
std::string project_;
flags flags_;

// creates the cmake tool for this MO project
//
Expand Down Expand Up @@ -623,11 +601,6 @@ namespace mob::tasks {
// duplicate warnings
std::set<fs::path> warned_;

// whether the given project name is a gamebryo task, `dir` is just for
// logging
//
bool is_gamebryo_plugin(const std::string& dir, const std::string& project);

// parses the directory name, walks all the .ts files, returns a project
// object for them
//
Expand All @@ -636,7 +609,7 @@ namespace mob::tasks {
// returns a lang object that contains at least the given main_ts_file,
// but might contain more if it's a gamebryo plugin
//
lang create_lang(bool gamebryo, const std::string& project_name,
lang create_lang(const std::string& project_name,
const fs::path& main_ts_file);
};

Expand Down
63 changes: 2 additions & 61 deletions src/tasks/translations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ namespace mob::tasks {
// walks all the .ts files in the project, creates a `lang` object for
// each
//
// each project directory is named "mod-organizer-2.project_name", so this
// splits on the dot to get the project name, checks if it's a gamebryo
// plugin, and adds the gamebryo .ts file as well if necessary

// splitting
const auto dir_name = path_to_utf8(dir.filename());
Expand All @@ -150,7 +147,6 @@ namespace mob::tasks {

// project
project p(project_name);
const bool gamebryo = is_gamebryo_plugin(dir_name, project_name);

// for each file
for (auto f : fs::directory_iterator(dir)) {
Expand All @@ -168,79 +164,24 @@ namespace mob::tasks {
}

// add a new `lang` object for it
p.langs.push_back(create_lang(gamebryo, project_name, f.path()));
p.langs.push_back(create_lang(project_name, f.path()));
}

return p;
}

translations::projects::lang
translations::projects::create_lang(bool gamebryo, const std::string& project_name,
translations::projects::create_lang(const std::string& project_name,
const fs::path& main_ts_file)
{
lang lg(path_to_utf8(main_ts_file.stem()));

// every lang has the .ts file from the project, gamebryo plugins have more
lg.ts_files.push_back(main_ts_file);

if (gamebryo) {
// this is a gamebryo plugin, so it needs the gamebryo .ts file as well,
// find it

// the .ts files for gamebryo are in mod-organizer-2.game_gamebryo/
const fs::path gamebryo_dir =
conf().transifex().get("project") + "." + "game_gamebryo";

// the .ts file has the same name, it's just "lang.ts"
const auto gamebryo_ts = root_ / gamebryo_dir / main_ts_file.filename();

if (fs::exists(gamebryo_ts)) {
// found, add it
lg.ts_files.push_back(gamebryo_ts);
}
else {
// not found, that means the plugin was translated into a language,
// but the gamebryo project wasn't; warn once
if (!warned_.contains(gamebryo_ts)) {
warned_.insert(gamebryo_ts);

warnings_.push_back(::std::format(
"{} is a gamebryo plugin but there is no '{}'; the "
".qm file will be missing some translations (will "
"only warn once)",
project_name, path_to_utf8(gamebryo_ts)));
}
}
}

return lg;
}

bool translations::projects::is_gamebryo_plugin(const std::string& dir,
const std::string& project)
{
const auto* t = task_manager::instance().find_one(project);

if (!t) {
warnings_.push_back(
::std::format("directory '{}' was parsed as project '{}', but there's "
"no task with this name",
dir, project));

return false;
}

// gamebryo plugins are all `modorganizer` tasks
const auto* mo_task = static_cast<const modorganizer*>(t);
if (!mo_task) {
// not an mo task, can't be a gamebryo plugin
return false;
}

// check the flag
return mo_task->is_gamebryo_plugin();
}

translations::translations() : task("translations") {}

fs::path translations::source_path()
Expand Down

0 comments on commit 33ac57f

Please sign in to comment.