未验证 提交 c2d6a3a4 编写于 作者: O openharmony_ci 提交者: Gitee

!518 enable iccarm toolchain

Merge pull request !518 from weifulun/iccarm_toolchain
......@@ -89,6 +89,12 @@ if (board_toolchain != "" && use_board_toolchain) {
ohos_current_strip_command =
"${compile_prefix}strip$toolchain_cmd_suffix --strip-unneeded"
default_target_configs = [ "//build/lite/config:clang_opt" ]
} else if (board_toolchain_type == "iccarm") {
ohos_current_cc_command = "${compile_prefix}iccarm$toolchain_cmd_suffix"
ohos_current_cxx_command = "${compile_prefix}iccarm$toolchain_cmd_suffix"
ohos_current_ar_command = "${compile_prefix}iarchive$toolchain_cmd_suffix"
ohos_current_as_command = "${compile_prefix}iasmarm$toolchain_cmd_suffix"
ohos_current_ld_command = "${compile_prefix}ilinkarm$toolchain_cmd_suffix"
}
# Overwrite ld cmd by customed cmd.
......@@ -112,17 +118,25 @@ if (board_toolchain != "" && use_board_toolchain) {
default_target_configs += [ "//build/lite/config:clang_opt" ]
}
default_target_configs += [
"//build/lite/config:board_config",
"//build/lite/config:cpu_arch",
"//build/lite/config:common",
"//build/lite/config:default_link_path",
]
if (board_toolchain_type != "iccarm") {
default_target_configs += [
"//build/lite/config:board_config",
"//build/lite/config:cpu_arch",
"//build/lite/config:common",
"//build/lite/config:default_link_path",
"//build/lite/config:language_c",
"//build/lite/config:language_cpp",
"//build/lite/config:kernel_macros",
]
if (ohos_build_type == "debug") {
default_target_configs += [ "//build/lite/config:debug" ]
} else if (ohos_build_type == "release") {
default_target_configs += [ "//build/lite/config:release" ]
}
if (ohos_build_type == "debug") {
default_target_configs += [ "//build/lite/config:debug" ]
} else if (ohos_build_type == "release") {
default_target_configs += [ "//build/lite/config:release" ]
if (ohos_kernel_type == "liteos_m") {
default_target_configs += [ "//build/lite/config:stack_protector" ]
}
}
if (ohos_kernel_type == "liteos_a") {
......@@ -135,16 +149,7 @@ if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") {
"//build/lite/config:security",
"//build/lite/config:exceptions",
]
} else if (ohos_kernel_type == "liteos_m") {
default_target_configs += [ "//build/lite/config:stack_protector" ]
}
default_target_configs += [
"//build/lite/config:language_c",
"//build/lite/config:language_cpp",
"//build/lite/config:kernel_macros",
]
default_shared_library_configs =
default_target_configs + [ "//build/lite/config:shared_library_config" ]
default_static_library_configs = default_target_configs
......
......@@ -19,6 +19,12 @@ import("//build/lite/ndk/ndk.gni")
config("cjson_config") {
include_dirs = [ "//third_party/cJSON" ]
ldflags = [ "-lm" ]
if (board_toolchain_type == "iccarm") {
cflags = [
"--diag_suppress",
"Pa084",
]
}
}
cjson_sources = [
......
......@@ -12,6 +12,7 @@
# limitations under the License.
import("//build/lite/toolchain/clang.gni")
import("//build/lite/toolchain/gcc.gni")
import("//build/lite/toolchain/iccarm.gni")
# Set toolchain configured by board.
if (board_toolchain != "" && use_board_toolchain) {
......@@ -31,6 +32,14 @@ if (board_toolchain != "" && use_board_toolchain) {
ld = ohos_current_ld_command
strip = ohos_current_strip_command
}
} else if (board_toolchain_type == "iccarm") {
iccarm_toolchain(board_toolchain) {
cc = ohos_current_cc_command
cxx = ohos_current_cxx_command
as = ohos_current_as_command
ar = ohos_current_ar_command
ld = ohos_current_ld_command
}
}
} else {
clang_toolchain("linux_x86_64_ohos_clang") {
......
# Copyright (c) 2020 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
template("iccarm_toolchain") {
toolchain(target_name) {
assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value")
assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value")
assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value")
assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value")
cc = invoker.cc
cxx = invoker.cxx
as = invoker.as
ar = invoker.ar
ld = invoker.ld
need_strip = false
if (defined(invoker.strip)) {
strip = invoker.strip
need_strip = true
}
if (defined(invoker.extra_ldflags) && invoker.extra_ldflags != "") {
extra_ldflags = " " + invoker.extra_ldflags
} else {
extra_ldflags = ""
}
tool("cc") {
command = "$cc {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
description = "iccarm cross compiler {{output}}"
outputs =
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
}
tool("cxx") {
depfile = "{{output}}.d"
command = "$cxx {{defines}} {{include_dirs}} {{cflags_cc}} -c {{source}} -o {{output}}"
description = "iccarm CXX {{output}}"
outputs =
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
}
tool("asm") {
depfile = "{{output}}.d"
command = "$as {{defines}} {{include_dirs}} {{asmflags}} {{source}} -o {{output}}"
description = "iccarm cross compiler {{output}}"
outputs =
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
}
tool("alink") {
outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
rspfile = "{{output}}.rsp"
rspfile_content = "{{inputs}}"
command = "rm -f {{output}} && $ar {{inputs}} -o {{output}}"
description = "AR {{output}}"
outputs = [ outfile ]
default_output_dir = "{{root_out_dir}}/libs"
default_output_extension = ".a"
output_prefix = "lib"
}
tool("solink") {
outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
unstripped_outfile = outfile
rspfile = "$outfile.rsp"
rspfile_content = "{{inputs}}"
command = ""
if (need_strip) {
unstripped_outfile = "{{output_dir}}/unstripped/usr/lib/{{target_output_name}}{{output_extension}}"
}
command += "$ld -shared {{ldflags}} $extra_ldflags " + "-Wl, --start-group {{inputs}} {{libs}} -Wl, --end-group -o $unstripped_outfile"
if (need_strip) {
command += " && $strip \"$unstripped_outfile\" -o \"$outfile\""
}
description = "SOLINK $outfile"
outputs = [ outfile ]
if (unstripped_outfile != outfile) {
outputs += [ unstripped_outfile ]
}
default_output_dir = "{{root_out_dir}}"
default_output_extension = ".so"
output_prefix = "lib"
}
tool("link") {
outfile = "{{output_dir}}/bin/{{target_output_name}}{{output_extension}}"
unstripped_outfile = outfile
rspfile = "$outfile.rsp"
command = ""
if (need_strip) {
unstripped_outfile = "{{output_dir}}/unstripped/bin/{{target_output_name}}{{output_extension}}"
}
command += "$ld {{ldflags}} $extra_ldflags " +
"{{inputs}} {{libs}} -o $unstripped_outfile"
if (need_strip) {
command += " && $strip \"$unstripped_outfile\" -o \"$outfile\""
}
description = "LINK $outfile $command"
default_output_dir = "{{root_out_dir}}"
rspfile_content = "{{inputs}}"
outputs = [ outfile ]
if (unstripped_outfile != outfile) {
outputs += [ unstripped_outfile ]
}
}
tool("stamp") {
if (host_os == "win") {
command = "cmd /c type nul > \"{{output}}\""
} else {
command = "/usr/bin/touch {{output}}"
}
description = "STAMP {{output}}"
}
tool("copy") {
if (host_os == "win") {
command = "python $ohos_root_path/build/lite/copy_files.py --src_type=file --src={{source}} --dest_dir={{output}}"
} else if (host_os == "linux") {
command = "cp -afd {{source}} {{output}}"
}
description = "COPY {{source}} {{output}}"
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册