Assembler accessable now from cli

This commit is contained in:
2025-08-31 05:34:43 -05:00
parent c75c79e3e0
commit 5d79d51462
5 changed files with 159 additions and 9 deletions

21
src/crossasmcli.cpp Normal file
View 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
View 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
View 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;
}