forked from semios/semios-packages
@@ -0,0 +1,21 @@
|
|||||||
|
import os
|
||||||
|
import types
|
||||||
|
|
||||||
|
|
||||||
|
def _wrap_treedir_entry(ent, prefix=""):
|
||||||
|
wrapped = types.SimpleNamespace()
|
||||||
|
wrapped.name = f"{prefix}/{ent.name}" if prefix else ent.name
|
||||||
|
wrapped.path = ent.path
|
||||||
|
wrapped.is_dir = ent.is_dir
|
||||||
|
wrapped.is_file = ent.is_file
|
||||||
|
wrapped.is_symlink = ent.is_symlink
|
||||||
|
return wrapped
|
||||||
|
|
||||||
|
|
||||||
|
def treedir(root: str, prefix: str = ""):
|
||||||
|
with os.scandir(root) as entries:
|
||||||
|
for ent in entries:
|
||||||
|
wrapped = _wrap_treedir_entry(ent, prefix)
|
||||||
|
yield wrapped
|
||||||
|
if wrapped.is_dir(follow_symlinks=False):
|
||||||
|
yield from treedir(ent.path, wrapped.name)
|
||||||
+52
-16
@@ -1,6 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from lib.common import treedir
|
||||||
|
|
||||||
from . import make as libmake
|
from . import make as libmake
|
||||||
from . import pkgcomposer
|
from . import pkgcomposer
|
||||||
|
|
||||||
@@ -9,6 +11,23 @@ def configure(rem: list[str] = []):
|
|||||||
subprocess.run(["./configure"] + rem, check=True)
|
subprocess.run(["./configure"] + rem, check=True)
|
||||||
|
|
||||||
|
|
||||||
|
def cmake(rem: list[str] = []):
|
||||||
|
source_dir = os.getcwd()
|
||||||
|
os.makedirs("../cmake_build", exist_ok=True)
|
||||||
|
os.chdir("../cmake_build")
|
||||||
|
subprocess.run(
|
||||||
|
[
|
||||||
|
"cmake",
|
||||||
|
"-GNinja",
|
||||||
|
"-DCMAKE_BUILD_TYPE=Release",
|
||||||
|
"-DCMAKE_INSTALL_PREFIX=/",
|
||||||
|
source_dir,
|
||||||
|
]
|
||||||
|
+ rem,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def make(rem: list[str] = []):
|
def make(rem: list[str] = []):
|
||||||
subprocess.run(["make", f"-j{os.cpu_count()}"] + rem, check=True)
|
subprocess.run(["make", f"-j{os.cpu_count()}"] + rem, check=True)
|
||||||
|
|
||||||
@@ -20,6 +39,18 @@ def make_install(rem: list[str] | None = None, chdir: bool = True):
|
|||||||
os.chdir("../cpp_install")
|
os.chdir("../cpp_install")
|
||||||
|
|
||||||
|
|
||||||
|
def ninja(rem: list[str] = []):
|
||||||
|
subprocess.run(["ninja"] + rem, check=True)
|
||||||
|
|
||||||
|
|
||||||
|
def ninja_install(rem: list[str] = [], chdir: bool = True):
|
||||||
|
if chdir:
|
||||||
|
os.environ["DESTDIR"] = os.getcwd() + "/../cpp_install"
|
||||||
|
subprocess.run(["ninja", "install"] + rem, check=True)
|
||||||
|
if chdir:
|
||||||
|
os.chdir(os.environ["DESTDIR"])
|
||||||
|
|
||||||
|
|
||||||
def _do_auto_pack(pc: pkgcomposer.PkgComposer, srcdir: str, dstdir: str, filter):
|
def _do_auto_pack(pc: pkgcomposer.PkgComposer, srcdir: str, dstdir: str, filter):
|
||||||
if not os.path.exists(srcdir):
|
if not os.path.exists(srcdir):
|
||||||
return
|
return
|
||||||
@@ -27,31 +58,36 @@ def _do_auto_pack(pc: pkgcomposer.PkgComposer, srcdir: str, dstdir: str, filter)
|
|||||||
pc.makedir(dstdir)
|
pc.makedir(dstdir)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
with os.scandir(srcdir) as entries:
|
for ent in treedir(srcdir):
|
||||||
for ent in entries:
|
if filter(ent):
|
||||||
if filter(ent):
|
if ent.is_file(follow_symlinks=False):
|
||||||
if ent.is_dir(follow_symlinks=False):
|
pc.makedirs(os.path.dirname(f"{dstdir}/{ent.name}"))
|
||||||
pc.makedir(f"{dstdir}/{ent.name}")
|
pc.addfile(ent.path, f"{dstdir}/{ent.name}")
|
||||||
elif ent.is_file(follow_symlinks=False):
|
elif ent.is_symlink() and not os.path.isabs(os.readlink(ent.path)):
|
||||||
pc.addfile(ent.path, f"{dstdir}/{ent.name}")
|
pc.addfile(ent.path, f"{dstdir}/{ent.name}")
|
||||||
elif ent.is_symlink() and not os.path.isabs(os.readlink(ent.path)):
|
|
||||||
pc.addfile(ent.path, f"{dstdir}/{ent.name}")
|
|
||||||
|
def _is_dev_file(ent) -> bool:
|
||||||
|
return (
|
||||||
|
ent.name.endswith(".o")
|
||||||
|
or ent.name.endswith(".a")
|
||||||
|
or ent.name.endswith(".la")
|
||||||
|
or ent.name.endswith(".pc")
|
||||||
|
or ent.name.endswith(".h")
|
||||||
|
or ent.name.endswith(".cmake")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _autopack_filter_lib(ent) -> bool:
|
def _autopack_filter_lib(ent) -> bool:
|
||||||
if ent.name.endswith(".o") or ent.name.endswith(".a"):
|
return not _is_dev_file(ent)
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def _autopack_filter_bin(ent) -> bool:
|
def _autopack_filter_bin(ent) -> bool:
|
||||||
return True
|
return os.access(ent.path, os.X_OK) and ent.is_file(follow_symlinks=False)
|
||||||
|
|
||||||
|
|
||||||
def _autopack_filter_dev(ent):
|
def _autopack_filter_dev(ent):
|
||||||
if ".so" in ent.name:
|
return _is_dev_file(ent)
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def _auto_pack(profiles: list[str], pc: pkgcomposer.PkgComposer):
|
def _auto_pack(profiles: list[str], pc: pkgcomposer.PkgComposer):
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ class PkgComposer:
|
|||||||
def makedir(self, name: str):
|
def makedir(self, name: str):
|
||||||
os.mkdir(f"{self.workdir}/bundle/{name}")
|
os.mkdir(f"{self.workdir}/bundle/{name}")
|
||||||
|
|
||||||
|
def makedirs(self, name: str):
|
||||||
|
os.makedirs(f"{self.workdir}/bundle/{name}", exist_ok=True)
|
||||||
|
|
||||||
def addfile(self, src: str, dst: str):
|
def addfile(self, src: str, dst: str):
|
||||||
shutil.copy2(src, f"{self.workdir}/bundle/{dst}", follow_symlinks=False)
|
shutil.copy2(src, f"{self.workdir}/bundle/{dst}", follow_symlinks=False)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import lib.cpp as cpp
|
||||||
|
from lib.make import *
|
||||||
|
|
||||||
|
version("5.0.0")
|
||||||
|
source_url("https://github.com/aws/aws-lc/archive/refs/tags/v5.0.0.tar.gz")
|
||||||
|
|
||||||
|
|
||||||
|
def build():
|
||||||
|
cpp.cmake(["-DBUILD_SHARED_LIBS=1"])
|
||||||
|
cpp.ninja()
|
||||||
|
cpp.ninja_install()
|
||||||
|
os.chdir("usr")
|
||||||
|
|
||||||
|
|
||||||
|
on_build(build)
|
||||||
|
|
||||||
|
package("aws-lc")
|
||||||
|
cpp.use_auto_pack(["lib"])
|
||||||
|
|
||||||
|
package("aws-lc-bin")
|
||||||
|
cpp.use_auto_pack(["bin"])
|
||||||
|
|
||||||
|
package("aws-lc-dev")
|
||||||
|
cpp.use_auto_pack(["dev"])
|
||||||
Reference in New Issue
Block a user