seL4自定义项目编译指南


为了创建自定义的项目工程,而非官方给的tutorials例程中的。通过dump官方的init.py脚本信息,加上自己摸索尝试,终于知道了其中的奥秘。下面给出流程。

1. 创建源代码目录

  • 首先创建一个源码文件夹,其中必须有seL4工程所必须的CMakeLists.txt<file_name>.camkesc code

  • CMakeList.txt - the file that defines how to build our CAmkES application

  • <file_name>.camkes - Our CAmkES file describing our static system

  • c code - support both c and CamkEs application, must have one

Note: C 和 CAmkES 应用均可被sel4编译系统收入,两者可以协同,但不可都没有,没有app运行,裸内核也没太大意义。

2. 创建build目录

  • 采用和官方例程一致的方式,讲src和build分开的方式管理project。

  • 后期的编译操作均在对应的build目录下进行。

3. 生成工具文件

调用命令:

$ /usr/bin/cmake -DCMAKE_TOOLCHAIN_FILE=../kernel/gcc.cmake \
  -G Ninja -DTUT_BOARD=pc -DTUT_ARCH=x86_64 -DFORCE_IOMMU=ON \
  -DTUTORIAL_DIR=<src_dir> ..

下面是对上面命令的说明:

  • -D defines a variable, in the form X=Y.
  • CROSS_COMPILER_PREFIX specifies the toolchain for cross-compilation, which cannot be changed after build directory initialisation. For further details, please see “Cross Compiling” here.
  • CMAKE_TOOLCHAIN_FILE which indicates that CMake should load the specified file as a ‘toolchain’ file. A toolchain file is able to set up the C compiler, linker etc., for building the project. In the example we assume a typical project layout, where seL4 is in the ‘kernel’ directory, at the top level. The gcc.cmake’ file from the seL4 repository sets up C compilers and linkers using the CROSS_COMPILER_PREFIX.
  • -G Ninja tells CMake to generate Ninja build scripts as opposed to GNU Makefiles. Only Ninja scripts are supported by parts of the kernel.
  • <src_dir> is the directory in the root of sel4 project which stores the whole source file for sel4 project
  • .. is the path to the top-level CMakeLists.txt file describing this project, which in this case is placed in the root directory of the project.

4. 生成编译文件

调用命令:

$ /usr/bin/cmake ..

到这一步正常成功后,就将项目所需的所有工具、配置、编译等临时文件生成完毕。

5. 调用ninja进行编译

调用命令:

$ ninja

第一次编译有camkes app的时候,百度很久都没查到为什么。最后在google上,看到了开发者之间的邮件[seL4] Camkes dependencies & development environment,才知道在编译的时候调用了The CapDL tool。根据邮件提示,it requires cabal >= 1.18 and ghc >= 7.8.4 [1]。后来才发现Ubuntu18.1 LTS 没有集成这个工具,需要手动安装,解决办法:

$ sudo apt install cabal-install

参考链接:

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。