Kati generates a shell script to run ninja, but that makes it difficult
to customize the ninja command line. Switch to sourcing the new env
script and then starting ninja manually.
Change-Id: I7139290a463018ddf5e05b4d61a0d2f18b1a2247
ANDROID_GOALS: any Android goals that need to be built.
KATI_GOALS: goals that we need to pass to Kati.
NINJA_GOALS: goals we need to pass to Ninja.
For modifier Android goals (dist, INTERNAL_MODIFIER_TARGETS),
we don't need to pass them to Ninja. See also commit
80e46c7c5c.
Restore the dist rule removed by the above commit.
Previously "droid" was never passed to Ninja. That's incorrect.
"make droid docs" should build both docs and droiod.
Fixed with this change.
Change-Id: I5c28061fe0ebe7848872ee349056d029b787ff71
When searching device, product, or hardware, allow
find to follow symlinks.
Add KATI_EMULATE_FIND=false to allow disabling the find
emulator which changes findleaves.py behavior wrt
symlinks.
BUG=24605247
TEST=works with CL:783781 (without the find wrapper in that CL)
Change-Id: Ia9d0e4add391a56f34828a09a6cec3f435ccc548
make 3.81 has a bug where combining an up-to-date .INTERMEDIATE rule
with -j causes an infinite loop (http://savannah.gnu.org/bugs/?15919).
.INTERMEDIATE was only necessary to support multiple outputs while only
running a command once, remove .INTERMEDIATE by replacing
$(KATI_OUTPUTS) dependencies with $(KATI_BUILD_NINJA). We can assume
that $(KATI_NINJA_SH) will be updated at the same time as
$(KATI_BUILD_NINJA), and not explicitly depend on it.
Also remove generateonly and fastincremental, which are no longer
necessary and were overcomplicating ninja.mk. kati now always runs due
to FORCE, and ninja is run by a phony rule that depends on
$(KATI_BUILD_NINJA).
Bug: 25344116
Change-Id: I99d2713b1532ea11d83da9a11b1be26cfe13a5d2
6ff74ce8ee
should have made this workaround unnecessary. Now, even with
old build/core, "m -j32 PRODUCT-aosp_mips64-eng dist" does not
output a ninja file with "$(cat )".
Bug: 24384320
Change-Id: I262edf00dce39f39ec4e55d5ed7b1b6f8d931f33
We should pass --gen_all_targets to have targets which are not declared
as .PHONY. However, this triggers some nasty behavior inherited from
make, where targets can get variables from things that depend on them.
--gen_all_targets will traverse the targets starting at random points in
the dependency tree, and any variables set higher in the tree will not
be visible. To work around this, keep --gen_all_phony_targets, which
will start traversing at the phony targets first. This will enter the
tree traversal at points we know don't use inherited variables, like
checkbuild or the PARSE_TIME_MAKE_GOALS, and will reach all the
dependencies that use inherited variables in the right order.
--gen_all_targets will then fill in any remaining targets that were not
in the main dependency tree, and hopefully none of them use any
inherited variables.
Bug: 24384320
Change-Id: I1ff07b7ef26e9481baae678e7fe0933b6d05f2a7
Move the ninja files from $(PRODUCT_OUT)/build.ninja to
$(OUT_DIR)/build-$(TARGET_PRODUCT).ninja. This will improve incremental
builds of host modules after swithing target products, because the
.ninja_deps file will be accurate across builds.
Change-Id: Ia12746ccde0de31f6fccd111b2bdbd48fc6900d7
After 3ad3549519 (Don't add CFLAGS to
CPPFLAGS), makeparallel now needs to explicitly include CFLAGS like
kati.
Change-Id: Ib50328da147f03647bb5b99f6d69948d644eece9
dist is a strange dual-use target, as both a flag and a goal. make dist
<target> means build <target>, but copy any dist-for-goals files to
$DIST_DIR. make dist without a target means build droid with
dist-for-goals files. This requires special handling of MAKECMDGOALS to
detect the case where dist is the only goal, which breaks when ninja.mk
doesn't pass all the goals to kati. Instead, let ninja handle the
default goal. Pass dist to kati if it is specified in order to turn on
the dist-for-goal rules, but filter it out of the goals passed to
ninja. If there are any other goals, ninja will build them. If there
are no goals, ninja will fall back to the default goal, which is droid.
Change-Id: Iafb184d28cb312cb7c5682cd3ff4f310b2d9f7e9
--gen_all_targets seems to be dropping some intermediate targets,
causing problems when kati is passed a goal and then ninja is run with
checkbuild as a goal, for example with:
m -j PRODUCT-aosp_flounder-userdebug checkbuild
This reverts commit 92bbf5667d.
Change-Id: If34a790028f8da98fcc713e3f7000d06c63dcf80
This isn't actually necessary, dist doesn't use MAKEDISTGOALS other than
to check if it contains any other real targets. The real issue is
caused by --gen_all_targets, and is broader than just "dist".
This reverts commit d3701e9e96.
Change-Id: Iaea1f158dbd1d4b9035954efef40b33485e6c6b3
We should pass --gen_all_targets instead of --gen_all_phony_targets
to have targets which are not declared as .PHONY.
Bug: 24384320
Change-Id: I616d8c74e6efd9d69b1a935cfc5116b716f100ff
Only goals that modify the parsing need to be passed to kati, filter out
everything else and only pass it to ninja.
Also, always specify --gen_all_phony_targets. With this flag, kati emits
all phony targets in the ninja file so a ninja file generated only with
PARSE_TIME_MAKE_GOALS can handle targets which don't change the parsing.
This is a reland attempt of
https://android-review.googlesource.com/#/c/172800/
The two issues should have been fixed by Ying in internal trees.
Bug: 24339367
Change-Id: I8ba2254f9bff271da2a7aa7684fd3d987e07c9d3
Distinguish between parsing makefiles in make for a pre-ninja build,
parsing makefiles in kati for a ninja build, and parsing makefiles in
make for a non-ninja build by leaving USE_NINJA=true enabled for the
kati pass but also setting BUILDING_WITH_NINJA.
Change-Id: I63f1ce1efe08cd86fdf41f8051901f720b38cfaf
The tests goal is not a parse time goal.
The checkbuild goal is only a parse time goal so that it doesn't result
in a circular dependency between droid and checkbuild when
ANDROID_BUILD_EVERYTHING_BY_DEFAULT is set. Get rid of the circular
dependency by making droid depend on droid_targets, and droid_targets
depend on the targets that are normally built for droid. checkbuild can
then always depend on droid_targets, and droid can condtionally depend
on checkbuild without introducing a circular dependency.
Bug: 24413153
Change-Id: I231d80e05ffe321384a5efbcdf5578f86ad84da0
Only goals that modify the parsing need to be passed to kati, filter out
everything else and only pass it to ninja.
Also, always specify --gen_all_phony_targets. With this flag, kati emits
all phony targets in the ninja file so a ninja file generated only with
PARSE_TIME_MAKE_GOALS can handle targets which don't change the parsing.
Bug: 24339367
Change-Id: I63237160c3c86817b53635665d56906790ec4e6a
We had fixed the filtering of %tests in art/Android.mk.
Actually the %tests leads to false build<suffix>.ninja when you run:
$ mmma cts/tests/tests/nativeopengl/libnativeopengltests
because the new mmma calls make with goals like
MODULES-IN/cts/tests/tests/nativeopengl/libnativeopengltests .
Bug: 24309760
Change-Id: I35af2e8d046ae40f3b90ec0a92473fcab8ff5db5
User can overwrite NINJA_REMOTE_NUM_JOBS for this purpose. The
number is passed to ninja instead of to kati so no we don't
need to regenerate a ninja file when a user changes this value.
Change-Id: I2ccfaaae4492d84a8b8045dff612cb5f6ebe2c79
Except for kati, we never use COMMON_GLOBAL_CPPFLAGS without also using
COMMON_GLOBAL_CFLAGS, which leads to duplicate command line entries.
Change-Id: I25d625924e9d157175a9e88bc3f15b7214cfb4ed
If there are any goals on the command line, kati hides targets that are
not dependencies of those goals. Revert this until kati is modified to
include all targets.
This reverts commit b71d24931c.
Bug: 24339367
Change-Id: I7c3a950aef8efc9a0eb72bd29ee07710d2faca99
Use md5sum as the build.ninja filename suffix if the suffix is longer
than 64 characters. Also store the original suffix in a corresponding
.suf file for human lookup.
This fixes the "File name too long" error when kati tries to write to
build.ninja with the long original suffix.
Bug: 24302576
Change-Id: Ie04b0c14e1a9d593aa5c2a6b357b19a9e8a7158e
Only goals that modify the parsing need to be passed to kati, filter out
everything else and only pass it to ninja.
Change-Id: I28788a3409d601fe838749bcf15394bc8f3d775b
When parallelism is being handled by ninja, pass --ninja to makeparallel
to have it translate -j with no number to default ninja parallelism, and
-k to -k0.
Bug: 24199503
Change-Id: Ic1be7572f93b33e4a71ed23e9e73dea1d4255703
For some special targets (PRODUCT-%), the MAKECMDGOALS variable is
modified. Before this change, using one would result in a "no rule to
make target" error, since the new target was not stubbed out.
Change-Id: I879642a48b84a66789d4bdb7db1b6fd1130819b7
When USE_NINJA=true is set, use makeparallel to claim all jobs from make and
pass them to ninja with -j. If USE_GOMA is set, pass the -j flag to
kati instead so the parallelism can be set in the local_pool instead.
Change-Id: I6e4f957c65683b74533ecb6d33e25de858922823
$(PARSE_TIME_MAKE_GOALS) is a list of known goals which affect
parsing of make (e.g., there is $(filter XXX,$(MAKECMDGOALS))).
If the make targets contain one of them, we keep using a
different build.ninja for each combination of make targets.
Otherwise, we use the same build.ninja which has all phony
targets.
Also load vendor/google/build/ninja_config.mk so it can add
Google-specific goals to $(PARSE_TIME_MAKE_GOALS).
Bug: 23685536
Change-Id: I3da5c76fa7644a05a55c374a754212f4fb794818
This fixes two issues:
- Switching make target didn't work well when the latter
make target is not a subset of the first make target.
- Switching between m and mm/mmm forced build.ninja to be
regenerated.
Bug: 23685536
Change-Id: I3c3550d6cca3007d166a13367d6bc22cc3feede2
With USE_GOMA, the path to gomacc in $GOMA_DIR or $HOME/goma
will be appended to CC_WRAPPER and CXX_WRAPPER.
Note this works only with USE_NINJA. Unlike ninja, GNU make
cannot change the parallelism depending on targets. Specifying
-j500 to GNU make would mean you may run 500 local jobs in
parallel, but with -j32 goma will just slow down the build.
Change-Id: I0f571454fd2a5b525ee29b445f7ab8715927ca00
* --regen
Re-generate build.ninja only when necessary. If either
1. .mk file is updated,
2. environment variable is updated,
3. $(wildcard) result is changed, or
4. $(shell) result is changed,
ckati will regenerate ninja file. This check takes only ~1
second, so incremental build will become much faster even
without "fastincremental" target.
* --ignore_dirty=out/%:
Some .mk files in out/ (e.g.,
out/target/product/generic/previous_build_config.mk)
are updated while ckati is running. With this flag, ckati
does not regenerate build.ninja when they look modified.
This should be OK for ninja based build, as ninja handles
command line changes nicely.
Change-Id: I7a2fca0e327d999599d6b16f06358e8a5e657565
The build system removes targets like "PRODUCT-full-eng" from
MAKECMDGOALS in build/core/product_config.mk.
Without this change, such target isn't passed to kati.
Change-Id: I0b3949ed1f5557445d7f5d5bd59b7875c0b2ea7f
If USE_NINJA=true, use kati to translate makefiles into ninja files,
and then execute them with ninja.
Builds kati from source using simplified versions of the rules
in binary.mk and definitions.mk.
Adds two new goals when USE_NINJA=true: generateonly will regenerate
build.ninja but not rebuild (useful for comparing build.ninja output
between runs), and fastincremental will skip regenerating build.ninja
and go directly to running ninja, providing ~5 second incremental
builds.
Change-Id: Ib85399e730f1fbb1be7371fafeee7d1c31080771