add stb_vorbis
This commit is contained in:
parent
631c920eb6
commit
e8f6dad025
@ -32,6 +32,7 @@ build_lib_wasm_release sokol_fetch fetch/sokol_fetch_wasm_gl_release SOKOL
|
|||||||
build_lib_wasm_release sokol_audio audio/sokol_audio_wasm_gl_release SOKOL_GLES3
|
build_lib_wasm_release sokol_audio audio/sokol_audio_wasm_gl_release SOKOL_GLES3
|
||||||
build_lib_wasm_release sokol_gl gl/sokol_gl_wasm_gl_release SOKOL_GLES3
|
build_lib_wasm_release sokol_gl gl/sokol_gl_wasm_gl_release SOKOL_GLES3
|
||||||
build_lib_wasm_release stb_image stbi/stb_image SOKOL_GLES3
|
build_lib_wasm_release stb_image stbi/stb_image SOKOL_GLES3
|
||||||
|
build_lib_wasm_release stb_vorbis stbv/stb_vorbis SOKOL_GLES3
|
||||||
|
|
||||||
# wasm + GL + Debug
|
# wasm + GL + Debug
|
||||||
build_lib_wasm_debug sokol_log log/sokol_log_wasm_gl_debug SOKOL_GLES3
|
build_lib_wasm_debug sokol_log log/sokol_log_wasm_gl_debug SOKOL_GLES3
|
||||||
@ -47,5 +48,6 @@ build_lib_wasm_debug sokol_fetch fetch/sokol_fetch_wasm_gl_debug SOKOL_G
|
|||||||
build_lib_wasm_debug sokol_audio audio/sokol_audio_wasm_gl_debug SOKOL_GLES3
|
build_lib_wasm_debug sokol_audio audio/sokol_audio_wasm_gl_debug SOKOL_GLES3
|
||||||
build_lib_wasm_debug sokol_gl gl/sokol_gl_wasm_gl_debug SOKOL_GLES3
|
build_lib_wasm_debug sokol_gl gl/sokol_gl_wasm_gl_debug SOKOL_GLES3
|
||||||
build_lib_wasm_debug stb_image stbi/stb_image SOKOL_GLES3
|
build_lib_wasm_debug stb_image stbi/stb_image SOKOL_GLES3
|
||||||
|
build_lib_wasm_debug stb_vorbis stbv/stb_vorbis SOKOL_GLES3
|
||||||
|
|
||||||
rm *.o
|
rm *.o
|
||||||
|
|||||||
9
modules/sokol-jai/sokol/c/stb_vorbis.c
Normal file
9
modules/sokol-jai/sokol/c/stb_vorbis.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifdef WIN32
|
||||||
|
#define __EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define __EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define extern extern __EXPORT
|
||||||
|
|
||||||
|
#include "stb_vorbis_impl.c"
|
||||||
5584
modules/sokol-jai/sokol/c/stb_vorbis_impl.c
Normal file
5584
modules/sokol-jai/sokol/c/stb_vorbis_impl.c
Normal file
File diff suppressed because it is too large
Load Diff
BIN
modules/stb_vorbis/android/arm64/stb_vorbis.a
Normal file
BIN
modules/stb_vorbis/android/arm64/stb_vorbis.a
Normal file
Binary file not shown.
BIN
modules/stb_vorbis/android/arm64/stb_vorbis.so
Normal file
BIN
modules/stb_vorbis/android/arm64/stb_vorbis.so
Normal file
Binary file not shown.
BIN
modules/stb_vorbis/android/x64/stb_vorbis.a
Normal file
BIN
modules/stb_vorbis/android/x64/stb_vorbis.a
Normal file
Binary file not shown.
BIN
modules/stb_vorbis/android/x64/stb_vorbis.so
Normal file
BIN
modules/stb_vorbis/android/x64/stb_vorbis.so
Normal file
Binary file not shown.
273
modules/stb_vorbis/bindings.jai
Normal file
273
modules/stb_vorbis/bindings.jai
Normal file
@ -0,0 +1,273 @@
|
|||||||
|
//
|
||||||
|
// This file was auto-generated using the following command:
|
||||||
|
//
|
||||||
|
// jai modules/stb_vorbis/generate.jai
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// normally stb_vorbis uses malloc() to allocate memory at startup,
|
||||||
|
// and alloca() to allocate temporary memory during a frame on the
|
||||||
|
// stack. (Memory consumption will depend on the amount of setup
|
||||||
|
// data in the file and how you set the compile flags for speed
|
||||||
|
// vs. size. In my test files the maximal-size usage is ~150KB.)
|
||||||
|
//
|
||||||
|
// You can modify the wrapper functions in the source (setup_malloc,
|
||||||
|
// setup_temp_malloc, temp_malloc) to change this behavior, or you
|
||||||
|
// can use a simpler allocation model: you pass in a buffer from
|
||||||
|
// which stb_vorbis will allocate _all_ its memory (including the
|
||||||
|
// temp memory). "open" may fail with a VORBIS_outofmem if you
|
||||||
|
// do not pass in enough data; there is no way to determine how
|
||||||
|
// much you do need except to succeed (at which point you can
|
||||||
|
// query get_info to find the exact amount required. yes I know
|
||||||
|
// this is lame).
|
||||||
|
//
|
||||||
|
// If you pass in a non-NULL buffer of the type below, allocation
|
||||||
|
// will occur from it as described above. Otherwise just pass NULL
|
||||||
|
// to use malloc()/alloca()
|
||||||
|
stb_vorbis_alloc :: struct {
|
||||||
|
alloc_buffer: *u8;
|
||||||
|
alloc_buffer_length_in_bytes: s32;
|
||||||
|
}
|
||||||
|
|
||||||
|
stb_vorbis :: struct {}
|
||||||
|
|
||||||
|
stb_vorbis_info :: struct {
|
||||||
|
sample_rate: u32;
|
||||||
|
channels: s32;
|
||||||
|
|
||||||
|
setup_memory_required: u32;
|
||||||
|
setup_temp_memory_required: u32;
|
||||||
|
temp_memory_required: u32;
|
||||||
|
|
||||||
|
max_frame_size: s32;
|
||||||
|
}
|
||||||
|
|
||||||
|
stb_vorbis_comment :: struct {
|
||||||
|
vendor: *u8;
|
||||||
|
|
||||||
|
comment_list_length: s32;
|
||||||
|
comment_list: **u8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get general information about the file
|
||||||
|
stb_vorbis_get_info :: (f: *stb_vorbis) -> stb_vorbis_info #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// get ogg comments
|
||||||
|
stb_vorbis_get_comment :: (f: *stb_vorbis) -> stb_vorbis_comment #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// get the last error detected (clears it, too)
|
||||||
|
stb_vorbis_get_error :: (f: *stb_vorbis) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// close an ogg vorbis file and free all memory in use
|
||||||
|
stb_vorbis_close :: (f: *stb_vorbis) -> void #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// this function returns the offset (in samples) from the beginning of the
|
||||||
|
// file that will be returned by the next decode, if it is known, or -1
|
||||||
|
// otherwise. after a flush_pushdata() call, this may take a while before
|
||||||
|
// it becomes valid again.
|
||||||
|
// NOT WORKING YET after a seek with PULLDATA API
|
||||||
|
stb_vorbis_get_sample_offset :: (f: *stb_vorbis) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// returns the current seek point within the file, or offset from the beginning
|
||||||
|
// of the memory buffer. In pushdata mode it returns 0.
|
||||||
|
stb_vorbis_get_file_offset :: (f: *stb_vorbis) -> u32 #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// this API allows you to get blocks of data from any source and hand
|
||||||
|
// them to stb_vorbis. you have to buffer them; stb_vorbis will tell
|
||||||
|
// you how much it used, and you have to give it the rest next time;
|
||||||
|
// and stb_vorbis may not have enough data to work with and you will
|
||||||
|
// need to give it the same data again PLUS more. Note that the Vorbis
|
||||||
|
// specification does not bound the size of an individual frame.
|
||||||
|
stb_vorbis_open_pushdata :: (datablock: *u8, datablock_length_in_bytes: s32, datablock_memory_consumed_in_bytes: *s32, error: *s32, alloc_buffer: *stb_vorbis_alloc) -> *stb_vorbis #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// create a vorbis decoder by passing in the initial data block containing
|
||||||
|
// the ogg&vorbis headers (you don't need to do parse them, just provide
|
||||||
|
// the first N bytes of the file--you're told if it's not enough, see below)
|
||||||
|
// on success, returns an stb_vorbis *, does not set error, returns the amount of
|
||||||
|
// data parsed/consumed on this call in *datablock_memory_consumed_in_bytes;
|
||||||
|
// on failure, returns NULL on error and sets *error, does not change *datablock_memory_consumed
|
||||||
|
// if returns NULL and *error is VORBIS_need_more_data, then the input block was
|
||||||
|
// incomplete and you need to pass in a larger block from the start of the file
|
||||||
|
stb_vorbis_decode_frame_pushdata :: (f: *stb_vorbis, datablock: *u8, datablock_length_in_bytes: s32, channels: *s32, output: ***float, samples: *s32) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// decode a frame of audio sample data if possible from the passed-in data block
|
||||||
|
//
|
||||||
|
// return value: number of bytes we used from datablock
|
||||||
|
//
|
||||||
|
// possible cases:
|
||||||
|
// 0 bytes used, 0 samples output (need more data)
|
||||||
|
// N bytes used, 0 samples output (resynching the stream, keep going)
|
||||||
|
// N bytes used, M samples output (one frame of data)
|
||||||
|
// note that after opening a file, you will ALWAYS get one N-bytes,0-sample
|
||||||
|
// frame, because Vorbis always "discards" the first frame.
|
||||||
|
//
|
||||||
|
// Note that on resynch, stb_vorbis will rarely consume all of the buffer,
|
||||||
|
// instead only datablock_length_in_bytes-3 or less. This is because it wants
|
||||||
|
// to avoid missing parts of a page header if they cross a datablock boundary,
|
||||||
|
// without writing state-machiney code to record a partial detection.
|
||||||
|
//
|
||||||
|
// The number of channels returned are stored in *channels (which can be
|
||||||
|
// NULL--it is always the same as the number of channels reported by
|
||||||
|
// get_info). *output will contain an array of float* buffers, one per
|
||||||
|
// channel. In other words, (*output)[0][0] contains the first sample from
|
||||||
|
// the first channel, and (*output)[1][0] contains the first sample from
|
||||||
|
// the second channel.
|
||||||
|
//
|
||||||
|
// *output points into stb_vorbis's internal output buffer storage; these
|
||||||
|
// buffers are owned by stb_vorbis and application code should not free
|
||||||
|
// them or modify their contents. They are transient and will be overwritten
|
||||||
|
// once you ask for more data to get decoded, so be sure to grab any data
|
||||||
|
// you need before then.
|
||||||
|
stb_vorbis_flush_pushdata :: (f: *stb_vorbis) -> void #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
stb_vorbis_decode_filename :: (filename: *u8, channels: *s32, sample_rate: *s32, output: **s16) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
stb_vorbis_decode_memory :: (mem: *u8, len: s32, channels: *s32, sample_rate: *s32, output: **s16) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// decode an entire file and output the data interleaved into a malloc()ed
|
||||||
|
// buffer stored in *output. The return value is the number of samples
|
||||||
|
// decoded, or -1 if the file could not be opened or was not an ogg vorbis file.
|
||||||
|
// When you're done with it, just free() the pointer returned in *output.
|
||||||
|
stb_vorbis_open_memory :: (data: *u8, len: s32, error: *s32, alloc_buffer: *stb_vorbis_alloc) -> *stb_vorbis #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
stb_vorbis_open_filename :: (filename: *u8, error: *s32, alloc_buffer: *stb_vorbis_alloc) -> *stb_vorbis #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// create an ogg vorbis decoder from a filename via fopen(). on failure,
|
||||||
|
// returns NULL and sets *error (possibly to VORBIS_file_open_failure).
|
||||||
|
stb_vorbis_open_file :: (f: *FILE, close_handle_on_close: s32, error: *s32, alloc_buffer: *stb_vorbis_alloc) -> *stb_vorbis #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// create an ogg vorbis decoder from an open FILE *, looking for a stream at
|
||||||
|
// the _current_ seek point (ftell). on failure, returns NULL and sets *error.
|
||||||
|
// note that stb_vorbis must "own" this stream; if you seek it in between
|
||||||
|
// calls to stb_vorbis, it will become confused. Moreover, if you attempt to
|
||||||
|
// perform stb_vorbis_seek_*() operations on this file, it will assume it
|
||||||
|
// owns the _entire_ rest of the file after the start point. Use the next
|
||||||
|
// function, stb_vorbis_open_file_section(), to limit it.
|
||||||
|
stb_vorbis_open_file_section :: (f: *FILE, close_handle_on_close: s32, error: *s32, alloc_buffer: *stb_vorbis_alloc, len: u32) -> *stb_vorbis #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
stb_vorbis_seek_frame :: (f: *stb_vorbis, sample_number: u32) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
stb_vorbis_seek :: (f: *stb_vorbis, sample_number: u32) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// these functions seek in the Vorbis file to (approximately) 'sample_number'.
|
||||||
|
// after calling seek_frame(), the next call to get_frame_*() will include
|
||||||
|
// the specified sample. after calling stb_vorbis_seek(), the next call to
|
||||||
|
// stb_vorbis_get_samples_* will start with the specified sample. If you
|
||||||
|
// do not need to seek to EXACTLY the target sample when using get_samples_*,
|
||||||
|
// you can also use seek_frame().
|
||||||
|
stb_vorbis_seek_start :: (f: *stb_vorbis) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// this function is equivalent to stb_vorbis_seek(f,0)
|
||||||
|
stb_vorbis_stream_length_in_samples :: (f: *stb_vorbis) -> u32 #foreign lib_stb_vorbis;
|
||||||
|
stb_vorbis_stream_length_in_seconds :: (f: *stb_vorbis) -> float #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// these functions return the total length of the vorbis stream
|
||||||
|
stb_vorbis_get_frame_float :: (f: *stb_vorbis, channels: *s32, output: ***float) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
stb_vorbis_get_frame_short_interleaved :: (f: *stb_vorbis, num_c: s32, buffer: *s16, num_shorts: s32) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
stb_vorbis_get_frame_short :: (f: *stb_vorbis, num_c: s32, buffer: **s16, num_samples: s32) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
// Channel coercion rules:
|
||||||
|
// Let M be the number of channels requested, and N the number of channels present,
|
||||||
|
// and Cn be the nth channel; let stereo L be the sum of all L and center channels,
|
||||||
|
// and stereo R be the sum of all R and center channels (channel assignment from the
|
||||||
|
// vorbis spec).
|
||||||
|
// M N output
|
||||||
|
// 1 k sum(Ck) for all k
|
||||||
|
// 2 * stereo L, stereo R
|
||||||
|
// k l k > l, the first l channels, then 0s
|
||||||
|
// k l k <= l, the first k channels
|
||||||
|
// Note that this is not _good_ surround etc. mixing at all! It's just so
|
||||||
|
// you get something useful.
|
||||||
|
stb_vorbis_get_samples_float_interleaved :: (f: *stb_vorbis, channels: s32, buffer: *float, num_floats: s32) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
stb_vorbis_get_samples_float :: (f: *stb_vorbis, channels: s32, buffer: **float, num_samples: s32) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
stb_vorbis_get_samples_short_interleaved :: (f: *stb_vorbis, channels: s32, buffer: *s16, num_shorts: s32) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
stb_vorbis_get_samples_short :: (f: *stb_vorbis, channels: s32, buffer: **s16, num_samples: s32) -> s32 #foreign lib_stb_vorbis;
|
||||||
|
|
||||||
|
//////// ERROR CODES
|
||||||
|
STBVorbisError :: enum u32 {
|
||||||
|
no_error :: 0;
|
||||||
|
|
||||||
|
need_more_data :: 1;
|
||||||
|
|
||||||
|
invalid_api_mixing :: 2;
|
||||||
|
outofmem :: 3;
|
||||||
|
feature_not_supported :: 4;
|
||||||
|
too_many_channels :: 5;
|
||||||
|
file_open_failure :: 6;
|
||||||
|
seek_without_length :: 7;
|
||||||
|
|
||||||
|
unexpected_eof :: 10;
|
||||||
|
seek_invalid :: 11;
|
||||||
|
|
||||||
|
invalid_setup :: 20;
|
||||||
|
invalid_stream :: 21;
|
||||||
|
|
||||||
|
missing_capture_pattern :: 30;
|
||||||
|
invalid_stream_structure_version :: 31;
|
||||||
|
continued_packet_flag_invalid :: 32;
|
||||||
|
incorrect_stream_serial_number :: 33;
|
||||||
|
invalid_first_page :: 34;
|
||||||
|
bad_packet_type :: 35;
|
||||||
|
cant_find_last_page :: 36;
|
||||||
|
seek_failed :: 37;
|
||||||
|
ogg_skeleton_not_supported :: 38;
|
||||||
|
|
||||||
|
VORBIS__no_error :: no_error;
|
||||||
|
|
||||||
|
VORBIS_need_more_data :: need_more_data;
|
||||||
|
|
||||||
|
VORBIS_invalid_api_mixing :: invalid_api_mixing;
|
||||||
|
VORBIS_outofmem :: outofmem;
|
||||||
|
VORBIS_feature_not_supported :: feature_not_supported;
|
||||||
|
VORBIS_too_many_channels :: too_many_channels;
|
||||||
|
VORBIS_file_open_failure :: file_open_failure;
|
||||||
|
VORBIS_seek_without_length :: seek_without_length;
|
||||||
|
|
||||||
|
VORBIS_unexpected_eof :: unexpected_eof;
|
||||||
|
VORBIS_seek_invalid :: seek_invalid;
|
||||||
|
|
||||||
|
VORBIS_invalid_setup :: invalid_setup;
|
||||||
|
VORBIS_invalid_stream :: invalid_stream;
|
||||||
|
|
||||||
|
VORBIS_missing_capture_pattern :: missing_capture_pattern;
|
||||||
|
VORBIS_invalid_stream_structure_version :: invalid_stream_structure_version;
|
||||||
|
VORBIS_continued_packet_flag_invalid :: continued_packet_flag_invalid;
|
||||||
|
VORBIS_incorrect_stream_serial_number :: incorrect_stream_serial_number;
|
||||||
|
VORBIS_invalid_first_page :: invalid_first_page;
|
||||||
|
VORBIS_bad_packet_type :: bad_packet_type;
|
||||||
|
VORBIS_cant_find_last_page :: cant_find_last_page;
|
||||||
|
VORBIS_seek_failed :: seek_failed;
|
||||||
|
VORBIS_ogg_skeleton_not_supported :: ogg_skeleton_not_supported;
|
||||||
|
}
|
||||||
|
|
||||||
|
#scope_file
|
||||||
|
|
||||||
|
|
||||||
|
#if OS == .WINDOWS {
|
||||||
|
lib_stb_vorbis :: #library "windows/stb_vorbis";
|
||||||
|
} else #if OS == .LINUX {
|
||||||
|
lib_stb_vorbis :: #library "linux/stb_vorbis";
|
||||||
|
} else #if OS == .MACOS {
|
||||||
|
lib_stb_vorbis :: #library "macos/stb_vorbis";
|
||||||
|
} else #if OS == .ANDROID {
|
||||||
|
#if CPU == .X64 {
|
||||||
|
lib_stb_vorbis :: #library "android/x64/stb_vorbis";
|
||||||
|
} else #if CPU == .ARM64 {
|
||||||
|
lib_stb_vorbis :: #library "android/arm64/stb_vorbis";
|
||||||
|
}
|
||||||
|
} else #if OS == .PS5 {
|
||||||
|
lib_stb_vorbis :: #library "ps5/stb_vorbis";
|
||||||
|
} else #if OS == .NN_SWITCH2 {
|
||||||
|
#if CPU == .X64 {
|
||||||
|
lib_stb_vorbis :: #library "windows/stb_vorbis";
|
||||||
|
} else #if CPU == .ARM64 {
|
||||||
|
lib_stb_vorbis :: #library "switch2/stb_vorbis";
|
||||||
|
}
|
||||||
|
} else #if OS == .WASM {
|
||||||
|
lib_stb_vorbis :: #library "wasm/stb_vorbis";
|
||||||
|
} else {
|
||||||
|
#assert false;
|
||||||
|
}
|
||||||
|
|
||||||
180
modules/stb_vorbis/generate.jai
Normal file
180
modules/stb_vorbis/generate.jai
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
AT_COMPILE_TIME :: true;
|
||||||
|
|
||||||
|
PS5_SUPPORT :: false;
|
||||||
|
NINTENDO_SUPPORT :: #run to_string(getenv("NINTENDO_SDK_ROOT")) != "";
|
||||||
|
|
||||||
|
SOURCE_PATH :: "source";
|
||||||
|
LIB_BASE_NAME :: "stb_vorbis";
|
||||||
|
LIB_DECLARATION_NAME :: "lib_stb_vorbis";
|
||||||
|
|
||||||
|
|
||||||
|
DECLARATIONS_TO_OMIT :: string.[
|
||||||
|
"STB_VORBIS_HEADER_ONLY", // No reason to export this.
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
#if AT_COMPILE_TIME {
|
||||||
|
#run,stallable {
|
||||||
|
set_build_options_dc(.{do_output=false});
|
||||||
|
options := get_build_options();
|
||||||
|
args := options.compile_time_command_line;
|
||||||
|
if !generate_bindings(args, options.minimum_os_version) {
|
||||||
|
compiler_set_workspace_status(.FAILED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
#import "System";
|
||||||
|
|
||||||
|
main :: () {
|
||||||
|
set_working_directory(path_strip_filename(get_path_of_running_executable()));
|
||||||
|
if !generate_bindings(get_command_line_arguments(), #run get_build_options().minimum_os_version) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_bindings :: (args: [] string, minimum_os_version: type_of(Build_Options.minimum_os_version)) -> bool {
|
||||||
|
using BG;
|
||||||
|
target_android := array_find(args, "-android");
|
||||||
|
target_switch2 := array_find(args, "-switch2");
|
||||||
|
target_ps5 := array_find(args, "-ps5");
|
||||||
|
target_x64 := array_find(args, "-x64");
|
||||||
|
target_arm := array_find(args, "-arm64");
|
||||||
|
compile := array_find(args, "-compile");
|
||||||
|
compile_debug := array_find(args, "-debug");
|
||||||
|
|
||||||
|
os_target := OS;
|
||||||
|
cpu_target := CPU;
|
||||||
|
if target_android os_target = .ANDROID;
|
||||||
|
if target_switch2 os_target = .NN_SWITCH2;
|
||||||
|
if target_ps5 os_target = .PS5;
|
||||||
|
|
||||||
|
if target_x64 cpu_target = .X64;
|
||||||
|
if target_arm cpu_target = .ARM64;
|
||||||
|
|
||||||
|
build_dynamic_lib := true;
|
||||||
|
lib_directory: string;
|
||||||
|
if os_target == {
|
||||||
|
case .WINDOWS;
|
||||||
|
lib_directory = "windows";
|
||||||
|
case .LINUX;
|
||||||
|
lib_directory = "linux";
|
||||||
|
case .MACOS;
|
||||||
|
lib_directory = "macos";
|
||||||
|
case .ANDROID;
|
||||||
|
lib_directory = ifx cpu_target == .X64 then "android/x64" else "android/arm64";
|
||||||
|
case .PS5;
|
||||||
|
build_dynamic_lib = false;
|
||||||
|
lib_directory = "ps5";
|
||||||
|
case .NN_SWITCH2;
|
||||||
|
build_dynamic_lib = false;
|
||||||
|
lib_directory = "switch2";
|
||||||
|
case;
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if compile {
|
||||||
|
source_file := tprint("%/stb_vorbis_custom.c", SOURCE_PATH);
|
||||||
|
|
||||||
|
make_directory_if_it_does_not_exist(lib_directory, recursive = true);
|
||||||
|
lib_path := tprint("%/%", lib_directory, LIB_BASE_NAME);
|
||||||
|
success := true;
|
||||||
|
if os_target == .MACOS {
|
||||||
|
success &&= Build_Cpp.build_universal_macos_binary(lib_path, source_file, type = .DYNAMIC_LIBRARY, debug = compile_debug);
|
||||||
|
success &&= Build_Cpp.build_universal_macos_binary(lib_path, source_file, type = .STATIC_LIBRARY, debug = compile_debug);
|
||||||
|
} else {
|
||||||
|
extra: [..] string;
|
||||||
|
if os_target == .ANDROID {
|
||||||
|
_, target_triple_with_sdk := get_android_target_triple(cpu_target);
|
||||||
|
array_add(*extra, "-target", target_triple_with_sdk);
|
||||||
|
}
|
||||||
|
if os_target != .WINDOWS {
|
||||||
|
array_add(*extra, "-fPIC");
|
||||||
|
}
|
||||||
|
|
||||||
|
if build_dynamic_lib {
|
||||||
|
success &&= Build_Cpp.build_cpp_dynamic_lib(lib_path, source_file, target = os_target, debug = compile_debug, extra = extra);
|
||||||
|
}
|
||||||
|
success &&= Build_Cpp.build_cpp_static_lib(lib_path, source_file, target = os_target, debug = compile_debug, extra = extra);
|
||||||
|
}
|
||||||
|
|
||||||
|
if !success return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
options: Generate_Bindings_Options;
|
||||||
|
options.os = os_target;
|
||||||
|
options.cpu = cpu_target;
|
||||||
|
{
|
||||||
|
using options;
|
||||||
|
|
||||||
|
array_add(*extra_clang_arguments, "-DSTB_VORBIS_HEADER_ONLY");
|
||||||
|
|
||||||
|
array_add(*library_search_paths, lib_directory);
|
||||||
|
array_add(*libraries, .{filename=LIB_BASE_NAME, identifier=LIB_DECLARATION_NAME});
|
||||||
|
array_add(*source_files, tprint("%/stb_vorbis.c", SOURCE_PATH));
|
||||||
|
|
||||||
|
generate_library_declarations = false;
|
||||||
|
footer = tprint(FOOTER_TEMPLATE, LIB_BASE_NAME, LIB_DECLARATION_NAME);
|
||||||
|
|
||||||
|
auto_detect_enum_prefixes = true;
|
||||||
|
log_stripped_declarations = false;
|
||||||
|
generate_compile_time_struct_checks = false;
|
||||||
|
|
||||||
|
visitor = stb_visitor;
|
||||||
|
}
|
||||||
|
|
||||||
|
output_filename := "bindings.jai";
|
||||||
|
return generate_bindings(options, output_filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
FOOTER_TEMPLATE :: #string END
|
||||||
|
|
||||||
|
#if OS == .WINDOWS {
|
||||||
|
%2 :: #library "windows/%1";
|
||||||
|
} else #if OS == .LINUX {
|
||||||
|
%2 :: #library "linux/%1";
|
||||||
|
} else #if OS == .MACOS {
|
||||||
|
%2 :: #library "macos/%1";
|
||||||
|
} else #if OS == .ANDROID {
|
||||||
|
#if CPU == .X64 {
|
||||||
|
%2 :: #library "android/x64/%1";
|
||||||
|
} else #if CPU == .ARM64 {
|
||||||
|
%2 :: #library "android/arm64/%1";
|
||||||
|
}
|
||||||
|
} else #if OS == .PS5 {
|
||||||
|
%2 :: #library "ps5/%1";
|
||||||
|
} else #if OS == .NN_SWITCH2 {
|
||||||
|
#if CPU == .X64 {
|
||||||
|
%2 :: #library "windows/%1";
|
||||||
|
} else #if CPU == .ARM64 {
|
||||||
|
%2 :: #library "switch2/%1";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
#assert false;
|
||||||
|
}
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
stb_visitor :: (decl: *BG.Declaration, parent_decl: *BG.Declaration) -> BG.Declaration_Visit_Result {
|
||||||
|
if !parent_decl {
|
||||||
|
if array_find(DECLARATIONS_TO_OMIT, decl.name) {
|
||||||
|
decl.decl_flags |= .OMIT_FROM_OUTPUT;
|
||||||
|
return .STOP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return .RECURSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#import "Basic";
|
||||||
|
BG :: #import "Bindings_Generator"(NINTENDO_SUPPORT = NINTENDO_SUPPORT);
|
||||||
|
Build_Cpp :: #import "BuildCpp"()(PS5_SUPPORT = PS5_SUPPORT, NINTENDO_SUPPORT = NINTENDO_SUPPORT);
|
||||||
|
#import "Compiler";
|
||||||
|
#import "File";
|
||||||
|
#import "Android/Toolchain";
|
||||||
|
#if OS == .WINDOWS {
|
||||||
|
#import "Windows";
|
||||||
|
} else {
|
||||||
|
#import "POSIX";
|
||||||
|
}
|
||||||
|
|
||||||
BIN
modules/stb_vorbis/linux/stb_vorbis.a
Normal file
BIN
modules/stb_vorbis/linux/stb_vorbis.a
Normal file
Binary file not shown.
BIN
modules/stb_vorbis/linux/stb_vorbis.so
Normal file
BIN
modules/stb_vorbis/linux/stb_vorbis.so
Normal file
Binary file not shown.
BIN
modules/stb_vorbis/macos/stb_vorbis.a
Normal file
BIN
modules/stb_vorbis/macos/stb_vorbis.a
Normal file
Binary file not shown.
BIN
modules/stb_vorbis/macos/stb_vorbis.dylib
Normal file
BIN
modules/stb_vorbis/macos/stb_vorbis.dylib
Normal file
Binary file not shown.
11
modules/stb_vorbis/module.jai
Normal file
11
modules/stb_vorbis/module.jai
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#load "bindings.jai";
|
||||||
|
|
||||||
|
#if OS == .WINDOWS || OS == .PS5 || OS == .NN_SWITCH2 || OS == .WASM {
|
||||||
|
#scope_module
|
||||||
|
FILE :: void;
|
||||||
|
} else #if OS_IS_UNIX {
|
||||||
|
#import "POSIX";
|
||||||
|
#library,system,link_always "libm";
|
||||||
|
} else {
|
||||||
|
#assert false;
|
||||||
|
}
|
||||||
5584
modules/stb_vorbis/source/stb_vorbis.c
Normal file
5584
modules/stb_vorbis/source/stb_vorbis.c
Normal file
File diff suppressed because it is too large
Load Diff
9
modules/stb_vorbis/source/stb_vorbis_custom.c
Normal file
9
modules/stb_vorbis/source/stb_vorbis_custom.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifdef WIN32
|
||||||
|
#define __EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define __EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define extern extern __EXPORT
|
||||||
|
|
||||||
|
#include "stb_vorbis.c"
|
||||||
BIN
modules/stb_vorbis/windows/stb_vorbis.dll
Normal file
BIN
modules/stb_vorbis/windows/stb_vorbis.dll
Normal file
Binary file not shown.
BIN
modules/stb_vorbis/windows/stb_vorbis.lib
Normal file
BIN
modules/stb_vorbis/windows/stb_vorbis.lib
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user