Skip to content

Instantly share code, notes, and snippets.

@tfwio
Last active August 29, 2015 14:10
Show Gist options
  • Save tfwio/b6ebf70bf7d268cddaeb to your computer and use it in GitHub Desktop.
Save tfwio/b6ebf70bf7d268cddaeb to your computer and use it in GitHub Desktop.
an update to https://gist.github.com/tfwio/83b2b499d5827f0d83bc since woff2 compress/decompress migrated to github.com/google/woff2
enc/block_splitter.h | 4 +++-
enc/write_bits.h | 6 +++++-
shared.mk | 4 ++--
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/enc/block_splitter.h b/enc/block_splitter.h
index 6e4682e..0b2c7d9 100644
--- a/enc/block_splitter.h
+++ b/enc/block_splitter.h
@@ -22,7 +22,9 @@
#include <string.h>
#include <vector>
#include <utility>
-
+#ifndef rand_r // mingw-w64-win32 (threading model)
+# include <pthread.h>
+#endif
#include "./command.h"
namespace brotli {
diff --git a/enc/write_bits.h b/enc/write_bits.h
index c3a72ba..b78b573 100644
--- a/enc/write_bits.h
+++ b/enc/write_bits.h
@@ -20,12 +20,16 @@
#include <assert.h>
#if defined(OS_MACOSX)
#include <machine/endian.h>
-#else
+#elseif USE_ENDIAN_H
#include <endian.h>
#endif
+#ifndef rand_r // mingw-w64-win32 (threading model)
+# include <pthread.h>
+#endif
#include <stdint.h>
#include <stdio.h>
+
#include "./port.h"
namespace brotli {
diff --git a/shared.mk b/shared.mk
index ab44cec..56d4846 100644
--- a/shared.mk
+++ b/shared.mk
@@ -1,10 +1,10 @@
OS := $(shell uname)
-GFLAGS=-no-canonical-prefixes -fno-omit-frame-pointer -m64
+GFLAGS=-static -no-canonical-prefixes -fno-omit-frame-pointer -D_POSIX_THREAD_SAFE_FUNCTIONS
CPP = g++
LFLAGS =
-CPPFLAGS = -c -std=c++0x $(GFLAGS)
+CPPFLAGS =-c -std=c++0x $(GFLAGS)
ifeq ($(OS), Darwin)
CPPFLAGS += -DOS_MACOSX
#!/bin/sh
#======================================================================
# use at your own risk.
# this script is released to the public domain without restriction.
# the Google woff2 project constitutes its own copyright
# and licensing information.
#======================================================================
WOFF2_GIT=https://github.com/google/woff2.git
WOFF2_SHA=2b35420fa91d7999423076a516eef9b1572be5af
GIST_TFW=https://gist.githubusercontent.com/tfwio
DIFF_FN1=woff2-2b35420fa-w32.patch
DIFF_FN2=brotli-94000f649-w32.patch
GIST_UR1=${GIST_TFW}/b6ebf70bf7d268cddaeb/raw/0d1e943f1233475e33d3c4a3850f3a5cb3411199/${DIFF_FN1}
GIST_UR2=${GIST_TFW}/b6ebf70bf7d268cddaeb/raw/c0d1fe223bb441f6b8259f99db6b6c9fd6563f19/${DIFF_FN2}
WORK_PATH=$PWD
WOFF2_NAM=woff2-${WOFF2_SHA::9}
WOFF2_DIR=${WORK_PATH}/${WOFF2_NAM}
CAT<<EOF
===================================requirements============
msys or msys2 + mingw-w64 (posix-threads) + git + curl
=========================================================t=
build script for mingw-w64 posix threading model
DATE: Nov 29 2014 -- script 0.3.1
REPO: https://github.com/google/woff2.git
SHA1: 2b35420fa91d7999423076a516eef9b1572be5af
==Brotli Compressed Data Format==WOFF2=====================
EOF
function do_build ()
{
cd ${WOFF2_DIR}
echo "- compiling (make all clean) --- please wait"
make clean all
echo - done
echo
cd ${WORK_PATH}
if [[ -f ${WOFF2_DIR}/woff2_compress.exe ]]
then
echo - success
find ${WOFF2_DIR}/*.exe
else
echo - compilation error
fi
echo - done
}
function do_ask_stuff ()
{
echo "- ${WOFF2_NAM} directory exists?"
while true
do
echo ------------------------------------
echo " 0 ) EXIT"
echo " 1 ) BUILD again"
echo " 2 ) DELETE './${WOFF2_NAM}' directory and rerun this script."
echo " 3 ) COPY app files here."
echo " 4 ) COPY app files here and REMOVE './${WOFF2_NAM}' directory."
echo " 5 ) REMOVE './${WOFF2_NAM}' directory and quit."
echo ------------------------------------
echo please select an option
read -p "" RESULT
echo
case $RESULT in
0 ) echo - exiting ; exit ;;
1 ) do_build ; exit ;;
2 ) rm -dfr ${WOFF2_DIR} ; echo - continuing ; get_and_patch ; sleep 1 ; break ;;
3 ) cp ${WOFF2_DIR}/*.exe . ; exit 0 ;;
4 ) cp ${WOFF2_DIR}/*.exe . ; rm -dfr ${WOFF2_DIR} ; echo - done ; exit 0 ;;
5 ) rm -dfr ${WOFF2_DIR} ; echo - done ; exit ;;
* ) ;;
esac
done
}
function get_and_patch ()
{
# git
echo - git clone
git clone ${WOFF2_GIT} ${WOFF2_NAM} &> /dev/null
cd ${WOFF2_DIR}
# get patches
echo - downloading patches
curl -L ${GIST_UR1} -o${DIFF_FN1} &> /dev/null
curl -L ${GIST_UR2} -o${DIFF_FN2} &> /dev/null
# git (continued)
echo - git checkout ${PKG_SHA::9}...
git checkout ${PKG_SHA}
echo - apply patch \#1/2
git apply ${WOFF2_DIR}/${DIFF_FN1}
echo "- initializing submodule (./brotli)"
git submodule init &> /dev/null
git submodule update &> /dev/null
# patch submodule
cd ${WOFF2_DIR}/brotli
echo - "apply patch #2/2 (submodule)"
git apply ${WOFF2_DIR}/${DIFF_FN2} &> /dev/null
# build
do_build
}
if [[ -d ${WOFF2_DIR} ]]; then do_ask_stuff; else get_and_patch; fi
# 201411290800CST - 0.3.1 added mingw-w64 win32-threading support (#include <pthread.h>)
# 201411281200CST - 0.3.0 rewritten for github acct --- and actually called `make all ; make clean` before attempting to copy binaries!
# 20141127<>????? - #.#.# added msys2/rand_r support (-D_POSIX_THREAD_SAFE_FUNCTIONS)
Makefile | 4 ++--
brotli | 0
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index fcb9525..f22889e 100644
--- a/Makefile
+++ b/Makefile
@@ -3,8 +3,8 @@ OS := $(shell uname)
IDIRS=-I./brotli/dec/ -I./brotli/enc/ -I./src
CXX = g++
-LFLAGS =
-GFLAGS=-no-canonical-prefixes -fno-omit-frame-pointer -m64
+LFLAGS =-s -static
+GFLAGS=-Wl,-s -static -no-canonical-prefixes -fno-omit-frame-pointer
CXXFLAGS = -c $(IDIRS) -std=c++0x $(GFLAGS)
ifeq ($(OS), Darwin)
diff --git a/brotli b/brotli
--- a/brotli
+++ b/brotli
@@ -1 +1 @@
-Subproject commit 94000f6490f42ba22b2464d5a045a03b022937bf
+Subproject commit 94000f6490f42ba22b2464d5a045a03b022937bf-dirty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment