summaryrefslogtreecommitdiff
path: root/libc/kernel/tools/cpp.py
AgeCommit message (Collapse)Author
2021-04-20Fix last python3 issues.Christopher Ferris
Includes pointing to the python3 version of the clang bindings. Also, remove stale .gitignore line. Test: Ran bionic/libc/kernel/tools/update_all.py and verified Test: the files generated the same exact way. Change-Id: I4eb9dd7382bca013f70d921b6ef48c7e7478615a
2021-04-19Update for python3.Christopher Ferris
This fixes all of the problems with our kernel scripts, but not the clang python script problems. I also removed the updateGitFiles function since that code was just silently failing any way. I replaced all calls with updateFiles. Test: Ran script using python2 to verify it still works. Test: Run script in python3 verifying that it starts to run. Change-Id: I223a31a8324c59e6bc4067f48a6110361b3e26e8
2021-04-15Force everything to use python3 for consistency.Elliott Hughes
Rather than "whatever people have installed as 'python' on their machine". I've removed check-symbols.py because that's been broken for years and we never even noticed, and I'm not sure it's worth fixing. Test: treehugger, manual Change-Id: Ieb996bbdf790a18d4b1fb46a409cc240ba2a2a49
2020-07-31More cleanup for #inclusivefixit.Elliott Hughes
Found manually with grep, since the script seems to miss stuff. Test: treehugger Change-Id: I5933cbade9792801d4a0bec1ccb077efa6ad8fbc
2020-04-10Update to v5.6 kernel headers.Christopher Ferris
Kernel headers coming from: Git: https://android.googlesource.com/kernel/common/ Branch: android-mainline Tag: android-mainline-5.6 Add a new method for removing structures. This is to deal with the kernel headers changing some definitions of timeval to __kernel_old_timeval and itimerval to __kernel_old_itimerval. Remove the __kernel_old_XX strutures and change the other structures to the previous definitions. This only works so long as these structures stay the same, if they diverge, then a different strategy will need to be implemented. Test: Booted cuttlefish/walleye. Test: Ran bionic-unit-tests on cuttlefish/walleye. Change-Id: I0a61f4fa6e4155c602e0414d9b38c2e1637829af
2019-01-10Rewrite removeVarsAndFuncs.Christopher Ferris
The current version has these bugs: - Adding a semicolon after a function results in the removal of structures following the function. - Function like macros get removed on accident rather than on purpose. - It removes extern "C" { completely, which might not be a bug, but doesn't seem right. I couldn't easily fix any of these problems because the code depends heavily on the header being correct. New unit tests added for the function to cover all of these cases. A follow-on CL will include the updated headers. Bug: 112290385 Test: Passes all new unit tests. Test: When run on the current kernel headers, the generated headers are Test: nearly the same, missing data is being added. Change-Id: Ib22a5f2e78873544e8a9d54e385af1156b2a72bb
2018-10-26Fix handling of #elif.Christopher Ferris
When a construct like: if defined(something) blocks1 elif 1 blocks2 else blocks3 endif The parser would put the first clause but then simply omit the elif and put all of blocks2 without a terminating #endif. The code also did something similar when the #else was an #endif. Also convert all of the unit tests to real unit tests and only run them if you run cpp.py by itself. Added new unit tests to cover the new cases. Test: Ran cpp.py unit tests. Test: Reran update_all.py and verified nothing changed, and that running Test: it on the new kernel headers that exposed this problem. Change-Id: Ie168511303c4e15afdb60c37baef75a966ca29a8
2017-12-14Use in_addr in ip_mreq_source and ip_msfilter.Elliott Hughes
This adds a new mechanism to say "replace struct S with #include <bits/S.h>". Also switch epoll_event over to the new mechanism. Also use the kernel's struct sockaddr_storage directly rather than behind an unnecessary #define. This patch also removes some dead code in the header scrubber. This code still needs rewriting completely. I learned that a "block" isn't necessarily a single struct definition, say; it might be a run of them. It seems like a block is a run of preprocessor directives or a run of regular code. Bug: https://issuetracker.google.com/36987220 Test: new test Change-Id: Ic6a5c09559766a4babe3cd4c3ea538b885e07308
2017-11-15Update to kernel headers v4.14.Christopher Ferris
Remove the hiding of the kernel structure binder_fd_array_object. This structure now matches the structure used in the binder code. Load the libclang_android.so shared library directly for parsing. This file changed name in a recent update to the prebuilts. Test: Compiles arm/arm64/x86/x86_64. Test: Boots on hikey and boots on a sailfish. Test: Ran bionic unit tests on hikey and sailfish. Change-Id: I141a4b93ac3511cd58f4d12bb3c0d4efaa4c2742
2017-08-31Use env to invoke pythonStephen Crane
/usr/bin/python may be python3. We should respect PATH to find the python executable so it can be locally overridden to be python2. Test: Build libc, repo upload Change-Id: Iaddd7cd4a1c2177c32786e4fa0fc664ab0ad36de
2017-05-25Remove the repetitive warnings from the uapi headers.Elliott Hughes
Having WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS every four lines made the headers harder to read, made the diffs much worse each time we upgraded, and wasn't really providing any benefit. Before the next uapi update, let's just stop doing this. Bug: N/A Test: builds, manually inspected files look right Change-Id: Id7088cf750894c9d24950f3d53587fe3156c4f7d
2015-04-22Update the search path for libclang.soTao Bao
Prebuilt shared libraries (libclang.so, libLLVM.so and etc) have been moved to prebuilts/sdk/tools/linux/lib64. Update the search path in cpp.py to match the change. Bug: 20485471 Change-Id: Ib7784db4d5529d16a1e2bfc07cb0237929bc5a64
2015-02-06Switch kernel header parsing to python libclangTao Bao
Replace the tokenizer in cpp.py with libclang. Bug: 18937958 Change-Id: I27630904c6d2849418cd5ca3d3c612ec3078686d
2014-08-20Clean up some of our python scripts.Elliott Hughes
Change-Id: Ifa75345db43434298cfb6113fbe2f7a33b88c79d
2014-05-01Keep the kernel header scrubber's data structures in sync.Elliott Hughes
If you rewrite the tokens of a #if you need to rewrite the expression to match because either might be used later. This was showing up as SIGRTMAX being rewritten in a #define but not in the #ifndef that guarded it, for which case I've added a unit test. Change-Id: I6929675461a1afe272edd667594529fd84a3dc4d
2014-02-11Fix NSIG.Elliott Hughes
Our sigset_t definition hasn't been tied to our NSIG definition since we switched to uapi headers, so we can now fix it without breaking the LP32 ABI. The kernel uapi headers define and use _NSIG, so we need to have our scripts rename the kernel's definitions out of the way, then we can define _NSIG and NSIG in terms of the kernel's off-by-one value. Bug: 12938442 Change-Id: Ic7c86fd5be5ad1d822f7b2b1d88c8a0d70a1ac0f
2013-11-21Add support for the ternary operator to the header scrubber.Elliott Hughes
Used in various uapi headers. Change-Id: Id0f862d2adc7ddc9727e8a29160d5435f8d547c3
2013-11-06Make cpp.py less braindead.Elliott Hughes
The old code ignored operator precedence (!), despite having two tables of operator precedence. The code's still pretty awful, but I've cleaned it up enough to fix this, the most important bug. This patch lets us correctly clean the uapi unistd.h, stat.h, and swab.h files, and also fixes the mess we were already making of various old kernel header files. I've added a bunch more tests, fixed the existing tests that the existing script was already failing (!), and changed the script so that the tests are run every time the script is run. We can probably remove some of the old kernel header files that we were parsing incorrectly, but we can worry about that later. Bug: 11253477 Change-Id: Ie66c65b3a7ae13b4e98ed8038a6a534f06eae0e5
2013-09-30Add x86_64 to the bionic headers.Elliott Hughes
Manual changes: cpp.py: cope with macros that refer to other macros. defaults.py: x86 no longer always implies __i386__; use __i386__ to replace the kernel CONFIG_X86_32 flag. asm/page.h: the upstream page.h isn't a uapi header and no longer includes the stuff we were using it for. Let's just have our own static file, since it's the same for all our architectures (both 32- and 64-bit). sys/select.h: we used to use the various FD_SET-related macros from the kernel header files, but they've gone. Adjust by adding trivial equivalent definitions. Automated changes: libc/kernel/arch-x86, libc/kernel/common: regenerated from external/kernel-headers. Change-Id: I84fc0ed52dc742e043b4ae300fd3b58ee99b7fcd
2013-01-30Clean up trailing whitespace in the kernel headers.Elliott Hughes
And fix the scripts so they stop letting trailing whitespace through. Change-Id: Ie109fbe1f63321e565ba0fa60fee8e9cf3a61cfc
2011-02-03libc: Update auto-gen scriptsDavid 'Digit' Turner
Make the scripts use external/kernel-headers/original by default. clean_header.py: Document -k<path>, add -d<path> find_headers.py: Make kernel config files optional update_all.py: Allow setting the path to kernel headers on the command-line update_all.py: Better formatting of output on ttys update_all.py: Automatically perform "git add/rm" on affected files. SYSCALLS.TXT: Fix typo in __socketcall definition. checksyscalls.py: Add support for superH architecture in the checks. gensyscalls.py: Automatically perform "git add/rm" on affected files. cpp.py: Fixed a bug that prevented certain type definitions to be kept in the generated clean header (e.g. struct ethtool_drvinfo in <linux/ethtool.h>) All scripts will use the content of external/kernel-headers/original by default now. The generated code removes all empty lines and trailing whitespace. This is useful to ensure a unified output even if we change the parser again in the future. The top-level disclaimer has been edited with update instructions to regenerate the headers when needed. Also, a warning is now inserted every 8th line in the final output: /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ Changes under kernel/arch-arm and kernel/arch-x86 should correspond to whitespace differences and additionnal struct definitions that were missed by the previous parser implementation. Change-Id: Icd1c056bacd766759f3e9b7bb5d63a246f3d656a WARNING: If you run these script, do not submit the result to gerrit for now. It seems there are discrepancies between the content of original headers and those currently commited under bionic/libc/kernel/. (This problem is the main motivation to insert the warning repeatedly). Current list of issues: - Missing SuperH headers (i.e. external/kernel-headers/original/asm-sh)
2010-12-08Add a method for replacing tokens in the preprocessed headersMartin Storsjo
Change-Id: I14cf6337945560b012732ae0fe7a247074810678
2009-03-03auto import from //depot/cupcake/@135843The Android Open Source Project
2009-03-03auto import from //depot/cupcake/@135843The Android Open Source Project
2009-01-09auto import from //branches/cupcake/...@125939The Android Open Source Project
2008-12-17Code drop from //branches/cupcake/...@124589The Android Open Source Project
2008-10-21Initial ContributionThe Android Open Source Project