This commit is contained in:
2024-10-08 09:55:52 -04:00
commit 5a4e1699b3
4 changed files with 121 additions and 0 deletions

33
.focus-config Normal file
View File

@@ -0,0 +1,33 @@
[6] # Version number. Do not delete.
[[workspace]]
# These directories and files will be scanned when a workspace is opened so that search etc. works.
./
[ignore]
.git
build_debug
.build
.DS_Store
console3d.dSYM
[[build commands]]
build_working_dir: ./
open_panel_on_build: true
close_panel_on_success: false
clear_build_output_before_running: true
error_regex: ^(?P<file>.*):(?P<line>\d+),(?P<col>\d+): (?P<type>Error|Warning|Info|...):* (?P<msg>.*)|^(?P<msg1>.*error LNK.*)
auto_jump_to_error: false
[Debug]
build_command: jai build.jai
[Build Debug Macos]
build_command: arch -x86_64 /opt/jai/bin/jai-macos build.jai
run_command: build_debug/console3d
key_binding: Cmd-Shift-B
[[settings]]
tab_size: 4
insert_spaces_when_pressing_tab: true
strip_trailing_whitespace_on_save: except_lines_with_cursor # options: all, except_lines_with_cursor, disabled

12
.gitignore vendored Normal file
View File

@@ -0,0 +1,12 @@
.build
build_debug
build_release
.DS_Store
*.obj
*.exe
*.pdb
*.lib
*.rdi
*.exp
*.bak

71
build.jai Normal file
View File

@@ -0,0 +1,71 @@
DEBUG := true;
#run build();
build :: () {
w := compiler_create_workspace();
if !w {
print("Compiler workspace creation failed.\n");
return;
}
assert(w != 0);
options := get_build_options();
options.output_executable_name = "console3d";
options.minimum_os_version = .{10, 13};
args := options.compile_time_command_line;
build_dir := "build_debug";
set_build_options_dc(.{do_output=false});
set_working_directory(#filepath);
set_optimization(*options, .DEBUG);
for arg: args {
if arg == {
case "release";
DEBUG = false;
build_dir = "build_release";
set_optimization(*options, .VERY_OPTIMIZED);
options.llvm_options.enable_split_modules = false;
options.array_bounds_check = .ON;
options.null_pointer_check = .ON;
options.arithmetic_overflow_check = .OFF;
case "debug";
case "no_output";
// useful if you want to compile to show errors, but not generate a build output
// which saves compile time
options.output_type = .NO_OUTPUT;
case;
compiler_report(tprint("Command-line argument #%, '%', is invalid. Valid options are: 'debug', 'release', 'no_output'.\n", it_index+1, arg));
}
}
make_directory_if_it_does_not_exist(build_dir);
options.output_path = build_dir;
set_build_options(options, w);
import_path: [..] string;
array_add(*import_path, "modules");
array_add(*import_path, ..options.import_path);
options.import_path = import_path;
// allows main program to use:
// #if DEBUG
build_constants := tprint(#string STRING
DEBUG :: %;
STRING,
ifx DEBUG then "true" else "false",
);
add_build_string(build_constants, w);
add_build_file(tprint("%src/main.jai", #filepath), w);
}
#import "Compiler";
#import "Basic";
#import "File";

5
src/main.jai Normal file
View File

@@ -0,0 +1,5 @@
main :: () {
print("Hello, world!");
}
#import "Basic";