template("build_edc") {
    forward_variables_from(invoker, [ "image_dirs", "sound_dirs", "font_dirs" ])

    edje_cc_opts = []
    if (defined(image_dirs)) {
        foreach(i, image_dirs) {
            edje_cc_opts += ["-id", rebase_path(i, root_out_dir)]
        }
    }

    if (defined(sound_dirs)) {
        foreach(s, sound_dirs) {
            edje_cc_opts += ["-sd", rebase_path(s, root_out_dir)]
        }
    }

    if (defined(font_dirs)) {
        foreach(s, font_dirs) {
            edje_cc_opts += ["-fd", rebase_path(s, root_out_dir)]
        }
    }

    enventor_dir = rebase_path("${tizen_studio}/tools/edc-editor/share/enventor", root_out_dir)
    edje_cc_opts += ["-id", rebase_path("${enventor_dir}/images", root_out_dir)]
    edje_cc_opts += ["-sd", rebase_path("${enventor_dir}/images", root_out_dir)]
    edje_cc_opts += ["-fd", rebase_path("${enventor_dir}/images", root_out_dir)]

    if (api_version == "2.3" || api_version == "2.3.1" || api_version == "2.3.2" || api_version == "2.4") {
        edje_cc_dir = rebase_path("${tizen_studio}/tools/efl-tool/efl-tools", root_out_dir)
    } else {
        edje_cc_dir = rebase_path("${tizen_studio}/platforms/tizen-$api_version/common/efl-tool/efl-tools", root_out_dir)
    }
    edje_cc = "LD_LIBRARY_PATH=${edje_cc_dir}/lib ${edje_cc_dir}/bin/edje_cc"
    if (host_os == "win") {
        edje_cc = "\"${edje_cc_dir}/bin/edje_cc\""
    }

    action_foreach(target_name) {
        command = "$edje_cc " + string_join(" ", edje_cc_opts) + " {{source}} {{output}}"
        description = "EDC {{output}}"
        sources = [ target_name ]
        outputs = [
            "${root_out_dir}/$native_out_dir/{{source_target_relative}}/../{{source_name_part}}.edj",
        ]
    }
}