Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mobile-nixos/mobile-nixos
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d5869523869e
Choose a base ref
...
head repository: mobile-nixos/mobile-nixos
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e6376850dc38
Choose a head ref

Commits on Dec 31, 2020

  1. mruby-lvgui: drop package

    samueldr committed Dec 31, 2020
    Copy the full SHA
    ac315d7 View commit details

Commits on Jan 2, 2021

  1. Copy the full SHA
    f3b51bf View commit details
  2. Copy the full SHA
    b33afce View commit details
  3. Copy the full SHA
    2b5d8ed View commit details
  4. Copy the full SHA
    b88d256 View commit details
  5. Copy the full SHA
    ffc4a12 View commit details
  6. Copy the full SHA
    447d8d5 View commit details
  7. Copy the full SHA
    d18d361 View commit details
  8. Copy the full SHA
    7449879 View commit details
  9. Copy the full SHA
    4b0a275 View commit details
  10. Copy the full SHA
    abdaa2a View commit details
  11. Copy the full SHA
    6ca59e8 View commit details
  12. Copy the full SHA
    bec41be View commit details
  13. Copy the full SHA
    45a4835 View commit details
  14. Copy the full SHA
    b50024f View commit details
  15. Copy the full SHA
    4bfdd25 View commit details
  16. Copy the full SHA
    e6e4e22 View commit details
  17. Copy the full SHA
    3cde402 View commit details
  18. Copy the full SHA
    af9912e View commit details
  19. Copy the full SHA
    d0ad7a8 View commit details
  20. Copy the full SHA
    a12e431 View commit details
  21. Copy the full SHA
    50a2a08 View commit details
  22. Copy the full SHA
    562ddc1 View commit details
  23. Copy the full SHA
    966f000 View commit details
  24. Copy the full SHA
    7cd9acd View commit details
  25. Copy the full SHA
    dc809d4 View commit details
  26. boot/splash: Fixes for extracted libs

    And additionally review how it's built.
    samueldr committed Jan 2, 2021
    Copy the full SHA
    2fefc0a View commit details
  27. Copy the full SHA
    6ebe6dd View commit details
  28. Merge pull request #270 from samueldr-wip/feature/mruby-lvgui-merge

    Import mruby-lvgui and minor mruby refactor
    samueldr authored Jan 2, 2021
    Copy the full SHA
    e637685 View commit details
Showing with 2,095 additions and 81 deletions.
  1. +15 −2 boot/error/default.nix
  2. +1 −1 boot/error/main.rb
  3. +14 −3 boot/init/default.nix
  4. 0 boot/{init/lib/monkey_patches → lib/00-monkey_patches}/dir.rb
  5. 0 boot/{init/lib/monkey_patches → lib/00-monkey_patches}/file.rb
  6. 0 boot/{init/lib/monkey_patches → lib/00-monkey_patches}/fileutils.rb
  7. 0 boot/{init/lib/monkey_patches → lib/00-monkey_patches}/pp.rb
  8. 0 boot/lib/{evdev.rb → evdev/__init.rb}
  9. +18 −0 boot/lib/hal/reboot_modes.rb
  10. 0 boot/{init/lib → lib/init}/configuration.rb
  11. +50 −0 boot/lib/lvgui/args.rb
  12. +100 −0 boot/lib/lvgui/fiddlier.rb
  13. +2 −0 boot/lib/lvgui/lvgl/__init.rb
  14. +437 −0 boot/lib/lvgui/lvgl/ffi.rb
  15. +97 −0 boot/lib/lvgui/lvgl/generated_ffi.rb
  16. +109 −0 boot/lib/lvgui/lvgl/hacks.rb
  17. +11 −0 boot/lib/lvgui/lvgl/introspection.rb
  18. +579 −0 boot/lib/lvgui/lvgl/lvgl.rb
  19. +2 −0 boot/lib/lvgui/lvgui/__init.rb
  20. +73 −0 boot/lib/lvgui/lvgui/base_window.rb
  21. +301 −0 boot/lib/lvgui/lvgui/gui.rb
  22. +92 −0 boot/lib/lvgui/lvgui/hal.rb
  23. +1 −1 boot/{splash/lib → lib/lvgui/lvgui}/keyboard.rb
  24. +1 −1 boot/{splash/lib → lib/lvgui/lvgui}/progress_bar.rb
  25. +5 −5 boot/{splash/lib → lib/lvgui/lvgui}/text_area.rb
  26. +53 −0 boot/lib/lvgui/lvgui/windows.rb
  27. +24 −0 boot/lib/lvgui/vtconsole.rb
  28. +16 −1 boot/recovery-menu/default.nix
  29. +0 −7 boot/recovery-menu/lib/configuration.rb
  30. +0 −16 boot/recovery-menu/lib/reboot_modes.rb
  31. +1 −1 boot/recovery-menu/main.rb
  32. +1 −5 boot/recovery-menu/simulator.nix
  33. +11 −2 boot/script-loader/default.nix
  34. +5 −0 boot/script-loader/mruby-lvgui-native-fragment/README.adoc
  35. +3 −6 ...y/mruby-builder/mrbgems/mruby-lvgui → boot/script-loader/mruby-lvgui-native-fragment}/default.nix
  36. 0 ...lay/mruby-builder/mrbgems/mruby-lvgui → boot/script-loader/mruby-lvgui-native-fragment}/lvgui.nix
  37. +16 −0 boot/script-loader/mruby-lvgui-native-fragment/mrbgem.rake
  38. +15 −3 boot/splash/default.nix
  39. +2 −10 boot/splash/simulator.nix
  40. +3 −3 boot/splash/{lib → }/ui.rb
  41. +16 −1 examples/hello/app/default.nix
  42. +1 −5 examples/hello/app/simulator.nix
  43. +1 −1 examples/testing/crash-before-switch-root/default.nix
  44. +1 −1 examples/testing/qemu-cryptsetup/default.nix
  45. +17 −0 overlay/mruby-builder/mruby/default.nix
  46. +1 −6 overlay/mruby-builder/overlay.nix
17 changes: 15 additions & 2 deletions boot/error/default.nix
Original file line number Diff line number Diff line change
@@ -3,20 +3,33 @@
, mruby
}:

let
inherit (lib) concatMapStringsSep;

# Select libs we need from the libs folder.
libs = concatMapStringsSep " " (name: "${../lib}/${name}") [
"hal/reboot_modes.rb"
"lvgui/args.rb"
"lvgui/fiddlier.rb"
"lvgui/lvgl/*.rb"
"lvgui/lvgui/*.rb"
"lvgui/vtconsole.rb"
];
in

# mkDerivation will append something like -aarch64-unknown-linux-gnu to the
# derivation name with cross, which will break the mruby code loading.
# Since we don't need anything from mkDerivation, really, let's use runCommand.
runCommand "boot-error.mrb" {
src = lib.cleanSource ./.;
lib = lib.cleanSource ../recovery-menu/lib;

nativeBuildInputs = [
mruby
];
} ''
mrbc \
-o $out \
$(find $lib -type f -name '*.rb' | sort) \
${libs} \
$(find $src/lib -type f -name '*.rb' | sort) \
$src/main.rb
''
2 changes: 1 addition & 1 deletion boot/error/main.rb
Original file line number Diff line number Diff line change
@@ -315,7 +315,7 @@ def cleanup_and_exit()
$ui.set_actions([
["Power off", ->() { run("poweroff") }],
["Kernel panic", ->() { $exit = true }],
*(RebootModes.options),
*(Hal::RebootModes.options),
])
end
]])
17 changes: 14 additions & 3 deletions boot/init/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{ stdenv
, fetchurl
, mrbgems
, mruby

# Additional tasks
@@ -14,6 +13,17 @@ let
url = "https://raw.githubusercontent.com/ruby/ruby/${ruby_rev}/lib/shellwords.rb";
sha256 = "197g7qvrrijmajixa2h9c4jw26l36y8ig6qjb5d43qg4qykhqfcx";
};

inherit (stdenv.lib) concatMapStringsSep;

# Select libs we need from the libs folder.
libs = concatMapStringsSep " " (name: "${../lib}/${name}") [
"00-monkey_patches/*.rb"
"hal/recovery.rb"
"evdev/*.rb"
"init/configuration.rb"
"linux/*.rb"
];
in
stdenv.mkDerivation {
pname = "mobile-nixos-init";
@@ -39,8 +49,9 @@ stdenv.mkDerivation {
}
# This is the "script" that will be loaded.
mrbc -o init.mrb \
$(find ${../lib} -type f | sort) \
mrbc \
-o init.mrb \
${libs} \
$(find lib -type f | sort) \
$(get_tasks) \
init.rb
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions boot/lib/hal/reboot_modes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Hal
module RebootModes
Android = {
"recovery" => ["Reboot to recovery", ->() { run("reboot recovery") }],
"bootloader" => ["Reboot to bootloader", ->() { run("reboot bootloader") }],
}

def self.options()
[
["Reboot to system", ->() { run("reboot") }],
] +
Configuration["HAL"]["boot"]["rebootModes"].map do |identifier|
const, key = identifier.split(".", 2)
const_get(const)[key]
end
end
end
end
File renamed without changes.
50 changes: 50 additions & 0 deletions boot/lib/lvgui/args.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Extremely minimal and naïve arguments parsing.
module Args
@@parsed = nil

def self.get(key, default = nil)
parse[:values][key] or default
end

def self.unused()
parsed[:unused]
end

def self.parse()
return @@parsed if @@parsed

argv = ARGV.dup
unused = []

# Default values.
# `nil` means it expects a parameter.
# `false` means it's a boolean toggle without parameter.
values = {}
while argv.length > 0
arg = argv.shift
if arg.match(/^--help$/)
# Assumes the programmer will add it
begin
print_help
rescue
$stderr.puts "Sorry, no help defined."
end
exit 0
elsif arg.match(/^--/)
key = arg.sub(/^--/, "").gsub("-", "_").to_sym
if argv.length > 0 && !argv[0].match(/^--/)
values[key] = argv.shift
else
values[key] = true
end
else
unused << arg
end
end

@@parsed = {
unused: unused,
values: values,
}
end
end
100 changes: 100 additions & 0 deletions boot/lib/lvgui/fiddlier.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# This module augments Fiddle with useful helpers.

module LVGL
end
module LVGL::Fiddlier
# Given a +type+, returns the value of the global +name+.
def get_global!(type, name)
addr = handler.sym(name)
raise(Fiddle::DLError, "cannot find symbol #{name}") unless addr
s = struct(["#{type} value"])
s.new(addr).value
end

# Given a +type+, sets the global +name+ to +new_value+.
def set_global!(type, name, new_value)
addr = handler.sym(name)
raise(Fiddle::DLError, "cannot find symbol #{name}") unless addr
s = struct(["#{type} value"])
tmp = s.new(addr)
tmp.value = new_value
tmp.value
end

def get_global_struct!(struct, name)
addr = handler.sym(name)
raise(Fiddle::DLError, "cannot find symbol for struct #{name}") unless addr
struct.new(addr)
end

# Using +set_global!+ and +get_global!+, creates accessors for a global
# variable.
def global!(type, name)
method_name = name.to_sym
define_method(method_name) do
get_global!(type, name)
end
module_function method_name

method_name = "#{name}=".to_sym
define_method(method_name) do |value|
set_global!(type, name, value)
end
module_function method_name
end

# TODO: parse `typedef enum {...} name;`
def enum!(name, values, type: "int")
typedef name.to_s, type.to_s
mod = self.const_set(name.to_sym, Module.new)
current_value = 0
values.each do |data|
if data.is_a? Hash
name = data.keys.first.to_sym
current_value = data.values.first
else
name = data.to_sym
end
mod.const_set(name, current_value)

current_value += 1
end
end

# Flattens the given nested struct
def flatten_struct!(fields, prefix: nil)
fields.map do |field|
type = field.first
name = [prefix, field.last].compact.join("_")

if type.is_a? Array then
flatten_struct!(type, prefix: name)
else
[[type.to_sym, name.to_sym]]
end
end.flatten(1)
end

# Parses nested structs into a flattened Fiddle struct.
# XXX: broken because of struct alignment padding / packing
# -> http://www.catb.org/esr/structure-packing/#_padding
def struct!(fields)
flattened = flatten_struct!(fields).map do |field|
type = field.first
name = field.last
"#{type} #{name}"
end
struct(flattened)
end

# Define the given +sym+ as a function.
# It will auto-wrap the method using a closure.
def bound_method!(sym, sig)
sym = sym.to_sym
module_function sym
ctx = self
@func_map[sym.to_s] = bind(sig) do |*args|
ctx.send(sym, *args)
end
end
end
2 changes: 2 additions & 0 deletions boot/lib/lvgui/lvgl/__init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module LVGL
end
Loading