MCPcopy Create free account
hub / github.com/Kitware/CMake / WriteSwiftObjectBuildStatement

Method WriteSwiftObjectBuildStatement

Source/cmNinjaTargetGenerator.cxx:1910–2109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1908}
1909
1910void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement(
1911 std::vector<cmSourceFile const*> const& sources, std::string const& config,
1912 std::string const& fileConfig, bool firstForConfig)
1913{
1914 // Swift sources are compiled as a module, not individually like with C/C++.
1915 // Flags, header search paths, and definitions are passed to the entire
1916 // module build, but we still need to emit compile-commands for each source
1917 // file in order to support CMAKE_EXPORT_COMPILE_COMMANDS.
1918 // In whole-module mode, with a single thread, the Swift compiler will
1919 // only emit a single object file, but if more than one thread is specified,
1920 // or building in other modes, the compiler will emit multiple object files.
1921 // When building a single-output, we do not provide an output-file-map (OFM),
1922 // and instead pass `-o` to tell the compiler where to write the object.
1923 // When building multiple outputs, we provide an OFM to tell the compiler
1924 // where to put each object.
1925 //
1926 //
1927 // Per-Target (module):
1928 // - Flags
1929 // - Definitions
1930 // - Include paths
1931 // - (single-output) output object filename
1932 // - Swiftmodule
1933 //
1934 // Per-File:
1935 // - compile-command
1936 // - (multi-output) OFM data
1937 // - (multi-output) output object filename
1938 //
1939 // Note: Due to the differences in the build models, we are only able to
1940 // build the object build-graph if we know what mode the target is built in.
1941 // For that, we need the "NEW" behavior for CMP0157. Otherwise, we have to
1942 // fall back on the old "linker" build. Otherwise, this should be
1943 // indistinguishable from the old behavior.
1944
1945 if (sources.empty()) {
1946 return;
1947 }
1948
1949 cmSwiftCompileMode compileMode;
1950 if (cm::optional<cmSwiftCompileMode> optionalCompileMode =
1951 this->LocalGenerator->GetSwiftCompileMode(this->GeneratorTarget,
1952 config)) {
1953 compileMode = *optionalCompileMode;
1954 } else {
1955 // CMP0157 is not NEW, bailing early!
1956 return;
1957 }
1958
1959 std::string const language = "Swift";
1960 std::string const objectDir = this->ConvertToNinjaPath(
1961 cmStrCat(this->GeneratorTarget->GetSupportDirectory(),
1962 this->GetGlobalGenerator()->ConfigDirectory(config)));
1963
1964 cmGeneratorTarget const& target = *this->GeneratorTarget;
1965 cmNinjaBuild objBuild(
1966 this->LanguageCompilerRule(language, config, WithScanning::No));
1967 cmNinjaVars& vars = objBuild.Variables;

Callers

nothing calls this directly

Calls 15

GetGlobalGeneratorMethod · 0.95
LanguageCompilerRuleMethod · 0.95
GetMakefileMethod · 0.95
GetGeneratorTargetMethod · 0.95
GetObjectFilePathMethod · 0.95
ForceResponseFileMethod · 0.95

Tested by

no test coverage detected