예제 #1
0
def hook_geneclipse(task, args):
    if (len(args) == 0):
        raise dragon.TaskError("module argument missing")

    if args[0] == "--help" or args[0] == "-h":
        dragon.LOGI("usage: ./build.sh -t %s [-f] <module1> <module2> ...",
                    task.name)
        return

    if args[0] == "--full" or args[0] == "-f":
        build_option = "-f"
        if (len(args) == 1):
            raise dragon.TaskError("module argument missing")
        projects = args[1:]
    else:
        build_option = "-d"
        projects = args[0:]

    # dump alchemy database in xml
    alchemy_xml = os.path.join(dragon.OUT_DIR, "alchemy-database.xml")
    dragon.exec_dir_cmd(dirpath=dragon.WORKSPACE_DIR,
                        cmd="./build.sh -p %s-%s -A dump-xml" %
                        (dragon.PRODUCT, dragon.VARIANT))

    # invoke alchemy eclipseproject python script
    build_cmd = r"-p \${TARGET_PRODUCT}-\${TARGET_PRODUCT_VARIANT} -A"
    dragon.exec_dir_cmd(dirpath=dragon.WORKSPACE_DIR,
                        cmd="%s/scripts/eclipseproject.py %s -b \"%s\" %s %s" %
                        (dragon.ALCHEMY_HOME, build_option, build_cmd,
                         alchemy_xml, " ".join(projects)))
def build_app(release=False):
    arbuildutils_dir = os.path.join(dragon.WORKSPACE_DIR, "packages", "ARBuildUtils")
    arfreeflight_android_dir = os.path.join(dragon.WORKSPACE_DIR, "packages", "ARFreeFlight", "Android")
    arfreeflight_android_script_dir = os.path.join(dragon.WORKSPACE_DIR, "packages", "ARFreeFlight", "Android", "script")

    # Build application
    dragon.exec_dir_cmd(dirpath=arbuildutils_dir, cmd="./generateAndroidResources.sh")
    dragon.exec_dir_cmd(dirpath=arbuildutils_dir, cmd="./generateLocalPropertiesFile.py")
    dragon.exec_dir_cmd(dirpath=arfreeflight_android_script_dir, cmd="./generateCompatiblesDevices.py")
    if release:
        dragon.exec_dir_cmd(dirpath=arfreeflight_android_dir, cmd="./gradlew assembleRelease")
    else:
        dragon.exec_dir_cmd(dirpath=arfreeflight_android_dir, cmd="./gradlew assembleDebug")
def build_app(task=None, args=None):
    arfreeflight_ios_dir = os.path.join(dragon.WORKSPACE_DIR, "packages",
            "ARFreeFlight", "iOS", "ARFreeFlight")

    # Build application
    cmd = "xcodebuild "
    cmd += "-project ARFreeFlight.xcodeproj "
    # TODO: archive does not work well with deps
    # TODO: -derivedDataPath works but result is only partial so not reammy useful
#    cmd += "-scheme ARFreeFlight "
#    cmd += "-derivedDataPath %s " % os.path.join(dragon.OUT_DIR, "ARFreeFlight")
#    cmd += "archive -archivePath %s " % os.path.join(dragon.OUT_DIR, "ARFreeFlight.xcarchive")
    if args:
        cmd += " ".join(args)
    dragon.exec_dir_cmd(dirpath=arfreeflight_ios_dir, cmd=cmd)
예제 #4
0
def hook_genqtcreator(task, args):
    if (len(args) == 0):
        raise dragon.TaskError("module or atom.mk directory argument missing")

    if args[0] == "--help" or args[0] == "-h":
        dragon.LOGI(
            "usage: ./build.sh -t %s [-f] <module1|dir1> <module2|dir2> ...",
            task.name)
        return

    projects = args[0:]

    # dump alchemy database in xml
    alchemy_xml = os.path.join(dragon.OUT_DIR, "alchemy-database.xml")
    dragon.exec_dir_cmd(dirpath=dragon.WORKSPACE_DIR,
                        cmd="./build.sh -p %s-%s -A dump-xml" %
                        (dragon.PRODUCT, dragon.VARIANT))

    # invoke alchemy qtcreatorproject python script
    build_cmd = "-p %s-%s -A" % (dragon.PRODUCT, dragon.VARIANT)
    dragon.exec_dir_cmd(
        dirpath=dragon.WORKSPACE_DIR,
        cmd="%s/scripts/qtcreatorproject.py %s -b '%s' %s" %
        (dragon.ALCHEMY_HOME, alchemy_xml, build_cmd, " ".join(projects)))
예제 #5
0
def generate_release_archive(release_id, additional_files=None,
        product_config="product_config.json", warn_on_overwrite=False,
        previous_manifest=None):

    # Disable police while generating the archive
    os.environ["POLICE_HOOK_DISABLED"] = "1"

    # Init final directories and sources
    release_dir = os.path.join(dragon.OUT_DIR, "release-" + release_id)
    release_config_dir = os.path.join(release_dir, "config")

    # Create base list of files for release
    archive_content = [
        {
            "src": os.path.join(dragon.OUT_DIR,
                "symbols-%s-%s.tar" % (dragon.PRODUCT, dragon.VARIANT)),
            "dest": os.path.join(release_dir, "symbols.tar"),
        },
        {
            "src": os.path.join(dragon.OUT_DIR,
                "sdk-%s-%s.tar.gz" % (dragon.PRODUCT, dragon.VARIANT)),
            "dest": os.path.join(release_dir, "sdk.tar.gz"),
        },
        {
            "src": os.path.join(dragon.OUT_DIR, "images"),
            "dest": os.path.join(release_dir, "images"),
        },
        {
            "src": os.path.join(dragon.OUT_DIR, "staging", "etc", "build.prop"),
            "dest": os.path.join(release_dir, "build.prop"),
        },
        {
            "src": os.path.join(dragon.OUT_DIR, "build", "linux", ".config"),
            "dest": os.path.join(release_config_dir, "linux.config"),
            "mandatory": False
        },
        {
            "src": os.path.join(dragon.OUT_DIR, "global.config"),
            "dest": os.path.join(release_config_dir, "global.config"),
        },
        {
            "src": os.path.join(dragon.WORKSPACE_DIR, "build", "dragon_build",
                "pinst_wrapper.py"),
            "dest": os.path.join(release_dir, "pinst_wrapper.py"),
        },
        {
            "src": os.path.join(dragon.OUT_DIR, "police"),
            "dest": os.path.join(release_dir, "police"),
            "mandatory": False
        },
        {
            "src": os.path.join(dragon.OUT_DIR, "oss-packages"),
            "dest": os.path.join(release_dir, "oss-packages"),
            "mandatory": False
        },
    ]

    release_manifest = "release.xml"
    if not previous_manifest:
        previous_manifest = release_manifest

    cfp = get_json_config(product_config)
    release_section = None
    if cfp:
        release_section = cfp.get_section("release")
    # As this section is optional, we add it only if present
    if release_section:
        json_filepath = cfp.get_config_filepath()
        archive_content.append({
            "src": json_filepath,
            "dest": os.path.join(release_dir, "product_config.json")
            })
        # Export current variables as environment to be used with json
        for _envvar in ["PARROT_BUILD_PROP_GROUP", "PARROT_BUILD_PROP_PROJECT",
                "PARROT_BUILD_PROP_PRODUCT", "PARROT_BUILD_PROP_VARIANT",
                "PARROT_BUILD_PROP_REGION", "PARROT_BUILD_PROP_UID",
                "PARROT_BUILD_PROP_VERSION", "WORKSPACE_DIR", "OUT_DIR" ]:
            os.environ[_envvar] = getattr(dragon, _envvar)

        json_add_files = release_section.get("additional_files", [])
        release_manifest = release_section.get("manifest_name",
                release_manifest)
        # In case of a previous manifest with different name
        # between two versions (It serves only for changelog)
        previous_manifest = release_section.get("previous_manifest",
                release_manifest)
        for _elem in json_add_files:
            archive_content.append({
                "src": os.path.expandvars(_elem["src"]),
                "dest": os.path.join(
                    release_dir, os.path.expandvars(_elem["dest"])),
                "mandatory":_elem.get("mandatory", True),
            })
        warn_on_overwrite = release_section.get("warn_on_overwrite", False)
    # For files provided by function calling
    if isinstance(additional_files, list):
        archive_content.extend(additional_files)

    for _elem in archive_content:
        src = _elem["src"]
        dest = _elem["dest"]
        # Optional field
        mandatory = _elem.get("mandatory", True)
        if os.path.exists(dest):
            if warn_on_overwrite:
                dragon.LOGW("%s will be overwritten.", dest)
            os.unlink(dest)
        # This function already do the parent dirname creation when needed
        if os.path.exists(src):
            relative_symlink(src, dest)
        else:
            if mandatory and not dragon.OPTIONS.dryrun:
                raise dragon.TaskError("%s file is absent. Cannot generate release." % src)

    # Normally it is also found in final/etc but in case the product does not
    # have this feature because of the task being overloaded.
    gen_manifest_xml(os.path.join(release_dir, "manifest.xml"))
    # Too bad if absent
    # Can raise error on first release, where no previous manifest is found
    try:
        dragon.exec_cmd("repo diffmanifest --full --graph --no-color "
                "+:{previous_xml_name} {xml_name} > {output}".format(
                    output=os.path.join(release_dir, "changelog.txt"),
                    xml_name=release_manifest,
                    previous_xml_name=previous_manifest)
                )
    except:
        pass

    # Generate md5sum file
    dragon.exec_dir_cmd(dirpath=release_dir, cmd="md5sum $(find -follow -type f) > md5sum.txt")

    # Archive the release
    dragon.exec_cmd("tar -C %s -hcf %s.tar ." % (release_dir, release_dir))

    # Re-enable police while generating the archive
    del os.environ["POLICE_HOOK_DISABLED"]

    # Do not move in workspace if output dir is somewhere else (jenkins for example)
    if dragon.OUT_DIR.startswith(dragon.WORKSPACE_DIR):
        dragon.exec_cmd("mv -f %s.tar %s " % (release_dir,
                os.path.join(dragon.WORKSPACE_DIR, "%s.tar" % dragon.PARROT_BUILD_PROP_UID)))
def build_jni():
    arfreeflight_android_jni_dir = os.path.join(dragon.WORKSPACE_DIR, "packages", "ARFreeFlight", "Android", "ARFreeFlight", "jni")

    # Call ndk-build
    dragon.exec_dir_cmd(dirpath=arfreeflight_android_jni_dir, cmd="${ANDROID_NDK_PATH}/ndk-build")