Awtk memo

Download node-v16.14.0-x64.msi from
https://nodejs.org/en/
or for win7 is
https://nodejs.org/download/release/v13.6.0
install it in Adminstrator cmd console.

Official repository:
https://github.com/zlgopen/awtk

1
2
3
4
5
6
python -m pip install pywin32
python -m pip install scons
 
cd awtk-master
scons
bin\demoui

Debug after attach demoui.exe,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
awtk-master\demos\demo_ui_app.c
 application_init
  WIDGET_FOR_EACH_CHILD_BEGIN(window_manager(), root, i)
   init_children_widget(root, (void*)win)
    widget_foreach(widget, init_widget, ctx)
     widget_on(widget, EVT_CLICK, on_menu_bar_open, win)
      on_menu_bar_open
       open_menu_bar
 
label_paint_text
 widget_draw_text_in_rect
 
window_create
 edit_create
 button_create
 label_create
  widget_set_text
window_close
dialog_create_simple
 dialog_set_title

Ui and style,

1
2
3
4
5
6
7
8
9
#doc/theme.md
bin/themegen input.xml output.bin -
 
#doc/ui_desc.md
bin/preview_ui demos/assets/raw/ui/main.xml
bin/xml_to_ui window1.xml window1.data
#include "res/ui/window1.data"
assets_manager_add((const asset_info_t*)ui_window1);
widget_t* win = window_open(name);

Message box,

Read more

Disable features in cmake command line

Identical to "./configure --help", when a project uses cmake, we get building instructions like below,

1
2
3
4
mkdir bld
cd bld
cmake ..
cmake . -L

wait a while we will see all the variables cmake defined in cache.

Or directly look into CMakeCache.txt.

If we want to modify a variable to off, or say, disable some functionality,

1
FEATURE_test_name:BOOL=ON

we run cmake once again like this,

1
cmake -DFEATURE_test_name:BOOL=OFF ..

refer to:
https://www.oschina.net/question/231677_45266

Build qt source in Fedora35

Extract qt-everywhere-src-6.2.2.zip to directory named qt,

sudo dnf install libxcb libxcb-devel xcb-util xcb-util-devel xcb-util-*-devel libX11-devel libXrender-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel libdrm-devel libXcursor-devel libXcomposite-devel

cd qt
mkdir bld
cd bld
cmake -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=`pwd`/installed -DCMAKE_BUILD_TYPE="Debug" ..
cmake --build . --parallel
cmake --install . --prefix=`pwd`/installed

Can't locate English.pm in @INC

sudo dnf install perl-English

This application failed to start because no Qt platform plugin could be init...

If "xcb" things missing, we should "dnf install libxcb..." like above, and an annoying step we can't image is after we install required packages, we must delete CMakeCache.txt first and then to invoke cmake, if not, some modules like xcb-sm are always displayed not to be built.

Feature accessibility_atspi_bridge is already defined to be "OFF" and should now be set to "ON" when importing features from Qt6::Gui.

We only need to not let the message interrupt building progress,

/mnt/SDC2/qt/bld/installed/lib/cmake/Qt6/QtFeature.cmake:1136

	message(STATUS "Feature ${feature} is already defined to be \"${QT_FEATURE_${feature}}\" and should now be set to \"${value}\" when importing features from ${target}.")

refer to:
https://download.qt.io/official_releases/qtcreator/6.0/6.0.1/qt-creator-opensource-linux-x86_64-6.0.1.run
https://wiki.qt.io/Building_Qt_5_from_Git#Linux.2FX11
https://forum.qt.io/topic/121386/built-qt6-from-sources-problem-with-xcb-plugin/15
https://forum.qt.io/topic/128887/build-qt6-from-source-xcb-issue/3
https://forum.qt.io/topic/92834/configure-errors-disabling-x11-accessibility-bridge-d-bus-or-at-spi-is-missing/7

Debug ue4 in Fedora35

After running Setup.sh and GenerateProjectFiles.sh, we found UE4.pro created. It's like a fresh breeze coming from the roof window, we are free now, no more need to fear the once unbearable torment in Visual Studio IDE.

Qt source is not necessary to ue4, qtcreator is only a visual debugger to ue4.

Build Steps:

1
make UE4Editor-Linux-Debug ShaderCompileWorker-Linux-Debug -j8

Clean Steps:

1
make UE4Editor-Linux-Debug ShaderCompileWorker-Linux-Debug ARGS=-clean -j8

refer to:
https://docs.unrealengine.com/4.27/en-US/SharingAndReleasing/Linux/BeginnerLinuxDeveloper/SettingUpQtCreator/

Build qemu in Fedora35

Build,

sudo dnf install ninja-build pixman-devel

cd qemu-6.2.0
mkdir bld
cd bld
../configure --enable-kvm --target-list=x86_64-softmmu --prefix=`pwd`/installed
make

Inspect through vnc,

dnf install vinagre

cd x86_64-softmmu
./qemu-system-x86_64 -m 3500 -smp 4 --enable-kvm -boot d -hda /mnt/DATA/vmimg/win7/win7.vmdk

Open vinagre, input "127.0.0.1:5900" in VNC host box, then connect, after a while we will see win7 running up.

Run in local gui,

sudo dnf install libepoxy-devel gtk3-devel

cd bld
../configure --enable-kvm --enable-gtk --enable-opengl --target-list=x86_64-softmmu --prefix=`pwd`/installed

cd x86_64-softmmu
./qemu-system-x86_64 -m 3500 -smp 4 --enable-kvm -display gtk,gl=on -vga vmware -usb -device usb-kbd -device usb-audio -boot c -netdev user,id=mynet0 -device e1000-82545em,netdev=mynet0 -boot d -hda /mnt/DATA/vmimg/win7/win7.vmdk

Frankly, qemu gui is not user friendly, and I have not found the way to setup 3d presentation in guest win7 yet.

refer to:
https://blog.csdn.net/haifeng_gu/article/details/108055083
https://blog.csdn.net/wanghuiyao/article/details/65627198

Build virtualbox in Ubuntu

Similar to in Fedora35, total difference is in from apt or from yum.

1
2
3
4
5
6
7
8
sudo apt-get install acpica-tools chrpath doxygen g++-multilib libasound2-dev libcap-dev \
        libcurl4-openssl-dev libdevmapper-dev libidl-dev libopus-dev libpam0g-dev \
        libpulse-dev libqt5opengl5-dev libqt5x11extras5-dev qttools5-dev libsdl1.2-dev libsdl-ttf2.0-dev \
        libssl-dev libvpx-dev libxcursor-dev libxinerama-dev libxml2-dev libxml2-utils \
        libxmu-dev libxrandr-dev make nasm python3-dev qttools5-dev-tools \
        unzip xsltproc glslang-dev glslang-tools \
        libstdc++5 libxslt1-dev linux-kernel-headers makeself \
        mesa-common-dev subversion yasm zlib1g-dev

refer to:
build virtualbox in fedora35

Fedora kernel: bad shim signature

One easy method is disabling Secure Boot option in machine EFI BIOS.

In other way, we can't sign vmlinuz using MOK, because MOK is only a gate keeper for kernel after vmlinuz booting up, and if we want EFI firmware to admit vmlinuz as descendant, we must require the machine manufacturer to sign the vmlinuz we built.

MOK: Machine Owner Key
UEFI: Unified Extensible Firmware Interface

refer to:
https://www.rodsbooks.com/efi-bootloaders/secureboot.html

Re-compress all Mame zip roms to 7z format

In advance,

trans_to_7z.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
 
PARENTDIR=$1
TMPDIR=`pwd`/tmp
 
PATH="/d/cext/Program Files/7-Zip:$PATH"
 
ISERR="no"
 
if [ "x$1" = x ] ; then
	echo "Please input dir to transform."
	exit
fi
 
if [ -e "$TMPDIR" ] ; then
	echo "Please rmdir [$TMPDIR] first."
	exit
fi
 
get_win_path()
{
	local win_path="$1"
	win_path="${win_path#/}"
	win_path="${win_path//\//\\}"
	win_path="${win_path/\\/\:\\}"
	echo $win_path
}
 
format_transform()
{
	local file_7z=$1
	local file_zip=$2
	local tmp_dir=$TMPDIR
	mkdir "$tmp_dir"
 
	7z x ${file_7z} -o"`get_win_path \"$tmp_dir\"`"
	(
		cd "$tmp_dir"
		ls
 
		7z a -mx9 "`get_win_path \"${file_zip}\"`" || ( echo "Creating 7z file failed." && ISERR="yes" )
	)
 
	rm -Rf "$tmp_dir"
}
 
cd "$PARENTDIR"
 
for fn in `ls *.zip`; do
 
	echo "$fn"
 
	format_transform $fn "`pwd`/${fn%.zip}.7z"
 
	if [ $ISERR = "yes" ]; then
		exit
	fi
done
 
echo "Transforming done."

How to use?

Copy trans_to_7z.sh to Mame root folder which contains roms sub-directory, right click at blank place of this Mame root window in Explorer, select "Git Bash Here" which prompts bash console, input below and return,

1
./trans_to_7z.sh roms

refer to:
https://www.cnblogs.com/wq242424/p/15564203.html

Switch between GPUs in Fedora35

Install Nvidia driver from rpmfusion,

yum install --nogpgcheck https://mirrors.tuna.tsinghua.edu.cn/rpmfusion/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.tuna.tsinghua.edu.cn/rpmfusion/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
dnf install akmod-nvidia

Before rebooting, must sign nividia driver using MOK.der, if not, we will receive at boot, "nvidia kernel module missing. falling back to nouveau".

Or install Nvidia driver from official site,

Clean up akmod-nvidia,

dnf remove akmod-nvidia
dnf remove xorg-x11-drv-nvidia

To blacklist the nouveau drivers,

dracut -v /boot/initramfs-`uname -r`.img `uname -r` --force

/etc/default/grub

GRUB_CMDLINE_LINUX="rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1"
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

After rebooting, download NVIDIA-Linux-x86_64-XXX.XX.XX.run from official site, install it using /root/signed-modules/MOK.* and reboot,
https://www.nvidia.com/download/index.aspx?lang=en-us

Check current GPU vendor,

1
glxinfo | egrep "OpenGL vendor|OpenGL renderer"

How to dynamically switch GPUs?

I found ue4 selecting /dev/nvidia0 by itself, we needn't care about if switch.

https://pellegrino.link/2015/11/29/signing-nvidia-proprietary-driver-on-fedora.html
https://www.cnblogs.com/Mingxx/p/3192483.html
https://docs.fedoraproject.org/en-US/quick-docs/how-to-set-nvidia-as-primary-gpu-on-optimus-based-laptops/

Build virtualbox in fedora35

Download VirtualBox source and extract it to /home/work/vb/VirtualBox-6.1.32.

Involve qt,

# read in ./configure
#	for q in $QT5DIR "$DEVDIR/linux.$TARGET_MACHINE"/qt/v5.*; do
# so download qt5.9.2 and install to /home/work/qt/Qt5.9.2
wget http://download.qt.io/archive/qt/5.9/5.9.2/qt-opensource-linux-x64-5.9.2.run
# make a link to qt5.9.2
cd /home/work/vb/VirtualBox-6.1.32/tools/linux.amd64
mkdir qt
ln -s /home/work/qt/Qt5.9.2/5.9.2/gcc_64 `pwd`/qt/v5.9.2

Build it,

# must add '--skip-broken', or else our fedora os will be mute curiously, suddenly
# in the subsequent experience.
yum install gcc-c++ subversion subversion-gnome kernel-devel which tar gzip bzip2 \
  doxygen mscgen wine-core \
  glibc-devel libcap-devel libcurl-devel libIDL-devel \
  libstdc++-static libxslt-devel libvpx-devel libXmu-devel \
  pam-devel pulseaudio-libs-devel python-devel qt-devel rpm-build SDL_ttf-devel \
  SDL-static device-mapper-devel glibc-static zlib-static \
  glibc-devel.i686 libstdc++.i686 pulseaudio \
  texlive texlive-latex texlive-latex-bin texlive-ec \
  texlive-collection-fontsrecommended texlive-pdftex-def texlive-fancybox texlive-tabulary \
  libpng-devel openssl-devel acpica-tools opus opus-devel --skip-broken

# in addition to offical prerequisites
yum install python3-devel libXcursor-devel libXinerama-devel libXrandr-devel alsa-lib-devel makeself yasm

cd /home/work/vb/VirtualBox-6.1.32

# modify ./configure
#SUPPYTHONLIBS="python3.10 python2.7 ..."

# RTAssertShouldPanic error: this statement may fall through [-Werror=implicit-fallthrough=]
# modify ./Config.kmk
# uncomment below line
#VBOX_WITH_TESTCASES = 1

./configure --disable-hardening --disable-docs --disable-java
source ./env.sh
kmk BUILD_TYPE=debug -j 1

how to run,

cd out/linux.x86/release/bin/src
make
sudo make install

#sign generated vbox kernel modules

cd ..
export LD_LIBRARY_PATH=/home/work/qt/Qt5.9.2/5.9.2/gcc_64/lib:LD_LIBRARY_PATH
./VirtualBox

VERR_VM_DRIVER_NOT_ACCESSIBLE?

chmod ugo+rw /dev/vboxdrv

The VM session was aborted?

Maybe we forgot load vboxnetadp and vboxnetflt,

#modprobe vboxdrv
#modprobe vboxnetadp
#modprobe vboxnetflt

or the shared folder locates in U-disk but we have not mounted it.

Where to get guest additions iso?

http://download.virtualbox.org/virtualbox/6.1.32/VBoxGuestAdditions_6.1.32.iso

But why my Fedora os often drops dead?

What can make system dead must be that the modules we insert to kernel have problem.

The correct way to insert modules is that we should install official bundle first which will insert an configuation file in /etc/udev, modify /etc/udev/rules.d/60-vboxdrv.rules, give current user read and write permission and reboot system that will effect the rule. Then install the vbox*.ko we built.

refer to:
https://www.virtualbox.org/wiki/Downloads
https://download.virtualbox.org/virtualbox
How to sign module
https://www.virtualbox.org/wiki/Linux%20build%20instructions
https://blog.csdn.net/u013004700/article/details/81943881
https://www.linuxidc.com/Linux/2008-05/13132.htm