Build routines

The Jai compiler will handle all the aspects of building an executable: compiling (in parallel), linking, etc.1

The compiler provides an api to work with build configuration options.2 3 4

For example:5

build := () {
    printf("In build (at compile time).\n");

    build_options.optimization_level = Optimization_Level.DEBUG;
    build_options.emit_line_directives = false;
    build_options.executable_name = "traveller.jai";

    update_build_options();

    printf("build_options.executable_name = %s\n", build_options.executable_name);
    printf("build_options.output_path = %s\n", build_options.output_path);

    printf("Building from file %s, line %d.\n", #file, #line);
    printf("filepath is: %s\n", #filepath);

    set_build_file_path(#filepath);

    add_build_file("misc.jai");
    add_build_file("invaders.jai");
    add_build_file("checks.jai");
    add_build_file("levels.jai");
}

#run build();

This also lets you re-use more code, and make build activities arbitrarily complex (code analysis, correctness checks, house rules, etc.) by using a general purpose programming language instead of various specialized build languages.

You can write programs that modify or generate code during compilation to use in a later part of the compilation process.6

value_table: [] float = #run generate_expensive_values(); // #run invokes the compile time execution

  1. you shouldn’t need wacky different tools on every operating system. you should need the compiler and your source code and that’s all.
    “Ideas about a new programming language for games.” YouTube, uploaded by Jonathan Blow, Sep 19, 2014, https://youtu.be/TH9VCN6UkyQ?t=5166 

  2. using the #run directive to run a build routine at compile time.
    “Demo: Base language, compile-time execution.” YouTube, uploaded by Jonathan Blow, Oct 31, 2014, https://youtu.be/UTqZNujQOlA?t=3859 

  3. this #run directive says that at compile time when this run directive is hit, we’re going to run this function and anything else that needs to get compiled to make that function work.
    “Demo: Iteration and arrays, uninitialized values, enums.” YouTube, uploaded by Jonathan Blow, Dec 10, 2014, https://youtu.be/-UPFH0eWHEI?t=1759 

  4. you have a struct that defines the build options, and you apply those build options to the compiler workspace.
    “Reboot Develop 2017 - Jonathan Blow, Thekla Inc. / Making Game Programming Less Terrible.” YouTube, uploaded by Reboot Develop, May 22, 2017, https://youtu.be/De0Am_QcZiQ?t=1759 

  5. this #run directive says that at compile time when this run directive is hit, we’re going to run this function and anything else that needs to get compiled to make that function work.
    “Demo: Iteration and arrays, uninitialized values, enums.” YouTube, uploaded by Jonathan Blow, Dec 10, 2014, https://youtu.be/-UPFH0eWHEI?t=251 

  6. you can modify compile-time data structures and resubmit them.
    “Reboot Develop 2017 - Jonathan Blow, Thekla Inc. / Making Game Programming Less Terrible.” YouTube, uploaded by Reboot Develop, May 22, 2017, https://youtu.be/De0Am_QcZiQ?t=2571 

jailang 2019 pixeldroid
https://github.com/pixeldroid/jailang
programming pages theme v0.5.21 (https://github.com/pixeldroid/programming-pages)