@@ -248,30 +248,6 @@ endif()
248248# =====================================
249249# Build Frontend Assets
250250# =====================================
251-
252- file (GLOB_RECURSE SDK_SOURCE_FILES
253- "${CMAKE_CURRENT_SOURCE_DIR} /sdk/**/*"
254- "${CMAKE_CURRENT_SOURCE_DIR} /sdk/*"
255- )
256- # Remove node_modules from SDK source files
257- list (FILTER SDK_SOURCE_FILES EXCLUDE REGEX ".*/node_modules/.*" )
258-
259- file (GLOB_RECURSE FRONTEND_SOURCE_FILES
260- "${CMAKE_CURRENT_SOURCE_DIR} /src/frontend/**/*"
261- "${CMAKE_CURRENT_SOURCE_DIR} /src/frontend/*"
262- )
263- # Remove node_modules from frontend source files
264- list (FILTER FRONTEND_SOURCE_FILES EXCLUDE REGEX ".*/node_modules/.*" )
265-
266- # Add all source files as configure dependencies
267- foreach (file ${SDK_SOURCE_FILES} )
268- set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${file} " )
269- endforeach ()
270-
271- foreach (file ${FRONTEND_SOURCE_FILES} )
272- set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${file} " )
273- endforeach ()
274-
275251# Find pnpm executable
276252find_program (PNPM_EXECUTABLE pnpm)
277253if (NOT PNPM_EXECUTABLE)
@@ -301,6 +277,9 @@ endif()
301277# =========================
302278# Build SDK
303279# =========================
280+
281+ if (CMAKE_BUILD_TYPE STREQUAL "Release" )
282+
304283message (STATUS "[Millennium] Building SDK with ${PNPM_COMMAND} ..." )
305284execute_process (
306285 COMMAND ${PNPM_COMMAND} install
@@ -365,6 +344,7 @@ if(NOT FRONTEND_BUILD_RESULT EQUAL 0)
365344endif ()
366345
367346message (STATUS "[Millennium] Frontend build completed successfully" )
347+ endif ()
368348
369349# =====================================
370350# Platform-Specific Compiler Flags
@@ -627,9 +607,7 @@ endif()
627607function (filename_to_identifier filename output_var)
628608 get_filename_component (name_without_ext "${filename} " NAME_WE )
629609 string (TOUPPER "${name_without_ext} " upper_name)
630-
631610 string (REGEX REPLACE "[-.]" "_" clean_name "${upper_name} " )
632-
633611 if (filename MATCHES "\\ .map$" )
634612 set (${output_var} "MILLENNIUM_${clean_name} _MAP_" PARENT_SCOPE)
635613 else ()
@@ -638,15 +616,17 @@ function(filename_to_identifier filename output_var)
638616endfunction ()
639617
640618file (GLOB CHUNK_FILES "${CMAKE_SOURCE_DIR} /sdk/typescript-packages/loader/build/chunks/*" )
641-
642619set (HEADER_CONTENT "/**\n * Auto-generated by Millennium during CMake configuration - do not edit manually :)\n */\n " )
643- set (HEADER_CONTENT "${HEADER_CONTENT} #define INCBIN_PREFIX\n " )
644- set (HEADER_CONTENT "${HEADER_CONTENT} #include \" incbin.h\"\n " )
645- set (HEADER_CONTENT "${HEADER_CONTENT} /** Millennium frontend library -- responsible for displaying Millennium UI, and loading themes */\n " )
646- set (HEADER_CONTENT "${HEADER_CONTENT} INCTXT(MILLENNIUM_FRONTEND_BIN_, \" ../../../build/frontend.bin\" );\n\n " )
647- set (HEADER_CONTENT "${HEADER_CONTENT} /** Millennium API library */\n " )
648- set (HEADER_CONTENT "${HEADER_CONTENT} INCTXT(MILLENNIUM_API_BIN_, \" ../../../sdk/typescript-packages/loader/build/millennium.js\" );\n " )
649- set (HEADER_CONTENT "${HEADER_CONTENT} /** Millennium API chunk files */\n " )
620+
621+ if (CMAKE_BUILD_TYPE STREQUAL "Release" )
622+ set (HEADER_CONTENT "${HEADER_CONTENT} #define INCBIN_PREFIX\n " )
623+ set (HEADER_CONTENT "${HEADER_CONTENT} #include \" incbin.h\"\n " )
624+ set (HEADER_CONTENT "${HEADER_CONTENT} /** Millennium frontend library -- responsible for displaying Millennium UI, and loading themes */\n " )
625+ set (HEADER_CONTENT "${HEADER_CONTENT} INCTXT(MILLENNIUM_FRONTEND_BIN_, \" ../../../build/frontend.bin\" );\n\n " )
626+ set (HEADER_CONTENT "${HEADER_CONTENT} /** Millennium API library */\n " )
627+ set (HEADER_CONTENT "${HEADER_CONTENT} INCTXT(MILLENNIUM_API_BIN_, \" ../../../sdk/typescript-packages/loader/build/millennium.js\" );\n " )
628+ set (HEADER_CONTENT "${HEADER_CONTENT} /** Millennium API chunk files */\n " )
629+ endif ()
650630
651631set (MAP_ENTRIES "" )
652632foreach (chunk_file ${CHUNK_FILES} )
@@ -657,16 +637,26 @@ foreach(chunk_file ${CHUNK_FILES})
657637 file (RELATIVE_PATH rel_path "${CMAKE_SOURCE_DIR} " "${chunk_file} " )
658638 filename_to_identifier("${filename} " var_name)
659639
660- set (HEADER_CONTENT "${HEADER_CONTENT} INCTXT(${var_name} , \" ../../../${rel_path} \" );\n " )
661- set (MAP_ENTRIES "${MAP_ENTRIES} \t { fmt::format(\" https://millennium.ftp/{}/chunks/${filename} \" , GetScrambledApiPathToken()), ${var_name} Data },\n " )
640+ if (CMAKE_BUILD_TYPE STREQUAL "Release" )
641+ set (HEADER_CONTENT "${HEADER_CONTENT} INCTXT(${var_name} , \" ../../../${rel_path} \" );\n " )
642+ set (MAP_ENTRIES "${MAP_ENTRIES} \t { fmt::format(\" https://millennium.ftp/{}/chunks/${filename} \" , GetScrambledApiPathToken()), []() { return ${var_name} Data; } },\n " )
643+ else ()
644+ set (MAP_ENTRIES "${MAP_ENTRIES} \t { fmt::format(\" https://millennium.ftp/{}/chunks/${filename} \" , GetScrambledApiPathToken()), []() { return SystemIO::ReadFileSync(MILLENNIUM_ROOT \" /${rel_path} \" ); } },\n " )
645+ endif ()
662646endforeach ()
663647
664648set (HEADER_CONTENT "${HEADER_CONTENT} \n // clang-format off\n " )
665- set (HEADER_CONTENT "${HEADER_CONTENT} std::unordered_map<std::string, const char*> INTERNAL_FTP_CALL_DATA = {\n " )
666- set (HEADER_CONTENT "${HEADER_CONTENT} \t { fmt::format(\" https://millennium.ftp/{}/millennium-frontend.js\" , GetScrambledApiPathToken()), MILLENNIUM_FRONTEND_BIN_Data },\n " )
667- set (HEADER_CONTENT "${HEADER_CONTENT} \t { fmt::format(\" https://millennium.ftp/{}/millennium.js\" , GetScrambledApiPathToken()), MILLENNIUM_API_BIN_Data },\n " )
668- set (HEADER_CONTENT "${HEADER_CONTENT}${MAP_ENTRIES} " )
649+ set (HEADER_CONTENT "${HEADER_CONTENT} std::unordered_map<std::string, std::function<const std::string()>> INTERNAL_FTP_CALL_DATA = {\n " )
650+
651+ if (CMAKE_BUILD_TYPE STREQUAL "Release" )
652+ set (HEADER_CONTENT "${HEADER_CONTENT} \t { fmt::format(\" https://millennium.ftp/{}/millennium-frontend.js\" , GetScrambledApiPathToken()), []() { return MILLENNIUM_FRONTEND_BIN_Data; } },\n " )
653+ set (HEADER_CONTENT "${HEADER_CONTENT} \t { fmt::format(\" https://millennium.ftp/{}/millennium.js\" , GetScrambledApiPathToken()), []() { return MILLENNIUM_API_BIN_Data; } },\n " )
654+ else ()
655+ set (HEADER_CONTENT "${HEADER_CONTENT} \t { fmt::format(\" https://millennium.ftp/{}/millennium-frontend.js\" , GetScrambledApiPathToken()), []() { return SystemIO::ReadFileSync(MILLENNIUM_ROOT \" /build/frontend.bin\" ); } },\n " )
656+ set (HEADER_CONTENT "${HEADER_CONTENT} \t { fmt::format(\" https://millennium.ftp/{}/millennium.js\" , GetScrambledApiPathToken()), []() { return SystemIO::ReadFileSync(MILLENNIUM_ROOT \" /sdk/typescript-packages/loader/build/millennium.js\" ); } },\n " )
657+ endif ()
669658
659+ set (HEADER_CONTENT "${HEADER_CONTENT}${MAP_ENTRIES} " )
670660string (REGEX REPLACE ",\n $" "\n " HEADER_CONTENT "${HEADER_CONTENT} " )
671661set (HEADER_CONTENT "${HEADER_CONTENT} };\n " )
672662set (HEADER_CONTENT "${HEADER_CONTENT} // clang-format on\n " )
0 commit comments