1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-09-17 14:57:22 +03:00

boot/script-loader: Add mruby-lvgui-native-fragment

This commit is contained in:
Samuel Dionne-Riel 2021-01-01 17:48:09 -05:00
parent ffc4a12fa1
commit 447d8d59e7
4 changed files with 156 additions and 0 deletions

View File

@ -0,0 +1,5 @@
= mruby-lvgui-native-fragment
This is glue code to build the mruby interpreter with the proper libraries.
The actual library parts are found under /boot/lib/

View File

@ -0,0 +1,32 @@
{ mrbgems
, callPackage
, fetchFromGitHub
, pkg-config
, buildPackages
# Configuration
, withSimulator ? false
}:
let
# This is an implementation detail of this gem.
# Even if unusual, let's keep it private.
lvgui = (callPackage ./lvgui.nix {
inherit withSimulator;
});
in
mrbgems.mkGem {
# Dirty since `default.nix` and `lvgui.nix` modifications will
# needlessly cause a rebuild, but good enough in reality.
src = ./.;
gemBuildInputs = [
lvgui
] ++ lvgui.buildInputs;
gemNativeBuildInputs = [
buildPackages.pkg-config
];
requiredGems = with mrbgems; [
mruby-fiddle
];
}

View File

@ -0,0 +1,103 @@
{ stdenv
, pkgs
, lib
, fetchFromGitHub
, pkg-config
, SDL2
, withSimulator ? false
}:
let
inherit (lib) optional optionals optionalString;
simulatorDeps = [
SDL2
];
# Allow libevdev to cross-compile.
libevdev = (pkgs.libevdev.override({
python3 = null;
})).overrideAttrs({nativeBuildsInputs ? [], ...}: {
nativeBuildInputs = nativeBuildsInputs ++ [
pkgs.buildPackages.python3
];
});
libxkbcommon = pkgs.callPackage (
{ stdenv
, libxkbcommon
, meson
, ninja
, pkgconfig
, yacc
}:
libxkbcommon.overrideAttrs({...}: {
nativeBuildInputs = [ meson ninja pkgconfig yacc ];
buildInputs = [ ];
mesonFlags = [
"-Denable-wayland=false"
"-Denable-x11=false"
"-Denable-docs=false"
# This is because we're forcing uses of this build
# to define config and locale root; for stage-1 use.
# In stage-2, use the regular xkbcommon lib.
"-Dxkb-config-root=/NEEDS/OVERRIDE/etc/X11/xkb"
"-Dx-locale-root=/NEEDS/OVERRIDE/share/X11/locale"
];
outputs = [ "out" "dev" ];
# Ensures we don't get any stray dependencies.
allowedReferences = [
"out"
"dev"
stdenv.cc.libc_lib
];
})
) {};
in
stdenv.mkDerivation {
pname = "lvgui";
version = "2020-11-20";
src = fetchFromGitHub {
repo = "lvgui";
owner = "mobile-nixos";
rev = "c94c3916012f5615af027389e77e7a974cc3e634";
sha256 = "16dfdky5v72jqs9v22h1k73g74bnif6fg52vhxw2k8sh6mw1cmzp";
};
# Document `LVGL_ENV_SIMULATOR` in the built headers.
# This allows the mrbgem to know about it.
# (In reality this should be part of a ./configure step or something similar.)
postPatch = ''
sed -i"" '/^#define LV_CONF_H/a #define LVGL_ENV_SIMULATOR ${if withSimulator then "1" else "0"}' lv_conf.h
'';
nativeBuildInputs = [
pkg-config
];
buildInputs = [
libevdev
libxkbcommon
]
++ optionals withSimulator simulatorDeps
;
NIX_CFLAGS_COMPILE = [
"-DX_DISPLAY_MISSING"
];
makeFlags = [
"PREFIX=${placeholder "out"}"
]
++ optional withSimulator "LVGL_ENV_SIMULATOR=1"
++ optional (!withSimulator) "LVGL_ENV_SIMULATOR=0"
;
enableParallelBuilding = true;
}

View File

@ -0,0 +1,16 @@
MRuby::Gem::Specification.new("mruby-lvgui-native-fragment") do |spec|
spec.license = "MIT"
spec.authors = "Samuel Dionne-Riel"
spec.version = "0.0.1"
# Ensures `lvgui` is built into the mruby interpreter.
spec.cc.include_paths << `pkg-config --cflags lvgui`.chomp
spec.linker.flags_after_libraries << `pkg-config --libs lvgui`.chomp
# Also declare dependencies properly here.
spec.add_dependency('mruby-fiddle')
spec.rbfiles = [
# Left empty by design, look under boot/lib
]
end