Skip to content

Commit

Permalink
Enable Jai for Krusher effect on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
jatinchowdhury18 committed Dec 3, 2023
1 parent 665a909 commit 39590eb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion modules/cmake/FindJaiCompiler.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if(NOT (IOS OR LINUX))
if(NOT LINUX)
if(WIN32)
set(JAI_COMPILER_EXE "jai.exe")
elseif(APPLE)
Expand Down
33 changes: 12 additions & 21 deletions src/jai/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
if(WIN32)
set(JAI_LIBRARY_FILE "byod_jai_lib.lib")
set(JAI_TARGET_OS "WINDOWS")
elseif(IOS)
set(JAI_LIBRARY_FILE "byod_jai_lib_ios.a")
set(JAI_TARGET_OS "IOS")
else()
set(JAI_LIBRARY_FILE "byod_jai_lib.a")
if(APPLE)
set(JAI_TARGET_OS "MACOS")
else()
set(JAI_TARGET_OS "LINUX")
endif()
endif()

add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${JAI_LIBRARY_FILE}
COMMAND ${JAI_COMPILER} build.jai
VERBATIM
COMMAND ${JAI_COMPILER} build.jai -add "TARGET_OS :: \"${JAI_TARGET_OS}\""
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS build.jai krusher/bit_reduction.jai krusher/lofi_downsampler.jai
)
Expand All @@ -20,23 +30,4 @@ set_target_properties(byod_jai_lib
)

target_link_libraries(BYOD PRIVATE byod_jai_lib)
target_sources(BYOD PRIVATE SharedJaiContext.cpp stb_sprintf.cpp)
target_compile_definitions(BYOD PRIVATE STB_SPRINTF_IMPLEMENTATION=1)

if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
string(JOIN " " STB_CXX_FLAGS
"-Wno-language-extension-token"
"-Wno-zero-as-null-pointer-constant"
"-Wno-cast-align"
"-Wno-implicit-fallthrough"
"-Wno-conditional-uninitialized"
"-Wno-duplicate-decl-specifier"
"-Wno-unreachable-code"
)
set_source_files_properties(stb_sprintf.cpp
TARGET_DIRECTORY BYOD
PROPERTIES COMPILE_FLAGS "${STB_CXX_FLAGS}"
)
endif()

#TODO: remove stb_sprintf once Jai.Basic no longer depends on it!
target_sources(BYOD PRIVATE SharedJaiContext.cpp)
25 changes: 18 additions & 7 deletions src/jai/build.jai
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SRC_FILES :: string.[
"krusher/bit_reduction.jai"
];

build :: (building_arm64 := false, lib_postfix := "") {
build :: (building_arm64 := false, gen_header := true, lib_postfix := "") {
header_info : Header_Info;

w := compiler_create_workspace();
Expand All @@ -20,7 +20,11 @@ build :: (building_arm64 := false, lib_postfix := "") {
set_optimization(*target_options, .OPTIMIZED);
if building_arm64 {
target_options.cpu_target = .ARM64;
target_options.llvm_options.target_system_triple = "arm64-apple-darwin20.1.0";
#if TARGET_OS == "IOS" {
target_options.llvm_options.target_system_triple = "arm64-apple-ios9.0";
} else {
target_options.llvm_options.target_system_triple = "arm64-apple-darwin20.1.0";
}
}

set_build_options(target_options, w);
Expand All @@ -39,14 +43,20 @@ build :: (building_arm64 := false, lib_postfix := "") {
}
compiler_end_intercept(w);

if ! building_arm64 {
if gen_header {
generate_header(*header_info, "byod_jai_lib.h");
}

set_build_options_dc(.{do_output=false}); // No executable for this workspace.
}

#if OS == .MACOS {
#if TARGET_OS == "IOS" {
#run {
print("Building arm64 binary on iOS...\n");
build(true, true, "_ios");
}
}
#if TARGET_OS == "MACOS" {
#run {
print("Building universal binary on MacOS...\n");

Expand All @@ -56,8 +66,8 @@ build :: (building_arm64 := false, lib_postfix := "") {
File.file_delete(arm_lib);
File.file_delete(x64_lib);

build(false, "_x64");
build(true, "_arm64");
build(false, true, "_x64");
build(true, false, "_arm64");

// For some reason we need to wait a second for the ARM build to finish?
// sleep_milliseconds(500);
Expand All @@ -71,6 +81,7 @@ build :: (building_arm64 := false, lib_postfix := "") {

Process :: #import "Process";
File :: #import "File";
} else {
}
#if TARGET_OS == "WINDOWS" || TARGET_OS == "LINUX" {
#run build();
}
2 changes: 1 addition & 1 deletion src/processors/other/krusher/Krusher.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "processors/BaseProcessor.h"

#define KRUSHER_USE_JAI_IMPL ! JUCE_IOS&& BYOD_BUILDING_JAI_MODULES
#define KRUSHER_USE_JAI_IMPL BYOD_BUILDING_JAI_MODULES

#if KRUSHER_USE_JAI_IMPL
#include "jai/byod_jai_lib.h"
Expand Down

0 comments on commit 39590eb

Please sign in to comment.