Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CMake
CMake
Commits
80de856b
Commit
80de856b
authored
Oct 18, 2015
by
Stephen Kelly
Browse files
Ninja: Port to cmGeneratorTarget.
parent
4c41e74d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Source/cmGlobalNinjaGenerator.cxx
View file @
80de856b
...
...
@@ -886,7 +886,7 @@ void cmGlobalNinjaGenerator::WriteDisclaimer(std::ostream& os)
<<
cmVersion
::
GetMinorVersion
()
<<
"
\n\n
"
;
}
void
cmGlobalNinjaGenerator
::
AddDependencyToAll
(
cmTarget
*
target
)
void
cmGlobalNinjaGenerator
::
AddDependencyToAll
(
cm
Generator
Target
*
target
)
{
this
->
AppendTargetOutputs
(
target
,
this
->
AllDependencies
);
}
...
...
@@ -912,18 +912,16 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies()
void
cmGlobalNinjaGenerator
::
AppendTargetOutputs
(
cmTarget
const
*
target
,
cmNinjaDeps
&
outputs
)
::
AppendTargetOutputs
(
cm
Generator
Target
const
*
target
,
cmNinjaDeps
&
outputs
)
{
std
::
string
configName
=
target
->
GetMakefile
()
->
GetSafeDefinition
(
"CMAKE_BUILD_TYPE"
);
cmGeneratorTarget
*
gtgt
=
this
->
GetGeneratorTarget
(
target
);
target
->
Target
->
GetMakefile
()
->
GetSafeDefinition
(
"CMAKE_BUILD_TYPE"
);
// for frameworks, we want the real name, not smple name
// frameworks always appear versioned, and the build.ninja
// will always attempt to manage symbolic links instead
// of letting cmOSXBundleGenerator do it.
bool
realname
=
gtg
t
->
IsFrameworkOnApple
();
bool
realname
=
targe
t
->
IsFrameworkOnApple
();
switch
(
target
->
GetType
())
{
case
cmState
::
EXECUTABLE
:
...
...
@@ -932,7 +930,7 @@ cmGlobalNinjaGenerator
case
cmState
::
MODULE_LIBRARY
:
{
outputs
.
push_back
(
this
->
ConvertToNinjaPath
(
gtg
t
->
GetFullPath
(
configName
,
false
,
realname
)));
targe
t
->
GetFullPath
(
configName
,
false
,
realname
)));
break
;
}
case
cmState
::
OBJECT_LIBRARY
:
...
...
@@ -962,16 +960,15 @@ cmGlobalNinjaGenerator
void
cmGlobalNinjaGenerator
::
AppendTargetDepends
(
cmTarget
const
*
target
,
cmNinjaDeps
&
outputs
)
::
AppendTargetDepends
(
cm
Generator
Target
const
*
target
,
cmNinjaDeps
&
outputs
)
{
if
(
target
->
GetType
()
==
cmState
::
GLOBAL_TARGET
)
{
// Global targets only depend on other utilities, which may not appear in
// the TargetDepends set (e.g. "all").
std
::
set
<
std
::
string
>
const
&
utils
=
target
->
GetUtilities
();
std
::
set
<
std
::
string
>
const
&
utils
=
target
->
Target
->
GetUtilities
();
std
::
copy
(
utils
.
begin
(),
utils
.
end
(),
std
::
back_inserter
(
outputs
));
}
else
{
cmGeneratorTarget
*
gt
=
this
->
GetGeneratorTarget
(
target
);
cmTargetDependSet
const
&
targetDeps
=
this
->
GetTargetDirectDepends
(
gt
);
cmTargetDependSet
const
&
targetDeps
=
this
->
GetTargetDirectDepends
(
target
);
for
(
cmTargetDependSet
::
const_iterator
i
=
targetDeps
.
begin
();
i
!=
targetDeps
.
end
();
++
i
)
{
...
...
@@ -979,13 +976,13 @@ cmGlobalNinjaGenerator
{
continue
;
}
this
->
AppendTargetOutputs
(
(
*
i
)
->
Target
,
outputs
);
this
->
AppendTargetOutputs
(
*
i
,
outputs
);
}
}
}
void
cmGlobalNinjaGenerator
::
AddTargetAlias
(
const
std
::
string
&
alias
,
cmTarget
*
target
)
{
cm
Generator
Target
*
target
)
{
cmNinjaDeps
outputs
;
this
->
AppendTargetOutputs
(
target
,
outputs
);
// Mark the target's outputs as ambiguous to ensure that no other target uses
...
...
Source/cmGlobalNinjaGenerator.h
View file @
80de856b
...
...
@@ -285,9 +285,11 @@ public:
ASD
.
insert
(
deps
.
begin
(),
deps
.
end
());
}
void
AppendTargetOutputs
(
cmTarget
const
*
target
,
cmNinjaDeps
&
outputs
);
void
AppendTargetDepends
(
cmTarget
const
*
target
,
cmNinjaDeps
&
outputs
);
void
AddDependencyToAll
(
cmTarget
*
target
);
void
AppendTargetOutputs
(
cmGeneratorTarget
const
*
target
,
cmNinjaDeps
&
outputs
);
void
AppendTargetDepends
(
cmGeneratorTarget
const
*
target
,
cmNinjaDeps
&
outputs
);
void
AddDependencyToAll
(
cmGeneratorTarget
*
target
);
void
AddDependencyToAll
(
const
std
::
string
&
input
);
const
std
::
vector
<
cmLocalGenerator
*>&
GetLocalGenerators
()
const
{
...
...
@@ -299,7 +301,7 @@ public:
int
GetRuleCmdLength
(
const
std
::
string
&
name
)
{
return
RuleCmdLength
[
name
];
}
void
AddTargetAlias
(
const
std
::
string
&
alias
,
cmTarget
*
target
);
void
AddTargetAlias
(
const
std
::
string
&
alias
,
cm
Generator
Target
*
target
);
virtual
void
ComputeTargetObjectDirectory
(
cmGeneratorTarget
*
gt
)
const
;
...
...
@@ -388,7 +390,7 @@ private:
/// The mapping from source file to assumed dependencies.
std
::
map
<
std
::
string
,
std
::
set
<
std
::
string
>
>
AssumedSourceDependencies
;
typedef
std
::
map
<
std
::
string
,
cmTarget
*>
TargetAliasMap
;
typedef
std
::
map
<
std
::
string
,
cm
Generator
Target
*>
TargetAliasMap
;
TargetAliasMap
TargetAliases
;
};
...
...
Source/cmLocalNinjaGenerator.cxx
View file @
80de856b
...
...
@@ -89,7 +89,7 @@ void cmLocalNinjaGenerator::Generate()
if
(
!
this
->
GetGlobalNinjaGenerator
()
->
IsExcluded
(
this
->
GetGlobalNinjaGenerator
()
->
GetLocalGenerators
()[
0
],
*
t
))
this
->
GetGlobalNinjaGenerator
()
->
AddDependencyToAll
(
(
*
t
)
->
Targe
t
);
this
->
GetGlobalNinjaGenerator
()
->
AddDependencyToAll
(
*
t
);
delete
tg
;
}
}
...
...
@@ -285,14 +285,14 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
void
cmLocalNinjaGenerator
::
AppendTargetOutputs
(
cmTarget
*
target
,
cmNinjaDeps
&
outputs
)
::
AppendTargetOutputs
(
cm
Generator
Target
*
target
,
cmNinjaDeps
&
outputs
)
{
this
->
GetGlobalNinjaGenerator
()
->
AppendTargetOutputs
(
target
,
outputs
);
}
void
cmLocalNinjaGenerator
::
AppendTargetDepends
(
cmTarget
*
target
,
cmNinjaDeps
&
outputs
)
::
AppendTargetDepends
(
cm
Generator
Target
*
target
,
cmNinjaDeps
&
outputs
)
{
this
->
GetGlobalNinjaGenerator
()
->
AppendTargetDepends
(
target
,
outputs
);
}
...
...
@@ -441,7 +441,7 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
}
void
cmLocalNinjaGenerator
::
AddCustomCommandTarget
(
cmCustomCommand
const
*
cc
,
cmTarget
*
target
)
cm
Generator
Target
*
target
)
{
this
->
CustomCommandTargets
[
cc
].
insert
(
target
);
}
...
...
@@ -459,7 +459,7 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements()
//
// FIXME: This won't work in certain obscure scenarios involving indirect
// dependencies.
std
::
set
<
cmTarget
*>::
iterator
j
=
i
->
second
.
begin
();
std
::
set
<
cm
Generator
Target
*>::
iterator
j
=
i
->
second
.
begin
();
assert
(
j
!=
i
->
second
.
end
());
std
::
vector
<
std
::
string
>
ccTargetDeps
;
this
->
AppendTargetDepends
(
*
j
,
ccTargetDeps
);
...
...
Source/cmLocalNinjaGenerator.h
View file @
80de856b
...
...
@@ -58,10 +58,11 @@ public:
std
::
string
BuildCommandLine
(
const
std
::
vector
<
std
::
string
>
&
cmdLines
);
void
AppendTargetOutputs
(
cmTarget
*
target
,
cmNinjaDeps
&
outputs
);
void
AppendTargetDepends
(
cmTarget
*
target
,
cmNinjaDeps
&
outputs
);
void
AppendTargetOutputs
(
cm
Generator
Target
*
target
,
cmNinjaDeps
&
outputs
);
void
AppendTargetDepends
(
cm
Generator
Target
*
target
,
cmNinjaDeps
&
outputs
);
void
AddCustomCommandTarget
(
cmCustomCommand
const
*
cc
,
cmTarget
*
target
);
void
AddCustomCommandTarget
(
cmCustomCommand
const
*
cc
,
cmGeneratorTarget
*
target
);
void
AppendCustomCommandLines
(
cmCustomCommandGenerator
const
&
ccg
,
std
::
vector
<
std
::
string
>
&
cmdLines
);
void
AppendCustomCommandDeps
(
cmCustomCommandGenerator
const
&
ccg
,
...
...
@@ -102,7 +103,7 @@ private:
std
::
string
HomeRelativeOutputPath
;
typedef
std
::
map
<
cmCustomCommand
const
*
,
std
::
set
<
cmTarget
*>
>
typedef
std
::
map
<
cmCustomCommand
const
*
,
std
::
set
<
cm
Generator
Target
*>
>
CustomCommandTargetMap
;
CustomCommandTargetMap
CustomCommandTargets
;
};
...
...
Source/cmNinjaNormalTargetGenerator.cxx
View file @
80de856b
...
...
@@ -399,7 +399,6 @@ static int calculateCommandLineLengthLimit(int linkRuleLength)
void
cmNinjaNormalTargetGenerator
::
WriteLinkStatement
()
{
cmTarget
&
target
=
*
this
->
GetTarget
();
cmGeneratorTarget
&
gt
=
*
this
->
GetGeneratorTarget
();
const
std
::
string
cfgName
=
this
->
GetConfigName
();
std
::
string
targetOutput
=
ConvertToNinjaPath
(
...
...
@@ -443,7 +442,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// Write comments.
cmGlobalNinjaGenerator
::
WriteDivider
(
this
->
GetBuildFileStream
());
const
cmState
::
TargetType
targetType
=
targe
t
.
GetType
();
const
cmState
::
TargetType
targetType
=
g
t
.
GetType
();
this
->
GetBuildFileStream
()
<<
"# Link build statements for "
<<
cmState
::
GetTargetTypeName
(
targetType
)
...
...
@@ -490,13 +489,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
&
genTarget
,
useWatcomQuote
);
if
(
this
->
GetMakefile
()
->
IsOn
(
"CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS"
)
&&
targe
t
.
GetType
()
==
cmState
::
SHARED_LIBRARY
)
&&
g
t
.
GetType
()
==
cmState
::
SHARED_LIBRARY
)
{
if
(
targe
t
.
GetPropertyAsBool
(
"WINDOWS_EXPORT_ALL_SYMBOLS"
))
if
(
g
t
.
GetPropertyAsBool
(
"WINDOWS_EXPORT_ALL_SYMBOLS"
))
{
std
::
string
name_of_def_file
=
gt
.
GetSupportDirectory
();
name_of_def_file
+=
"/"
+
targe
t
.
GetName
();
name_of_def_file
+=
"/"
+
g
t
.
GetName
();
name_of_def_file
+=
".def "
;
vars
[
"LINK_FLAGS"
]
+=
" /DEF:"
;
vars
[
"LINK_FLAGS"
]
+=
this
->
GetLocalGenerator
()
...
...
@@ -505,7 +504,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
}
this
->
addPoolNinjaVariable
(
"JOB_POOL_LINK"
,
&
targe
t
,
vars
);
this
->
addPoolNinjaVariable
(
"JOB_POOL_LINK"
,
&
g
t
,
vars
);
this
->
AddModuleDefinitionFlag
(
vars
[
"LINK_FLAGS"
]);
vars
[
"LINK_FLAGS"
]
=
cmGlobalNinjaGenerator
...
...
@@ -599,9 +598,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
const
std
::
vector
<
cmCustomCommand
>
*
cmdLists
[
3
]
=
{
&
t
arget
.
GetPreBuildCommands
(),
&
t
arget
.
GetPreLinkCommands
(),
&
t
arget
.
GetPostBuildCommands
()
&
gt
.
T
arget
->
GetPreBuildCommands
(),
&
gt
.
T
arget
->
GetPreLinkCommands
(),
&
gt
.
T
arget
->
GetPostBuildCommands
()
};
std
::
vector
<
std
::
string
>
preLinkCmdLines
,
postBuildCmdLines
;
...
...
@@ -626,17 +625,17 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
// maybe create .def file from list of objects
if
(
targe
t
.
GetType
()
==
cmState
::
SHARED_LIBRARY
&&
if
(
g
t
.
GetType
()
==
cmState
::
SHARED_LIBRARY
&&
this
->
GetMakefile
()
->
IsOn
(
"CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS"
))
{
if
(
targe
t
.
GetPropertyAsBool
(
"WINDOWS_EXPORT_ALL_SYMBOLS"
))
if
(
g
t
.
GetPropertyAsBool
(
"WINDOWS_EXPORT_ALL_SYMBOLS"
))
{
std
::
string
cmakeCommand
=
this
->
GetLocalGenerator
()
->
ConvertToOutputFormat
(
cmSystemTools
::
GetCMakeCommand
(),
cmLocalGenerator
::
SHELL
);
std
::
string
name_of_def_file
=
gt
.
GetSupportDirectory
();
name_of_def_file
+=
"/"
+
targe
t
.
GetName
();
name_of_def_file
+=
"/"
+
g
t
.
GetName
();
name_of_def_file
+=
".def"
;
std
::
string
cmd
=
cmakeCommand
;
cmd
+=
" -E __create_def "
;
...
...
@@ -699,11 +698,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
const
std
::
string
rspfile
=
std
::
string
(
cmake
::
GetCMakeFilesDirectoryPostSlash
())
+
targe
t
.
GetName
()
+
".rsp"
;
+
g
t
.
GetName
()
+
".rsp"
;
// Gather order-only dependencies.
cmNinjaDeps
orderOnlyDeps
;
this
->
GetLocalGenerator
()
->
AppendTargetDepends
(
this
->
GetTarget
(),
this
->
GetLocalGenerator
()
->
AppendTargetDepends
(
this
->
Get
Generator
Target
(),
orderOnlyDeps
);
// Ninja should restat after linking if and only if there are byproducts.
...
...
@@ -772,8 +771,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
// Add aliases for the file name and the target name.
globalGen
.
AddTargetAlias
(
this
->
TargetNameOut
,
&
targe
t
);
globalGen
.
AddTargetAlias
(
this
->
GetTargetName
(),
&
targe
t
);
globalGen
.
AddTargetAlias
(
this
->
TargetNameOut
,
&
g
t
);
globalGen
.
AddTargetAlias
(
this
->
GetTargetName
(),
&
g
t
);
}
//----------------------------------------------------------------------------
...
...
@@ -781,7 +780,8 @@ void cmNinjaNormalTargetGenerator::WriteObjectLibStatement()
{
// Write a phony output that depends on all object files.
cmNinjaDeps
outputs
;
this
->
GetLocalGenerator
()
->
AppendTargetOutputs
(
this
->
GetTarget
(),
outputs
);
this
->
GetLocalGenerator
()
->
AppendTargetOutputs
(
this
->
GetGeneratorTarget
(),
outputs
);
cmNinjaDeps
depends
=
this
->
GetObjects
();
this
->
GetGlobalGenerator
()
->
WritePhonyBuild
(
this
->
GetBuildFileStream
(),
"Object library "
...
...
@@ -791,5 +791,5 @@ void cmNinjaNormalTargetGenerator::WriteObjectLibStatement()
// Add aliases for the target name.
this
->
GetGlobalGenerator
()
->
AddTargetAlias
(
this
->
GetTargetName
(),
this
->
GetTarget
());
this
->
Get
Generator
Target
());
}
Source/cmNinjaTargetGenerator.cxx
View file @
80de856b
...
...
@@ -486,7 +486,8 @@ cmNinjaTargetGenerator
si
!=
customCommands
.
end
();
++
si
)
{
cmCustomCommand
const
*
cc
=
(
*
si
)
->
GetCustomCommand
();
this
->
GetLocalGenerator
()
->
AddCustomCommandTarget
(
cc
,
this
->
GetTarget
());
this
->
GetLocalGenerator
()
->
AddCustomCommandTarget
(
cc
,
this
->
GetGeneratorTarget
());
// Record the custom commands for this target. The container is used
// in WriteObjectBuildStatement when called in a loop below.
this
->
CustomCommands
.
push_back
(
cc
);
...
...
@@ -511,7 +512,8 @@ cmNinjaTargetGenerator
}
cmNinjaDeps
orderOnlyDeps
;
this
->
GetLocalGenerator
()
->
AppendTargetDepends
(
this
->
Target
,
orderOnlyDeps
);
this
->
GetLocalGenerator
()
->
AppendTargetDepends
(
this
->
GeneratorTarget
,
orderOnlyDeps
);
// Add order-only dependencies on custom command outputs.
for
(
std
::
vector
<
cmCustomCommand
const
*>::
const_iterator
...
...
@@ -633,7 +635,8 @@ cmNinjaTargetGenerator
ConvertToNinjaPath
(
objectFileDir
),
cmLocalGenerator
::
SHELL
);
this
->
addPoolNinjaVariable
(
"JOB_POOL_COMPILE"
,
this
->
GetTarget
(),
vars
);
this
->
addPoolNinjaVariable
(
"JOB_POOL_COMPILE"
,
this
->
GetGeneratorTarget
(),
vars
);
this
->
SetMsvcTargetPdbVariable
(
vars
);
...
...
@@ -782,7 +785,7 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
void
cmNinjaTargetGenerator
::
addPoolNinjaVariable
(
const
std
::
string
&
pool_property
,
cmTarget
*
target
,
cm
Generator
Target
*
target
,
cmNinjaVars
&
vars
)
{
const
char
*
pool
=
target
->
GetProperty
(
pool_property
);
...
...
Source/cmNinjaTargetGenerator.h
View file @
80de856b
...
...
@@ -53,9 +53,6 @@ protected:
cmGeneratedFileStream
&
GetBuildFileStream
()
const
;
cmGeneratedFileStream
&
GetRulesFileStream
()
const
;
cmTarget
*
GetTarget
()
const
{
return
this
->
Target
;
}
cmGeneratorTarget
*
GetGeneratorTarget
()
const
{
return
this
->
GeneratorTarget
;
}
...
...
@@ -152,7 +149,7 @@ protected:
std
::
set
<
std
::
string
>
MacContentFolders
;
void
addPoolNinjaVariable
(
const
std
::
string
&
pool_property
,
cmTarget
*
target
,
cm
Generator
Target
*
target
,
cmNinjaVars
&
vars
);
private:
...
...
Source/cmNinjaUtilityTargetGenerator.cxx
View file @
80de856b
...
...
@@ -16,7 +16,6 @@
#include
"cmGlobalNinjaGenerator.h"
#include
"cmMakefile.h"
#include
"cmSourceFile.h"
#include
"cmTarget.h"
#include
"cmCustomCommandGenerator.h"
cmNinjaUtilityTargetGenerator
::
cmNinjaUtilityTargetGenerator
(
...
...
@@ -34,8 +33,8 @@ void cmNinjaUtilityTargetGenerator::Generate()
cmNinjaDeps
deps
,
outputs
,
util_outputs
(
1
,
utilCommandName
);
const
std
::
vector
<
cmCustomCommand
>
*
cmdLists
[
2
]
=
{
&
this
->
GetTarget
()
->
GetPreBuildCommands
(),
&
this
->
GetTarget
()
->
GetPostBuildCommands
()
&
this
->
Get
GeneratorTarget
()
->
Target
->
GetPreBuildCommands
(),
&
this
->
Get
GeneratorTarget
()
->
Target
->
GetPostBuildCommands
()
};
bool
uses_terminal
=
false
;
...
...
@@ -66,7 +65,8 @@ void cmNinjaUtilityTargetGenerator::Generate()
{
cmCustomCommandGenerator
ccg
(
*
cc
,
this
->
GetConfigName
(),
this
->
GetLocalGenerator
());
this
->
GetLocalGenerator
()
->
AddCustomCommandTarget
(
cc
,
this
->
GetTarget
());
this
->
GetLocalGenerator
()
->
AddCustomCommandTarget
(
cc
,
this
->
GetGeneratorTarget
());
// Depend on all custom command outputs.
const
std
::
vector
<
std
::
string
>&
ccOutputs
=
ccg
.
GetOutputs
();
...
...
@@ -78,8 +78,10 @@ void cmNinjaUtilityTargetGenerator::Generate()
}
}
this
->
GetLocalGenerator
()
->
AppendTargetOutputs
(
this
->
GetTarget
(),
outputs
);
this
->
GetLocalGenerator
()
->
AppendTargetDepends
(
this
->
GetTarget
(),
deps
);
this
->
GetLocalGenerator
()
->
AppendTargetOutputs
(
this
->
GetGeneratorTarget
(),
outputs
);
this
->
GetLocalGenerator
()
->
AppendTargetDepends
(
this
->
GetGeneratorTarget
(),
deps
);
if
(
commands
.
empty
())
{
this
->
GetGlobalGenerator
()
->
WritePhonyBuild
(
this
->
GetBuildFileStream
(),
...
...
@@ -140,5 +142,5 @@ void cmNinjaUtilityTargetGenerator::Generate()
}
this
->
GetGlobalGenerator
()
->
AddTargetAlias
(
this
->
GetTargetName
(),
this
->
GetTarget
());
this
->
Get
Generator
Target
());
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment