Thinking about a language for build definitions

I want to write a little tool that parses build definitions and converts them to a ninja.build file. It should not abstract compilation like CMake or Meson, but be similar to make in that you manually write the commands for a build step.

I have built an almost working solution in Python, but there are some stepping stones that I could not easily solve yet and the design is not ideal. My main goal is to have modular build definitions and be able to modify these definitions from another project for its requirements. Imagine

use platform
use platform.compiler as compiler

# Another user created build definition file.
use foolib

build_dir : join(project_path, 'build')
foolib.build_dir : build_dir  # Here we change the build_dir of the library
foolib.defines : array(foolib.defines, 'FOOLIB_LEGACY_API')  # And here we add another define

sources : wildcard('source/*.cpp')
objects : transform(sources, 'source', join(build_dir, 'obj'), platform.objsuffix)
executable : join(build_dir, platform.exename('main'))
includes : array(localpath('include'), foolib.includes)
defines : array(foolib.defines, 'BUFSIZE=512')
flags : compiler.includes(includes) compiler.defines(defines)

# Automatically deduces to issue a command for each source/object pair
target sources -> objects  
    compiler.cpp quote(input) flags compiler.compile_only compiler.out(output)

target array(objects, foolib.library) -> executable
    compiler.cpp quote(input) flags compiler.out(executable)

foolib would look pretty similar, outputting a library file from source files to its build_dir.

I use lazy variable expansion at all times to allow things like changing the build directory of an imported project or update macro definitions used while compiling the dependency.

The problem I have with lazy evaluation is with self-references, and it also adds a lot of overhead. However, doing immediate evaluation on assignment will not allow this late configuration change.

Another aspect is that I want to be able to specify options on the command-line that will have effect on the modules configuration. For instance, let’s say I want to build my program in debug mode.

if debug == 'true'
    executable : join(build_dir, platform.exename('main-dbg'))
    flags : flags compiler.debug
    defines : array(defines, 'DEBUG')

If foolib uses the same conditional to update its compilation flags and defines, it will be built in debug mode as well. Although in this special case, it would be desirable, there might be a case where I want to be specific to make it set only for my program but not for foolib module.

Do you have ideas for improvements, a different or better design?

3

It’s probably a good idea to read through https://wiki.debian.org/UpstreamGuide#Your_Build_System (other Linux distros will probably have something similar). Respecting environment variables (e.g. CFLAGS) is important (see the SCons and waf discussion for the problems created by not doing this).

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật