Compare commits

..

3 commits

5 changed files with 84 additions and 7 deletions

View file

@ -1,15 +1,28 @@
build: clean
mkdir -p ./bin/
odin build ./src/ -out:bin/odin_runner.exe -debug
mkdir -p ./bin/debug/
odin build ./src/ -out:bin/debug/odin_runner.exe -debug
build_rel: clean_rel
mkdir -p ./bin/release/
odin build ./src/ -out:bin/release/odin_runner.exe
run:
./bin/odin_runner.exe
./bin/debug/odin_runner.exe
run_rel:
./bin/release/odin_runner.exe
check:
odin check ./src/
clean:
rm -rf ./bin/odin_runner.*
rm -rf ./bin/debug/
clean_rel:
rm -rf ./bin/release/
cleanall:
rm -rf ./bin/
nuke:
rm -rf ./bin

View file

@ -3,8 +3,8 @@
"collections": [],
"flags": [],
"source": "./src/",
"output_dir": "./bin/",
"binary_name": "binary_name.bin"
"output_dir": "",
"binary_name": ""
},
"configurations": [
{

View file

@ -2,10 +2,13 @@
Because I can.
# How to use
Usage:
Usage examples:
```
* `odin_runner` - Run the default command with the defautl configuration (i.e. build with the defaults)
* `odin_runner build` - Same as above
* `odin_runner build debug` - Same as above but with an explicit configuration (`debug`)
* `odin_runner check` - Runs odin check with the defaults
* `odin_runner check debug` - Same as above but with an explicit configuration (`debug`)
* `odin_runner clean debug` - Cleans up build artefacts in the build directory of an explicit configuration (`debug`)
```

BIN
src.bin

Binary file not shown.

View file

@ -16,6 +16,26 @@ execute_command :: proc(
configuration: ConfigurationTargets,
) -> (
error: ExecutionError,
) {
if command == .CHECK || command == .BUILD {
return build_or_check(command, target_name, configuration)
}
if command == .CLEAN {
return clean(command, target_name, configuration)
}
if command == .TEST {
return test(command, target_name, configuration)
}
return
}
build_or_check :: proc(
command: Command,
target_name: TargetName,
configuration: ConfigurationTargets,
) -> (
error: ExecutionError,
) {
target_config, found_target_in_config := configuration[target_name]
if !found_target_in_config && target_name != "" {
@ -32,6 +52,7 @@ execute_command :: proc(
strings.write_string(&sb, command_to_string(command))
strings.write_byte(&sb, ' ')
// Append the command
if def_config, ok := configuration[DEFAULT_TARGET_NAME]; ok && !found_target_in_config {
strings.write_string(&sb, string(def_config.source))
} else if found_target_in_config {
@ -69,6 +90,26 @@ execute_command :: proc(
strings.write_string(&sb, flag)
}
}
// Append the output dir
if command == .BUILD {
output_dir: Path;binary_name: string
if def_config, ok := configuration[DEFAULT_TARGET_NAME]; ok {
if len(def_config.output_dir) != 0 && len(def_config.binary_name) != 0 {
output_dir = def_config.output_dir
binary_name = def_config.binary_name
}
}
if found_target_in_config {
output_dir = target_config.output_dir
binary_name = target_config.binary_name
}
if len(output_dir) > 0 && len(binary_name) > 0 {
strings.write_string(&sb, " -out:")
strings.write_string(&sb, string(output_dir))
strings.write_string(&sb, binary_name)
}
}
compile_flags = strings.to_string(sb)
@ -78,3 +119,23 @@ execute_command :: proc(
return
}
clean :: proc(
command: Command,
target_name: TargetName,
configuration: ConfigurationTargets,
) -> (
error: ExecutionError,
) {
return
}
test :: proc(
command: Command,
target_name: TargetName,
configuration: ConfigurationTargets,
) -> (
error: ExecutionError,
) {
return
}