Added args and shell
This commit is contained in:
parent
1ffaac6bb4
commit
f9e9f26ff9
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "Tesses.CrossLang.Args",
|
||||
"version": "1.0.0.0-prod",
|
||||
"info": {
|
||||
"maintainer": "Mike Nolan",
|
||||
"type": "lib",
|
||||
"repo": "https://gitea.site.tesses.net/tesses50/crosslang/crosslang-libs",
|
||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||
"license": "LGPLv3"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
func Tesses.CrossLang.Args(args)
|
||||
{
|
||||
var filename = args[0];
|
||||
|
||||
if(args.Count < 1) return null;
|
||||
var flags = [];
|
||||
var options = [];
|
||||
var pos = [];
|
||||
|
||||
var onlyPos=false;
|
||||
|
||||
for(var i = 1; i < args.Count; i++)
|
||||
{
|
||||
if(args[i] == "--") {
|
||||
onlyPos=true;
|
||||
continue;
|
||||
}
|
||||
if(!onlyPos && args[i].Count > 2 && args[i][0] == '-' && args[i][1] == '-')
|
||||
{
|
||||
var p = args[i].Substring(2).Split("=",true,2);
|
||||
if(p.Count == 1)
|
||||
flags.Add(p[0]);
|
||||
else if(p.Count == 2)
|
||||
options.Add({Key = p[0],Value=p[1]});
|
||||
}
|
||||
else {
|
||||
pos.Add(args[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
Options = options,
|
||||
FileName = filename,
|
||||
Flags = flags,
|
||||
Arguments = pos
|
||||
};
|
||||
|
||||
}
|
|
@ -51,7 +51,6 @@ func Tesses.CrossLang.BuildTool(pm)
|
|||
};
|
||||
},
|
||||
BuildProject = (this,projectDirectory)=>{
|
||||
|
||||
var dir = FS.MakeFull(projectDirectory);
|
||||
var dirStr = dir.ToString();
|
||||
|
||||
|
@ -99,10 +98,12 @@ func Tesses.CrossLang.BuildTool(pm)
|
|||
{
|
||||
each(var dep : configData.project_dependencies)
|
||||
{
|
||||
if(dep.IsRelative())
|
||||
dependencies.Add(this.BuildProject(dir / dep));
|
||||
if(Path.FromString(dep).IsRelative())
|
||||
{
|
||||
dependencies.Add(this.BuildProject((dir / dep)));
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
dependencies.Add(this.BuildProject(dep));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"license": "LGPLv3"
|
||||
},
|
||||
"project_dependencies": [
|
||||
"./Tesses.CrossLang.BuildEssentials"
|
||||
"../Tesses.CrossLang.BuildEssentials",
|
||||
"../Tesses.CrossLang.Args"
|
||||
]
|
||||
}
|
|
@ -1,4 +1,64 @@
|
|||
func main(args)
|
||||
{
|
||||
Console.WriteLine("Hello, world");
|
||||
var dd = Tesses.CrossLang.Args(args);
|
||||
if(dd.Arguments.Count > 0)
|
||||
{
|
||||
var commandName = dd.Arguments[0];
|
||||
if(commandName == "args")
|
||||
{
|
||||
each(var arg : dd.Arguments)
|
||||
{
|
||||
Console.WriteLine(arg);
|
||||
}
|
||||
}
|
||||
if(commandName == "build")
|
||||
{
|
||||
var offline=false;
|
||||
var buildPath = ".";
|
||||
if(dd.Arguments.Count > 1)
|
||||
{
|
||||
buildPath = dd.Arguments[1];
|
||||
}
|
||||
each(var flag : dd.Flags)
|
||||
{
|
||||
if(flag == "offline")
|
||||
{
|
||||
offline = true;
|
||||
}
|
||||
}
|
||||
var pm = Tesses.CrossLang.PackageManager();
|
||||
pm.Offline = offline;
|
||||
var bt = Tesses.CrossLang.BuildTool(pm);
|
||||
bt.BuildProject(buildPath);
|
||||
}
|
||||
else if(commandName == "run")
|
||||
{
|
||||
var offline=false;
|
||||
var buildPath = ".";
|
||||
|
||||
each(var flag : dd.Flags)
|
||||
{
|
||||
if(flag == "offline")
|
||||
{
|
||||
offline = true;
|
||||
}
|
||||
}
|
||||
var pm = Tesses.CrossLang.PackageManager();
|
||||
pm.Offline = offline;
|
||||
var bt = Tesses.CrossLang.BuildTool(pm);
|
||||
var output = bt.BuildProject(buildPath).Output;
|
||||
|
||||
var env = VM.CreateEnvironment({});
|
||||
env.RegisterEverything();
|
||||
env.LockRegister();
|
||||
|
||||
env.LoadFileWithDependencies(FS.Local,output);
|
||||
var myArgs = [];
|
||||
for(var i = 1; i < dd.Arguments.Count; i++)
|
||||
{
|
||||
myArgs.Add(dd.Arguments[i]);
|
||||
}
|
||||
return env.GetDictionary().main(myArgs);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
#!/bin/bash
|
||||
cd Tesses.CrossLang.BuildEssentials && crossc -o ./bin-tmp -n Tesses.CrossLang.BuildEssentials -v 1.0.0.0-prod main.tcross src/*.tcross && cd ..
|
||||
crossvm ./Tesses.CrossLang.BuildEssentials/bin-tmp/Tesses.CrossLang.BuildEssentials-1.0.0.0-prod.crvm Tesses.CrossLang.Shell
|
||||
crossvm ./Tesses.CrossLang.BuildEssentials/bin-tmp/Tesses.CrossLang.BuildEssentials-1.0.0.0-prod.crvm Tesses.CrossLang.Shell
|
||||
crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build Tesses.CrossLang.PackageServer
|
||||
#crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build Tesses.CrossLang.Website
|
Loading…
Reference in New Issue