summaryrefslogtreecommitdiff
path: root/libc/kernel/tools/clean_header.py
AgeCommit message (Collapse)Author
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-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-04-15clean_header: Run outside of $ANDROID_BUILD_TOPDaniel Mentz
Enable the use case where we run clean_header.py from outside of $ANDROID_BUILD_TOP. Previously, this script required the current working directory to be under $ANDROID_BUILD_TOP. Running it from a different directory resulted in the following error message: clean_header.py: error: Not in android tree pointed at by ANDROID_BUILD_TOP (....) Change-Id: I48210ea1a0033228a9aaa4124d28247b07cee6d4
2019-04-15clean_header: Fix error handling for no-such-file caseDaniel Mentz
The function cleanupFile should always return a single value (as opposed to a tuple or list). In addition, if it encounters an error, it is expected to return a value that evaluates to False. As it stands, however, it returns (None, None) in certain error cases. Change this function to return None, in those cases. We previously saw the following error message, when we tried to run clean_header.py on a non-existent file. Traceback (most recent call last): File "clean_header.py", line 208, in <module> b.updateGitFiles() File "utils.py", line 164, in updateGitFiles self._writeFile(dst) File "utils.py", line 136, in _writeFile f.write(self.new_data[dst]) TypeError: expected a string or other character buffer object Change-Id: I5f717dd1a4388f598f0fd4bfd5e6129017de9095
2019-03-29clean_header: Don't print extraneous newline charDaniel Mentz
Don't print an extraneous newline character at the end of the include file if clean_header.py is used in the non-update mode. This is necessary to achieve consistent results in the update and non-update modes. Running clean_header in the non-update mode and redirecting the output to a file should have the same result as using the update mode and have the script write to the file directly. Change-Id: I6b176c5365840d66e4499bacd205f1fa77302a2b
2019-03-29clean_header: Write to correct dst_fileDaniel Mentz
Write to correct dst_file when in update mode. This enables use cases like the following: ../../../bionic/libc/kernel/tools/clean_header.py -k original-kernel-headers/ -d kernel-headers/ -u linux/ion.h Previously, we had to cd into kernel-headers/ and then run ../../../../bionic/libc/kernel/tools/clean_header.py -k ../original-kernel-headers/ -d . -u linux/ion.h because the tool didn't allow the relative path to be different from the destination path. Change-Id: I8c5e284ce7a6737d77a2f5ead3e7e5db01317425
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-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
2017-03-02Refactor the kernel update scripts.Christopher Ferris
The previous versions of the scripts did a lot of redundant changes and were hard to follow. I rewrote most of update_all.py so that it's clear about what's going on. I updated clean_header.py to change the cleanupFile function so that there is no magic about where the destination file is going to wind up. Now the caller specifies the final location. I updated utils.py so that if you are trying to do an update in one location, but your lunch target is from another location, it causes an error. Bug: 35726570 Change-Id: Ic5a44d90c2774a627eecde34c0c403bc925a497c Test: Ran the updater and verified it works properly. Test: Verified that doing an update in one tree to another tree Test: fails.
2016-07-22More kernel header cleanup.Christopher Ferris
Modify the generate script to add a new option and copy the types.h arm header file since it's not currently being created properly. Also manually generate the arm types.h uapi header since it's not being properly generated right now. Modify both generate scripts to delete the target directories before adding the files to handle moved/deleted header files. Move the common/scsi headers into android and delete the common directory. Change the scripts to reflect this change. Update the scsi headers since they've been modified in upstream kernels. Bug: 30072483 Change-Id: Ia43d4b238b6a041350d60cc30184ecbd4829d7d5
2015-09-17Add support for manually modified kernel headers.Christopher Ferris
This changes the scripts so that if some kernel files exists in external/kernel-headers/modified, that they will be preferred over the same files found in original. This is to support the case where the kernel headers cannot be taken without some small modifications. Included with this change, is a general cleanup of the python scripts. This also modifies the generate uapi headers script to indicate if the source of the modified headers has changed. Change-Id: Id13523b244ced52a2ecd9f1399c43996dd8296fa
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-06-06Update kernel header generation docs.Christopher Ferris
Also move the description of the cleanup data to the cleanup script. Bug: 15433575 Change-Id: I21e2cbbfab55da483af1bbe36bbe59126b518e3c
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
2013-10-16Tweaked the cleanup scripts to handle uapi and aarch64 headers.Ben Cheng
The processed uapi directory is now placed at libc/kernel/uapi as opposed to libc/kernel/common/uapi as it contains architectural-dependent headers now. Change-Id: I53f814704a4d231b452fde398cd94257a0fb2eea
2013-01-17Add functionlity to the scripts to replace tokens in kernel headersRaghu Gandham
based on architecture.
2012-03-23Fixed to #include correct 32-bit headers; Refreshed libc/kernel headersAndrew Hsieh
This patch fixes an issue where 64-bit hreaders are incorrectly included in kernel headers. For example, file "libc/kernel/arch-x86/asm/io.h" incorreclty includes "io_64.h" (missing, BTW) instead of "io_32.h". The reason is because CONFIG_X86_32 isn't considered pre-defined in "kernel_default_arch_macros" for x86, and clean_header.py doesn't look at it at all anyway (ie. __i386__ is also ignored, but it's okay since x86 cross compiler defines it back) Fixed 2 tools/*py, README.TXT, and refreshed libc/kernel headers Change-Id: Iac834cc8b3548f055d3f2a214af36072dd679fe8
2012-01-13Fix misspelled Python variable name and typosGlenn Kasten
Typos: - Update pathname in README.txt - Fix missing newlines in header update script. Change-Id: Ib0e053f92a27ff10071b9805fa64e5653ab31b0c
2011-05-25Fixed bug where -k option would not be passed to cleanupFile functionFrank Maker
Changed cleanupFile to have no default original path, forcing it to be passed instead, thereby conforming to the Google Python style guide.
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-08Replace all occurrances of asm with __asm__ in the output headersMartin Storsjo
asm() conflicts with userland code compiled with -std=c99, the userland libc should only use __asm__() instead. Therefore, this transformation has to be applied to all exported headers. This only changes arch-arm/asm/byteorder.h. Change-Id: I1cf88c37201c3a91668d387293a18885c316d53c
2009-08-05libc: kernel: let clean_header tool take path to kernel originals as argumentDima Zavin
Signed-off-by: Dima Zavin <dima@android.com>
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-10-21Initial ContributionThe Android Open Source Project