Skip to content

Instantly share code, notes, and snippets.

View makotokato's full-sized avatar

Makoto Kato makotokato

View GitHub Profile
@makotokato
makotokato / GeckoViewBuildOnAppleSilicon.md
Last active February 22, 2021 19:57
GeckoView Build On Apple Silicon

TL;DR

  • Actually, we don't support GeckoView build on Apple Sillicon simply yet. Although Rust has native binaries, we have to use some x86_64 tools for clang, OpenJDK and Python 2.7.
  • You can use https://github.com/google/android-emulator-m1-preview on macOS. But ./mach install doesn't detect this emulator now.
  • GV's unit tests doesn't work yet.

Step

  1. Set up development environment via https://bit.ly/36bUmEx
  2. Install OpenJDK (macOS x86_64) since it has no aarch64 packages.
  3. Add your rust target like aarch64-linux-android via rustup target add aarch64-linux-android
  4. Comment out https://searchfox.org/mozilla-central/rev/c8ce16e4299a3afd560320d8d094556f2b5504cd/python/mozboot/mozboot/osx.py#197 like "# sys.exit(1)"
@makotokato
makotokato / gtk3-input.c
Created October 10, 2020 04:35
GTK3 keyboard sample
// build:
// gcc gtk3-entry-keyboard-event.c `pkg-config --cflags gtk+-3.0` `pkg-config
// --libs gtk+-3.0`
#include <gtk/gtk.h>
static gboolean print_keypress(GtkWidget *widget, GdkEventKey *event,
gpointer user_data) {
printf("keypress: %#06x %#06x\n", event->keyval, event->hardware_keycode);
return FALSE;
@makotokato
makotokato / GeckoViewOnWindows.md
Last active May 10, 2023 01:55
How to build GeckoView on Windows workstation

How to build GeckoView on Windows workstation

Actually, we can build GeckoView on WSL and VMs. but since Android Studio runs under Windows, not WSL, if using WSL, you cannot use Android Studio to debug GeckoView. We have limited support to build GV on the mozilla-build environment.

Using WSL (Bash for Windows, Windows Subsystem for Linux)

Same as Linux. But,

  • You cannot use Android Studio to debug GV
  • WSL doesn't support USB. So ./mach install or ./mach run doesn't work. But this has workaround (see using ADB).
  • WSL2 (comming in Windows 10 20H1)'s filesystem is fast, but if using NTFS filesystem's directory, it will be too slow (microsoft/WSL#4197).
  • WSL2 may have limited USB support, but I don't know about adb (microsoft/WSL#2195)
@makotokato
makotokato / setup-nss.sh
Created June 11, 2019 04:54
Setup NSS build environment on Amazon AMI
sudo yum groupinstall "Development Tools"
sudo yum install ninja-build
wget https://www.mercurial-scm.org/release/mercurial-5.0.1.tar.gz
tar xf mercurial-5.0.1.tar.gz
cd mercurial-5.0.1.tar.gz
make all
sudo make install
cd ..
/usr/local/bin/hg clone https://hg.mozilla.org/projects/nspr
./configure --host=x86_64-pc-mingw32 --build=x86_64-pc-mingw32 --disable-shared --enable-static CC="$(pwd)/msvcc.sh -m64" CPP="cl -nologo -EP" SHELL=sh.exe LD=link
@makotokato
makotokato / update_command.sh
Created January 19, 2018 03:34
Update ICU for Gecko
PYTHONPATH=../python/mozbuild ./update-icu.sh http://source.icu-project.org/repos/icu/trunk/icu4c
@makotokato
makotokato / vsync.c
Created March 6, 2016 12:17
get vsync using libdrm
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
#include "xf86drm.h"
// gcc -I/usr/include/libdrm/ -ldrm vsync.c
int64_t get_time(void)
{
<?DOCTYPE html>
<html>
<head>
<script>
var crypto = window.crypto;
var data = convertStringToArrayBufferView('ABCDEFGHIJKLMNOP');
var vector = crypto.getRandomValues(new Uint8Array(16));
function convertStringToArrayBufferView(str)
{
@makotokato
makotokato / colorglyph.cpp
Created March 10, 2014 03:16
Draw Color Glyph with DirectWrite 1.2
void DrawGlyphRun(ID2D1RenderTarget* target, IDWriteFactory factory, IDWriteFont* fontFace, ID2D1Brush* defaultBrush, DWRITE_GLYPH_RUN* glyphRun)
{
bool isColor = false;
IDWriteColorGlyphRunEnumerator* colorLayer;
IDWriteFont2* fontFace2;
fontFace->QueryInterface(reinterpret_cast<IDWriteFontFace2**>(&fontFace2));
if (fontFace2->IsColorFont()) {
IDWriteFactory2* factory2;
factory->QueryIntarface(reinterpret_cast<IDWriteFactory2**>(&factory2));
@makotokato
makotokato / emojiinfo.cpp
Created March 7, 2014 07:59
Access Color Emoji Font on Windows 8.1 with DirectWrite
#include <dwrite.h>
#include <dwrite_2.h>
#include <stdio.h>
#pragma comment(lib, "dwrite.lib")
int main()
{
HRESULT hr;
IDWriteFactory* dwriteFactory;