From 484eee86248e7eab71fe78dab2c1419a42e61271 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 25 Jun 2018 23:25:22 +0200 Subject: [PATCH] Tidy --- python/servo/bootstrap_commands.py | 1 - python/servo/util.py | 3 +++ servo-tidy.toml | 1 + support/android/egl-configs/Cargo.toml | 1 + support/android/egl-configs/build.rs | 4 ++++ support/android/egl-configs/ld.sh | 18 +++++++++++++---- support/android/egl-configs/run.sh | 26 ++++++++++++++++--------- support/android/egl-configs/src/ffi.rs | 4 ++++ support/android/egl-configs/src/main.rs | 8 ++++++-- 9 files changed, 50 insertions(+), 16 deletions(-) diff --git a/python/servo/bootstrap_commands.py b/python/servo/bootstrap_commands.py index eadebb837ce..dcc278797a2 100644 --- a/python/servo/bootstrap_commands.py +++ b/python/servo/bootstrap_commands.py @@ -72,7 +72,6 @@ class MachCommands(CommandBase): system_image = "google_apis;armeabi-v7a" avd_name = "servo-armv7" - toolchains = path.join(self.context.topdir, "android-toolchains") if not path.isdir(toolchains): os.makedirs(toolchains) diff --git a/python/servo/util.py b/python/servo/util.py index 7c4cc5aee1b..d71cffe27da 100644 --- a/python/servo/util.py +++ b/python/servo/util.py @@ -153,6 +153,7 @@ def download_file(desc, src, dst): download(desc, src, fd) os.rename(tmp_path, dst) + # https://stackoverflow.com/questions/39296101/python-zipfile-removes-execute-permissions-from-binaries # In particular, we want the executable bit for executable files. class ZipFileWithUnixPermissions(zipfile.ZipFile): @@ -169,6 +170,7 @@ class ZipFileWithUnixPermissions(zipfile.ZipFile): os.chmod(extracted, mode) return extracted + def extract(src, dst, movedir=None, remove=True): assert src.endswith(".zip") ZipFileWithUnixPermissions(src).extractall(dst) @@ -183,6 +185,7 @@ def extract(src, dst, movedir=None, remove=True): if remove: os.remove(src) + def check_hash(filename, expected, algorithm): hasher = hashlib.new(algorithm) with open(filename, "rb") as f: diff --git a/servo-tidy.toml b/servo-tidy.toml index ce69b5a24cc..286a303d303 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -58,6 +58,7 @@ files = [ "./resources/hsts_preload.json", "./tests/wpt/metadata/MANIFEST.json", "./support/android/openssl.sh", + "./support/android/egl-configs/Cargo.lock", # Upstream code from Khronos/WebGL uses tabs for indentation "./tests/wpt/mozilla/tests/webgl", # Ignore those files since the issues reported are on purpose diff --git a/support/android/egl-configs/Cargo.toml b/support/android/egl-configs/Cargo.toml index 9ce73a900f5..ae5a6f5d342 100644 --- a/support/android/egl-configs/Cargo.toml +++ b/support/android/egl-configs/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "egl-configs" version = "0.1.0" +license = "MPL-2.0" [build-dependencies] gl_generator = "0.9" diff --git a/support/android/egl-configs/build.rs b/support/android/egl-configs/build.rs index 8c0e589607c..62558fbafd4 100644 --- a/support/android/egl-configs/build.rs +++ b/support/android/egl-configs/build.rs @@ -1,3 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + extern crate gl_generator; use gl_generator::{Registry, Api, Profile, Fallbacks}; diff --git a/support/android/egl-configs/ld.sh b/support/android/egl-configs/ld.sh index 98d61a1dc88..f49c9940c4c 100755 --- a/support/android/egl-configs/ld.sh +++ b/support/android/egl-configs/ld.sh @@ -1,6 +1,16 @@ -#!/bin/sh -NDK=../../../android-toolchains/android-ndk-r12b-linux-x86_64/android-ndk-r12b +#!/usr/bin/env bash -"${NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc" \ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +set -o errexit +set -o nounset +set -o pipefail + +NDK=../../../android-toolchains/android-ndk-r12b-linux-x86_64/android-ndk-r12b +BIN="${NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/" + +"${BIN}/arm-linux-androideabi-gcc" \ --sysroot "${NDK}/platforms/android-18/arch-arm" \ - "$@" + "${@}" diff --git a/support/android/egl-configs/run.sh b/support/android/egl-configs/run.sh index 3842b4bb372..dfe4a1dbd4e 100755 --- a/support/android/egl-configs/run.sh +++ b/support/android/egl-configs/run.sh @@ -1,22 +1,30 @@ -#!/bin/sh +#!/usr/bin/env bash + +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +set -o errexit +set -o nounset +set -o pipefail # Any -#target="" +target="" # Specific device #target="-s something" # Emulator -target="-e" +#target="-e" # USB #target="-d" -path="$1" -base="$(basename $1)" -remote_path="/data/local/tmp/$base" +path="${1}" +base="$(basename ${1})" +remote_path="/data/local/tmp/${base}" shift -adb $target "wait-for-device" -adb $target push "$path" "$remote_path" >&2 -adb $target shell "$remote_path" "$@" +adb ${target} "wait-for-device" +adb ${target} push "${path}" "${remote_path}" >&2 +adb ${target} shell "${remote_path}" "${@}" diff --git a/support/android/egl-configs/src/ffi.rs b/support/android/egl-configs/src/ffi.rs index ce106bb0a94..ee2b43aebd4 100644 --- a/support/android/egl-configs/src/ffi.rs +++ b/support/android/egl-configs/src/ffi.rs @@ -1,3 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + #![allow(non_camel_case_types)] use std::os::raw::*; diff --git a/support/android/egl-configs/src/main.rs b/support/android/egl-configs/src/main.rs index 5fada2458ee..eb7a4388263 100644 --- a/support/android/egl-configs/src/main.rs +++ b/support/android/egl-configs/src/main.rs @@ -1,3 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + use ffi::*; use ffi::types::*; use std::ptr::null_mut; @@ -11,8 +15,8 @@ fn main() { } macro_rules! check { - ($name: ident ( $($arg: expr),* )) => { - check($name( $($arg),* ), stringify!($name)) + ($name: ident($($arg: expr),*)) => { + check($name($($arg),*), stringify!($name)) } }