summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLucas Wojciechowski <lucas@mapbox.com>2015-09-16 17:26:12 -0700
committerMike Morris <michael.patrick.morris@gmail.com>2015-11-04 11:34:35 -0500
commitda569c266b663b815b0fa754be59c78904b92fa6 (patch)
treed17d39da14883baa641f4cc0fa49bc3b88f9db08 /scripts
parent8e63084c9e77486c9843ce469e0e8b663bfebb03 (diff)
downloadqtlocation-mapboxgl-da569c266b663b815b0fa754be59c78904b92fa6.tar.gz
[node] enable npm to build mapbox-gl-native package from source
This reverts commit 311bf93abe9f815668e8e0a779c87c3eb5c1199d. more explicit require paths in tests
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build-version.py43
-rw-r--r--scripts/main.mk6
2 files changed, 35 insertions, 14 deletions
diff --git a/scripts/build-version.py b/scripts/build-version.py
index 0110e6a2e1..1a01f6cd2b 100755
--- a/scripts/build-version.py
+++ b/scripts/build-version.py
@@ -1,22 +1,22 @@
#!/usr/bin/env python
-import sys, os, errno, re
+import sys, os, errno, re, subprocess
+DEFAULT_TAG = [0, 0, 0]
+DEFAULT_REV = 'unknown'
-output_dir = sys.argv[1]
+def is_git_repo():
+ try:
+ subprocess.check_output("git rev-parse", shell=True)
+ return True
+ except subprocess.CalledProcessError as exc:
+ return False
-if len(sys.argv) <= 3:
- tag = [0, 0, 0]
- rev = sys.argv[2][0:8]
-else:
- # When they're identical, the git describe can't find a tag and reports the rev instead.
- if sys.argv[2] == sys.argv[3]:
- tag = [0, 0, 0]
- else:
- ver = re.sub("[^0-9.]", "", sys.argv[2])
- tag = map(int, ver.split('.'))
- rev = sys.argv[3][0:8]
+def parse_tag(raw_tag):
+ return map(int, re.sub("[^0-9.]", "", raw_tag).split('.'))
+def parse_rev(raw_rev):
+ return raw_rev[0:8]
def mkdir_p(path):
try:
@@ -26,6 +26,22 @@ def mkdir_p(path):
pass
else: raise
+output_dir = sys.argv[1]
+
+if is_git_repo():
+ raw_tag = subprocess.check_output("git describe --tags --always --abbrev=0", shell=True)
+ raw_rev = subprocess.check_output("git rev-parse HEAD", shell=True)
+
+ # When they're identical, the "git describe" can't find a tag and reports the rev instead.
+ if raw_tag == raw_rev:
+ tag = DEFAULT_TAG
+ rev = parse_rev(raw_rev)
+ else:
+ tag = parse_tag(raw_tag)
+ rev = parse_rev(raw_rev)
+else:
+ tag = DEFAULT_TAG
+ rev = DEFAULT_REV
header = """// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.
#ifndef MBGL_UTIL_VERSION
@@ -60,4 +76,3 @@ extern const unsigned int number;
header_path = os.path.join(output_dir, 'include/mbgl/util/version.hpp')
mkdir_p(os.path.dirname(header_path))
with open(header_path, 'w') as f: f.write(header)
-
diff --git a/scripts/main.mk b/scripts/main.mk
index 15e3484e01..b4a5f9894e 100644
--- a/scripts/main.mk
+++ b/scripts/main.mk
@@ -16,6 +16,10 @@ HOST_VERSION ?= $(BUILD_VERSION)
export MASON_PLATFORM=$(HOST)
export MASON_PLATFORM_VERSION=$(HOST_VERSION)
+ifneq (,$(wildcard scripts/$(HOST)/$(HOST_VERSION)/configure.sh))
+ CONFIGURE_FILES += scripts/$(HOST)/$(HOST_VERSION)/configure.sh
+endif
+
HOST_SLUG = $(HOST)-$(HOST_VERSION)
CONFIGURE_FILES = scripts/$(HOST)/configure.sh
ifneq (,$(wildcard scripts/$(HOST)/$(HOST_VERSION)/configure.sh))
@@ -39,6 +43,7 @@ default: ;
#### Dependencies ##############################################################
+ifneq (,$(wildcard .git/.))
SUBMODULES += .mason/mason.sh
.mason/mason.sh:
./scripts/flock.py .git/Submodule.lock git submodule update --init .mason
@@ -52,6 +57,7 @@ SUBMODULES += test/ios/KIF/KIF.xcodeproj
test/ios/KIF/KIF.xcodeproj:
./scripts/flock.py .git/Submodule.lock git submodule update --init test/ios/KIF
endif
+endif
# Wildcard targets get removed after build by default, but we want to preserve the config.
.PRECIOUS: config/%.gypi