|
|
@ -32,14 +32,11 @@ from .. import compilers |
|
|
|
from ..arglist import CompilerArgs |
|
|
|
from ..arglist import CompilerArgs |
|
|
|
from ..compilers import ( |
|
|
|
from ..compilers import ( |
|
|
|
Compiler, CCompiler, |
|
|
|
Compiler, CCompiler, |
|
|
|
DmdDCompiler, |
|
|
|
|
|
|
|
FortranCompiler, |
|
|
|
FortranCompiler, |
|
|
|
LLVMDCompiler, |
|
|
|
|
|
|
|
PGICCompiler, |
|
|
|
PGICCompiler, |
|
|
|
VisualStudioCsCompiler, |
|
|
|
|
|
|
|
VisualStudioLikeCompiler, |
|
|
|
VisualStudioLikeCompiler, |
|
|
|
) |
|
|
|
) |
|
|
|
from ..linkers import ArLinker, VisualStudioLinker |
|
|
|
from ..linkers import ArLinker, RSPFileSyntax |
|
|
|
from ..mesonlib import ( |
|
|
|
from ..mesonlib import ( |
|
|
|
File, LibType, MachineChoice, MesonException, OrderedSet, PerMachine, |
|
|
|
File, LibType, MachineChoice, MesonException, OrderedSet, PerMachine, |
|
|
|
ProgressBar, quote_arg, unholder, |
|
|
|
ProgressBar, quote_arg, unholder, |
|
|
@ -51,6 +48,8 @@ from ..interpreter import Interpreter |
|
|
|
|
|
|
|
|
|
|
|
if T.TYPE_CHECKING: |
|
|
|
if T.TYPE_CHECKING: |
|
|
|
from ..linkers import StaticLinker |
|
|
|
from ..linkers import StaticLinker |
|
|
|
|
|
|
|
from ..compilers.cs import CsCompiler |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FORTRAN_INCLUDE_PAT = r"^\s*#?include\s*['\"](\w+\.\w+)['\"]" |
|
|
|
FORTRAN_INCLUDE_PAT = r"^\s*#?include\s*['\"](\w+\.\w+)['\"]" |
|
|
|
FORTRAN_MODULE_PAT = r"^\s*\bmodule\b\s+(\w+)\s*(?:!+.*)*$" |
|
|
|
FORTRAN_MODULE_PAT = r"^\s*\bmodule\b\s+(\w+)\s*(?:!+.*)*$" |
|
|
@ -92,12 +91,6 @@ else: |
|
|
|
rmfile_prefix = ['rm', '-f', '{}', '&&'] |
|
|
|
rmfile_prefix = ['rm', '-f', '{}', '&&'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dlang_cl_rsp(compiler: Compiler) -> bool: |
|
|
|
|
|
|
|
'''Return whether the D compiler accepts cl style RSP quote''' |
|
|
|
|
|
|
|
return (isinstance(compiler, DmdDCompiler) or |
|
|
|
|
|
|
|
mesonlib.is_windows() and isinstance(compiler, LLVMDCompiler)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_rsp_threshold(): |
|
|
|
def get_rsp_threshold(): |
|
|
|
'''Return a conservative estimate of the commandline size in bytes |
|
|
|
'''Return a conservative estimate of the commandline size in bytes |
|
|
|
above which a response file should be used. May be overridden for |
|
|
|
above which a response file should be used. May be overridden for |
|
|
@ -183,7 +176,7 @@ class NinjaComment: |
|
|
|
class NinjaRule: |
|
|
|
class NinjaRule: |
|
|
|
def __init__(self, rule, command, args, description, |
|
|
|
def __init__(self, rule, command, args, description, |
|
|
|
rspable = False, deps = None, depfile = None, extra = None, |
|
|
|
rspable = False, deps = None, depfile = None, extra = None, |
|
|
|
rspfile_quote_style = 'gcc'): |
|
|
|
rspfile_quote_style: RSPFileSyntax = RSPFileSyntax.GCC): |
|
|
|
|
|
|
|
|
|
|
|
def strToCommandArg(c): |
|
|
|
def strToCommandArg(c): |
|
|
|
if isinstance(c, NinjaCommandArg): |
|
|
|
if isinstance(c, NinjaCommandArg): |
|
|
@ -217,7 +210,7 @@ class NinjaRule: |
|
|
|
self.rspable = rspable # if a rspfile can be used |
|
|
|
self.rspable = rspable # if a rspfile can be used |
|
|
|
self.refcount = 0 |
|
|
|
self.refcount = 0 |
|
|
|
self.rsprefcount = 0 |
|
|
|
self.rsprefcount = 0 |
|
|
|
self.rspfile_quote_style = rspfile_quote_style # rspfile quoting style is 'gcc' or 'cl' |
|
|
|
self.rspfile_quote_style = rspfile_quote_style |
|
|
|
|
|
|
|
|
|
|
|
if self.depfile == '$DEPFILE': |
|
|
|
if self.depfile == '$DEPFILE': |
|
|
|
self.depfile += '_UNQUOTED' |
|
|
|
self.depfile += '_UNQUOTED' |
|
|
@ -235,7 +228,7 @@ class NinjaRule: |
|
|
|
return ninja_quote(qf(str(x))) |
|
|
|
return ninja_quote(qf(str(x))) |
|
|
|
|
|
|
|
|
|
|
|
def write(self, outfile): |
|
|
|
def write(self, outfile): |
|
|
|
if self.rspfile_quote_style == 'cl': |
|
|
|
if self.rspfile_quote_style is RSPFileSyntax.MSVC: |
|
|
|
rspfile_quote_func = cmd_quote |
|
|
|
rspfile_quote_func = cmd_quote |
|
|
|
else: |
|
|
|
else: |
|
|
|
rspfile_quote_func = gcc_rsp_quote |
|
|
|
rspfile_quote_func = gcc_rsp_quote |
|
|
@ -395,7 +388,7 @@ class NinjaBuildElement: |
|
|
|
outfile.write(line) |
|
|
|
outfile.write(line) |
|
|
|
|
|
|
|
|
|
|
|
if use_rspfile: |
|
|
|
if use_rspfile: |
|
|
|
if self.rule.rspfile_quote_style == 'cl': |
|
|
|
if self.rule.rspfile_quote_style is RSPFileSyntax.MSVC: |
|
|
|
qf = cmd_quote |
|
|
|
qf = cmd_quote |
|
|
|
else: |
|
|
|
else: |
|
|
|
qf = gcc_rsp_quote |
|
|
|
qf = gcc_rsp_quote |
|
|
@ -1872,7 +1865,7 @@ int dummy; |
|
|
|
pool = None |
|
|
|
pool = None |
|
|
|
self.add_rule(NinjaRule(rule, cmdlist, args, description, |
|
|
|
self.add_rule(NinjaRule(rule, cmdlist, args, description, |
|
|
|
rspable=static_linker.can_linker_accept_rsp(), |
|
|
|
rspable=static_linker.can_linker_accept_rsp(), |
|
|
|
rspfile_quote_style='cl' if isinstance(static_linker, VisualStudioLinker) else 'gcc', |
|
|
|
rspfile_quote_style=static_linker.rsp_file_syntax(), |
|
|
|
extra=pool)) |
|
|
|
extra=pool)) |
|
|
|
|
|
|
|
|
|
|
|
def generate_dynamic_link_rules(self): |
|
|
|
def generate_dynamic_link_rules(self): |
|
|
@ -1895,8 +1888,7 @@ int dummy; |
|
|
|
pool = None |
|
|
|
pool = None |
|
|
|
self.add_rule(NinjaRule(rule, command, args, description, |
|
|
|
self.add_rule(NinjaRule(rule, command, args, description, |
|
|
|
rspable=compiler.can_linker_accept_rsp(), |
|
|
|
rspable=compiler.can_linker_accept_rsp(), |
|
|
|
rspfile_quote_style='cl' if (compiler.get_argument_syntax() == 'msvc' or |
|
|
|
rspfile_quote_style=compiler.rsp_file_syntax(), |
|
|
|
dlang_cl_rsp(compiler)) else 'gcc', |
|
|
|
|
|
|
|
extra=pool)) |
|
|
|
extra=pool)) |
|
|
|
|
|
|
|
|
|
|
|
args = self.environment.get_build_command() + \ |
|
|
|
args = self.environment.get_build_command() + \ |
|
|
@ -1918,14 +1910,14 @@ int dummy; |
|
|
|
description = 'Compiling Java object $in' |
|
|
|
description = 'Compiling Java object $in' |
|
|
|
self.add_rule(NinjaRule(rule, command, [], description)) |
|
|
|
self.add_rule(NinjaRule(rule, command, [], description)) |
|
|
|
|
|
|
|
|
|
|
|
def generate_cs_compile_rule(self, compiler): |
|
|
|
def generate_cs_compile_rule(self, compiler: 'CsCompiler') -> None: |
|
|
|
rule = self.compiler_to_rule_name(compiler) |
|
|
|
rule = self.compiler_to_rule_name(compiler) |
|
|
|
command = compiler.get_exelist() |
|
|
|
command = compiler.get_exelist() |
|
|
|
args = ['$ARGS', '$in'] |
|
|
|
args = ['$ARGS', '$in'] |
|
|
|
description = 'Compiling C Sharp target $out' |
|
|
|
description = 'Compiling C Sharp target $out' |
|
|
|
self.add_rule(NinjaRule(rule, command, args, description, |
|
|
|
self.add_rule(NinjaRule(rule, command, args, description, |
|
|
|
rspable=mesonlib.is_windows(), |
|
|
|
rspable=mesonlib.is_windows(), |
|
|
|
rspfile_quote_style='cl' if isinstance(compiler, VisualStudioCsCompiler) else 'gcc')) |
|
|
|
rspfile_quote_style=compiler.rsp_file_syntax())) |
|
|
|
|
|
|
|
|
|
|
|
def generate_vala_compile_rules(self, compiler): |
|
|
|
def generate_vala_compile_rules(self, compiler): |
|
|
|
rule = self.compiler_to_rule_name(compiler) |
|
|
|
rule = self.compiler_to_rule_name(compiler) |
|
|
@ -2019,8 +2011,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) |
|
|
|
depfile = '$DEPFILE' |
|
|
|
depfile = '$DEPFILE' |
|
|
|
self.add_rule(NinjaRule(rule, command, args, description, |
|
|
|
self.add_rule(NinjaRule(rule, command, args, description, |
|
|
|
rspable=compiler.can_linker_accept_rsp(), |
|
|
|
rspable=compiler.can_linker_accept_rsp(), |
|
|
|
rspfile_quote_style='cl' if (compiler.get_argument_syntax() == 'msvc' or |
|
|
|
rspfile_quote_style=compiler.rsp_file_syntax(), |
|
|
|
dlang_cl_rsp(compiler)) else 'gcc', |
|
|
|
|
|
|
|
deps=deps, depfile=depfile)) |
|
|
|
deps=deps, depfile=depfile)) |
|
|
|
|
|
|
|
|
|
|
|
def generate_pch_rule_for(self, langname, compiler): |
|
|
|
def generate_pch_rule_for(self, langname, compiler): |
|
|
|