mirror of
https://onedev.site.tesses.net/crosslang
synced 2026-02-08 17:15:45 +00:00
Add runtime packages to CPKG
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,7 @@
|
|||||||
|
publish
|
||||||
build
|
build
|
||||||
builds
|
builds
|
||||||
|
compilers
|
||||||
bin
|
bin
|
||||||
*.db
|
*.db
|
||||||
*.crvm
|
*.crvm
|
||||||
|
|||||||
@@ -62,9 +62,15 @@ jobs:
|
|||||||
cd Packaging/Linux
|
cd Packaging/Linux
|
||||||
bash build-ubuntu-jammy.sh
|
bash build-ubuntu-jammy.sh
|
||||||
bash push-ubuntu-jammy.sh
|
bash push-ubuntu-jammy.sh
|
||||||
|
apt update -y
|
||||||
|
apt install -y crosslang git
|
||||||
|
cd ../CPKG
|
||||||
|
bash pack_and_publish.sh
|
||||||
envVars:
|
envVars:
|
||||||
- name: GITEA_AUTH
|
- name: GITEA_AUTH
|
||||||
value: '@secret:GITEA_AUTH@'
|
value: '@secret:GITEA_AUTH@'
|
||||||
|
- name: CPKG_KEY
|
||||||
|
value: '@secret:CPKG_KEY@'
|
||||||
useTTY: true
|
useTTY: true
|
||||||
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
||||||
- !CommandStep
|
- !CommandStep
|
||||||
|
|||||||
55
Packaging/CPKG/ConsoleOrServer/CMakeLists.txt
Normal file
55
Packaging/CPKG/ConsoleOrServer/CMakeLists.txt
Normal 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()
|
||||||
61
Packaging/CPKG/ConsoleOrServer/main.cpp
Normal file
61
Packaging/CPKG/ConsoleOrServer/main.cpp
Normal 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;
|
||||||
|
}
|
||||||
9
Packaging/CPKG/extract_compiler.sh
Normal file
9
Packaging/CPKG/extract_compiler.sh
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
rm -r compilers
|
||||||
|
mkdir -p compilers
|
||||||
|
cd compilers
|
||||||
|
wget https://downloads.tesses.net/cache/compilers/$1-cross.tgz
|
||||||
|
tar xvzf $1-cross.tgz
|
||||||
|
mv $1-cross/* .
|
||||||
|
rmdir $1-cross
|
||||||
|
rm $1-cross.tgz
|
||||||
4
Packaging/CPKG/pack.sh
Normal file
4
Packaging/CPKG/pack.sh
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
mkdir compilers
|
||||||
|
export PATH=$COMPILERS/bin:$PATH
|
||||||
|
crossint pack.tcross
|
||||||
206
Packaging/CPKG/pack.tcross
Normal file
206
Packaging/CPKG/pack.tcross
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
var VERSION="1.0.0.0-dev";
|
||||||
|
var statics = [
|
||||||
|
{
|
||||||
|
target="powerpc-linux-musl",
|
||||||
|
cpu = "powerpc"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target="powerpc64-linux-musl",
|
||||||
|
cpu = "powerpc64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target="i686-linux-musl",
|
||||||
|
cpu = "i686"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target="arm-linux-musleabihf",
|
||||||
|
cpu="armv7l"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target="riscv32-linux-musl",
|
||||||
|
cpu="riscv32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target="riscv64-linux-musl",
|
||||||
|
cpu="riscv64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target="x86_64-linux-musl",
|
||||||
|
cpu="x86_64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target="mips-linux-musl",
|
||||||
|
cpu="mips"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target="mips64-linux-musl",
|
||||||
|
cpu="mips64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target="aarch64-linux-musl",
|
||||||
|
cpu="aarch64"
|
||||||
|
}
|
||||||
|
|
||||||
|
];
|
||||||
|
func CPUS()
|
||||||
|
{
|
||||||
|
var p = Process.Start({
|
||||||
|
FileName = Env.GetRealExecutablePath("nproc").ToString(),
|
||||||
|
RedirectStandardOutput=true
|
||||||
|
});
|
||||||
|
var ms = new MemoryStream(true);
|
||||||
|
p.StandardOutput.CopyTo(ms);
|
||||||
|
return ParseLong(ms.GetBytes().ToString().Replace("\n","").Replace("\r",""));
|
||||||
|
}
|
||||||
|
var nproc = CPUS();
|
||||||
|
func BuildConsoleOrServerLinuxStatic(dir,cmake_toolchain)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Building Linux Static {dir}");
|
||||||
|
var build_dir = "builds" / $"linux-{dir}-static";
|
||||||
|
var publish_dir = "publish" / $"linux-{dir}-static";
|
||||||
|
FS.Local.CreateDirectory(build_dir);
|
||||||
|
FS.Local.CreateDirectory(publish_dir);
|
||||||
|
|
||||||
|
var args = ["-S","ConsoleOrServer","-B",build_dir.ToString(),"-DCROSSAPPPUBLISH_STATIC=ON"];
|
||||||
|
if(TypeOf(cmake_toolchain) == "String")
|
||||||
|
{
|
||||||
|
args.Add($"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain}");
|
||||||
|
}
|
||||||
|
Process.Start({
|
||||||
|
FileName = Env.GetRealExecutablePath("cmake").ToString(),
|
||||||
|
Arguments = args
|
||||||
|
}).Join();
|
||||||
|
|
||||||
|
|
||||||
|
var p = new Process();
|
||||||
|
p.FileName = Env.GetRealExecutablePath("make").ToString();
|
||||||
|
p.WorkingDirectory = build_dir.MakeAbsolute().ToString();
|
||||||
|
p.Arguments = [$"-j{nproc}"];
|
||||||
|
if(p.Start())
|
||||||
|
p.Join();
|
||||||
|
|
||||||
|
|
||||||
|
mvFile(build_dir/"crossapp", publish_dir / "crossapp");
|
||||||
|
var info = {
|
||||||
|
type = "archive",
|
||||||
|
maintainer = "Mike Nolan",
|
||||||
|
repo = "https://onedev.site.tesses.net/crosslang",
|
||||||
|
homepage = "https://crosslang.tesseslanguage.com/",
|
||||||
|
executable_name = "crossapp",
|
||||||
|
executable_can_be_renamed = true,
|
||||||
|
executable_runtime = $"linux-{dir}-static"
|
||||||
|
};
|
||||||
|
|
||||||
|
var name = $"Tesses.CrossLang.Runtime.linux-{dir}-static";
|
||||||
|
|
||||||
|
var subDir = new SubdirFilesystem(FS.Local,publish_dir);
|
||||||
|
var pkgStrm = FS.Local.OpenFile("publish"/$"{name}-{VERSION}.crvm","wb");
|
||||||
|
FS.CreateArchive(subDir,pkgStrm, name ,VERSION, Json.Encode(info));
|
||||||
|
pkgStrm.Close();
|
||||||
|
}
|
||||||
|
func BuildConsoleOrServerLinuxStaticBasedOnTarget(target,cpu)
|
||||||
|
{
|
||||||
|
var compiler = ("compilers"/"bin"/target).MakeAbsolute().ToString();
|
||||||
|
var p = new Process();
|
||||||
|
p.FileName = Env.GetRealExecutablePath("bash").ToString();
|
||||||
|
p.Arguments = ["extract_compiler.sh",target];
|
||||||
|
if(p.Start())
|
||||||
|
p.Join();
|
||||||
|
|
||||||
|
var toolchain = $"
|
||||||
|
set(CMAKE_C_COMPILER \"{compiler}-gcc\")
|
||||||
|
set(CMAKE_CXX_COMPILER \"{compiler}-g++\")
|
||||||
|
set(CMAKE_C_FLAGS \"-static-libgcc -static-libstdc++ -static\")
|
||||||
|
set(CMAKE_CXX_FLAGS \"-static-libgcc -static-libstdc++ -static\")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS \"-static-libgcc -static-libstdc++ -static\")
|
||||||
|
|
||||||
|
|
||||||
|
set(CMAKE_SYSTEM_NAME Linux)
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR {cpu})
|
||||||
|
";
|
||||||
|
if(target == "riscv32-linux-musl" || target == "riscv64-linux-musl")
|
||||||
|
{
|
||||||
|
toolchain += "set(CMAKE_POSITION_INDEPENDENT_CODE ON)\n";
|
||||||
|
}
|
||||||
|
FS.WriteAllText(FS.Local,"compilers"/$"{target}.cmake", toolchain);
|
||||||
|
BuildConsoleOrServerLinuxStatic(cpu,("compilers"/$"{target}.cmake").MakeAbsolute().ToString());
|
||||||
|
}
|
||||||
|
func BuildConsoleOrServerLinuxShared(dir,$cmake_toolchain)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Building Linux Shared {dir}");
|
||||||
|
var build_dir = "builds" / $"linux-{dir}";
|
||||||
|
var publish_dir = "publish" / $"linux-{dir}";
|
||||||
|
FS.Local.CreateDirectory(build_dir);
|
||||||
|
FS.Local.CreateDirectory(publish_dir);
|
||||||
|
|
||||||
|
var args = ["-S","ConsoleOrServer","-B",build_dir.ToString()];
|
||||||
|
if(TypeOf(cmake_toolchain) == "String")
|
||||||
|
{
|
||||||
|
args.Add($"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain}");
|
||||||
|
}
|
||||||
|
Process.Start({
|
||||||
|
FileName = Env.GetRealExecutablePath("cmake").ToString(),
|
||||||
|
Arguments = args
|
||||||
|
}).Join();
|
||||||
|
|
||||||
|
|
||||||
|
var p = new Process();
|
||||||
|
p.FileName = Env.GetRealExecutablePath("make").ToString();
|
||||||
|
p.WorkingDirectory = build_dir.MakeAbsolute().ToString();
|
||||||
|
p.Arguments = [$"-j{nproc}"];
|
||||||
|
if(p.Start())
|
||||||
|
p.Join();
|
||||||
|
p = new Process();
|
||||||
|
p.FileName = Env.GetRealExecutablePath("make").ToString();
|
||||||
|
p.WorkingDirectory = build_dir.MakeAbsolute().ToString();
|
||||||
|
p.Arguments = ["install","DESTDIR=."];
|
||||||
|
if(p.Start())
|
||||||
|
p.Join();
|
||||||
|
|
||||||
|
mvFile(build_dir/"dir"/"crossapp", publish_dir / "crossapp");
|
||||||
|
each(var lib : FS.Local.EnumeratePaths(build_dir/"dir"))
|
||||||
|
{
|
||||||
|
if(lib.GetExtension() == ".so")
|
||||||
|
{
|
||||||
|
mvFile(lib,publish_dir / lib.GetFileName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var info = {
|
||||||
|
type = "archive",
|
||||||
|
maintainer = "Mike Nolan",
|
||||||
|
repo = "https://onedev.site.tesses.net/crosslang",
|
||||||
|
homepage = "https://crosslang.tesseslanguage.com/",
|
||||||
|
executable_name = "crossapp",
|
||||||
|
executable_can_be_renamed = true,
|
||||||
|
executable_runtime = $"linux-{dir}"
|
||||||
|
};
|
||||||
|
|
||||||
|
var name = $"Tesses.CrossLang.Runtime.linux-{dir}";
|
||||||
|
|
||||||
|
var subDir = new SubdirFilesystem(FS.Local,publish_dir);
|
||||||
|
var pkgStrm = FS.Local.OpenFile("publish"/$"{name}-{VERSION}.crvm","wb");
|
||||||
|
FS.CreateArchive(subDir,pkgStrm, name ,VERSION, Json.Encode(info));
|
||||||
|
pkgStrm.Close();
|
||||||
|
}
|
||||||
|
func mvFile(src,dest)
|
||||||
|
{
|
||||||
|
Process.Start({
|
||||||
|
FileName = Env.GetRealExecutablePath("mv").ToString(),
|
||||||
|
Arguments = [src.MakeAbsolute().ToString(),dest.MakeAbsolute().ToString()]
|
||||||
|
}).Join();
|
||||||
|
}
|
||||||
|
func main(args)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Got {nproc} cpus");
|
||||||
|
BuildConsoleOrServerLinuxShared("x86_64");
|
||||||
|
BuildConsoleOrServerLinuxShared("aarch64", "/opt/toolchains/arm64.cmake");
|
||||||
|
BuildConsoleOrServerLinuxShared("armv7l", "/opt/toolchains/armhf.cmake");
|
||||||
|
BuildConsoleOrServerLinuxShared("riscv64", "/opt/toolchains/riscv64.cmake");
|
||||||
|
|
||||||
|
|
||||||
|
each(var static : statics)
|
||||||
|
{
|
||||||
|
BuildConsoleOrServerLinuxStaticBasedOnTarget(static.target,static.cpu);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
3
Packaging/CPKG/pack_and_publish.sh
Normal file
3
Packaging/CPKG/pack_and_publish.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
bash ./pack.sh
|
||||||
|
bash ./publish.sh
|
||||||
2
Packaging/CPKG/publish.sh
Normal file
2
Packaging/CPKG/publish.sh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
find publish -name "*.crvm" -exec upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/" "{}" \;
|
||||||
Reference in New Issue
Block a user