Add Windows bindings
This commit is contained in:
parent
06c2a05a81
commit
c202b30d19
21
.editorconfig
Normal file
21
.editorconfig
Normal file
|
@ -0,0 +1,21 @@
|
|||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles # between different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.bat]
|
||||
end_of_line = crlf
|
||||
|
||||
[*.tsv]
|
||||
indent_style = tab
|
||||
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.exe
|
||||
*.pdb
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "source"]
|
||||
path = source
|
||||
url = git@github.com:mackron/miniaudio.git
|
45
LICENSE
Normal file
45
LICENSE
Normal file
|
@ -0,0 +1,45 @@
|
|||
This software is available as a choice of the following licenses. Choose
|
||||
whichever you prefer.
|
||||
|
||||
===============================================================================
|
||||
ALTERNATIVE 1 - Public Domain (www.unlicense.org)
|
||||
===============================================================================
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
commercial or non-commercial, and by any means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
this software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
||||
|
||||
===============================================================================
|
||||
ALTERNATIVE 2 - MIT No Attribution
|
||||
===============================================================================
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
23
README.md
Normal file
23
README.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
# miniaudio.jai
|
||||
|
||||
Jai bindings for [miniaudio](https://github.com/mackron/miniaudio)
|
||||
|
||||
## Initial setup
|
||||
|
||||
If you want to build the lib then you'll need the source code. You can do this with: `git submodule update --init --recursive`.
|
||||
In the future if you need to pull in the source submodule again (e.g. the folder got deleted), then run: `git submodule update --recursive`
|
||||
|
||||
## Usage
|
||||
|
||||
Simply import the module. If you're using a static library version then you're set. If you generated a DLL (and new bindings to load it) then you need to copy the DLL from the windows/ folder to the working directory of your exe.
|
||||
|
||||
## TODO
|
||||
|
||||
* Manually add these static inline implementations
|
||||
./source/extras/miniaudio_split/miniaudio.h:2407:28: Stripping function that’s missing from foreign libs: ma_get_bytes_per_frame
|
||||
./source/extras/miniaudio_split/miniaudio.h:6005:25: Stripping function that’s missing from foreign libs: ma_offset_pcm_frames_ptr_f32
|
||||
./source/extras/miniaudio_split/miniaudio.h:6006:31: Stripping function that’s missing from foreign libs: ma_offset_pcm_frames_const_ptr_f32
|
||||
* Replace malloc, realloc, free with Jai procs.
|
||||
* Add support for other platforms (currently only supporting Windows).
|
||||
* Review bindings to see if any declarations are missing.
|
||||
|
147
generate.jai
Normal file
147
generate.jai
Normal file
|
@ -0,0 +1,147 @@
|
|||
AT_COMPILE_TIME :: true;
|
||||
COMPILE :: true; // Enable to compile the miniaudio library from source before generating bindings.
|
||||
COMPILE_DEBUG :: false; // Compile a debug or release version of miniaudio
|
||||
|
||||
MAKE_DYNAMIC_LIB :: false; // Will make a static lib if false.
|
||||
|
||||
// There are a bunch of defines that you can set to configure the library to
|
||||
// your liking. Check out heading "2.7. Build Options" in the miniaudio source
|
||||
// file for the full list.
|
||||
//
|
||||
// We're using the default configuration, with the option to enable debug
|
||||
// logging and to specify which decoders you want to support. You can easily
|
||||
// add your own defines by including them in the extra array in generate_bindings().
|
||||
ENABLE_MINIAUDIO_DEBUG_LOGS :: false;
|
||||
|
||||
MINIAUDIO_SUPPORTED_DECODERS: Libs : .WAV | .FLAC | .MP3; // @consider making this a metaprogram/command line arg. Can then use this as a git submodule in a project and a script/build file can generate bindings for what the project requires.
|
||||
|
||||
Libs :: enum_flags {
|
||||
WAV;
|
||||
FLAC;
|
||||
MP3;
|
||||
}
|
||||
|
||||
SOURCE_PATH :: "source/extras/miniaudio_split";
|
||||
|
||||
#if AT_COMPILE_TIME {
|
||||
#run {
|
||||
set_build_options_dc(.{do_output=false});
|
||||
if !generate_bindings() {
|
||||
compiler_set_workspace_status(.FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
#import "System";
|
||||
|
||||
main :: () {
|
||||
set_working_directory(path_strip_filename(get_path_of_running_executable()));
|
||||
if !generate_bindings() {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
generate_bindings :: () -> bool {
|
||||
extra: [..] string;
|
||||
array_add(*extra, "/DMINIAUDIO_IMPLEMENTATION");
|
||||
|
||||
#if ENABLE_MINIAUDIO_DEBUG_LOGS {
|
||||
array_add(*extra, "/DMA_DEBUG_OUTPUT");
|
||||
}
|
||||
|
||||
libs := type_info(Libs);
|
||||
for libs.names {
|
||||
if !(MINIAUDIO_SUPPORTED_DECODERS & (xx libs.values[it_index])) {
|
||||
array_add(*extra, tprint("/DMA_NO_%", it));
|
||||
}
|
||||
}
|
||||
|
||||
#if COMPILE {
|
||||
#import "BuildCpp";
|
||||
|
||||
src_file := tprint("%/miniaudio.c", SOURCE_PATH);
|
||||
success := false;
|
||||
|
||||
#if OS == .WINDOWS {
|
||||
make_directory_if_it_does_not_exist("windows");
|
||||
|
||||
#if MAKE_DYNAMIC_LIB {
|
||||
array_add(*extra, "/DMA_DLL");
|
||||
success = build_cpp_dynamic_lib("windows/miniaudio", src_file, extra = extra, debug = COMPILE_DEBUG);
|
||||
}
|
||||
else {
|
||||
success = build_cpp_static_lib("windows/miniaudio", src_file, extra = extra, debug = COMPILE_DEBUG);
|
||||
if success {
|
||||
// Remove existing DLL otherwise the bindings will have a "#library" directive that loads the DLL. The lib version is "#library,no_dll"
|
||||
if file_exists("windows/miniaudio.dll") {
|
||||
deleted := file_delete("windows/miniaudio.dll");
|
||||
if !deleted {
|
||||
log_error("Failed to remove existing miniaudio.dll from the windows/ folder.\n\n");
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
log_error("This OS isn't supported yet.\n");
|
||||
}
|
||||
|
||||
if !success return false;
|
||||
}
|
||||
|
||||
output_filename: string;
|
||||
opts: Generate_Bindings_Options;
|
||||
{
|
||||
using opts;
|
||||
|
||||
#if OS == .WINDOWS {
|
||||
array_add(*libpaths, "windows");
|
||||
output_filename = "windows.jai";
|
||||
}
|
||||
else {
|
||||
log_error("This OS isn't supported yet.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
array_add(*libpaths, ".");
|
||||
array_add(*libnames, "miniaudio");
|
||||
array_add(*system_include_paths, GENERATOR_DEFAULT_SYSTEM_INCLUDE_PATH);
|
||||
array_add(*include_paths, SOURCE_PATH);
|
||||
array_add(*source_files, tprint("%/miniaudio.h", SOURCE_PATH));
|
||||
|
||||
array_add(*extra_clang_arguments, "-x", "c++", "-DWIN32_LEAN_AND_MEAN");
|
||||
|
||||
#if MAKE_DYNAMIC_LIB {
|
||||
array_add(*extra_clang_arguments, "-DMA_DLL");
|
||||
}
|
||||
|
||||
#if ENABLE_MINIAUDIO_DEBUG_LOGS {
|
||||
array_add(*extra_clang_arguments, "-DMA_DEBUG_OUTPUT");
|
||||
}
|
||||
|
||||
libs := type_info(Libs);
|
||||
for libs.names {
|
||||
if !(MINIAUDIO_SUPPORTED_DECODERS & (xx libs.values[it_index])) {
|
||||
array_add(*extra_clang_arguments, tprint("-DMA_NO_%", it));
|
||||
}
|
||||
}
|
||||
|
||||
strip_enum_prefixes = false;
|
||||
auto_detect_enum_prefixes = false;
|
||||
|
||||
log_stripped_declarations = true; // Set to true if things aren't working...
|
||||
generate_compile_time_struct_checks = true;
|
||||
}
|
||||
return generate_bindings(opts, output_filename);
|
||||
}
|
||||
|
||||
#scope_file
|
||||
|
||||
#import "Basic";
|
||||
#import "Bindings_Generator";
|
||||
#import "Compiler";
|
||||
#import "File";
|
||||
#import "File_Utilities";
|
||||
|
15
module.jai
Normal file
15
module.jai
Normal file
|
@ -0,0 +1,15 @@
|
|||
#scope_module
|
||||
|
||||
size_t :: s64;
|
||||
DWORDLONG :: u64;
|
||||
|
||||
#import "Basic";
|
||||
|
||||
#if OS == .WINDOWS {
|
||||
#import "Windows";
|
||||
#load "windows.jai";
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
|
1
source
Submodule
1
source
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 3898fff8ed923e118326bf07822961d222cb2a9a
|
8856
windows.jai
Normal file
8856
windows.jai
Normal file
File diff suppressed because it is too large
Load Diff
BIN
windows/miniaudio.lib
Normal file
BIN
windows/miniaudio.lib
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user