Commit graph

197 commits

Author SHA1 Message Date
Colin Cross
9978ffe347 Support .mm files
libchrome uses Objective C++ (.mm) files, treat them like .cc files
and pass them to g++/clang++.

Test: mmma -j external/libchrome
Change-Id: Ib9e5e82d8a9eff5f80a9fe06498a988d70ca4553
2016-12-01 15:33:16 -08:00
Dan Willemsen
21ec49068f Add subdir to GenPath
We were emulating this for proto files, standardize it and make the
other generators use it as well.

Test: Compare out/soong/build.ninja before/after change
Test: mmma -j system/tools/hidl
Change-Id: I1888c7b981749060a398387bbb9b481270bf6d75
2016-11-02 21:19:11 -07:00
Dan Willemsen
a03cf6d322 Add clang-tidy support
For every file which we can run clang-tidy (C/C++ clang-built), we add a
new build node that depends on the object file (since clang-tidy does
not export a depfile), and is depended on by the link step. This is
better than how we're doing it in make, since calling tidy can be turned
on or off without needing to rebuild the object files.

This does not attempt to port WITH_TIDY_ONLY from Make, since the way
that it works is broken (due to the lack of a depfile).

Bug: 32244182
Test: WITH_TIDY=true mmma -j bionic/libc
Test: ./soong (Setting ClangTidy: true)
Change-Id: I40bbb5bb00d292d72bf1c293b93080b5f9f6d8ea
2016-10-31 16:21:01 -07:00
Dan Willemsen
5cb580f407 Start using "struct Objects" to store object Paths
So that we can represent other files that get generated along with the
objects, like the gcno coverage information, and per-file clang-tidy
runs.

Test: Soong's build.ninja identical before/after
Change-Id: I5c553a153c436d5403549f62c73fe79c5f101779
2016-10-31 16:18:49 -07:00
Colin Cross
0c461f1f6e Add support for .proto files
.proto files are translated to .pb.cc and .pb.h files, which are then
compiled normally.

Bug: 32286026
Test: mmma -j system/extras/perfprofd
Change-Id: I538071424d667aacf35b4b8bfebe217f5f092726
2016-10-27 15:28:09 -07:00
Colin Cross
26c34ede29 Add support for toc optimization in soong
Skip relinking against shared libraries whose interface hasn't changed.

Test: mmma -j frameworks/native/libs/gui
Test: touch frameworks/native/libs/gui/BufferItem.cpp
Test: mmma -j frameworks/native/libs/gui, see nothing relinks past libgui
Bug: 26014946
Change-Id: I4d4b8da6a35c682341ae51869f5c72b51e192053
2016-09-30 21:05:59 -07:00
Dan Willemsen
27279ece28 Remove shared lib name checks
Now that we're no longer using -l, we don't need to strip off the "lib"
prefix and ".so" suffix. Therefore we don't need to make sure the prefix
and suffix exists.

Bug: 31742855
Test: Attempt to link android.hardware.* (hardware/interfaces/*)
Change-Id: I38555014cdc0e430f94359e173bb09e35d45c44e
2016-09-28 20:58:38 -07:00
Colin Cross
9d45bb78c5 Enable goma in soong
When the UseGoma flag is set, put all rules except the C compilation
rule in an externally defined local_pool, which will have been created
by kati.  The gomacc wrapper will already be in the CC_WRAPPER
environment variable.

Bug: 31142427
Change-Id: I699d4edff2e302eee398dad8692ceb14721a628c
2016-08-31 09:48:08 -07:00
Alistair Strachan
777475cb48 Add CC_WRAPPER support
Change-Id: If252c41ec1e3d708f599990c72be69dc8117ae14
2016-08-29 20:39:32 +00:00
Colin Cross
01344df46e Remove unused flags.Nocrt
Nocrt is handled through deps.CrtBegin/End, flags.Nocrt is unused

Change-Id: I8ab5313bb2eb3a00e336504d6dd3813350fbe14d
Test: soong builds
2016-08-05 10:22:29 -07:00
Colin Cross
a24166b5c7 Fix mac soong build
Change-Id: I50b3ca1af571d00a0cc5efc80c5d1c6f0b1f789b
2016-08-01 15:42:38 -07:00
Colin Cross
b98c8b0595 Move toolchain and global variables into separate package
Move all of the configuration into a cc/config package

Change-Id: If56fc7242062ed1ce3cb297f78a1e0ef7537373c
2016-08-01 13:37:01 -07:00
Dan Albert
ce2b839257 Don't add -L for libs that don't need it.
We're already referring to the library by the full path. The -L is
unnecessary.

Follow up to https://android-review.googlesource.com/#/c/249544/

Test: Still builds.
Change-Id: Id27dff29f75797c4c0dcc66704ac08cc0b58cfe3
2016-07-27 11:12:07 -07:00
Dan Albert
9840e1bf1a Use the full path to the shared lib.
Using only -lc (for example) means that in the case where we have one
library path with libc.a but no libc.so (such as prebuilts/ndk) and
another with libc.so (such as the out directory), we'll always use the
static version.

We can link shared libraries by their full path to be sure that we
always get the right library.

Change-Id: Idf5707fc4aaf9e651d7d8936611200760eab3c7c
2016-07-21 10:01:55 -07:00
Stephen Hines
1034786c37 Revert "Revert "Switch libcompiler_rt-extras to LateStaticLibs.""
This reverts commit 15e4554049.

Change-Id: Iff62dd9fd45746847440f50240c25d32747367df
2016-07-18 16:06:05 -07:00
Colin Cross
635c3b0157 Rename common to android
Rename the "common" package to "android", because common is too
generic.  Also removes all android.Android naming stutter.

Ran:
gomvpkg -from 'android/soong/common' -to 'android/soong/android'
gorename -from '"android/soong/android".AndroidModuleContext' -to 'ModuleContext'
gorename -from '"android/soong/android".AndroidBaseContext' -to 'BaseContext'
gorename -from '"android/soong/android".AndroidModuleBase' -to 'ModuleBase'
gorename -from '"android/soong/android".AndroidBottomUpMutatorContext' -to 'BottomUpMutatorContext'
gorename -from '"android/soong/android".AndroidTopDownMutatorContext' -to 'TopDownMutatorContext'
gorename -from '"android/soong/android".AndroidModule' -to 'Module'

Change-Id: I3b23590b8ce7c8a1ea1139411d84a53163288da7
2016-05-18 15:37:25 -07:00
Dan Willemsen
9f0b550a15 Create empty .a on Darwin when there is no obj file.
On Darwin ar would fail if there is no object file to add.
We work around by adding a dummy.o.

Port to Soong of build/ 4aaa1a1fd8e7eb23ac5557cd326d1a48efdb54cd

Change-Id: I68bbebea2726058c25863d7026a645a520d05167
2016-05-13 15:07:37 -07:00
Colin Cross
b8ecdfe039 Fix stripping on Darwin
The strip tool is different on Darwin, use a separate darwinStrip rule
instead of calling strip.sh for host builds on Darwin.

Change-Id: I6d421cba0dcea04367d5bc638a03f64c81e2ead0
2016-05-03 15:52:51 -07:00
Colin Cross
665dce9320 Support stripping shared libraries and binaries
Strip all shared libraries and binaries by default.  Use a shell script
to wrap the long sequences of commands needed by some strip variants.

Change-Id: I465bf7cc48330913e60e24762fd55fa2a7731c26
2016-05-03 14:03:38 -07:00
Colin Cross
1474741435 Move shell and python scripts to scripts/ directory
Change-Id: Icdff44a54d14ddfc2266d99cf0578a8105716918
2016-04-29 13:59:56 -07:00
Colin Cross
16b2349190 Add support for sanitizer property
Add a new feature to cc modules that adds the cflags and libraries
necessary to implement AddressSanitizer, ThreadSanitizer, and
UndefinedBehaviorSanitizer.

Change-Id: Ibe5ffadc7ece56080a2521f2c7c00da9ef712584
2016-04-21 16:42:08 -07:00
Dan Willemsen
b40aab6955 Fix generated sources and headers
Add two cc properties: `generated_sources` and `generated_headers`,
instead of just adding genrule modules to `deps`. Label these with the
dep tagging mechanism, add the generated_headers paths to the include
paths, and add dependencies to generated headers for each compile.

Add dependencies so that regular sources can include generated yacc
headers, not just other generated lex/yacc files. Static/shared specific
sources still don't have dependencies to or from regular sources though.

Switch from an implicit dependency on generated files to an orderonly
dependency, since the depfile will take care of the necessary implicit
dependencies for incremental builds.

Change-Id: I436675acb1f57329d98b81c56dcb4384201a68ea
2016-04-20 15:54:19 -07:00
Dan Willemsen
be03f346b3 Port GLOBAL[_CLANG]_CFLAGS_NO_OVERRIDE from make
Change-Id: I4f0f8ec7620e4477f60bf9cf1ae0c005470c89d4
2016-03-03 17:21:04 -08:00
Dan Willemsen
cf7c71bc47 Use xcrun and xcode-select to auto-configure mac sdk
This roughly matches what make uses, but with less string parsing.
Also use a full path to "ar", so that we can depend on it.

Change-Id: I5e9d4c06b6cbbbfbf93e563dace128943db21b02
2015-12-22 15:53:01 -08:00
Dan Willemsen
34cc69e4bf Use Path instead of string for file paths
This centralizes verification and common operations, like converting the
path to a source file to the path for a built object.

It also embeds the configuration knowledge into the path, so that we can
remove "${SrcDir}/path" from the ninja file. When SrcDir is '.', that
leads to paths like './path' instead of just 'path' like make is doing,
causing differences in compiled binaries.

Change-Id: Ib4e8910a6e867ce1b7b420d927c04f1142a7589e
2015-12-09 14:29:12 -08:00
Dan Willemsen
490fd49557 Support cross-compiling Windows binaries on Linux
This defines another mutator between HostOrDevice and Arch that will
expand host modules into a module for each host type
(Darwin/Linux/Windows) that is currently being built.

Change-Id: I4c8ac6b616c229f6bd45ad8a35902652fb6a4fff
2015-11-30 15:28:31 -08:00
Colin Cross
41280a4225 pass ldflags to partial ld rules
x86 crt partial ld steps need to pass -m32 through ldflags.  Use gcc to
run partial ld instead of going directly to ld.  Allows reusing
ToolchainLdflags, which have linker arguments prefixed with "-Wl,".

Change-Id: I1e01ca5831061a11c9f550ab198d8e5b8dccf8bd
2015-11-24 21:33:29 +00:00
Dan Willemsen
c94a768a2a Use Rule-local implicit dependencies
Depends on https://github.com/google/blueprint/pull/78

This uses the new CommandDeps field to move implicit dependencies
embedded in the Command string next to the definition, instead of having
to specify them in every BuildParam struct. This should make it easier
to verify dependencies.

Change-Id: I2711b160920e22fa962a436e1f7041272166f50f
2015-11-17 19:05:07 -08:00
Dan Willemsen
322a0a6b59 Fix and optimize relPwd in cc
We cannot use the PWD trick for any compile on Darwin, since /proc
doesn't exist. So instead of checking for darwin host modules, just
check runtime.GOOS.

And since this isn't a per-module decision, don't pass it along as a
variable to every build command, but make it a global variable.

Change-Id: Iea8609f49a9d316c58aed527f62d1986c970eaac
2015-11-17 18:09:57 -08:00
Dan Willemsen
e65404514c Updates from make
Contains equivalent changes for:

  561b4c1 Set mcpu targets based on cpu variant.
  6a66a88 Stop encoding absolute paths in symbols
  63e3b02 Enable color output from gcc and clang
  eb3e3fa Use exported includes for libc++.
  3a0a891 Link libgtest_main before libgtest

Change-Id: I45a06c02e9af1d40f0c52f1e6a20d6cd382a27fb
2015-10-20 16:44:55 -07:00
Dan Willemsen
87b17d1ff4 Use SRCDIR as a working directory
The existing behavior of using the build directory as the working
directory is useful if you want to move/copy the output directory around
and SRCDIR still refers the the source. But, it's more useful to have
the source directory be the working directory. Tools like cpp(__FILE__)
and other debug prints embed relative paths from the working directory.
We also have tools that expect the working directory to be $TOP.

Change-Id: Ia0f1d3c6b7df72d61cf5628efa2baa98bd19775b
2015-09-17 23:42:25 -07:00
Dan Willemsen
edc385f5eb Fix libgcc/libatomic link order
This is the equivalent commit to https://android-review.googlesource.com/144749

Change-Id: I79374f33766fa307fd031ffd0cbd9e9d37848324
2015-07-08 18:10:14 -07:00
Colin Cross
aee540a439 Add version_script property
Add version_script property to cc_library to pass a file to
the linker with --version-script.

Change-Id: Ieefb04e15c8dfa72c2eb63b4349f8860222662b2
2015-07-07 10:34:19 -07:00
Colin Cross
d81496084b Fix repeated ccCmd dependencies on object files
ccCmd was being added as a dependency each time through the object
file loop, tripling the size of the build.ninja file.  Create a
new slice for dependencies on each object file.

Change-Id: Id768d8ea6e5300c15f0f1a5fac5fcbdfdf5e6b0a
2015-05-13 00:50:25 +00:00
Colin Cross
0af4b8468b Add support for building on Darwin hosts
Add toolchain and build rules for building on Darwin.

Change-Id: I78e21f4051b2941182121b28c9ddfa24396ada41
2015-05-07 14:09:48 -07:00
Dan Albert
c3144b1553 ndk: Use prebuilt NDK CRT objects.
Change-Id: Ie8d58fa7c4ef2a62338c20c3078603ac98be0f9c
2015-04-29 10:27:00 -07:00
Colin Cross
28344528cf Simplify flags in c compiling, fix NDK build warnings
Reduce the number of flags variables when compiling C by getting
rid of the separately-tracked IncludeDirs variables, and putting
them directly in GlobalFlags.  Also changes exportedIncludeDirs
to exportedFlags, which will allow exporting flags besides -I.

Also fixes a bug when building a module with the NDK and -Werror
by passing NDK exported include directories with -isystem instead
of -I, which will ignore warnings from those includes.

Also fixes a bug where the default includes were being inserted
into all cflags by the arm and arm64 toolchain modules.

Change-Id: Ice97f84e637b21d20c38c85b881afa315f9f92ae
2015-04-22 14:08:45 -07:00
Colin Cross
1332b0035c Move config into common and provide helper
Using ctx.Config().(Config) everywhere is a mouthful, and it is
inefficient to do the type assertion.  Put the Config interface into
the context, and provide an AConfig() to return the Config already
converted to the right type.

Change-Id: I301a1fd7d2a005580aabca7866a37c5d42ad8c69
2015-04-08 15:19:24 -07:00
Colin Cross
581c189988 Add yacc and lex support
Add support for yacc (.y or .yy) and lex (.l or .ll) files.  Also
tweak locations of .o files for normal and generated sources to
makes sure they don't collide.

Change-Id: I03172cddbdc022525bf392a81d72050406b8cdb3
2015-04-08 15:17:45 -07:00
Colin Cross
7d21c4430d Use @files for ld and ar
ld and ar command lines often end up larger than ARG_MAX, use Ninja's
rsp file support to automatically write the object files to a temporary
file and pass it in using @file support.

This isn't going to work on Darwin host builds, where the host
toolchains don't support @.

Change-Id: Ida2f4e114ab02df6967e863577fa324e197827d5
2015-04-02 14:48:55 -07:00
Colin Cross
bfae8859f2 Support prefix_symbols for linker
The linker needs to add __dl_ to the beginning of all of its symbols
to avoid conflicts.  Add support for a prefix_symbols property, and
insert an objcopy --prefix_symbols build step to produce the final
binary.

Change-Id: I70de7c830cd64305e5900c6de53efecea2e17c75
2015-03-27 15:58:24 -07:00
Colin Cross
ed4cf0b655 Refactor ccDynamic for static binaries
ccLibrary uses ccDynamic for linking shared libraries, but bypasses
it by calling directly into ccBase for static libraries.  Instead of
duplicating the same mess for ccBinary, rename ccDynamic to ccLinked
and add the logic for dealing with static or shared linkage.  This
also allows moving the stl logic out of ccBase and into ccLinked.

Change-Id: Idfa6d86de16911c8851f694d6ed92681c8939281
2015-03-27 15:57:49 -07:00
Colin Cross
97ba073833 Export cc types for art to inherit from
Art needs a custom module type in order to perform complicated
build logic like depending on environment variables and varying
cflags based on cpu variant.  Export enough of the types and
functions from cc for art_cc_library to inherit from cc_library.

While I'm touching every line, also rename the New* methods
to *Factory.

Change-Id: I7123aa47019c4ced7a1ab57c394225bc7844b5ea
2015-03-25 11:33:06 -07:00
Colin Cross
70b4059e3f Update import paths for changes to blueprint
Blueprint has been modified to include a canonical import path,
update soong to match.

Change-Id: If29d31afbf3bf2e6364961a66456fa5f8f738455
2015-03-23 12:57:34 -07:00
Colin Cross
3075ad07e4 Add dependencies on late static libraries
Late static libraries were added to the build command line, but not
the implicit dependencies.

Change-Id: I20ed8be6ae1ec7c1b78f16a6d1da7d1535ff5cba
2015-03-17 10:47:08 -07:00
Colin Cross
77b00fa6f1 Add late static libraries for libgcc
libgcc has to be last on the command line, after -lc for libc.

Change-Id: I5c867cef59ca84e23ff5cea406da3ec3f261aa76
2015-03-16 16:22:52 -07:00
Colin Cross
3f40fa460d Add soong_build primary builder
Initial build logic for building android with soong.  It can build
a variety of C and C++ files for arm/arm64 and host.

Change-Id: I10eb37c2c2a50be6af1bb5fd568c0962b9476bf0
2015-03-13 20:28:16 -07:00