Commit ffde6002 authored by Gautier Pelloux-Prayer's avatar Gautier Pelloux-Prayer Committed by Ghislain MARY

prepare.py: implement check_tools

parent d810c322
...@@ -26,15 +26,16 @@ import argparse ...@@ -26,15 +26,16 @@ import argparse
import os import os
import platform import platform
import sys import sys
from logging import error, warning, info, INFO, basicConfig
from subprocess import Popen from subprocess import Popen
from distutils.spawn import find_executable from distutils.spawn import find_executable
sys.dont_write_bytecode = True sys.dont_write_bytecode = True
sys.path.insert(0, 'submodules/cmake-builder') sys.path.insert(0, 'submodules/cmake-builder')
try: try:
import prepare import prepare
except: except Exception as e:
print( error(
"Could not find prepare module, probably missing submodules/cmake-builder? Try running:\ngit submodule update --init --recursive") "Could not find prepare module: {}, probably missing submodules/cmake-builder? Try running:\ngit submodule update --init --recursive".format(e))
exit(1) exit(1)
...@@ -52,6 +53,7 @@ class DesktopTarget(prepare.Target): ...@@ -52,6 +53,7 @@ class DesktopTarget(prepare.Target):
current_path + '/submodules' current_path + '/submodules'
] ]
class PythonTarget(prepare.Target): class PythonTarget(prepare.Target):
def __init__(self): def __init__(self):
...@@ -68,6 +70,7 @@ class PythonTarget(prepare.Target): ...@@ -68,6 +70,7 @@ class PythonTarget(prepare.Target):
current_path + '/submodules' current_path + '/submodules'
] ]
class PythonRaspberryTarget(prepare.Target): class PythonRaspberryTarget(prepare.Target):
def __init__(self): def __init__(self):
...@@ -83,10 +86,10 @@ class PythonRaspberryTarget(prepare.Target): ...@@ -83,10 +86,10 @@ class PythonRaspberryTarget(prepare.Target):
] ]
def check_is_installed(binary, prog=None, warn=True): def check_is_installed(binary, prog='it', warn=True):
if not find_executable(binary): if not find_executable(binary):
if warn: if warn:
print("Could not find {}. Please install {}.".format(binary, prog)) error("Could not find {}. Please install {}.".format(binary, prog))
return False return False
return True return True
...@@ -94,13 +97,20 @@ def check_is_installed(binary, prog=None, warn=True): ...@@ -94,13 +97,20 @@ def check_is_installed(binary, prog=None, warn=True):
def check_tools(): def check_tools():
ret = 0 ret = 0
#at least FFmpeg requires no whitespace in sources path...
if " " in os.path.dirname(os.path.realpath(__file__)): if " " in os.path.dirname(os.path.realpath(__file__)):
print("Invalid location: path should not contain any spaces.") error("Invalid location: path should not contain any spaces.")
ret = 1
ret |= not check_is_installed('cmake')
if not os.path.isdir("submodules/linphone/mediastreamer2/src") or not os.path.isdir("submodules/linphone/oRTP/src"):
error("Missing some git submodules. Did you run:\n\tgit submodule update --init --recursive")
ret = 1 ret = 1
print("check_tools: todo.. (see ios)")
return ret return ret
def generate_makefile(generator): def generate_makefile(generator):
makefile = """ makefile = """
.PHONY: all .PHONY: all
...@@ -135,6 +145,8 @@ help: help-prepare-options ...@@ -135,6 +145,8 @@ help: help-prepare-options
def main(argv=None): def main(argv=None):
basicConfig(format="%(levelname)s: %(message)s", level=INFO)
if argv is None: if argv is None:
argv = sys.argv argv = sys.argv
argparser = argparse.ArgumentParser( argparser = argparse.ArgumentParser(
...@@ -194,18 +206,19 @@ def main(argv=None): ...@@ -194,18 +206,19 @@ def main(argv=None):
if args.tunnel or os.path.isdir("submodules/tunnel"): if args.tunnel or os.path.isdir("submodules/tunnel"):
if not os.path.isdir("submodules/tunnel"): if not os.path.isdir("submodules/tunnel"):
print("Tunnel wanted but not found yet, trying to clone it...") info("Tunnel wanted but not found yet, trying to clone it...")
p = Popen("git clone gitosis@git.linphone.org:tunnel.git submodules/tunnel".split(" ")) p = Popen("git clone gitosis@git.linphone.org:tunnel.git submodules/tunnel".split(" "))
p.wait() p.wait()
if p.retcode != 0: if p.returncode != 0:
print("Could not clone tunnel. Please see http://www.belledonne-communications.com/voiptunnel.html") error("Could not clone tunnel. Please see http://www.belledonne-communications.com/voiptunnel.html")
return 1 return 1
print("Tunnel enabled.") info("Tunnel enabled.")
additional_args += ["-DENABLE_TUNNEL=YES"] additional_args += ["-DENABLE_TUNNEL=YES"]
# install_git_hook() # install_git_hook()
target = None target = None
if args.python: if args.python:
target = PythonTarget() target = PythonTarget()
elif args.python_raspberry: elif args.python_raspberry:
...@@ -226,19 +239,19 @@ def main(argv=None): ...@@ -226,19 +239,19 @@ def main(argv=None):
Popen("make help-prepare-options".split(" ")) Popen("make help-prepare-options".split(" "))
retcode = 0 retcode = 0
return retcode return retcode
#only generated makefile if we are using Ninja or Makefile # only generated makefile if we are using Ninja or Makefile
if args.generator.endswith('Ninja'): if args.generator.endswith('Ninja'):
if not check_is_installed("ninja", "it"): if not check_is_installed("ninja", "it"):
return 1 return 1
generate_makefile('ninja -C') generate_makefile('ninja -C')
print("You can now run 'make' to build.") info("You can now run 'make' to build.")
elif args.generator.endswith("Unix Makefiles"): elif args.generator.endswith("Unix Makefiles"):
generate_makefile('$(MAKE) -C') generate_makefile('$(MAKE) -C')
print("You can now run 'make' to build.") info("You can now run 'make' to build.")
elif args.generator == "Xcode": elif args.generator == "Xcode":
print("You can now open Xcode project with: open WORK/cmake/Project.xcodeproj") info("You can now open Xcode project with: open WORK/cmake/Project.xcodeproj")
else: else:
print("Not generating meta-makefile for generator {}.".format(args.generator)) warning("Not generating meta-makefile for generator {}.".format(args.generator))
return 0 return 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment