Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lists ROMFS files explicity instead of using GLOB_RECURSE #9107

Merged
merged 7 commits into from
Mar 26, 2018

Conversation

ksschwabe
Copy link
Contributor

@ksschwabe ksschwabe commented Mar 19, 2018

Fixes #9093.

Previously, when ROMFS files that were not airframes were touched, the ROMFS
would not be rebuilt. The ROMFS files are now specified explicityl in a
CMakeLists.txt file that is located in the root ROMFS directory.

Now when one of the ROMFS files is touched the whole ROMFS is rebuilt.

When new files are added to the ROMFS, they need to be explicity added to
the CMakeLists in the ROMFS root directory.

Previously, when ROMFS files that were not airframes were touched, the ROMFS
would not be rebuilt. The ROMFS files are now specified explicityl in a
CMakeLists.txt file that is located in the root ROMFS directory.

Now when one of the ROMFS files is touched the whole ROMFS is rebuilt.

When new files are added to the ROMFS, they need to be explicity added to
the CMakeLists in the ROMFS root directory.
@ksschwabe ksschwabe force-pushed the feature_romfs_cmakelists_list_files branch from 530a5e3 to 6c57c4e Compare March 19, 2018 14:46
@dagar
Copy link
Member

dagar commented Mar 19, 2018

What do you think about including the CMakeLists.txt in the deepest directory? At each higher level back to the root you can have a CMakeLists.txt that simply adds each directory (add_subdirectory(init.d)).

I say this now because I'd like to come back and sort the airframes and mixers by group later.

@ksschwabe
Copy link
Contributor Author

ksschwabe commented Mar 19, 2018

@dagar: Do you not think that might get a bit too confusing? Too many layers and levels of CMakeLists.txt? Especially when each of these CMakeLists will only be setting/appending to the lists and not actually creating targets/outputs. It is only the ROMFS/CMakeLists.txt that is currently creating any output.

I guess, it depends on how often you think you might be modifying the ROMFS files.

@dagar
Copy link
Member

dagar commented Mar 19, 2018

Personally I find lists and directories with ~ 100 things overwhelming and hard to sift through.

The only way I know to get a handle on that complexity is to break it down and keep it modular. I started doing this last year, but never got it merged. #7628
In the process I came across a number of effectively duplicated and obsolete mixers and airframes.

Either way is fine for now, but this is what I'd like to consider doing later.

@ksschwabe
Copy link
Contributor Author

ksschwabe commented Mar 19, 2018

@dagar: I can take a crack at adding in CMakeLists.txt files in each subdirectory.

How do you want me to add the files in the deeper directories to the "master" list in the upper directory, though? In each subdirectory, do a

APPEND(config_romfs_files_list ...<list of new files>)

set(config_romfs_files_list ${config_romfs_files_list} PARENT_SCOPE)

?
I hope that won't be too confusing. If you add a new directory and forget to add the parent scope, or you do a SET instead of an APPEND, then you'll mess up your ROMFS build. (But I guess that should be ok...)

@dagar
Copy link
Member

dagar commented Mar 19, 2018

In the top level ROMFS CMakeLists.txt you set(config_romfs_files_list).

Then in each subdirectory you append

list(APPEND config_romfs_files_list
    AAERTWF.main.mix
    AAVVTWFF.main.mix
    AERT.main.mix
    AETRFG.main.mix
    bebop.main.mix
    blade130.main.mix
    ...
)

The other thing that just occurred to me is the exclude mechanism. We need to make sure that still works (available flash is currently quite limited on the original 1MB pixhawk). https:/PX4/Firmware/blob/master/ROMFS/px4fmu_common/init.d/13004_quad%2B_tailsitter#L19

@ksschwabe
Copy link
Contributor Author

This is becoming messy. Each level of CMakeLists adds a CMakeLists directory and .cmake file in the temp romfs directory. I I would have to prune these out, or we need to find a better solution to prevent CMake files from littering the temp ROMFS directory. - I think the px4fmu-v2 build overflowed because these additional cmake build files were copied into the ROMFS.

@dagar
Copy link
Member

dagar commented Mar 19, 2018

If they're ending up in the tmp ROMFS at all I think you should change the path to avoid the conflict entirely. The location for ROMFS in the build directory is arbitrary, and placed at the top level for minor convenience. Unless it's trivial to tell genromfs what to exclude (or only include) I'd simply change the path.

@ksschwabe
Copy link
Contributor Author

@dagar: I can't quite work out how to get CMake not to generate the cmake_install.cmake file and CMakeFiles directory in the romfs. You'll see that I tried to use a separate temp romfs directory with #set(romfs_temp_dir ${PX4_BINARY_DIR}/ROMFS/romfs), but it still generates the cmake files in this new temp directory.

I'd rather like to not have to specifically prune those files or exclude them manually in the genromfs program if possible, because that will make the ROMFS build all the more obscure.

Any ideas? Sorry to be a pain.... :-(

@ksschwabe
Copy link
Contributor Author

It looks like whenever I have an add_subdirectory call, a cmake_install.cmake file and a CMakeFiles directory are created in the "subdirectory location" in the binary directory.

@dagar
Copy link
Member

dagar commented Mar 21, 2018

This is all internal cmake stuff, so let's not try to prune. All we need to do is pick a folder in the build directory that doesn't overlap with the cmake tmp (corresponding to source tree) at all.

Something like ${PX4_BINARY_DIR}/genromfs would be fine.

@ksschwabe ksschwabe force-pushed the feature_romfs_cmakelists_list_files branch 2 times, most recently from e8812fd to 3796617 Compare March 21, 2018 10:47
@ksschwabe
Copy link
Contributor Author

@dagar: Setting the romfs_temp_dir to romfs_temp_dir ${PX4_BINARY_DIR}/ROMFS/genromfs helped to avoid having the cmake_install files included in the genromfs directory. Thanks! 👍

I have had to add set(config_romfs_files_list ${config_romfs_files_list} PARENT_SCOPE) to the bottom of each subdirectory CMakeLists file to make sure that the global list is correctly updated.

You will also see that in each of the subdirectory CMakeLists, I have had to add the ${CMAKE_CURRENT_LIST_DIR}/ path to each filename, otherwise I am unable to correctly build the list of all files uponwhich the ROMFS depends. If you have a more elegant solution to the problem of generating this list, let me know.

Also moves the temporary ROMFS build directory to ${PX4_BINARY_DIR}/ROMFS/genromfs
so that the cmake_install.cmake files and the CMakeFiles directories (generated whenever
are not add_subdirectory() is called) are not generated in the temporary ROMFS directory
from which the ROMFS binary is created.
@ksschwabe ksschwabe force-pushed the feature_romfs_cmakelists_list_files branch from 3796617 to 7a98d07 Compare March 21, 2018 13:15
@dagar
Copy link
Member

dagar commented Mar 23, 2018

How about something like this this? ksschwabe#1

The px4io.bin file was being generated in a directory one level deeper than
in the ROMFS than the rest of the ROMFS files.
@dagar
Copy link
Member

dagar commented Mar 23, 2018

Looking good. To be paranoid let's check the romfs.txt (search the build dir) is identical in this PR and master. I'd also check that booting a pixhawk actually works (including IO flash).

@ksschwabe
Copy link
Contributor Author

ksschwabe commented Mar 23, 2018

I've fixed the path issue. The ROMFS files are now generated in the temp directory <build>/genromfs/${config_romfs_root}/. I have also added a brief explanatory comment to the px4_add_romfs_files function.

I see two "issues"/problems still to discuss.

  1. The copying of files is still determined ONLY by the $config_romfs_root variable:
    COMMAND cmake -E copy_directory ${romfs_src_dir} ${romfs_temp_dir}
    The px4_add_romfs_files function only adds to a list that determines the dependencies for when this directory copy function is called. Are we happy with this? We aren't actually using the config_romfs_files_list variable to perform the copy. It seems a bit confusing.

  2. Maybe we should put the px4_add_romfs_files function into cmake/common/px4_base.cmake so that it is in the same place as all the other cmake function definitions. Although if we do that, we sort of lose "transparency" on where the config_romfs_files_list comes from.

@dagar
Copy link
Member

dagar commented Mar 23, 2018

  1. Yes, and unfortunately we don't have visibility into the actual output files. The python script that does this may exclude things based on board.

  2. I'm not sure what proper cmake convention is for functions, but you could move it to another file if appropriate. If it makes sense I'd prefer to keep everything to do with ROMFS generation together. From a PX4 perspective this keeps it as modular and simple as possible.

@ksschwabe
Copy link
Contributor Author

  1. Let's keep the px4_add_romfs_files function in the ROMFS/CMakeLists, then. I think it will be clearer from a "readability" standpoint.

@@ -0,0 +1,35 @@
############################################################################
#
# Copyright (c) 2016 PX4 Development Team. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong copyright year.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the Copyright header with a 2018 header.

I also added a 2018 copyright header to the ROMFS/CMakeLists.txt file - it previously didn't have one at all. Should the one for the ROMFS/CMakeLists.txt be a purely 2018 copyright header, or should we make it a 20XX - 2018 header?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2018 only is fine for the new ones.

@ksschwabe ksschwabe force-pushed the feature_romfs_cmakelists_list_files branch from 83c5fa0 to 87ccba6 Compare March 26, 2018 14:38
@dagar
Copy link
Member

dagar commented Mar 26, 2018

I verified the ROMFS contents are identical vs master and did some actual testing on a pixhawk.

@dagar dagar merged commit 500a1c8 into PX4:master Mar 26, 2018
@dagar
Copy link
Member

dagar commented Mar 26, 2018

Thank you!

@ksschwabe ksschwabe deleted the feature_romfs_cmakelists_list_files branch March 26, 2018 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants