summaryrefslogtreecommitdiff
path: root/mach
blob: 7b076b00ab25efc2cd2d6181eb2f9ec848f4b963 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash

BINOC_MACH=real-mach
BINOC_TARGET_OS=`uname | tr [:upper:] [:lower:]`
BINOC_CONFIG_GUESS=`./build/autoconf/config.guess 2>/dev/null`
BINOC_PYTHON=`which python2.7 2>/dev/null`
BINOC_GIT=`which git 2>/dev/null`
BINOC_CURL=`which curl 2>/dev/null`

# =====================================================================================================================

if [ -z "$BINOC_PYTHON" ]; then
  printf "We could not find Python 2.7 which is required for just about everything!\n"
  exit 1
fi

# =====================================================================================================================

# Determine the current OS
# This will also be exported so it can be picked up by .mozconfig
if [[ "$BINOC_TARGET_OS" == "mingw32_nt-"* ]]; then
  BINOC_TARGET_OS=windows
  
  if [[ "$BINOC_CONFIG_GUESS" == "x86_64-pc-mingw32" ]]; then
    BINOC_CONFIG_GUESS=win64
  else
    BINOC_CONFIG_GUESS=win32
  fi
fi

export BINOC_TARGET_OS=$BINOC_TARGET_OS
export BINOC_CONFIG_GUESS=$BINOC_CONFIG_GUESS

# =====================================================================================================================

if [[ "$1" == "build-release" ]]; then
  $BINOC_MACH build && $BINOC_MACH package && $BINOC_MACH mar --bz2 && $BINOC_MACH langpack && $BINOC_MACH theme
  if [[ "$BINOC_TARGET_OS" == "windows" ]]; then
    $BINOC_MACH installer
  fi
elif [ "$1" == "localbuild" ]; then
  # This builds and stages the application in dist/MOZ_APP_NAME but does not
  # actually generate an archive or any of the other stuff
  $BINOC_MACH build
  if [[ "$BINOC_TARGET_OS" == "windows" ]]; then
    $BINOC_MACH installer && $BINOC_MACH install
  else
    $BINOC_MACH stage
  fi
elif [[ "$1" == "superclobber" && -d "../.obj" ]]; then
  printf "Removing all object directories in ../.obj"
  rm -rf ../.obj/*
elif [ "$1" == "version" ]; then
  # This will execute version2k.py and pass any remaining args to it
  $BINOC_PYTHON ./build/version2k.py ${@:2}
elif [[ "$1" == "webpatch" ]] && [[ -n "$BINOC_GIT" ]] && [[ -n "$BINOC_CURL" ]]; then
  if [ -z "$2" ]; then
    printf "Patch with what?"
    exit 1
  else
    if [[ "$2" == *"github.com"* ]] ||
       [[ "$2" == *"code.binaryoutcast.com"* ]] ||
       [[ "$2" == *"repo.palemoon.org"* ]]; then
      echo ${2}.patch
      $BINOC_CURL -L ${2}.patch | "$BINOC_GIT" apply --reject
    else
      $BINOC_CURL -L ${2} | "$BINOC_GIT" apply --reject
    fi
  fi
elif [[ "$1" == "amend-author" ]]; then
  if [[ -z "$2" ]]; then
    printf "Amend author on commit with what? (First Last <email@domain.tld>"
    exit 1
  fi
  "$BINOC_GIT" commit --amend --no-edit --author "$(echo ${@:2})"
else
  # We don't know what the command is but real-mach might so just pass
  # all the args to it
  ./$BINOC_MACH $@
fi

# =====================================================================================================================