Skip to content

Commit f0d10df

Browse files
committed
Added recipes for p4a
1 parent 486efd6 commit f0d10df

File tree

149 files changed

+55859
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+55859
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/.DS_Store
1+
.DS_Store

android/libusb/__init__.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from pythonforandroid.recipe import NDKRecipe, IncludedFilesBehaviour
2+
from pythonforandroid.util import current_directory
3+
from pythonforandroid.logger import shprint
4+
from os.path import join
5+
import shutil
6+
import sh
7+
8+
9+
class LibusbRecipe(NDKRecipe, IncludedFilesBehaviour):
10+
version = '1.0'
11+
url = None
12+
site_packages_name = 'libusb'
13+
name = 'libusb'
14+
src_filename = './src'
15+
generated_libraries = ['libusb1.0.so']
16+
17+
def should_build(self, arch):
18+
return True
19+
20+
def get_recipe_env(self, arch):
21+
env = super().get_recipe_env(arch)
22+
23+
env['LOCAL_C_INCLUDES'] = ' $(LIBUSB_ROOT_ABS)'
24+
env['LOCAL_SHARED_LIBRARIES'] = ' libusb1.0'
25+
return env
26+
27+
def get_lib_dir(self, arch):
28+
return join(self.get_build_dir(arch.arch), 'android', 'obj', 'local', arch.arch)
29+
30+
def get_jni_dir(self, arch):
31+
return join(self.get_build_dir(arch.arch), 'android', 'jni')
32+
33+
def build_arch(self, arch, *extra_args):
34+
env = self.get_recipe_env(arch)
35+
with current_directory(self.get_build_dir(arch.arch)):
36+
shprint(
37+
sh.Command(join(self.ctx.ndk_dir, "ndk-build")),
38+
'NDK_PROJECT_PATH=' + self.get_build_dir(arch.arch) + '/android',
39+
'NDK='+self.ctx.ndk_dir,
40+
'APP_PLATFORM=android-' + str(self.ctx.ndk_api),
41+
'APP_ABI=' + arch.arch,
42+
*extra_args, _env=env
43+
)
44+
45+
shutil.copyfile(join(self.get_build_dir(arch.arch), 'android', 'libs', arch.arch, 'libusb1.0.so'), join(self.ctx.get_libs_dir(arch.arch), 'libusb1.0.so'))
46+
47+
recipe = LibusbRecipe()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This directory contains private internal scripts used by the libusb
2+
project maintainers.
3+
4+
These scripts are not intended for general usage and will not be
5+
exported when producing release archives.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
buildsys="${1}-${Platform}"
6+
7+
if [ "${buildsys}" == "MinGW-Win32" ]; then
8+
export PATH="/c/mingw-w64/i686-6.3.0-posix-dwarf-rt_v5-rev1/mingw32/bin:${PATH}"
9+
elif [ "${buildsys}" == "MinGW-x64" ]; then
10+
export PATH="/c/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin:${PATH}"
11+
fi
12+
13+
builddir="build-${buildsys}"
14+
installdir="${PWD}/libusb-${buildsys}"
15+
16+
cd libusb
17+
18+
echo "Bootstrapping ..."
19+
./bootstrap.sh
20+
echo ""
21+
22+
exec .private/ci-build.sh --build-dir "${builddir}" --install -- "--prefix=${installdir}"

android/libusb/src/.private/bm.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/sh
2+
# produce the MinGW binary files for snapshots
3+
# !!!THIS SCRIPT IS FOR INTERNAL DEVELOPER USE ONLY!!!
4+
5+
PWD=`pwd`
6+
cd ..
7+
date=`date +%Y.%m.%d`
8+
target=e:/dailies/$date
9+
mkdir -p $target/include/libusb-1.0
10+
cp -v libusb/libusb-1.0.def $target
11+
cp -v libusb/libusb.h $target/include/libusb-1.0
12+
13+
#
14+
# 32 bit binaries
15+
#
16+
target=e:/dailies/$date/MinGW32
17+
git clean -fdx
18+
# Not using debug (-g) in CFLAGS DRAMATICALLY reduces the size of the binaries
19+
export CFLAGS="-O2 -m32"
20+
export LDFLAGS="-m32"
21+
export RCFLAGS="--target=pe-i386"
22+
export DLLTOOLFLAGS="-m i386 -f --32"
23+
echo `pwd`
24+
(glibtoolize --version) < /dev/null > /dev/null 2>&1 && LIBTOOLIZE=glibtoolize || LIBTOOLIZE=libtoolize
25+
$LIBTOOLIZE --copy --force || exit 1
26+
aclocal || exit 1
27+
autoheader || exit 1
28+
autoconf || exit 1
29+
automake -a -c || exit 1
30+
./configure
31+
make -j2
32+
mkdir -p $target/static
33+
mkdir -p $target/dll
34+
cp -v libusb/.libs/libusb-1.0.a $target/static
35+
cp -v libusb/.libs/libusb-1.0.dll $target/dll
36+
cp -v libusb/.libs/libusb-1.0.dll.a $target/dll
37+
make clean -j2
38+
39+
#
40+
# 64 bit binaries
41+
#
42+
target=e:/dailies/$date/MinGW64
43+
export CFLAGS="-O2"
44+
export LDFLAGS=""
45+
export RCFLAGS=""
46+
export DLLTOOLFLAGS=""
47+
./configure
48+
make -j2
49+
mkdir -p $target/static
50+
mkdir -p $target/dll
51+
cp -v libusb/.libs/libusb-1.0.a $target/static
52+
cp -v libusb/.libs/libusb-1.0.dll $target/dll
53+
cp -v libusb/.libs/libusb-1.0.dll.a $target/dll
54+
cd $PWD
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
builddir=
6+
install=no
7+
8+
while [ $# -gt 0 ]; do
9+
case "$1" in
10+
--build-dir)
11+
if [ $# -lt 2 ]; then
12+
echo "ERROR: missing argument for --build-dir option" >&2
13+
exit 1
14+
fi
15+
builddir=$2
16+
shift 2
17+
;;
18+
--install)
19+
install=yes
20+
shift
21+
;;
22+
--)
23+
shift
24+
break;
25+
;;
26+
*)
27+
echo "ERROR: Unexpected argument: $1" >&2
28+
exit 1
29+
esac
30+
done
31+
32+
if [ -z "${builddir}" ]; then
33+
echo "ERROR: --build-dir option not specified" >&2
34+
exit 1
35+
fi
36+
37+
if [ -e "${builddir}" ]; then
38+
echo "ERROR: directory entry named '${builddir}' already exists" >&2
39+
exit 1
40+
fi
41+
42+
mkdir "${builddir}"
43+
cd "${builddir}"
44+
45+
cflags="-O2"
46+
47+
# enable extra warnings
48+
cflags+=" -Winline"
49+
cflags+=" -Wmissing-include-dirs"
50+
cflags+=" -Wnested-externs"
51+
cflags+=" -Wpointer-arith"
52+
cflags+=" -Wredundant-decls"
53+
cflags+=" -Wswitch-enum"
54+
55+
echo ""
56+
echo "Configuring ..."
57+
CFLAGS="${cflags}" ../configure --enable-examples-build --enable-tests-build "$@"
58+
59+
echo ""
60+
echo "Building ..."
61+
make -j4 -k
62+
63+
if [ "${install}" = "yes" ]; then
64+
echo ""
65+
echo "Installing ..."
66+
make install
67+
fi
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
# keep container around if $DEBUG is set
6+
[ -n "${DEBUG:-}" ] || OPTS="--rm"
7+
8+
if type podman >/dev/null 2>&1; then
9+
RUNC=podman
10+
else
11+
RUNC="sudo docker"
12+
fi
13+
14+
MOUNT_MODE=":ro"
15+
16+
$RUNC run --interactive ${RUNC_OPTIONS:-} ${OPTS:-} --volume `pwd`:/source${MOUNT_MODE:-} ${1:-docker.io/amd64/ubuntu:rolling} /bin/bash << EOF
17+
set -ex
18+
19+
# avoid meson exit code 125; https://github.com/containers/podman/issues/11540
20+
trap '[ \$? -eq 0 ] || exit 1' EXIT
21+
22+
# go-faster apt
23+
echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/90nolanguages
24+
25+
# upgrade
26+
export DEBIAN_FRONTEND=noninteractive
27+
apt-get update
28+
apt-get install -y eatmydata
29+
eatmydata apt-get -y --purge dist-upgrade
30+
31+
# install build and test dependencies
32+
eatmydata apt-get install -y make libtool libudev-dev pkg-config umockdev libumockdev-dev
33+
34+
# run build as user
35+
useradd build
36+
su -s /bin/bash - build << EOG
37+
set -ex
38+
39+
mkdir "/tmp/builddir"
40+
cd "/tmp/builddir"
41+
42+
CFLAGS="-O2"
43+
44+
# enable extra warnings
45+
CFLAGS+=" -Winline"
46+
CFLAGS+=" -Wmissing-include-dirs"
47+
CFLAGS+=" -Wnested-externs"
48+
CFLAGS+=" -Wpointer-arith"
49+
CFLAGS+=" -Wredundant-decls"
50+
CFLAGS+=" -Wswitch-enum"
51+
export CFLAGS
52+
53+
echo ""
54+
echo "Configuring ..."
55+
/source/configure --enable-examples-build --enable-tests-build
56+
57+
echo ""
58+
echo "Building ..."
59+
make -j4 -k
60+
61+
echo ""
62+
echo "Running umockdev tests ..."
63+
tests/umockdev
64+
65+
echo "Running stress tests ..."
66+
tests/stress
67+
tests/stress_mt
68+
EOG
69+
EOF
70+
71+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
#
3+
# Detect amended commits and warn user if .amend is missing
4+
#
5+
# To have git run this script on commit, create a "post-rewrite" text file in
6+
# .git/hooks/ with the following content:
7+
# #!/bin/sh
8+
# if [ -x .private/post-rewrite.sh ]; then
9+
# . .private/post-rewrite.sh
10+
# fi
11+
#
12+
# NOTE: These versioning hooks are intended to be used *INTERNALLY* by the
13+
# libusb development team and are NOT intended to solve versioning for any
14+
# derivative branch, such as one you would create for private development.
15+
#
16+
17+
if [ -n "$LIBUSB_SKIP_NANO" ]; then
18+
exit 0
19+
fi
20+
21+
case "$1" in
22+
amend)
23+
# Check if a .amend exists. If none, create one and warn user to re-commit.
24+
if [ -f .amend ]; then
25+
rm .amend
26+
else
27+
echo "Amend commit detected, but no .amend file - One has now been created."
28+
echo "Please re-commit as is (amend), so that the version number is correct."
29+
touch .amend
30+
fi ;;
31+
*) ;;
32+
esac
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/sh
2+
#
3+
# Sets the nano version according to the number of commits on this branch, as
4+
# well as the branch offset.
5+
#
6+
# To have git run this script on commit, first make sure you change
7+
# BRANCH_OFFSET to 60000 or higher, then create a "pre-commit" text file in
8+
# .git/hooks/ with the following content:
9+
# #!/bin/sh
10+
# if [ -x .private/pre-commit.sh ]; then
11+
# . .private/pre-commit.sh
12+
# fi
13+
#
14+
# NOTE: These versioning hooks are intended to be used *INTERNALLY* by the
15+
# libusb development team and are NOT intended to solve versioning for any
16+
# derivative branch, such as one you would create for private development.
17+
#
18+
# Should you wish to reuse these scripts for your own versioning, in your own
19+
# private branch, we kindly ask you to first set BRANCH_OFFSET to 60000, or
20+
# higher, as any offset below below 60000 is *RESERVED* for libusb official
21+
# usage.
22+
23+
################################################################################
24+
## YOU *MUST* SET THE FOLLOWING TO 60000 OR HIGHER IF YOU REUSE THIS SCRIPT ##
25+
################################################################################
26+
BRANCH_OFFSET=10000
27+
################################################################################
28+
29+
if [ -n "$LIBUSB_SKIP_NANO" ]; then
30+
exit 0
31+
fi
32+
33+
if [ "$BASH_VERSION" = '' ]; then
34+
TYPE_CMD="type git >/dev/null 2>&1"
35+
else
36+
TYPE_CMD="type -P git &>/dev/null"
37+
fi
38+
39+
eval $TYPE_CMD || { echo "git command not found. Aborting." >&2; exit 1; }
40+
41+
NANO=`git log --oneline | wc -l`
42+
NANO=`expr $NANO + $BRANCH_OFFSET`
43+
# Amended commits need to have the nano corrected. Current versions of git hooks
44+
# only allow detection of amending post commit, so we require a .amend file,
45+
# which will be created post commit with a user warning if none exists when an
46+
# amend is detected.
47+
if [ -f .amend ]; then
48+
NANO=`expr $NANO - 1`
49+
fi
50+
echo "setting nano to $NANO"
51+
echo "#define LIBUSB_NANO $NANO" > libusb/version_nano.h
52+
git add libusb/version_nano.h

0 commit comments

Comments
 (0)