Add runtime packages to CPKG

This commit is contained in:
2025-09-26 16:30:20 -05:00
parent fbdc9862a7
commit 46a70e021f
9 changed files with 348 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.16)
project(CrossLangPublish)
option(CROSSAPPPUBLISH_STATIC "Build static version" OFF)
if(CROSSAPPPUBLISH_STATIC)
set(TESSESFRAMEWORK_ENABLE_RPATH OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(TESSESFRAMEWORK_ENABLE_STATIC ON CACHE INTERNAL "For TessesFramework" FORCE)
set(TESSESFRAMEWORK_ENABLE_EXAMPLES OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(TESSESFRAMEWORK_ENABLE_APPS OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(TESSESFRAMEWORK_ENABLE_SHARED OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(TESSESFRAMEWORK_FETCHCONTENT ON CACHE INTERNAL "For TessesFramework" FORCE)
set(CROSSLANG_ENABLE_BINARIES OFF CACHE INTERNAL "For CrossLang" FORCE)
else()
set(TESSESFRAMEWORK_ENABLE_RPATH OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(TESSESFRAMEWORK_ENABLE_STATIC OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(TESSESFRAMEWORK_ENABLE_EXAMPLES OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(TESSESFRAMEWORK_ENABLE_APPS OFF CACHE INTERNAL "For TessesFramework" FORCE)
set(TESSESFRAMEWORK_ENABLE_SHARED ON CACHE INTERNAL "For TessesFramework" FORCE)
set(TESSESFRAMEWORK_FETCHCONTENT ON CACHE INTERNAL "For TessesFramework" FORCE)
set(CROSSLANG_ENABLE_BINARIES OFF CACHE INTERNAL "For CrossLang" FORCE)
set(CMAKE_INSTALL_BINDIR "." CACHE INTERNAL "For CrossLang" FORCE)
set(CMAKE_INSTALL_LIBDIR "." CACHE INTERNAL "For CrossLang" FORCE)
set(CMAKE_INSTALL_PREFIX "/dir" CACHE INTERNAL "For CrossLang" FORCE)
set(CMAKE_PLATFORM_NO_VERSIONED_SONAME ON CACHE INTERNAL "For CrossLang" FORCE)
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON CACHE INTERNAL "For CrossLang" FORCE)
if (APPLE)
set(CMAKE_INSTALL_RPATH "@executable_path/" CACHE INTERNAL "For CrossLang" FORCE)
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN/" CACHE INTERNAL "For CrossLang" FORCE)
endif()
endif()
include(FetchContent)
FetchContent_Declare(
TessesCrossLang
GIT_REPOSITORY https://onedev.site.tesses.net/crosslang.git
)
FetchContent_MakeAvailable(TessesCrossLang)
add_executable(crossapp main.cpp)
if(CROSSAPPPUBLISH_STATIC)
target_link_libraries(crossapp PUBLIC crosslang_static)
else()
install(TARGETS crossapp DESTINATION "${CMAKE_INSTALL_BINDIR}")
target_link_libraries(crossapp PUBLIC crosslang_shared)
endif()

View File

@@ -0,0 +1,61 @@
#include <CrossLang.hpp>
using namespace Tesses::Framework;
using namespace Tesses::CrossLang;
int main(int argc, char** argv)
{
std::string name = argv[0];
Tesses::Framework::Filesystem::LocalFilesystem fs;
Tesses::Framework::Filesystem::VFSPath exePath=fs.SystemToVFSPath(name);
exePath.MakeAbsolute();
exePath.ChangeExtension(".crvm");
TF_InitWithConsole();
GC gc;
gc.Start();
GCList ls(gc);
TRootEnvironment* env = TRootEnvironment::Create(ls, TDictionary::Create(ls));
TStd::RegisterStd(&gc,env);
env->LoadFileWithDependencies(&gc, &fs, exePath);
if(env->HasVariable("WebAppMain"))
{
Args args(argc, argv);
int port = 4206;
for(auto& item : args.options)
{
if(item.first == "port")
{
port = std::stoi(item.second);
}
}
TList* args2 = TList::Create(ls);
args2->Add(exePath.ToString());
for(auto& item : args.positional)
{
args2->Add(item);
}
auto res = env->CallFunction(ls, "WebAppMain", {args2});
TObjectHttpServer http(&gc, res);
Tesses::Framework::Http::HttpServer svr(port,http,false);
svr.StartAccepting();
TF_RunEventLoop();
TF_Quit();
}
else {
TList* args = TList::Create(ls);
args->Add(exePath.ToString());
for(int arg=1;arg<argc;arg++)
args->Add(argv[arg]);
auto res = env->CallFunction(ls,"main",{args});
int64_t iresult;
if(GetObject(res,iresult))
return (int)iresult;
}
return 0;
}