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
038e7716
Commit
038e7716
authored
May 14, 2016
by
Nicolas Despres
Committed by
Brad King
May 17, 2016
Browse files
Ninja: Pass all build paths through a central method
This gives us a central location to revise paths.
parent
7c26a6a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Source/cmGlobalNinjaGenerator.cxx
View file @
038e7716
...
...
@@ -488,8 +488,8 @@ void cmGlobalNinjaGenerator::Generate()
this
->
OpenBuildFileStream
();
this
->
OpenRulesFileStream
();
this
->
TargetAll
=
"all"
;
this
->
CMakeCacheFile
=
"CMakeCache.txt"
;
this
->
TargetAll
=
this
->
NinjaOutputPath
(
"all"
)
;
this
->
CMakeCacheFile
=
this
->
NinjaOutputPath
(
"CMakeCache.txt"
)
;
this
->
PolicyCMP0058
=
this
->
LocalGenerators
[
0
]
->
GetMakefile
()
->
GetPolicyStatus
(
...
...
@@ -722,6 +722,7 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path)
cmLocalNinjaGenerator
*
ng
=
static_cast
<
cmLocalNinjaGenerator
*>
(
this
->
LocalGenerators
[
0
]);
std
::
string
convPath
=
ng
->
Convert
(
path
,
cmOutputConverter
::
HOME_OUTPUT
);
convPath
=
this
->
NinjaOutputPath
(
convPath
);
#ifdef _WIN32
cmSystemTools
::
ReplaceString
(
convPath
,
"/"
,
"
\\
"
);
#endif
...
...
@@ -734,6 +735,7 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaFolderRule(
cmLocalNinjaGenerator
*
ng
=
static_cast
<
cmLocalNinjaGenerator
*>
(
this
->
LocalGenerators
[
0
]);
std
::
string
convPath
=
ng
->
Convert
(
path
+
"/all"
,
cmOutputConverter
::
HOME
);
convPath
=
this
->
NinjaOutputPath
(
convPath
);
#ifdef _WIN32
cmSystemTools
::
ReplaceString
(
convPath
,
"/"
,
"
\\
"
);
#endif
...
...
@@ -849,7 +851,7 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs(
case
cmState
::
GLOBAL_TARGET
:
// Always use the target in HOME instead of an unused duplicate in a
// subdirectory.
outputs
.
push_back
(
target
->
GetName
());
outputs
.
push_back
(
this
->
NinjaOutputPath
(
target
->
GetName
())
)
;
break
;
default:
...
...
@@ -883,6 +885,7 @@ void cmGlobalNinjaGenerator::AppendTargetDepends(
void
cmGlobalNinjaGenerator
::
AddTargetAlias
(
const
std
::
string
&
alias
,
cmGeneratorTarget
*
target
)
{
std
::
string
buildAlias
=
this
->
NinjaOutputPath
(
alias
);
cmNinjaDeps
outputs
;
this
->
AppendTargetOutputs
(
target
,
outputs
);
// Mark the target's outputs as ambiguous to ensure that no other target uses
...
...
@@ -893,7 +896,7 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
// Insert the alias into the map. If the alias was already present in the
// map and referred to another target, mark it as ambiguous.
std
::
pair
<
TargetAliasMap
::
iterator
,
bool
>
newAlias
=
TargetAliases
.
insert
(
std
::
make_pair
(
a
lias
,
target
));
TargetAliases
.
insert
(
std
::
make_pair
(
buildA
lias
,
target
));
if
(
newAlias
.
second
&&
newAlias
.
first
->
second
!=
target
)
newAlias
.
first
->
second
=
0
;
}
...
...
@@ -1182,9 +1185,10 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
variables
[
"pool"
]
=
"console"
;
}
std
::
string
const
ninjaBuildFile
=
this
->
NinjaOutputPath
(
NINJA_BUILD_FILE
);
this
->
WriteBuild
(
os
,
"Re-run CMake if any of its inputs changed."
,
"RERUN_CMAKE"
,
/*outputs=*/
cmNinjaDeps
(
1
,
NINJA_BUILD_FILE
),
/*outputs=*/
cmNinjaDeps
(
1
,
ninjaBuildFile
),
/*explicitDeps=*/
cmNinjaDeps
(),
implicitDeps
,
/*orderOnlyDeps=*/
cmNinjaDeps
(),
variables
);
...
...
@@ -1221,7 +1225,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
/*restat=*/
""
,
/*generator=*/
false
);
WriteBuild
(
os
,
"Clean all the built files."
,
"CLEAN"
,
/*outputs=*/
cmNinjaDeps
(
1
,
"clean"
),
/*outputs=*/
cmNinjaDeps
(
1
,
this
->
NinjaOutputPath
(
"clean"
)
)
,
/*explicitDeps=*/
cmNinjaDeps
(),
/*implicitDeps=*/
cmNinjaDeps
(),
/*orderOnlyDeps=*/
cmNinjaDeps
(),
...
...
@@ -1240,9 +1244,14 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os)
/*restat=*/
""
,
/*generator=*/
false
);
WriteBuild
(
os
,
"Print all primary targets available."
,
"HELP"
,
/*outputs=*/
cmNinjaDeps
(
1
,
"help"
),
/*outputs=*/
cmNinjaDeps
(
1
,
this
->
NinjaOutputPath
(
"help"
)
)
,
/*explicitDeps=*/
cmNinjaDeps
(),
/*implicitDeps=*/
cmNinjaDeps
(),
/*orderOnlyDeps=*/
cmNinjaDeps
(),
/*variables=*/
cmNinjaVars
());
}
std
::
string
cmGlobalNinjaGenerator
::
NinjaOutputPath
(
std
::
string
const
&
path
)
{
return
path
;
}
Source/cmGlobalNinjaGenerator.h
View file @
038e7716
...
...
@@ -314,6 +314,8 @@ public:
static
std
::
string
RequiredNinjaVersionForConsolePool
()
{
return
"1.5"
;
}
bool
SupportsConsolePool
()
const
;
std
::
string
NinjaOutputPath
(
std
::
string
const
&
path
);
protected:
virtual
void
Generate
();
...
...
Source/cmLocalNinjaGenerator.cxx
View file @
038e7716
...
...
@@ -225,8 +225,13 @@ void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os)
cmGlobalNinjaGenerator
::
WriteDivider
(
os
);
os
<<
"# Include auxiliary files.
\n
"
<<
"
\n
"
;
cmGlobalNinjaGenerator
::
WriteInclude
(
os
,
cmGlobalNinjaGenerator
::
NINJA_RULES_FILE
,
"Include rules file."
);
cmGlobalNinjaGenerator
*
ng
=
this
->
GetGlobalNinjaGenerator
();
std
::
string
const
ninjaRulesFile
=
ng
->
NinjaOutputPath
(
cmGlobalNinjaGenerator
::
NINJA_RULES_FILE
);
std
::
string
const
rulesFilePath
=
ng
->
EncodeIdent
(
ng
->
EncodePath
(
ninjaRulesFile
),
os
);
cmGlobalNinjaGenerator
::
WriteInclude
(
os
,
rulesFilePath
,
"Include rules file."
);
os
<<
"
\n
"
;
}
...
...
Source/cmNinjaUtilityTargetGenerator.cxx
View file @
038e7716
...
...
@@ -33,6 +33,8 @@ void cmNinjaUtilityTargetGenerator::Generate()
{
std
::
string
utilCommandName
=
cmake
::
GetCMakeFilesDirectoryPostSlash
();
utilCommandName
+=
this
->
GetTargetName
()
+
".util"
;
utilCommandName
=
this
->
GetGlobalGenerator
()
->
NinjaOutputPath
(
utilCommandName
);
std
::
vector
<
std
::
string
>
commands
;
cmNinjaDeps
deps
,
outputs
,
util_outputs
(
1
,
utilCommandName
);
...
...
Brad King
@brad.king
mentioned in commit
e0da6c3b
·
May 19, 2016
mentioned in commit
e0da6c3b
mentioned in commit e0da6c3b562f7fd25b83b00c432f016439c24c22
Toggle commit list
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