Skip to content
Snippets Groups Projects
Select Git revision
  • 56b84abec1bcbbd973eefe854c3d4820e1819c81
  • master default protected
  • release/202005
  • release/202001
  • release/201912
  • release/windows-test/201910
  • release/201908
  • release/201906
  • release/201905
  • release/201904
  • release/201903
  • release/201902
  • release/201901
  • release/201812
  • release/201811
  • release/201808
  • wip/patches_poly_2017/cedryk_doucet/abderahmane_bouziane
  • releases/beta1
  • android/release_461
  • android/release_460
  • android/release_459
  • android/release_458
  • android/release_457
  • android/release_456
  • android/release_455
  • android/release_454
  • android/release_453
  • android/release_452
  • android/release_451
  • android/release_450
  • android/release_449
  • android/release_448
  • android/release_447
  • android/release_446
  • android/release_445
  • android/release_444
  • android/release_443
  • android/release_442
38 results

ConversationActivity.java

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    build-plugin.py 4.67 KiB
    #!/usr/bin/env python3
    #
    # Copyright (C) 2020-2021 Savoir-faire Linux Inc.
    #
    # Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
    #
    # This program is free software: you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation, either version 3 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program.  If not, see <http://www.gnu.org/licenses/>.
    #
    # Creates packaging targets for a distribution and architecture.
    # This helps reduce the length of the top Makefile.
    #
    
    # This script must unify the Plugins build for
    # every project and Operational System
    
    import os
    import sys
    import json
    import platform
    import argparse
    import subprocess
    import multiprocessing
    
    IOS_DISTRIBUTION_NAME = "ios"
    OSX_DISTRIBUTION_NAME = "osx"
    ANDROID_DISTRIBUTION_NAME = "android"
    WIN32_DISTRIBUTION_NAME = "win32"
    UBUNTU_DISTRIBUTION_NAME = "ubuntu"
    
    def parse():
        parser = argparse.ArgumentParser(description='Builds Plugins projects')
        parser.add_argument('--projects', type=str,
                            help='Select plugins to be build.')
        parser.add_argument('--distribution')
        parser.add_argument('--processor', type=str, default="GPU",
                            help='Runtime plugin CPU/GPU setting.')
        parser.add_argument('--buildOptions', default='', type=str,
                            help="Type all build optionsto pass to package.json 'defines' property.\nThis argument consider that you're using cmake.")
        parser.add_argument('--arch', type=str, default=None,
                            help='Specify the architecture (arm64 or x86_64).')
    
        dist = choose_distribution()
    
    
        args = parser.parse_args()
        args.projects = args.projects.split(',')
        args.processor = args.processor.split(',')
    
        if (args.distribution is not None):
            args.distribution = args.distribution.lower()
        else:
            args.distribution = dist
    
        if (len(args.processor) == 1):
            args.processor *= len(args.projects)
    
        validate_args(args)
    
        return args
    
    
    def validate_args(parsed_args):
        """Validate the args values, exit if error is found"""
    
        # Filter unsupported distributions.
        supported_distros = [
            ANDROID_DISTRIBUTION_NAME, UBUNTU_DISTRIBUTION_NAME,
            WIN32_DISTRIBUTION_NAME, OSX_DISTRIBUTION_NAME
        ]
    
        if parsed_args.distribution not in supported_distros:
            print('Distribution \'{0}\' not supported.\nChoose one of: {1}'.format(
                parsed_args.distribution, ', '.join(supported_distros)
            ))
            sys.exit(1)
    
        if (len(parsed_args.processor) != len(parsed_args.projects)):
            sys.exit('Processor must be single or the same size as projects.')
    
        for processor in parsed_args.processor:
            if (processor not in ['GPU', 'CPU']):
                sys.exit('Processor can only be GPU or CPU.')
    
        if (parsed_args.buildOptions):
            parsed_args.buildOptions = parsed_args.buildOptions.split(',')
    
        valid_archs = ['arm64', 'x86_64', None]
        if parsed_args.arch not in valid_archs:
            sys.exit(f"Invalid architecture: {parsed_args.arch}. Must be one of {valid_archs}")
    
    
    def choose_distribution():
        system = platform.system().lower()
    
        if system == "linux" or system == "linux2":
            if os.path.isfile("/etc/arch-release"):
                return "arch"
            with open("/etc/os-release") as f:
                for line in f:
                    k, v = line.split("=")
                    if k.strip() == 'ID':
                        return v.strip().replace('"', '').split(' ')[0]
        elif system == "darwin":
            return OSX_DISTRIBUTION_NAME
        elif system == "windows":
            return WIN32_DISTRIBUTION_NAME
    
        return 'Unknown'
    
    
    def buildPlugin(pluginPath):
        # Change the current working directory to pluginPath
        os.chdir(pluginPath)
    
        # Create a new directory named 'build-local'
        if not os.path.exists('build-local'):
            os.mkdir('build-local')
    
        # Change the current working directory to the newly created 'build-local' directory
        os.chdir('build-local')
    
        # Prepare build-local
        os.system('cmake ..')
    
        # Run the cmake build command
        os.system('cmake --build .')
    
    def main():
        args = parse()
        currentDir = os.getcwd()
    
        for i, plugin in enumerate(args.projects):
            os.chdir(currentDir + "/" + plugin)
            buildPlugin(currentDir + "/" + plugin)
    
    if __name__ == "__main__":
        main()