mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:57:45 +00:00
Meta: Add serenity toolchain to gn build
This commit is contained in:
parent
f8e1544f41
commit
f4e37c8ad4
5 changed files with 77 additions and 11 deletions
|
@ -142,6 +142,7 @@ config("compiler_defaults") {
|
||||||
if (sysroot != "") {
|
if (sysroot != "") {
|
||||||
if (current_os != "mac" && current_os != "android") {
|
if (current_os != "mac" && current_os != "android") {
|
||||||
cflags += [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
|
cflags += [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
|
||||||
|
ldflags += [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
31
Meta/gn/build/serenity_target.gni
Normal file
31
Meta/gn/build/serenity_target.gni
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
declare_args() {
|
||||||
|
# Serenity architecture to build for
|
||||||
|
serenity_arch = "x86_64"
|
||||||
|
|
||||||
|
# Serenity compiler to use, Clang or GNU
|
||||||
|
serenity_toolchain = "GNU"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serenity_toolchain == "GNU") {
|
||||||
|
toolchain_root =
|
||||||
|
rebase_path("//Toolchain/Local/$serenity_arch/", root_build_dir)
|
||||||
|
toolchain_bin = toolchain_root + "bin/"
|
||||||
|
|
||||||
|
serenity_cc = toolchain_bin + serenity_arch + "-pc-serenity-gcc"
|
||||||
|
serenity_cxx = toolchain_bin + serenity_arch + "-pc-serenity-g++"
|
||||||
|
serenity_ld = serenity_cxx
|
||||||
|
serenity_nm = toolchain_bin + serenity_arch + "-pc-serenity-nm"
|
||||||
|
serenity_objcopy = toolchain_bin + serenity_arch + "-pc-serenity-objcopy"
|
||||||
|
serenity_compiler_version = "13.1.0"
|
||||||
|
} else {
|
||||||
|
assert(serenity_toolchain == "Clang",
|
||||||
|
"Expected GNU or Clang for serenity_toolchain")
|
||||||
|
toolchain_root = rebase_path("//Toolchain/Local/clang/", root_build_dir)
|
||||||
|
toolchain_bin = toolchain_root + "bin/"
|
||||||
|
serenity_cc = toolchain_bin + serenity_arch + "-pc-serenity-clang"
|
||||||
|
serenity_cxx = toolchain_bin + serenity_arch + "-pc-serenity-clang++"
|
||||||
|
serenity_ld = serenity_cxx
|
||||||
|
serenity_nm = toolchain_bin + "llvm-nm"
|
||||||
|
serenity_objcopy = toolchain_bin + "llvm-objcopy"
|
||||||
|
serenity_compiler_version = "16"
|
||||||
|
}
|
|
@ -1,4 +1,7 @@
|
||||||
declare_args() {
|
declare_args() {
|
||||||
# Path of sysroot to use.
|
# Path of sysroot to use.
|
||||||
sysroot = ""
|
sysroot = ""
|
||||||
|
if (current_os == "serenity") {
|
||||||
|
sysroot = "$root_build_dir/Root"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import("//Meta/gn/build/serenity_target.gni")
|
||||||
|
import("//Meta/gn/build/toolchain/compiler.gni")
|
||||||
|
|
||||||
unix_copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
|
unix_copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
|
||||||
|
|
||||||
template("unix_toolchain") {
|
template("unix_toolchain") {
|
||||||
|
@ -10,6 +13,13 @@ template("unix_toolchain") {
|
||||||
forward_variables_from(invoker.toolchain_args, "*")
|
forward_variables_from(invoker.toolchain_args, "*")
|
||||||
forward_variables_from(invoker, "*")
|
forward_variables_from(invoker, "*")
|
||||||
|
|
||||||
|
not_needed([
|
||||||
|
"current_cpu",
|
||||||
|
"cc",
|
||||||
|
"is_clang",
|
||||||
|
"use_lld",
|
||||||
|
])
|
||||||
|
|
||||||
tool("cc") {
|
tool("cc") {
|
||||||
depfile = "{{output}}.d"
|
depfile = "{{output}}.d"
|
||||||
command = "$cc -MMD -MF $depfile -o {{output}} -c {{source}} {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}"
|
command = "$cc -MMD -MF $depfile -o {{output}} -c {{source}} {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}"
|
||||||
|
@ -55,11 +65,13 @@ template("unix_toolchain") {
|
||||||
description = "AR {{output}}"
|
description = "AR {{output}}"
|
||||||
outputs = [ "{{output_dir}}/{{target_output_name}}.a" ]
|
outputs = [ "{{output_dir}}/{{target_output_name}}.a" ]
|
||||||
output_prefix = "lib"
|
output_prefix = "lib"
|
||||||
if (current_os != "serenity") {
|
if (current_os == "serenity") {
|
||||||
|
default_output_dir = "{{target_out_dir}}"
|
||||||
|
} else {
|
||||||
output_prefix = "liblagom-"
|
output_prefix = "liblagom-"
|
||||||
}
|
|
||||||
default_output_dir = "{{root_out_dir}}/lib"
|
default_output_dir = "{{root_out_dir}}/lib"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Make these apply to all tools below.
|
# Make these apply to all tools below.
|
||||||
lib_switch = "-l"
|
lib_switch = "-l"
|
||||||
|
@ -77,11 +89,13 @@ template("unix_toolchain") {
|
||||||
description = "SOLINK $outfile"
|
description = "SOLINK $outfile"
|
||||||
outputs = [ outfile ]
|
outputs = [ outfile ]
|
||||||
output_prefix = "lib"
|
output_prefix = "lib"
|
||||||
if (current_os != "serenity") {
|
if (current_os == "serenity") {
|
||||||
|
default_output_dir = "{{target_out_dir}}"
|
||||||
|
} else {
|
||||||
output_prefix = "liblagom-"
|
output_prefix = "liblagom-"
|
||||||
}
|
|
||||||
default_output_dir = "{{root_out_dir}}/lib"
|
default_output_dir = "{{root_out_dir}}/lib"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tool("solink_module") {
|
tool("solink_module") {
|
||||||
outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
|
outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
|
||||||
|
@ -94,11 +108,13 @@ template("unix_toolchain") {
|
||||||
}
|
}
|
||||||
description = "SOLINK $outfile"
|
description = "SOLINK $outfile"
|
||||||
outputs = [ outfile ]
|
outputs = [ outfile ]
|
||||||
if (current_os != "serenity") {
|
if (current_os == "serenity") {
|
||||||
|
default_output_dir = "{{target_out_dir}}"
|
||||||
|
} else {
|
||||||
output_prefix = "lagom-"
|
output_prefix = "lagom-"
|
||||||
}
|
|
||||||
default_output_dir = "{{root_out_dir}}/lib"
|
default_output_dir = "{{root_out_dir}}/lib"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tool("link") {
|
tool("link") {
|
||||||
outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
|
outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
|
||||||
|
@ -110,10 +126,14 @@ template("unix_toolchain") {
|
||||||
description = "LINK $outfile"
|
description = "LINK $outfile"
|
||||||
outputs = [ outfile ]
|
outputs = [ outfile ]
|
||||||
|
|
||||||
|
if (current_os == "serenity") {
|
||||||
# Setting this allows targets to override the default executable output by
|
# Setting this allows targets to override the default executable output by
|
||||||
# setting output_dir.
|
# setting output_dir.
|
||||||
|
default_output_dir = "{{target_out_dir}}"
|
||||||
|
} else {
|
||||||
default_output_dir = "{{root_out_dir}}/bin"
|
default_output_dir = "{{root_out_dir}}/bin"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tool("copy") {
|
tool("copy") {
|
||||||
command = unix_copy_command
|
command = unix_copy_command
|
||||||
|
@ -157,4 +177,15 @@ unix_toolchain("unix") {
|
||||||
cxx = host_cxx
|
cxx = host_cxx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Note: For serenity, we can override cc and cxx etc in toolchain_args
|
|
||||||
|
unix_toolchain("serenity") {
|
||||||
|
cc = serenity_cc
|
||||||
|
cxx = serenity_cxx
|
||||||
|
ld = serenity_ld
|
||||||
|
toolchain_args = {
|
||||||
|
current_os = "serenity"
|
||||||
|
current_cpu = serenity_arch
|
||||||
|
is_clang = serenity_toolchain == "Clang"
|
||||||
|
use_lld = is_clang
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
declare_args() {
|
declare_args() {
|
||||||
# Set to true when host compiler is clang so that clang flags will be passed to it
|
# Set to true when host compiler is clang so that clang flags will be passed to it
|
||||||
is_clang = host_os == "mac"
|
is_clang = current_os == "mac"
|
||||||
|
|
||||||
# Enable setting -fuse-ld and other flags for using the lld linker.
|
# Enable setting -fuse-ld and other flags for using the lld linker.
|
||||||
# Should not be set on macOS when using the default system compiler.
|
# Should not be set on macOS when using the default system compiler.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue