Skip to content

Commit

Permalink
Updating for new machine
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Peacock committed Jun 26, 2018
1 parent 3105229 commit fe783bc
Show file tree
Hide file tree
Showing 8 changed files with 706 additions and 725 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Configurations - BASH

I use the cygwin64 shell with my prefered teminal being ConEmu.

## Files of interest

If you don't intent to run bash in any shape or form, you can still find helpful commands in
- git.bash: Make changes to your `.gitconfig` using the aliases here
# Configurations - BASH

I use the cygwin64 shell with my prefered teminal being ConEmu.

## Files of interest

If you don't intent to run bash in any shape or form, you can still find helpful commands in
- git.bash: Make changes to your `.gitconfig` using the aliases here
- android.bash: Commands can be replicated in Windows CMD to interact more easily with Android applications
708 changes: 354 additions & 354 deletions adb_commands.py

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions android.bash
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# ADB Commands shortcut
ac () { python $MY_HOME_WIN\\adb_commands.py $@ 2>&1; }
ac () { python $ANDROID_SCRIPTS_WIN\\adb_commands.py $@ 2>&1; }

# Gradle commands shortcut
gdl() { python $MY_HOME_WIN\\gradle.py $@ --root_dir="$CURR_CDP_WIN" 2>&1; }
gdl() { python $ANDROID_SCRIPTS_WIN\\gradle.py $@ 2>&1; }

# Install the app's APK using ADB
adb_in() { python $MY_HOME_WIN\\adb_commands.py install --root_dir="$CURR_CDP_WIN" --launch $@ 2>&1; }
adb_in() { python $ANDROID_SCRIPTS_WIN\\adb_commands.py install --launch $@ 2>&1; }

# Shortcut for launching an application
launch() { python $MY_HOME_WIN\\adb_commands.py launch $@ 2>&1; }
launch() { python $ANDROID_SCRIPTS_WIN\\adb_commands.py launch $@ 2>&1; }

# OneRomanApp sign in / credential shortcut
ora () { python $MY_HOME_WIN\\one_rome_sign_in.py $@ 2>&1; }
Expand All @@ -17,16 +17,19 @@ ora () { python $MY_HOME_WIN\\one_rome_sign_in.py $@ 2>&1; }
logcat () { python "$D_WIN\git_repos\pidcat\pidcat.py" $@; }

# Build gradle task
build() { python $MY_HOME_WIN\\gradle.py build --root_dir="$CURR_CDP_WIN" $@ 2>&1; }
build() { python $ANDROID_SCRIPTS_WIN\\gradle.py $@ 2>&1; }

# Removes all files under build dirs
clean() { python $MY_HOME_WIN\\gradle.py clean --root_dir="$CURR_CDP_WIN" $@ 2>&1; }
clean() { python $ANDROID_SCRIPTS_WIN\\clean_build.py $@ 2>&1; }

# Run the given TDD tests
tdd_run() { python $MY_HOME_WIN\\adb_commands.py tdd --tests $@ 2>&1; }
tdd_run() { python $ANDROID_SCRIPTS_WIN\\adb_commands.py tdd --tests $@ 2>&1; }

# Clean, build and install that task
build_in() { build $1 && adb_in $@; }

# one_rome_test. If there are any changes to the app itself, you need to generate the APK seperatley. This is because a new ORA APK is not generated with `build one_rome_test`
build_test() { build ora && build ora_test && ac install ora $@ && ac install ora_test $@ 2>&1; }
# Build OneRomanApp Tests
bot() { python $ANDROID_SCRIPTS_WIN\\build_ora_test.py $@ 2>&1; }

# Run OneRomanApp Tests
rot() { python $ANDROID_SCRIPTS_WIN\\run_ora_test.py $@ 2>&1; }
320 changes: 160 additions & 160 deletions gradle.py
Original file line number Diff line number Diff line change
@@ -1,160 +1,160 @@
import argparse
import subprocess
import os
import pprint

BUILD_KEYS = {
# Converged SDK
"conv": "connecteddevices-sdk",
# OneRomanApp
"ora": "oneRomanApp",
"ora_activities": "oneRomanApp-activities",
"ora_relay": "oneRomanApp-relay",
# WNS Ping Test Application
"wnsping": "wnspingtest",
# CDP Host
"cdphost": "cdphost",
# TDD Runner
"tdd": "tdd"
}

CLEAN_KEYS = {
# Converged SDK
"conv": "sdk/converged/projections/android/build",
# OneRomanApp
"ora": "samples/oneromanapp/android/app/projects/full/build",
"ora_activities": "samples/oneromanapp/android/app/projects/activities/build",
"ora_relay": "samples/oneromanapp/android/app/projects/relay/build",
# WNS Ping Test Application
"wnsping": "samples/wnspingtest/app/build",
# CDP Host
"cdphost": "samples/CDPHost/android/app/build",
# TDD Runner
"tdd": "test/tdd/runners/android/app/build"
}

FLAVOR = {
"DEBUG": "debug",
"RELEASE": "release"
}

ARCH = {
"ARM": "arm",
"X86": "x86"
}

GRADLEW_COMMAND = "{root}\gradlew :{task}:assemble{arch}{type}"
GRADLEW_TEST_COMMAND = "{root}\gradlew :sdk_test:connected{arch}{type}AndroidTest -PinstrumentedTestBuildType={type}"
GRADLEW_BUILD_ONE_ROMANAPP_TEST_COMMAND = "{root}\gradlew :oneRomanApp:assemble{arch}{type}AndroidTest"
GRADLEW_BUILD_AND_RUN_ONE_ROMANAPP_TEST_COMMAND = "{root}\gradlew :oneRomanApp:connected{arch}{type}AndroidTest"

# $adbTestFilter = "-e package com.microsoft.connecteddevices"
# if ((-not ([string]::IsNullOrEmpty($SdkTestFilter)))) {
# $adbTestFilter = "-e class $SdkTestFilter"
# }

# $adbOutput = RunAdb shell am instrument -w -r $adbTestFilter com.microsoft.connecteddevices.test/android.support.test.runner.AndroidJUnitRunner

CLEAN_COMMAND = "rm -rf {root}/{build_dir}"

class ArgParser:
# Utility functions
def __get_flavour(self, args):
if args.debug:
return FLAVOR["DEBUG"]
if args.release:
return FLAVOR["RELEASE"]
# Return default value of debug
return FLAVOR["DEBUG"]

def __get_arch(self, args):
if args.arm:
return ARCH["ARM"]
if args.x86:
return ARCH["X86"]
# Return default value of arm
return ARCH["ARM"]

# Argument setup functions
def __setup_build(self, subparsers, parent_parser):
parser = subparsers.add_parser('build', help='Build the given task.', parents = [parent_parser])
# TODO: Handle the `notify` arg
parser.add_argument(
'-n', '--notify', help='If a notification should be sent on build completion. NOTE: This has note been enabled yet', action='store_true')
parser.add_argument(
'build_task', help='The task to run. The following are the valid tasks' + pprint.pformat(BUILD_KEYS.keys()))

flavor_group = parser.add_mutually_exclusive_group()
flavor_group.add_argument('--debug', help='Install debug version of the APK', action='store_true')
flavor_group.add_argument('--release', help='Install release version of the APK', action='store_true')

arch_group = parser.add_mutually_exclusive_group()
arch_group.add_argument('--arm', help='Install the ARM version of the APK', action='store_true')
arch_group.add_argument('--x86', help='Install the x86 version of the APK', action='store_true')

parser.set_defaults(func=self.build)

def __setup_clean(self, subparsers, parent_parser):
parser = subparsers.add_parser('clean', help='Clean the given task\'s build directory.', parents = [parent_parser])
parser.add_argument(
'build_task', help='The task to run. The following are the valid tasks' + pprint.pformat(BUILD_KEYS.keys()))

parser.set_defaults(func=self.clean)

# Action functions
def build(self, args):
if args.build_task == "sdk_test":
return GRADLEW_TEST_COMMAND.format(root=args.root_dir, arch=self.__get_arch(args), type=self.__get_flavour(args))
if args.build_task == "ora_test":
return GRADLEW_BUILD_ONE_ROMANAPP_TEST_COMMAND.format(root=args.root_dir, arch=self.__get_arch(args), type=self.__get_flavour(args))
return GRADLEW_COMMAND.format(root=args.root_dir, task=BUILD_KEYS[args.build_task], type=self.__get_flavour(args), arch=self.__get_arch(args))

def clean(self, args):
return CLEAN_COMMAND.format(root=args.root_dir, build_dir=CLEAN_KEYS[args.build_task])

def __init__(self):
"""Parse arguments"""
parser = argparse.ArgumentParser(description='Some description')
parser.add_argument('-q', '--quiet', help='Do not display the gradle command used', action='store_true')
subparsers = parser.add_subparsers()

parent_parser = argparse.ArgumentParser(add_help=False)
parent_parser.add_argument('-rd', '--root_dir', help='The root directory where gradlew is located. Default is the current directory', default=os.getcwd())

# General app
self.__setup_build(subparsers, parent_parser)
self.__setup_clean(subparsers, parent_parser)

args = parser.parse_args()

try:
command = args.func(args)
if args.quiet is not True:
print("Running: ", command)
result = subprocess.call(command, shell=True)
assert result == 0
except AttributeError:
print("Given action " + args.cmd_action + " was not found.")

def main():
"""Main"""
arg_parser = ArgParser()

return 0

if __name__ == "__main__":
exit(main())

# #### Building Android - Private Functions ####

# _gradlew () { dos2unix gradlew && $GRADLEW $1; }

# _javap () { javap -classpath $CLASSES_JAR "com.microsoft.connecteddevices.$1"; }

# #### Building Android - Public Functions ####

# # build_in() { build $1 && adb_in $1 $2; }

# # Removes all files under build dirs

# build_jni() { _execute _build_jni jni_keys $1; }
import argparse
import subprocess
import os
import pprint

BUILD_KEYS = {
# Converged SDK
"conv": "connecteddevices-sdk",
# OneRomanApp
"ora": "oneRomanApp",
"ora_activities": "oneRomanApp-activities",
"ora_relay": "oneRomanApp-relay",
# WNS Ping Test Application
"wnsping": "wnspingtest",
# CDP Host
"cdphost": "cdphost",
# TDD Runner
"tdd": "tdd"
}

CLEAN_KEYS = {
# Converged SDK
"conv": "sdk/converged/projections/android/build",
# OneRomanApp
"ora": "samples/oneromanapp/android/app/projects/full/build",
"ora_activities": "samples/oneromanapp/android/app/projects/activities/build",
"ora_relay": "samples/oneromanapp/android/app/projects/relay/build",
# WNS Ping Test Application
"wnsping": "samples/wnspingtest/app/build",
# CDP Host
"cdphost": "samples/CDPHost/android/app/build",
# TDD Runner
"tdd": "test/tdd/runners/android/app/build"
}

FLAVOR = {
"DEBUG": "debug",
"RELEASE": "release"
}

ARCH = {
"ARM": "arm",
"X86": "x86"
}

GRADLEW_COMMAND = "{root}\gradlew :{task}:assemble{arch}{type}"
GRADLEW_TEST_COMMAND = "{root}\gradlew :sdk_test:connected{arch}{type}AndroidTest -PinstrumentedTestBuildType={type}"
GRADLEW_BUILD_ONE_ROMANAPP_TEST_COMMAND = "{root}\gradlew :oneRomanApp:assemble{arch}{type}AndroidTest"
GRADLEW_BUILD_AND_RUN_ONE_ROMANAPP_TEST_COMMAND = "{root}\gradlew :oneRomanApp:connected{arch}{type}AndroidTest"

# $adbTestFilter = "-e package com.microsoft.connecteddevices"
# if ((-not ([string]::IsNullOrEmpty($SdkTestFilter)))) {
# $adbTestFilter = "-e class $SdkTestFilter"
# }

# $adbOutput = RunAdb shell am instrument -w -r $adbTestFilter com.microsoft.connecteddevices.test/android.support.test.runner.AndroidJUnitRunner

CLEAN_COMMAND = "rm -rf {root}/{build_dir}"

class ArgParser:
# Utility functions
def __get_flavour(self, args):
if args.debug:
return FLAVOR["DEBUG"]
if args.release:
return FLAVOR["RELEASE"]
# Return default value of debug
return FLAVOR["DEBUG"]

def __get_arch(self, args):
if args.arm:
return ARCH["ARM"]
if args.x86:
return ARCH["X86"]
# Return default value of arm
return ARCH["ARM"]

# Argument setup functions
def __setup_build(self, subparsers, parent_parser):
parser = subparsers.add_parser('build', help='Build the given task.', parents = [parent_parser])
# TODO: Handle the `notify` arg
parser.add_argument(
'-n', '--notify', help='If a notification should be sent on build completion. NOTE: This has note been enabled yet', action='store_true')
parser.add_argument(
'build_task', help='The task to run. The following are the valid tasks' + pprint.pformat(BUILD_KEYS.keys()))

flavor_group = parser.add_mutually_exclusive_group()
flavor_group.add_argument('--debug', help='Install debug version of the APK', action='store_true')
flavor_group.add_argument('--release', help='Install release version of the APK', action='store_true')

arch_group = parser.add_mutually_exclusive_group()
arch_group.add_argument('--arm', help='Install the ARM version of the APK', action='store_true')
arch_group.add_argument('--x86', help='Install the x86 version of the APK', action='store_true')

parser.set_defaults(func=self.build)

def __setup_clean(self, subparsers, parent_parser):
parser = subparsers.add_parser('clean', help='Clean the given task\'s build directory.', parents = [parent_parser])
parser.add_argument(
'build_task', help='The task to run. The following are the valid tasks' + pprint.pformat(BUILD_KEYS.keys()))

parser.set_defaults(func=self.clean)

# Action functions
def build(self, args):
if args.build_task == "sdk_test":
return GRADLEW_TEST_COMMAND.format(root=args.root_dir, arch=self.__get_arch(args), type=self.__get_flavour(args))
if args.build_task == "ora_test":
return GRADLEW_BUILD_ONE_ROMANAPP_TEST_COMMAND.format(root=args.root_dir, arch=self.__get_arch(args), type=self.__get_flavour(args))
return GRADLEW_COMMAND.format(root=args.root_dir, task=BUILD_KEYS[args.build_task], type=self.__get_flavour(args), arch=self.__get_arch(args))

def clean(self, args):
return CLEAN_COMMAND.format(root=args.root_dir, build_dir=CLEAN_KEYS[args.build_task])

def __init__(self):
"""Parse arguments"""
parser = argparse.ArgumentParser(description='Some description')
parser.add_argument('-q', '--quiet', help='Do not display the gradle command used', action='store_true')
subparsers = parser.add_subparsers()

parent_parser = argparse.ArgumentParser(add_help=False)
parent_parser.add_argument('-rd', '--root_dir', help='The root directory where gradlew is located. Default is the current directory', default=os.getcwd())

# General app
self.__setup_build(subparsers, parent_parser)
self.__setup_clean(subparsers, parent_parser)

args = parser.parse_args()

try:
command = args.func(args)
if args.quiet is not True:
print("Running: ", command)
result = subprocess.call(command, shell=True)
assert result == 0
except AttributeError:
print("Given action " + args.cmd_action + " was not found.")

def main():
"""Main"""
arg_parser = ArgParser()

return 0

if __name__ == "__main__":
exit(main())

# #### Building Android - Private Functions ####

# _gradlew () { dos2unix gradlew && $GRADLEW $1; }

# _javap () { javap -classpath $CLASSES_JAR "com.microsoft.connecteddevices.$1"; }

# #### Building Android - Public Functions ####

# # build_in() { build $1 && adb_in $1 $2; }

# # Removes all files under build dirs

# build_jni() { _execute _build_jni jni_keys $1; }
Loading

0 comments on commit fe783bc

Please sign in to comment.