mirror of
https://onedev.site.tesses.net/crosslang
synced 2026-02-08 17:15:45 +00:00
Assembler accessable now from cli
This commit is contained in:
21
src/crossasmcli.cpp
Normal file
21
src/crossasmcli.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "CrossLang.hpp"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
using namespace Tesses::Framework;
|
||||
using namespace Tesses::Framework::Streams;
|
||||
using namespace Tesses::Framework::Filesystem;
|
||||
using namespace Tesses::CrossLang;
|
||||
if(argc > 1 && strcmp(argv[1],"--help"))
|
||||
{
|
||||
std::cout << "Run this command in directory you want to assemble (with the crossasm.json)" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
auto curdir = VFSPath::GetAbsoluteCurrentDirectory();
|
||||
SubdirFilesystem sdfs(&LocalFS,curdir,false);
|
||||
auto path = Assemble(&sdfs);
|
||||
path.relative = true;
|
||||
std::cout << "Output: " << (curdir / path).ToString() << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
60
src/crossdisasmcli.cpp
Normal file
60
src/crossdisasmcli.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "CrossLang.hpp"
|
||||
void help(char* program)
|
||||
{
|
||||
std::cout << "USAGE: " << program << " [flags] FILE.CRVM" << std::endl;
|
||||
std::cout << "USAGE: " << program << " [flags] FILE.CRVM DIR" << std::endl;
|
||||
std::cout << "Flags:" << std::endl;
|
||||
std::cout << "--no-json\tNo json" << std::endl;
|
||||
std::cout << "--no-resources\nNo resources" << std::endl;
|
||||
|
||||
exit(0);
|
||||
}
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
using namespace Tesses::Framework;
|
||||
using namespace Tesses::Framework::Streams;
|
||||
using namespace Tesses::Framework::Filesystem;
|
||||
using namespace Tesses::CrossLang;
|
||||
|
||||
std::string file;
|
||||
Tesses::Framework::Filesystem::VFSPath path = VFSPath::GetAbsoluteCurrentDirectory();
|
||||
int curPos = 0;
|
||||
bool json=true;
|
||||
bool resources = true;
|
||||
for(int i = 1; i < argc; i++)
|
||||
{
|
||||
if(strcmp(argv[i],"--no-json") == 0)
|
||||
{
|
||||
json = false;
|
||||
}
|
||||
else if(strcmp(argv[i],"--no-resources") == 0)
|
||||
{
|
||||
resources = false;
|
||||
}
|
||||
else if(strcmp(argv[i],"--help") == 0)
|
||||
{
|
||||
help(argv[0]);
|
||||
}
|
||||
else {
|
||||
if(curPos == 0)
|
||||
{
|
||||
file = argv[i];
|
||||
curPos++;
|
||||
}
|
||||
else if(curPos == 1)
|
||||
{
|
||||
path = LocalFS.SystemToVFSPath(argv[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(file.empty())
|
||||
{
|
||||
help(argv[0]);
|
||||
}
|
||||
auto strm = LocalFS.OpenFile(file,"rb");
|
||||
SubdirFilesystem sdir(&LocalFS,path,false);
|
||||
if(strm->CanRead())
|
||||
Disassemble(strm, &sdir,json,resources);
|
||||
delete strm;
|
||||
return 0;
|
||||
}
|
||||
43
src/crossmergecli.cpp
Normal file
43
src/crossmergecli.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "CrossLang.hpp"
|
||||
void help(char* program)
|
||||
{
|
||||
std::cout << "USAGE: " << program << " FILE.CRVM DEST.CRVM" << std::endl;
|
||||
|
||||
exit(0);
|
||||
}
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
using namespace Tesses::Framework;
|
||||
using namespace Tesses::Framework::Streams;
|
||||
using namespace Tesses::Framework::Filesystem;
|
||||
using namespace Tesses::CrossLang;
|
||||
|
||||
if(argc < 3)
|
||||
{
|
||||
help(argv[0]);
|
||||
}
|
||||
|
||||
std::string src=argv[1];
|
||||
std::string dest=argv[2];
|
||||
|
||||
|
||||
|
||||
VFSPath srcF = src;
|
||||
VFSPath destF = dest;
|
||||
srcF.MakeAbsolute();
|
||||
destF.MakeAbsolute();
|
||||
|
||||
|
||||
SubdirFilesystem sdir(&LocalFS,srcF.GetParent(),false);
|
||||
SubdirFilesystem ddir(&LocalFS,destF+"_tmp",false);
|
||||
|
||||
|
||||
auto outpath = Merge(&sdir,"/"+srcF.GetFileName(), &ddir);
|
||||
outpath.relative=true;
|
||||
outpath = (destF+"_tmp") / outpath;
|
||||
LocalFS.MoveFile(outpath,destF);
|
||||
LocalFS.DeleteDirectoryRecurse(destF+"_tmp");
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user