winetricks support

This commit is contained in:
Nicholas O'Connor 2017-03-27 16:14:04 -07:00
parent 26dc361eec
commit 70fa9f4cf7
4 changed files with 50 additions and 3 deletions

View File

@ -12,6 +12,8 @@ using namespace cellar::commands;
namespace cellar { namespace cellar {
namespace launch { namespace launch {
extern void popen(string);
/*[[[cog /*[[[cog
import cog import cog

View File

@ -1,3 +1,4 @@
launch launch_command Launch a program in WINE. launch launch_command Launch a program in WINE.
winecfg launch_winecfg Launch winecfg. winecfg launch_winecfg Launch winecfg.
regedit launch_regedit Launch regedit. regedit launch_regedit Launch regedit.
winetricks winetricks Launch winetricks.

View File

@ -15,10 +15,9 @@ using namespace cellar;
void cellar::launch::launch_program(vector<string> args) { void cellar::launch::launch_program(vector<string> args) {
vector<string> wineargs = args; vector<string> wineargs = args;
wineargs[0] = "wine"; wineargs[0] = "wine";
string winelaunch = boost::algorithm::join(wineargs, " "); string winelaunch = boost::algorithm::join(wineargs, " ");
auto wine = subprocess::Popen(winelaunch); launch::popen(winelaunch);
wine.wait();
} }
void cellar::launch::launch_command(int argc, vector<string> args) { void cellar::launch::launch_command(int argc, vector<string> args) {
@ -28,3 +27,9 @@ void cellar::launch::launch_command(int argc, vector<string> args) {
} }
launch::launch_program(args); launch::launch_program(args);
} }
// BULLSHIT: subprocess.hpp throws linker errors if included in multiple files
void cellar::launch::popen(string argv) {
auto wine = subprocess::Popen(argv);
wine.wait();
}

39
src/launch/winetricks.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <string>
#include <vector>
#include <boost/algorithm/string/join.hpp>
// linker claims the one time in launch.cpp was enough, we'll believe it
//#include "subprocess.hpp"
#include "bottles.hpp"
#include "cellar.hpp"
#include "launch.hpp"
#include "internal/launch.hpp"
#include "output.hpp"
using namespace std;
using namespace cellar;
void cellar::launch::winetricks(int argc, vector<string> argv) {
if (argc == 1) {
output::error("");
return;
}
auto winetricks_argv = argv;
winetricks_argv[0] = "winetricks";
string winetricks_str = boost::algorithm::join(winetricks_argv, " ");
//output::statement(winetricks_str);
launch::popen(winetricks_str);
if (cellar::active_bottle.config.find("winetricks") == cellar::active_bottle.config.end()) {
cellar::active_bottle.config.emplace("winetricks", vector<string>());
}
for (string winetrick : winetricks_argv) {
if (winetrick == "winetricks") { continue; }
else if (winetrick.substr(0,1) == "-") { continue; } // opts don't get saved
else { cellar::active_bottle.config["winetricks"].push_back(winetrick); }
}
cellar::active_bottle.save_config();
}