Got it working on Windows using Mingw

This commit is contained in:
Mike Nolan 2024-12-29 21:43:52 -06:00
parent 7e8ce5d58a
commit 7aae9fadba
11 changed files with 130 additions and 31 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
build
bin

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
build
builds
bin
*.db
*.crvm

View File

@ -14,10 +14,9 @@ option(CROSSLANG_ENABLE_PROCESS "Enable process" ON)
option(CROSSLANG_ENABLE_SDL2 "Enable SDL2 (For Drawing)" ON)
option(CROSSLANG_ENABLE_TERMIOS "Enable termios (For changing terminal options)" ON)
option(CROSSLANG_ENABLE_64BIT_FILE "Allow files over 2GiB" ON)
set(JANSSON_DIR "Directory for Jansson" "")
set(JANSSON_DIR "Directory for Jansson" CACHE PATH "Jansson directory")
find_package(TessesFramework REQUIRED)

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM ubuntu:noble
RUN apt update -y && \
apt install -y --no-install-recommends \
libjansson-dev cmake git ca-certificates wget libmbedtls-dev g++ gcc libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev build-essential && \
apt clean -y && \
rm -rf /var/lib/apt/lists/*
WORKDIR /tmp
RUN git clone https://gitea.site.tesses.net/tesses50/tesses-framework && cd tesses-framework && mkdir build && cd build && cmake -S .. -B . && make -j4 && make install && cd /tmp && rm -r /tmp/tesses-framework
COPY . /src
WORKDIR /src
RUN mkdir build && cd build && cmake -S .. -B . && make -j4 && make install && cd / && rm -r /src
WORKDIR /

View File

@ -9,6 +9,13 @@ Tesses Cross Language
- CMake
- SDL2 (but can be turned off)
## Use in docker
```bash
git clone https://gitea.site.tesses.net/tesses50/crosslang
cd crosslang
sudo docker build -t crosslang:latest .
```
## To Install
- [Follow TessesFramework setup](https://gitea.site.tesses.net/tesses50/tesses-framework)
- Follow the commands bellow

View File

@ -670,7 +670,7 @@ namespace Tesses::CrossLang
{
expr = AdvancedSyntaxNode::Create(LessThanEqualsExpression, true, {expr,ParseShift()});
}
else if(tkn.text == ">")
else if(tkn.text == ">=")
{
expr = AdvancedSyntaxNode::Create(GreaterThanEqualsExpression, true, {expr,ParseShift()});
}

View File

@ -1,9 +1,22 @@
#include "CrossLang.hpp"
#include "../sago/platform_folders.h"
#if defined(_WIN32)
#include <windows.h>
#endif
namespace Tesses::CrossLang
{
static std::string GetHomeFolder()
{
#if !defined(SAGO_DISABLE)
return sago::getHomeDir();
#elif defined(__EMSCRIPTEN__)
return "/home/web_user";
#else
return "/CrossLangProfile";
#endif
}
static TObject Env_getPlatform(GCList& ls, std::vector<TObject> args)
{
#if defined(__SWITCH__)
@ -52,7 +65,7 @@ namespace Tesses::CrossLang
std::string key;
if(GetArgument(args,0,key))
{
auto res = getenv(key.c_str());
auto res = std::getenv(key.c_str());
if(res == nullptr) return nullptr;
std::string value = res;
return value;
@ -66,57 +79,108 @@ namespace Tesses::CrossLang
if(GetArgument(args,0,key))
{
if(GetArgument(args,1,value))
setenv(key.c_str(), value.c_str(),1);
#if defined(_WIN32)
SetEnvironmentVariable(key.c_str(),value.c_str());
#else
setenv(key.c_str(), value.c_str(),1);
#endif
else
#if defined(_WIN32)
{
}
#else
unsetenv(key.c_str());
#endif
return value;
}
return nullptr;
}
static TObject Env_getDownloads(GCList& ls, std::vector<TObject> args)
{
#if !defined(SAGO_DISABLE)
return sago::getDownloadFolder();
#else
return GetHomeFolder() + "/Downloads";
#endif
}
static TObject Env_getMusic(GCList& ls, std::vector<TObject> args)
{
#if !defined(SAGO_DISABLE)
return sago::getMusicFolder();
#else
return GetHomeFolder() + "/Music";
#endif
}
static TObject Env_getPictures(GCList& ls, std::vector<TObject> args)
{
return sago::getMusicFolder();
#if !defined(SAGO_DISABLE)
return sago::getPicturesFolder();
#else
return GetHomeFolder() + "/Pictures";
#endif
}
static TObject Env_getVideos(GCList& ls, std::vector<TObject> args)
{
#if !defined(SAGO_DISABLE)
return sago::getVideoFolder();
#else
return GetHomeFolder() + "/Videos";
#endif
}
static TObject Env_getDocuments(GCList& ls, std::vector<TObject> args)
{
#if !defined(SAGO_DISABLE)
return sago::getDocumentsFolder();
#else
return GetHomeFolder() + "/Documents";
#endif
}
static TObject Env_getConfig(GCList& ls, std::vector<TObject> args)
{
#if !defined(SAGO_DISABLE)
return sago::getConfigHome();
#else
return GetHomeFolder() + "/Config";
#endif
}
static TObject Env_getDesktop(GCList& ls, std::vector<TObject> args)
{
#if !defined(SAGO_DISABLE)
return sago::getDesktopFolder();
#else
return GetHomeFolder() + "/Desktop";
#endif
}
static TObject Env_getState(GCList& ls, std::vector<TObject> args)
{
#if !defined(SAGO_DISABLE)
return sago::getStateDir();
#else
return GetHomeFolder() + "/State";
#endif
}
static TObject Env_getCache(GCList& ls, std::vector<TObject> args)
{
#if !defined(SAGO_DISABLE)
return sago::getCacheDir();
#else
return GetHomeFolder() + "/Cache";
#endif
}
static TObject Env_getData(GCList& ls, std::vector<TObject> args)
{
#if !defined(SAGA_DISABLE)
return sago::getDataHome();
#else
return GetHomeFolder() + "/Data";
#endif
}
static TObject Env_getUser(GCList& ls, std::vector<TObject> args)
{
return sago::getHomeDir();
return GetHomeFolder();
}
void TStd::RegisterEnv(GC* gc, TRootEnvironment* env)
{

View File

@ -1,12 +1,7 @@
#include "CrossLang.hpp"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <csignal>
#include <arpa/inet.h>
#include <iostream>
#include <netinet/tcp.h>
#include <unistd.h>
#include <cstring>
using namespace Tesses::Framework::Streams;
@ -552,4 +547,4 @@ namespace Tesses::CrossLang
env->DeclareVariable("Net", dict);
gc->BarrierEnd();
}
}
}

View File

@ -26,6 +26,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/*
Modified by Mike Nolan for this project
I modified it to return home directory and conditionally compile for systems that are not GEKKO / NX etc
*/
#if !defined(SAGO_DISABLE)
#include "platform_folders.h"
#include <iostream>
#include <stdexcept>
@ -218,7 +224,12 @@ std::string getDataHome() {
}
std::string getHomeDir()
{
#if defined(_WIN32)
return GetKnownWindowsFolder(FOLDERID_Profile, "Profile could not be found");
#else
return getHome();
#endif
}
std::string getConfigHome() {
#ifdef _WIN32
@ -458,3 +469,4 @@ std::string getSaveGamesFolder2() {
}
} //namespace sago
#endif

View File

@ -26,9 +26,25 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/*
Modified by Mike Nolan for this project
I modified it to return home directory and conditionally compile for systems that are not GEKKO / NX etc
*/
#ifndef SAGO_PLATFORM_FOLDERS_H
#define SAGO_PLATFORM_FOLDERS_H
#if defined(GEKKO) || defined(__SWITCH__) || defined(__EMSCRIPTEN__)
#define SAGO_DISABLE
#endif
#if !defined(SAGO_DISABLE)
#include <vector>
#include <string>
@ -285,5 +301,5 @@ private:
} //namespace sago
#endif
#endif /* PLATFORM_FOLDERS_H */

View File

@ -919,7 +919,7 @@ namespace Tesses::CrossLang {
if(std::holds_alternative<int64_t>(left) && std::holds_alternative<int64_t>(right))
{
cse.back()->Push(gc,std::get<int64_t>(left) || std::get<int64_t>(right));
cse.back()->Push(gc,std::get<int64_t>(left) | std::get<int64_t>(right));
}
else if(std::holds_alternative<THeapObjectHolder>(left))
{
@ -928,7 +928,7 @@ namespace Tesses::CrossLang {
if(dict != nullptr)
{
gc->BarrierBegin();
TObject fn = dict->GetValue("operator||");
TObject fn = dict->GetValue("operator|");
gc->BarrierEnd();
return InvokeTwo(ls,fn,left,right);
}
@ -989,7 +989,7 @@ namespace Tesses::CrossLang {
if(std::holds_alternative<int64_t>(left) && std::holds_alternative<int64_t>(right))
{
cse.back()->Push(gc,std::get<int64_t>(left) && std::get<int64_t>(right));
cse.back()->Push(gc,std::get<int64_t>(left) & std::get<int64_t>(right));
}
else if(std::holds_alternative<THeapObjectHolder>(left))
{
@ -998,7 +998,7 @@ namespace Tesses::CrossLang {
if(dict != nullptr)
{
gc->BarrierBegin();
TObject fn = dict->GetValue("operator&&");
TObject fn = dict->GetValue("operator&");
gc->BarrierEnd();
return InvokeTwo(ls,fn,left,right);
}
@ -3597,6 +3597,7 @@ namespace Tesses::CrossLang {
break;
case RIGHTSHIFT:
TVM_HANDLER(RShift);
break;
case LESSTHAN:
TVM_HANDLER(Lt);
break;
@ -4179,19 +4180,9 @@ namespace Tesses::CrossLang {
auto dict = dynamic_cast<TDictionary*>(obj);
if(dict != nullptr)
{
gc->BarrierBegin();
auto v = dict->GetValue("ToString");
gc->BarrierEnd();
if(std::holds_alternative<THeapObjectHolder>(v))
{
auto callable=dynamic_cast<TCallable*>(std::get<THeapObjectHolder>(v).obj);
if(callable != nullptr)
{
GCList ls(gc);
auto res = callable->Call(ls,{});
return ToString(gc,res);
}
}
GCList ls(gc);
return ToString(gc,dict->CallMethod(ls,"ToString",{}));
}
}