Skip to content
Permalink
Browse files

Add uri: open build script command.

  • Loading branch information...
egorpugin committed Mar 5, 2019
1 parent 2832c14 commit e8645eba587bf46eab744990f6eb8ca171a2853d
Showing with 130 additions and 13 deletions.
  1. +49 −12 src/client/client.cpp
  2. +1 −1 src/driver/cpp/solution.cpp
  3. +80 −0 utils/cc/win2android.cpp
@@ -248,12 +248,13 @@ int parse_main(int argc, char **argv)
overview += " - " + n + "\n";
}

const std::vector<std::string> args0(argv + 1, argv + argc);
std::vector<std::string> args0(argv + 1, argv + argc);
Strings args;
args.push_back(argv[0]);
for (auto &a : args0)
{
std::vector<std::string> t;
//boost::replace_all(a, "%5F", "_");
boost::split_regex(t, a, boost::regex("%20"));
args.insert(args.end(), t.begin(), t.end());
}
@@ -661,26 +662,54 @@ SUBCOMMAND_DECL(uri)
#ifdef _WIN32
if (sdb.isPackageInstalled(p))
{
auto pidl = uri_args[0] == "sw:sdir" ?
ILCreateFromPath(p.getDirSrc2().wstring().c_str()) :
ILCreateFromPath(p.getDirObj().wstring().c_str())
;
if (pidl)
{
auto pidl = uri_args[0] == "sw:sdir" ?
ILCreateFromPath(p.getDirSrc2().wstring().c_str()) :
ILCreateFromPath(p.getDirObj().wstring().c_str())
;
if (pidl)
{
CoInitialize(0);
auto r = SHOpenFolderAndSelectItems(pidl, 0, 0, 0);
if (FAILED(r))
{
message_box(sw::getProgramName(), "Error in SHOpenFolderAndSelectItems");
}
// ShellExecute does not work here for some scenarios
auto r = SHOpenFolderAndSelectItems(pidl, 0, 0, 0);
if (FAILED(r))
{
message_box(sw::getProgramName(), "Error in SHOpenFolderAndSelectItems");
}
ILFree(pidl);
}
else
{
message_box(sw::getProgramName(), "Error in ILCreateFromPath");
}
}
else
{
message_box(sw::getProgramName(), "Package '" + p.toString() + "' not installed");
}
#endif
return;
}

if (uri_args[0] == "sw:open_build_script")
{
#ifdef _WIN32
if (sdb.isPackageInstalled(p))
{
auto f = (p.getDirSrc2() / "sw.cpp").wstring();

CoInitialize(0);
auto r = ShellExecute(0, L"open", f.c_str(), 0, 0, 0);
if (r <= (HINSTANCE)HINSTANCE_ERROR)
{
message_box(sw::getProgramName(), "Error in ShellExecute");
}
}
else
{
message_box(sw::getProgramName(), "Package '" + p.toString() + "' not installed");
}
#endif
return;
}

if (uri_args[0] == "sw:install")
@@ -698,13 +727,15 @@ SUBCOMMAND_DECL(uri)
message_box(sw::getProgramName(), "Package '" + p.toString() + "' is already installed");
}
#endif
return;
}

if (uri_args[0] == "sw:remove")
{
sdb.removeInstalledPackage(p);
error_code ec;
fs::remove_all(p.getDir(), ec);
return;
}

if (uri_args[0] == "sw:build")
@@ -717,6 +748,7 @@ SUBCOMMAND_DECL(uri)
fs::create_directories(d);
ScopedCurrentPath scp(d, CurrentPathScope::All);
sw::build(p.toString());
return;
}

if (uri_args[0] == "sw:run")
@@ -729,6 +761,7 @@ SUBCOMMAND_DECL(uri)
fs::create_directories(d);
ScopedCurrentPath scp(d, CurrentPathScope::All);
sw::run(p);
return;
}

if (uri_args[0] == "sw:upload")
@@ -770,7 +803,11 @@ SUBCOMMAND_DECL(uri)
c.out.inherit = true;
c.err.inherit = true;
c.execute();*/

return;
}

message_box(sw::getProgramName(), "Unknown command: " + uri_args[0]);
}
catch (std::exception &e)
{
@@ -132,7 +132,6 @@ static path getImportPchFile()
return getImportFilePrefix() += ".cpp";
}


static path getPackageHeader(const ExtendedPackageData &p /* resolved pkg */, const UnresolvedPackage &up)
{
// depends on upkg, not on pkg!
@@ -159,6 +158,7 @@ static path getPackageHeader(const ExtendedPackageData &p /* resolved pkg */, co
primitives::Context ctx;
ctx.addLine("#pragma once");
ctx.addLine();
//ctx.addLine("#line 1 \"" + normalize_path(cfg) + "\""); // determine correct line number first

primitives::Context prefix;
/*prefix.addLine("#define THIS_PREFIX \"" + p.ppath.slice(0, p.prefix).toString() + "\"");
@@ -0,0 +1,80 @@
void configure(Build &b)
{
auto &s = b.addCustomSolution();

s.Settings.TargetOS.Type = OSType::Android;
s.Settings.TargetOS.Arch = ArchType::aarch64;
s.Settings.Native.CompilerType = CompilerType::Clang;
s.Settings.Native.SDK.setAndroidApiVersion(24);

{
{
auto Librarian = std::make_shared<GNULibrarian>();
Librarian->Type = LinkerType::GNU;
Librarian->file = "d:/dev/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android-ar.exe";
Librarian->Extension = s.Settings.TargetOS.getStaticLibraryExtension();
s.registerProgram("org.gnu.binutils.ar", Librarian);
}

{
NativeLinkerOptions LOpts;
LOpts.System.LinkLibraries.push_back("c++");
//LOpts.System.LinkLibraries.push_back("c++fs");

auto Linker = std::make_shared<GNULinker>();
Linker->Type = LinkerType::GNU;
Linker->file = "d:/dev/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android28-clang.cmd";
Linker->use_start_end_groups = false;
*Linker = LOpts;
s.registerProgram("org.LLVM.clang.ld", Linker);
}

NativeCompilerOptions COpts;

// ASM
/*{
auto L = std::make_shared<NativeLanguage>();
L->CompiledExtensions = { ".s", ".S" };
auto C = std::make_shared<GNUASMCompiler>();
C->Type = CompilerType::GNU;
C->file = "x86_64-apple-darwin15-as";
*C = COpts;
L->compiler = C;
s.registerProgramAndLanguage("org.gnu.gcc.as", C, L);
}*/

// C
{
auto L = std::make_shared<NativeLanguage>();
L->CompiledExtensions = { ".c" };

auto C = std::make_shared<GNUCompiler>();
C->Type = CompilerType::GNU;
C->file = "d:/dev/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe";
*C = COpts;
L->compiler = C;
s.registerProgramAndLanguage("org.LLVM.clang", C, L);

auto cmd = C->createCommand();
cmd->args.push_back("-fno-addrsig");
}

// CPP
{
auto L = std::make_shared<NativeLanguage>();
L->CompiledExtensions = sw::getCppSourceFileExtensions();

auto C = std::make_shared<GNUCompiler>();
C->Type = CompilerType::GNU;
C->file = "d:/dev/android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe";
*C = COpts;
L->compiler = C;
s.registerProgramAndLanguage("org.LLVM.clangpp", C, L);

auto cmd = C->createCommand();
cmd->args.push_back("-fno-addrsig");
cmd->args.push_back("-stdlib=libc++");
}
}
}

0 comments on commit e8645eb

Please sign in to comment.
You can’t perform that action at this time.