adding hash library + multi windows support being started
This commit is contained in:
1 parent
f96b2e99cf
commit
7e8e626e24
17 files changed
+383
-136
No files matched your search
@@ -4,3 +4,6 @@
|
|||||||
[submodule "Juliet/external/stb"]
|
[submodule "Juliet/external/stb"]
|
||||||
path = Juliet/external/stb
|
path = Juliet/external/stb
|
||||||
url = https://github.com/nothings/stb.git
|
url = https://github.com/nothings/stb.git
|
||||||
|
[submodule "Juliet/external/xxhash"]
|
||||||
|
path = Juliet/external/xxhash
|
||||||
|
url = https://github.com/Cyan4973/xxHash.git
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
// clang-format off
|
|
||||||
// ========================================================================= //
|
|
||||||
// Includes
|
|
||||||
|
|
||||||
// Headers
|
|
||||||
#include "core/core_inc.h"
|
|
||||||
#include "window_manager/window_manager_inc.h"
|
|
||||||
#include "render/render_inc.h"
|
|
||||||
|
|
||||||
// C
|
|
||||||
#include "core/core_inc.c"
|
|
||||||
#include "window_manager/window_manager_inc.c"
|
|
||||||
#include "render/render_inc.c"
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
global WM_Window hello;
|
|
||||||
|
|
||||||
internal bool32 frame()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
TempArena scratch = scratch_begin(0, 0);
|
|
||||||
|
|
||||||
WM_EventList events = { 0 };
|
|
||||||
bool32 wait = 0;
|
|
||||||
events = wm_get_events(scratch.arena, wait);
|
|
||||||
|
|
||||||
if (hello.handle[0] == 0)
|
|
||||||
{
|
|
||||||
hello = wm_window_open(rect2fp(50.f, 50.f, 1280.f, 720.f), WM_WindowFlag_UseDefaultPosition, str8_literal("Hello"));
|
|
||||||
wm_window_first_paint(hello);
|
|
||||||
}
|
|
||||||
|
|
||||||
scratch_end(scratch);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
sleep_ms(16);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void entry_point()
|
|
||||||
{
|
|
||||||
wm_init();
|
|
||||||
|
|
||||||
for (bool32 quit = 0; !quit;)
|
|
||||||
{
|
|
||||||
quit = update();
|
|
||||||
}
|
|
||||||
wm_window_close(hello);
|
|
||||||
}
|
|
||||||
@@ -70,6 +70,11 @@
|
|||||||
# error AlignOf not defined for this compiler
|
# error AlignOf not defined for this compiler
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// For loop helpers
|
||||||
|
|
||||||
|
#define EachIndex(it, count) (uint64 it = 0; it < (count); ++it)
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Memory Helpers
|
// Memory Helpers
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// =============================================================================
|
||||||
|
// Hash Functions
|
||||||
|
|
||||||
|
#define HASH_STRING 4259
|
||||||
|
|
||||||
|
internal uint64 uint64_hash_from_string(String8 string)
|
||||||
|
{
|
||||||
|
uint64 result = uint64_hash_from_seed_string(HASH_STRING, string);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal uint64 uint64_hash_from_seed_string(uint64 seed, String8 string)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// Hash Functions
|
||||||
|
|
||||||
|
internal uint64 uint64_hash_from_string(String8 string);
|
||||||
|
internal uint64 uint64_hash_from_seed_string(uint64 seed, String8 string);
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "core_arena.c"
|
#include "core_arena.c"
|
||||||
#include "core_math.c"
|
#include "core_math.c"
|
||||||
#include "core_string.c"
|
#include "core_string.c"
|
||||||
|
#include "core_hash.c"
|
||||||
#include "core_system.c"
|
#include "core_system.c"
|
||||||
#include "core_threads.c"
|
#include "core_threads.c"
|
||||||
#include "core_thread_context.c"
|
#include "core_thread_context.c"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "core_arena.h"
|
#include "core_arena.h"
|
||||||
#include "core_math.h"
|
#include "core_math.h"
|
||||||
#include "core_string.h"
|
#include "core_string.h"
|
||||||
|
#include "core_hash.h"
|
||||||
#include "core_system.h"
|
#include "core_system.h"
|
||||||
#include "core_threads.h"
|
#include "core_threads.h"
|
||||||
#include "core_thread_context.h"
|
#include "core_thread_context.h"
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ internal uint64 cstring32_length(uint32* cstring);
|
|||||||
// String Constructor
|
// String Constructor
|
||||||
|
|
||||||
#define str8_literal(S) str8((uint8*)(S), sizeof(S) - 1)
|
#define str8_literal(S) str8((uint8*)(S), sizeof(S) - 1)
|
||||||
|
|
||||||
|
#define str8_struct(S) str8((uint8*)(S), sizeof(*(S)))
|
||||||
|
|
||||||
internal String8 str8(uint8* str, uint64 size);
|
internal String8 str8(uint8* str, uint64 size);
|
||||||
internal String8 str8_zero();
|
internal String8 str8_zero();
|
||||||
internal String16 str16(uint16* str, uint64 size);
|
internal String16 str16(uint16* str, uint64 size);
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
internal void ja_init()
|
||||||
|
{
|
||||||
|
Arena* arena = arena_alloc();
|
||||||
|
ja_state = push_array(arena, JA_State, 1);
|
||||||
|
ja_state->arena = arena;
|
||||||
|
|
||||||
|
// Window cache
|
||||||
|
ja_state->window_state_gen_id = 1;
|
||||||
|
ja_state->first_window_state = ja_state->last_window_state = &ja_nil_window_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ja_frame()
|
||||||
|
{
|
||||||
|
TempArena scratch = scratch_begin(0, 0);
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// Events from os
|
||||||
|
WM_EventList events = { 0 };
|
||||||
|
bool32 wait = 0;
|
||||||
|
events = wm_get_events(scratch.arena, wait);
|
||||||
|
|
||||||
|
// if (hello.handle[0] == 0)
|
||||||
|
// {
|
||||||
|
// hello = wm_window_open(rect2fp(50.f, 50.f, 1280.f, 720.f), WM_WindowFlag_UseDefaultPosition,
|
||||||
|
// str8_literal("Hello")); wm_window_first_paint(hello);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// Consume events
|
||||||
|
{
|
||||||
|
for (WM_Event *event = events.first, *next = 0; event != 0; event = next)
|
||||||
|
{
|
||||||
|
bool32 take = 0;
|
||||||
|
if (event->kind == WM_EventKind_WindowClose)
|
||||||
|
{
|
||||||
|
ja_state->quit = 1;
|
||||||
|
take = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (take)
|
||||||
|
{
|
||||||
|
wm_eat_event(&events, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Window management (open/render)
|
||||||
|
{
|
||||||
|
for
|
||||||
|
EachIndex(slot_idx, ja_state->window_state_gen_id)
|
||||||
|
{
|
||||||
|
JA_WindowState* ws = ja_window_state_from_id(slot_idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scratch_end(scratch);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ja_shutdown()
|
||||||
|
{
|
||||||
|
// wm_window_close(aaa);
|
||||||
|
arena_clear(ja_state->arena);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// Window Functions
|
||||||
|
|
||||||
|
internal JA_WindowState* ja_window_state_from_id(JA_ID id)
|
||||||
|
{
|
||||||
|
// scan existing windows
|
||||||
|
JA_WindowState* ws = &ja_nil_window_state;
|
||||||
|
if (id != 0 && id == ja_state->window_state_last_accessed_id && id == ja_state->window_state_last_accessed->id)
|
||||||
|
{
|
||||||
|
ws = ja_state->window_state_last_accessed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint64 hash = uint64_hash_from_string(str8_struct(&id));
|
||||||
|
}
|
||||||
|
|
||||||
|
// allocate / open window if none found for this id
|
||||||
|
|
||||||
|
return ws;
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// Core Types
|
||||||
|
typedef uint64 JA_ID;
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// States Types
|
||||||
|
|
||||||
|
typedef struct JA_WindowState JA_WindowState;
|
||||||
|
struct JA_WindowState
|
||||||
|
{
|
||||||
|
JA_WindowState* order_next;
|
||||||
|
JA_WindowState* order_previous;
|
||||||
|
JA_WindowState* hash_next;
|
||||||
|
JA_WindowState* hash_previous;
|
||||||
|
JA_ID id;
|
||||||
|
WM_Window plat_handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct JA_State JA_State;
|
||||||
|
struct JA_State
|
||||||
|
{
|
||||||
|
// Base
|
||||||
|
Arena* arena;
|
||||||
|
bool32 quit;
|
||||||
|
|
||||||
|
// Windows
|
||||||
|
JA_WindowState* first_window_state;
|
||||||
|
JA_WindowState* last_window_state;
|
||||||
|
JA_WindowState* window_state_last_accessed;
|
||||||
|
JA_ID window_state_last_accessed_id;
|
||||||
|
JA_ID window_state_gen_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// Globals
|
||||||
|
|
||||||
|
read_only global JA_WindowState ja_nil_window_state = { &ja_nil_window_state, &ja_nil_window_state };
|
||||||
|
|
||||||
|
global JA_State* ja_state = 0;
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// Top level Functions
|
||||||
|
|
||||||
|
internal void ja_init();
|
||||||
|
internal void ja_frame();
|
||||||
|
internal void ja_shutdown();
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// Window Functions
|
||||||
|
|
||||||
|
internal JA_WindowState* ja_window_state_from_id(JA_ID id);
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include "julietapp_core.c"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "julietapp_core.h"
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
// clang-format off
|
||||||
|
// ========================================================================= //
|
||||||
|
// Includes
|
||||||
|
|
||||||
|
// Headers
|
||||||
|
#include "core/core_inc.h"
|
||||||
|
#include "window_manager/window_manager_inc.h"
|
||||||
|
#include "render/render_inc.h"
|
||||||
|
#include "julietapp/julietapp_inc.h"
|
||||||
|
|
||||||
|
// C
|
||||||
|
#include "core/core_inc.c"
|
||||||
|
#include "window_manager/window_manager_inc.c"
|
||||||
|
#include "render/render_inc.c"
|
||||||
|
#include "julietapp/julietapp_inc.c"
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
internal bool32 frame()
|
||||||
|
{
|
||||||
|
ja_frame();
|
||||||
|
return ja_state->quit;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void entry_point()
|
||||||
|
{
|
||||||
|
wm_init();
|
||||||
|
ja_init();
|
||||||
|
|
||||||
|
for (bool32 quit = 0; !quit;)
|
||||||
|
{
|
||||||
|
quit = update();
|
||||||
|
}
|
||||||
|
ja_shutdown();
|
||||||
|
}
|
||||||
@@ -1,6 +1,12 @@
|
|||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Event Functions
|
// Event Functions
|
||||||
|
|
||||||
|
internal void wm_eat_event(WM_EventList* events, WM_Event* event)
|
||||||
|
{
|
||||||
|
DLL_remove(events->first, events->last, event);
|
||||||
|
events->count -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
internal WM_Event* wm_event_list_push_new(Arena* arena, WM_EventList* events, WM_EventKind kind)
|
internal WM_Event* wm_event_list_push_new(Arena* arena, WM_EventList* events, WM_EventKind kind)
|
||||||
{
|
{
|
||||||
WM_Event* evt = push_array(arena, WM_Event, 1);
|
WM_Event* evt = push_array(arena, WM_Event, 1);
|
||||||
|
|||||||
@@ -96,11 +96,13 @@ struct WM_EventList
|
|||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Application defined frame hook
|
// Application defined frame hook
|
||||||
|
|
||||||
internal bool32 frame();
|
internal bool32 frame();
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Event Functions
|
// Event Functions
|
||||||
|
|
||||||
|
internal void wm_eat_event(WM_EventList* events, WM_Event* event);
|
||||||
internal WM_Event* wm_event_list_push_new(Arena* arena, WM_EventList* events, WM_EventKind kind);
|
internal WM_Event* wm_event_list_push_new(Arena* arena, WM_EventList* events, WM_EventKind kind);
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|||||||
+12
-12
@@ -9,10 +9,10 @@ cd /D "%~dp0"
|
|||||||
::
|
::
|
||||||
:: Examples:
|
:: Examples:
|
||||||
:: new_build
|
:: new_build
|
||||||
:: new_build appbin
|
:: new_build julietapp
|
||||||
:: new_build appbin clang
|
:: new_build julietapp clang
|
||||||
:: new_build appbin release
|
:: new_build julietapp release
|
||||||
:: new_build appbin msvc debug asan
|
:: new_build julietapp msvc debug asan
|
||||||
:: new_build clean
|
:: new_build clean
|
||||||
::
|
::
|
||||||
|
|
||||||
@@ -45,12 +45,12 @@ if "%release%"=="1" set debug=0 && echo [release mode]
|
|||||||
if "%clang%"=="1" set msvc=0 && echo [clang compile]
|
if "%clang%"=="1" set msvc=0 && echo [clang compile]
|
||||||
if "%msvc%"=="1" set clang=0 && echo [msvc compile]
|
if "%msvc%"=="1" set clang=0 && echo [msvc compile]
|
||||||
|
|
||||||
:: Default target: appbin
|
:: Default target: julietapp
|
||||||
if "%~1"=="" echo [default mode, assuming `appbin` build] && set appbin=1
|
if "%~1"=="" echo [default mode, assuming `julietapp` build] && set julietapp=1
|
||||||
if "%~1"=="release" if "%~2"=="" echo [default mode, assuming `appbin` build] && set appbin=1
|
if "%~1"=="release" if "%~2"=="" echo [default mode, assuming `julietapp` build] && set julietapp=1
|
||||||
if "%~1"=="debug" if "%~2"=="" echo [default mode, assuming `appbin` build] && set appbin=1
|
if "%~1"=="debug" if "%~2"=="" echo [default mode, assuming `julietapp` build] && set julietapp=1
|
||||||
if "%~1"=="clang" if "%~2"=="" echo [default mode, assuming `appbin` build] && set appbin=1
|
if "%~1"=="clang" if "%~2"=="" echo [default mode, assuming `julietapp` build] && set julietapp=1
|
||||||
if "%~1"=="msvc" if "%~2"=="" echo [default mode, assuming `appbin` build] && set appbin=1
|
if "%~1"=="msvc" if "%~2"=="" echo [default mode, assuming `julietapp` build] && set julietapp=1
|
||||||
|
|
||||||
:: --- Unpack Command Line Build Arguments ------------------------------------
|
:: --- Unpack Command Line Build Arguments ------------------------------------
|
||||||
set auto_compile_flags=
|
set auto_compile_flags=
|
||||||
@@ -112,12 +112,12 @@ if not exist build mkdir build
|
|||||||
|
|
||||||
:: --- Build Targets (@build_targets) -----------------------------------------
|
:: --- Build Targets (@build_targets) -----------------------------------------
|
||||||
pushd build
|
pushd build
|
||||||
if "%appbin%"=="1" set didbuild=1 && %compile% ..\Juliet\appbin\appbin_main.c %compile_link% %out%appbin.exe || exit /b 1
|
if "%julietapp%"=="1" set didbuild=1 && %compile% ..\Juliet\julietapp\julietapp_main.c %compile_link% %out%julietapp.exe || exit /b 1
|
||||||
popd
|
popd
|
||||||
|
|
||||||
:: --- Warn On No Builds ------------------------------------------------------
|
:: --- Warn On No Builds ------------------------------------------------------
|
||||||
if "%didbuild%"=="" (
|
if "%didbuild%"=="" (
|
||||||
echo [WARNING] no valid build target specified; must use build target names like `new_build appbin`.
|
echo [WARNING] no valid build target specified; must use build target names like `new_build julietapp`.
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+153
-73
@@ -251,7 +251,7 @@ static void get_normalized_cwd(char* out_cwd, size_t out_cwd_size, char* out_rea
|
|||||||
static int32 get_layer_order_from_main(char layers[32][64])
|
static int32 get_layer_order_from_main(char layers[32][64])
|
||||||
{
|
{
|
||||||
int32 count = 0;
|
int32 count = 0;
|
||||||
FILE* file = fopen("Juliet/appbin/appbin_main.c", "rb");
|
FILE* file = fopen("Juliet/julietapp/julietapp_main.c", "rb");
|
||||||
if (file != NULL)
|
if (file != NULL)
|
||||||
{
|
{
|
||||||
char line[512];
|
char line[512];
|
||||||
@@ -324,7 +324,7 @@ static int32 get_layer_order_from_main(char layers[32][64])
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discover any other directories in Juliet/ that have <dir>_inc.h but weren't in appbin_main.c yet
|
// Discover any other directories in Juliet/ that have <dir>_inc.h but weren't in julietapp_main.c yet
|
||||||
WIN32_FIND_DATAA find_data;
|
WIN32_FIND_DATAA find_data;
|
||||||
HANDLE find_handle = FindFirstFileA("Juliet\\*", &find_data);
|
HANDLE find_handle = FindFirstFileA("Juliet\\*", &find_data);
|
||||||
if (find_handle != INVALID_HANDLE_VALUE)
|
if (find_handle != INVALID_HANDLE_VALUE)
|
||||||
@@ -339,7 +339,14 @@ static int32 get_layer_order_from_main(char layers[32][64])
|
|||||||
{
|
{
|
||||||
if (_stricmp(find_data.cFileName, "src") == 0 ||
|
if (_stricmp(find_data.cFileName, "src") == 0 ||
|
||||||
_stricmp(find_data.cFileName, "include") == 0 ||
|
_stricmp(find_data.cFileName, "include") == 0 ||
|
||||||
_stricmp(find_data.cFileName, "appbin") == 0)
|
_stricmp(find_data.cFileName, "external") == 0 ||
|
||||||
|
_stricmp(find_data.cFileName, "win32") == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
char inc_check_path[512];
|
||||||
|
snprintf(inc_check_path, sizeof(inc_check_path), "Juliet\\%s\\%s_inc.h", find_data.cFileName, find_data.cFileName);
|
||||||
|
if (GetFileAttributesA(inc_check_path) == INVALID_FILE_ATTRIBUTES)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -369,25 +376,20 @@ static int32 find_layer_index_for_file(const char* file_path, char layers[32][64
|
|||||||
{
|
{
|
||||||
Assert(file_path != NULL);
|
Assert(file_path != NULL);
|
||||||
|
|
||||||
if (strstr(file_path, "win32/core") != NULL || strstr(file_path, "win32\\core") != NULL)
|
|
||||||
{
|
|
||||||
for (int32 i = 0; i < layer_count; ++i)
|
|
||||||
{
|
|
||||||
if (_stricmp(layers[i], "core") == 0)
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32 i = 0; i < layer_count; ++i)
|
for (int32 i = 0; i < layer_count; ++i)
|
||||||
{
|
{
|
||||||
char prefix1[128];
|
char prefix1[128];
|
||||||
char prefix2[128];
|
char prefix2[128];
|
||||||
|
char win32_prefix1[128];
|
||||||
|
char win32_prefix2[128];
|
||||||
snprintf(prefix1, sizeof(prefix1), "Juliet/%s/", layers[i]);
|
snprintf(prefix1, sizeof(prefix1), "Juliet/%s/", layers[i]);
|
||||||
snprintf(prefix2, sizeof(prefix2), "Juliet\\%s\\", layers[i]);
|
snprintf(prefix2, sizeof(prefix2), "Juliet\\%s\\", layers[i]);
|
||||||
|
snprintf(win32_prefix1, sizeof(win32_prefix1), "Juliet/win32/%s/", layers[i]);
|
||||||
|
snprintf(win32_prefix2, sizeof(win32_prefix2), "Juliet\\win32\\%s\\", layers[i]);
|
||||||
if (_strnicmp(file_path, prefix1, strlen(prefix1)) == 0 ||
|
if (_strnicmp(file_path, prefix1, strlen(prefix1)) == 0 ||
|
||||||
_strnicmp(file_path, prefix2, strlen(prefix2)) == 0)
|
_strnicmp(file_path, prefix2, strlen(prefix2)) == 0 ||
|
||||||
|
_strnicmp(file_path, win32_prefix1, strlen(win32_prefix1)) == 0 ||
|
||||||
|
_strnicmp(file_path, win32_prefix2, strlen(win32_prefix2)) == 0)
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -396,6 +398,73 @@ static int32 find_layer_index_for_file(const char* file_path, char layers[32][64
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool file_directly_includes_target(const char* header_disk_path, const char* header_layer_name, const char* target_file_path)
|
||||||
|
{
|
||||||
|
Assert(header_disk_path != NULL);
|
||||||
|
Assert(header_layer_name != NULL);
|
||||||
|
Assert(target_file_path != NULL);
|
||||||
|
|
||||||
|
FILE* file = fopen(header_disk_path, "rb");
|
||||||
|
if (file == NULL)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
char line[512];
|
||||||
|
while (fgets(line, sizeof(line), file) != NULL)
|
||||||
|
{
|
||||||
|
char* hash = strchr(line, '#');
|
||||||
|
if (hash == NULL)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
char* inc_pos = strstr(hash, "include");
|
||||||
|
if (inc_pos == NULL)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
char* quote_start = strchr(inc_pos, '"');
|
||||||
|
if (quote_start == NULL)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
quote_start++;
|
||||||
|
char* quote_end = strchr(quote_start, '"');
|
||||||
|
if (quote_end == NULL)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
size_t inc_file_len = (size_t)(quote_end - quote_start);
|
||||||
|
if (inc_file_len == 0 || inc_file_len >= 256)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
char inc_file[256];
|
||||||
|
memcpy(inc_file, quote_start, inc_file_len);
|
||||||
|
inc_file[inc_file_len] = '\0';
|
||||||
|
normalize_path_slashes_forward(inc_file);
|
||||||
|
|
||||||
|
char candidate_layer[512];
|
||||||
|
snprintf(candidate_layer, sizeof(candidate_layer), "Juliet/%s/%s", header_layer_name, inc_file);
|
||||||
|
normalize_path_slashes_forward(candidate_layer);
|
||||||
|
|
||||||
|
char candidate_root[512];
|
||||||
|
snprintf(candidate_root, sizeof(candidate_root), "Juliet/%s", inc_file);
|
||||||
|
normalize_path_slashes_forward(candidate_root);
|
||||||
|
|
||||||
|
if (_stricmp(candidate_layer, target_file_path) == 0 ||
|
||||||
|
_stricmp(candidate_root, target_file_path) == 0)
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(file);
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
static void get_preceding_includes_from_inc_h(const char* layer_name, const char* target_file_path, char* out_flags, size_t out_flags_size)
|
static void get_preceding_includes_from_inc_h(const char* layer_name, const char* target_file_path, char* out_flags, size_t out_flags_size)
|
||||||
{
|
{
|
||||||
Assert(layer_name != NULL);
|
Assert(layer_name != NULL);
|
||||||
@@ -448,35 +517,33 @@ static void get_preceding_includes_from_inc_h(const char* layer_name, const char
|
|||||||
inc_file[inc_file_len] = '\0';
|
inc_file[inc_file_len] = '\0';
|
||||||
normalize_path_slashes_forward(inc_file);
|
normalize_path_slashes_forward(inc_file);
|
||||||
|
|
||||||
|
char candidate_in_layer[512];
|
||||||
|
snprintf(candidate_in_layer, sizeof(candidate_in_layer), "Juliet/%s/%s", layer_name, inc_file);
|
||||||
|
normalize_path_slashes_forward(candidate_in_layer);
|
||||||
|
|
||||||
char full_inc_path[512];
|
char full_inc_path[512];
|
||||||
if (strstr(inc_file, "/") != NULL)
|
char fi_rel_path[512];
|
||||||
|
if (GetFileAttributesA(candidate_in_layer) != INVALID_FILE_ATTRIBUTES)
|
||||||
{
|
{
|
||||||
snprintf(full_inc_path, sizeof(full_inc_path), "Juliet/%s", inc_file);
|
strncpy_s(full_inc_path, sizeof(full_inc_path), candidate_in_layer, _TRUNCATE);
|
||||||
|
snprintf(fi_rel_path, sizeof(fi_rel_path), "%s/%s", layer_name, inc_file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf(full_inc_path, sizeof(full_inc_path), "Juliet/%s/%s", layer_name, inc_file);
|
snprintf(full_inc_path, sizeof(full_inc_path), "Juliet/%s", inc_file);
|
||||||
|
strncpy_s(fi_rel_path, sizeof(fi_rel_path), inc_file, _TRUNCATE);
|
||||||
}
|
}
|
||||||
normalize_path_slashes_forward(full_inc_path);
|
normalize_path_slashes_forward(full_inc_path);
|
||||||
|
normalize_path_slashes_forward(fi_rel_path);
|
||||||
char expected_suffix[256];
|
|
||||||
snprintf(expected_suffix, sizeof(expected_suffix), "/%s", inc_file);
|
|
||||||
|
|
||||||
if (_stricmp(full_inc_path, target_file_path) == 0 ||
|
if (_stricmp(full_inc_path, target_file_path) == 0 ||
|
||||||
str_ends_with_no_case(target_file_path, expected_suffix))
|
file_directly_includes_target(full_inc_path, layer_name, target_file_path))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
char flag[512];
|
char flag[512];
|
||||||
if (strstr(inc_file, "/") != NULL)
|
snprintf(flag, sizeof(flag), " \"/FI%s\",\n", fi_rel_path);
|
||||||
{
|
|
||||||
snprintf(flag, sizeof(flag), " \"/FI%s\",\n", inc_file);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf(flag, sizeof(flag), " \"/FI%s/%s\",\n", layer_name, inc_file);
|
|
||||||
}
|
|
||||||
strncat_s(out_flags, out_flags_size, flag, _TRUNCATE);
|
strncat_s(out_flags, out_flags_size, flag, _TRUNCATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,7 +568,7 @@ static void generate_compile_commands(void)
|
|||||||
char layers[32][64];
|
char layers[32][64];
|
||||||
int32 layer_count = get_layer_order_from_main(layers);
|
int32 layer_count = get_layer_order_from_main(layers);
|
||||||
|
|
||||||
// 1. Scan new Juliet modules (core, render, ui, appbin, etc.)
|
// 1. Scan new Juliet modules (core, window_manager, render, julietapp, etc.)
|
||||||
WIN32_FIND_DATAA find_data;
|
WIN32_FIND_DATAA find_data;
|
||||||
HANDLE find_handle = FindFirstFileA("Juliet\\*", &find_data);
|
HANDLE find_handle = FindFirstFileA("Juliet\\*", &find_data);
|
||||||
if (find_handle != INVALID_HANDLE_VALUE)
|
if (find_handle != INVALID_HANDLE_VALUE)
|
||||||
@@ -515,7 +582,9 @@ static void generate_compile_commands(void)
|
|||||||
|
|
||||||
if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
{
|
{
|
||||||
if (_stricmp(find_data.cFileName, "src") == 0 || _stricmp(find_data.cFileName, "include") == 0)
|
if (_stricmp(find_data.cFileName, "src") == 0 ||
|
||||||
|
_stricmp(find_data.cFileName, "include") == 0 ||
|
||||||
|
_stricmp(find_data.cFileName, "external") == 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -531,11 +600,12 @@ static void generate_compile_commands(void)
|
|||||||
char forced_inc_flags[1024] = "";
|
char forced_inc_flags[1024] = "";
|
||||||
int32 file_layer_idx = find_layer_index_for_file(node->path, layers, layer_count);
|
int32 file_layer_idx = find_layer_index_for_file(node->path, layers, layer_count);
|
||||||
|
|
||||||
if (file_layer_idx >= 0 && _stricmp(layers[file_layer_idx], "appbin") != 0)
|
if (file_layer_idx >= 0 && !str_ends_with_no_case(node->path, "_main.c"))
|
||||||
{
|
{
|
||||||
for (int32 i = 0; i <= file_layer_idx; ++i)
|
if (is_c_source_file(node->path))
|
||||||
{
|
{
|
||||||
if (i < file_layer_idx)
|
// In the unity build, all layer _inc.h headers are included before any _inc.c file
|
||||||
|
for (int32 i = 0; i < layer_count; ++i)
|
||||||
{
|
{
|
||||||
char inc_disk_path[512];
|
char inc_disk_path[512];
|
||||||
snprintf(inc_disk_path, sizeof(inc_disk_path), "Juliet\\%s\\%s_inc.h", layers[i], layers[i]);
|
snprintf(inc_disk_path, sizeof(inc_disk_path), "Juliet\\%s\\%s_inc.h", layers[i], layers[i]);
|
||||||
@@ -546,9 +616,12 @@ static void generate_compile_commands(void)
|
|||||||
strncat_s(forced_inc_flags, sizeof(forced_inc_flags), flag, _TRUNCATE);
|
strncat_s(forced_inc_flags, sizeof(forced_inc_flags), flag, _TRUNCATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (is_c_source_file(node->path))
|
for (int32 i = 0; i <= file_layer_idx; ++i)
|
||||||
|
{
|
||||||
|
if (i < file_layer_idx)
|
||||||
{
|
{
|
||||||
char inc_disk_path[512];
|
char inc_disk_path[512];
|
||||||
snprintf(inc_disk_path, sizeof(inc_disk_path), "Juliet\\%s\\%s_inc.h", layers[i], layers[i]);
|
snprintf(inc_disk_path, sizeof(inc_disk_path), "Juliet\\%s\\%s_inc.h", layers[i], layers[i]);
|
||||||
@@ -595,7 +668,12 @@ static void generate_compile_commands(void)
|
|||||||
" \"/nologo\",\n"
|
" \"/nologo\",\n"
|
||||||
" \"/clang:-std=c11\",\n"
|
" \"/clang:-std=c11\",\n"
|
||||||
" \"/W4\",\n"
|
" \"/W4\",\n"
|
||||||
" \"/Wno-unused-function\",\n"
|
" \"-Wno-unused-function\",\n"
|
||||||
|
" \"-Wno-unused-parameter\",\n"
|
||||||
|
" \"-Wno-unused-variable\",\n"
|
||||||
|
" \"-Wno-missing-braces\",\n"
|
||||||
|
" \"-Wno-missing-field-initializers\",\n"
|
||||||
|
" \"-Wno-cast-function-type-mismatch\",\n"
|
||||||
" \"/clang:-Wno-initializer-overrides\",\n"
|
" \"/clang:-Wno-initializer-overrides\",\n"
|
||||||
" \"/utf-8\",\n"
|
" \"/utf-8\",\n"
|
||||||
" \"/DBUILD_DEBUG=1\",\n"
|
" \"/DBUILD_DEBUG=1\",\n"
|
||||||
@@ -718,11 +796,11 @@ static void generate_vs_files(void)
|
|||||||
CreateDirectoryA("vs", NULL);
|
CreateDirectoryA("vs", NULL);
|
||||||
|
|
||||||
// Discover modules in Juliet/
|
// Discover modules in Juliet/
|
||||||
ProjectInfo appbin_project = {0};
|
ProjectInfo julietapp_project = {0};
|
||||||
strncpy_s(appbin_project.name, sizeof(appbin_project.name), "appbin", _TRUNCATE);
|
strncpy_s(julietapp_project.name, sizeof(julietapp_project.name), "julietapp", _TRUNCATE);
|
||||||
generate_deterministic_guid(appbin_project.name, appbin_project.guid, sizeof(appbin_project.guid));
|
generate_deterministic_guid(julietapp_project.name, julietapp_project.guid, sizeof(julietapp_project.guid));
|
||||||
|
|
||||||
// Gather all new module files for appbin project
|
// Gather all new module files for julietapp project
|
||||||
WIN32_FIND_DATAA find_data;
|
WIN32_FIND_DATAA find_data;
|
||||||
HANDLE find_handle = FindFirstFileA("Juliet\\*", &find_data);
|
HANDLE find_handle = FindFirstFileA("Juliet\\*", &find_data);
|
||||||
if (find_handle != INVALID_HANDLE_VALUE)
|
if (find_handle != INVALID_HANDLE_VALUE)
|
||||||
@@ -736,7 +814,9 @@ static void generate_vs_files(void)
|
|||||||
|
|
||||||
if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
{
|
{
|
||||||
if (_stricmp(find_data.cFileName, "src") == 0 || _stricmp(find_data.cFileName, "include") == 0)
|
if (_stricmp(find_data.cFileName, "src") == 0 ||
|
||||||
|
_stricmp(find_data.cFileName, "include") == 0 ||
|
||||||
|
_stricmp(find_data.cFileName, "external") == 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -751,11 +831,11 @@ static void generate_vs_files(void)
|
|||||||
{
|
{
|
||||||
if (is_c_source_file(node->path))
|
if (is_c_source_file(node->path))
|
||||||
{
|
{
|
||||||
file_list_push(&appbin_project.c_files, node->path);
|
file_list_push(&julietapp_project.c_files, node->path);
|
||||||
}
|
}
|
||||||
else if (is_c_header_file(node->path))
|
else if (is_c_header_file(node->path))
|
||||||
{
|
{
|
||||||
file_list_push(&appbin_project.h_files, node->path);
|
file_list_push(&julietapp_project.h_files, node->path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -766,7 +846,7 @@ static void generate_vs_files(void)
|
|||||||
FindClose(find_handle);
|
FindClose(find_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Generate vs/appbin.vcxproj
|
// 1. Generate vs/julietapp.vcxproj
|
||||||
size_t buf_cap = 2 * 1024 * 1024;
|
size_t buf_cap = 2 * 1024 * 1024;
|
||||||
char* vcxproj_buf = (char*)malloc(buf_cap);
|
char* vcxproj_buf = (char*)malloc(buf_cap);
|
||||||
Assert(vcxproj_buf != NULL);
|
Assert(vcxproj_buf != NULL);
|
||||||
@@ -788,7 +868,7 @@ static void generate_vs_files(void)
|
|||||||
" <PropertyGroup Label=\"Globals\">\n"
|
" <PropertyGroup Label=\"Globals\">\n"
|
||||||
" <ProjectGuid>{%s}</ProjectGuid>\n"
|
" <ProjectGuid>{%s}</ProjectGuid>\n"
|
||||||
" <Keyword>MakeFileProj</Keyword>\n"
|
" <Keyword>MakeFileProj</Keyword>\n"
|
||||||
" <ProjectName>appbin</ProjectName>\n"
|
" <ProjectName>julietapp</ProjectName>\n"
|
||||||
" </PropertyGroup>\n"
|
" </PropertyGroup>\n"
|
||||||
" <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n"
|
" <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n"
|
||||||
" <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n"
|
" <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n"
|
||||||
@@ -804,25 +884,25 @@ static void generate_vs_files(void)
|
|||||||
" <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n"
|
" <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n"
|
||||||
" <ImportGroup Label=\"ExtensionSettings\" />\n"
|
" <ImportGroup Label=\"ExtensionSettings\" />\n"
|
||||||
" <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n"
|
" <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n"
|
||||||
" <NMakeBuildCommandLine>cd $(SolutionDir)..\\ & new_build.bat appbin debug</NMakeBuildCommandLine>\n"
|
" <NMakeBuildCommandLine>cd $(SolutionDir)..\\ & new_build.bat julietapp debug</NMakeBuildCommandLine>\n"
|
||||||
" <NMakeReBuildCommandLine>cd $(SolutionDir)..\\ & new_build.bat clean & new_build.bat appbin debug</NMakeReBuildCommandLine>\n"
|
" <NMakeReBuildCommandLine>cd $(SolutionDir)..\\ & new_build.bat clean & new_build.bat julietapp debug</NMakeReBuildCommandLine>\n"
|
||||||
" <NMakeCleanCommandLine>cd $(SolutionDir)..\\ & new_build.bat clean</NMakeCleanCommandLine>\n"
|
" <NMakeCleanCommandLine>cd $(SolutionDir)..\\ & new_build.bat clean</NMakeCleanCommandLine>\n"
|
||||||
" <NMakeOutput>$(SolutionDir)..\\build\\appbin.exe</NMakeOutput>\n"
|
" <NMakeOutput>$(SolutionDir)..\\build\\julietapp.exe</NMakeOutput>\n"
|
||||||
" <NMakeIncludeSearchPath>$(SolutionDir)..\\Juliet;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>\n"
|
" <NMakeIncludeSearchPath>$(SolutionDir)..\\Juliet;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>\n"
|
||||||
" <NMakePreprocessorDefinitions>BUILD_DEBUG=1;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>\n"
|
" <NMakePreprocessorDefinitions>BUILD_DEBUG=1;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>\n"
|
||||||
" </PropertyGroup>\n"
|
" </PropertyGroup>\n"
|
||||||
" <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n"
|
" <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n"
|
||||||
" <NMakeBuildCommandLine>cd $(SolutionDir)..\\ & new_build.bat appbin release</NMakeBuildCommandLine>\n"
|
" <NMakeBuildCommandLine>cd $(SolutionDir)..\\ & new_build.bat julietapp release</NMakeBuildCommandLine>\n"
|
||||||
" <NMakeReBuildCommandLine>cd $(SolutionDir)..\\ & new_build.bat clean & new_build.bat appbin release</NMakeReBuildCommandLine>\n"
|
" <NMakeReBuildCommandLine>cd $(SolutionDir)..\\ & new_build.bat clean & new_build.bat julietapp release</NMakeReBuildCommandLine>\n"
|
||||||
" <NMakeCleanCommandLine>cd $(SolutionDir)..\\ & new_build.bat clean</NMakeCleanCommandLine>\n"
|
" <NMakeCleanCommandLine>cd $(SolutionDir)..\\ & new_build.bat clean</NMakeCleanCommandLine>\n"
|
||||||
" <NMakeOutput>$(SolutionDir)..\\build\\appbin.exe</NMakeOutput>\n"
|
" <NMakeOutput>$(SolutionDir)..\\build\\julietapp.exe</NMakeOutput>\n"
|
||||||
" <NMakeIncludeSearchPath>$(SolutionDir)..\\Juliet;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>\n"
|
" <NMakeIncludeSearchPath>$(SolutionDir)..\\Juliet;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>\n"
|
||||||
" <NMakePreprocessorDefinitions>BUILD_DEBUG=0;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>\n"
|
" <NMakePreprocessorDefinitions>BUILD_DEBUG=0;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>\n"
|
||||||
" </PropertyGroup>\n"
|
" </PropertyGroup>\n"
|
||||||
" <ItemGroup>\n",
|
" <ItemGroup>\n",
|
||||||
appbin_project.guid);
|
julietapp_project.guid);
|
||||||
|
|
||||||
for (FileNode* node = appbin_project.c_files.first; node != NULL; node = node->next)
|
for (FileNode* node = julietapp_project.c_files.first; node != NULL; node = node->next)
|
||||||
{
|
{
|
||||||
char backslash_path[512];
|
char backslash_path[512];
|
||||||
strncpy_s(backslash_path, sizeof(backslash_path), node->path, _TRUNCATE);
|
strncpy_s(backslash_path, sizeof(backslash_path), node->path, _TRUNCATE);
|
||||||
@@ -832,7 +912,7 @@ static void generate_vs_files(void)
|
|||||||
}
|
}
|
||||||
offset += snprintf(vcxproj_buf + offset, buf_cap - offset, " </ItemGroup>\n <ItemGroup>\n");
|
offset += snprintf(vcxproj_buf + offset, buf_cap - offset, " </ItemGroup>\n <ItemGroup>\n");
|
||||||
|
|
||||||
for (FileNode* node = appbin_project.h_files.first; node != NULL; node = node->next)
|
for (FileNode* node = julietapp_project.h_files.first; node != NULL; node = node->next)
|
||||||
{
|
{
|
||||||
char backslash_path[512];
|
char backslash_path[512];
|
||||||
strncpy_s(backslash_path, sizeof(backslash_path), node->path, _TRUNCATE);
|
strncpy_s(backslash_path, sizeof(backslash_path), node->path, _TRUNCATE);
|
||||||
@@ -855,11 +935,11 @@ static void generate_vs_files(void)
|
|||||||
" <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n"
|
" <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n"
|
||||||
"</Project>\n");
|
"</Project>\n");
|
||||||
|
|
||||||
write_entire_file("vs\\appbin.vcxproj", vcxproj_buf, offset);
|
write_entire_file("vs\\julietapp.vcxproj", vcxproj_buf, offset);
|
||||||
printf("[SUCCESS] Generated vs\\appbin.vcxproj\n");
|
printf("[SUCCESS] Generated vs\\julietapp.vcxproj\n");
|
||||||
free(vcxproj_buf);
|
free(vcxproj_buf);
|
||||||
|
|
||||||
// 2. Generate vs/appbin.vcxproj.filters
|
// 2. Generate vs/julietapp.vcxproj.filters
|
||||||
char* filters_buf = (char*)malloc(buf_cap);
|
char* filters_buf = (char*)malloc(buf_cap);
|
||||||
Assert(filters_buf != NULL);
|
Assert(filters_buf != NULL);
|
||||||
|
|
||||||
@@ -869,17 +949,17 @@ static void generate_vs_files(void)
|
|||||||
"<Project ToolsVersion=\"17.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
|
"<Project ToolsVersion=\"17.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
|
||||||
" <ItemGroup>\n"
|
" <ItemGroup>\n"
|
||||||
" <Filter Include=\"core\" />\n"
|
" <Filter Include=\"core\" />\n"
|
||||||
" <Filter Include=\"appbin\" />\n"
|
" <Filter Include=\"julietapp\" />\n"
|
||||||
" </ItemGroup>\n"
|
" </ItemGroup>\n"
|
||||||
" <ItemGroup>\n");
|
" <ItemGroup>\n");
|
||||||
|
|
||||||
for (FileNode* node = appbin_project.c_files.first; node != NULL; node = node->next)
|
for (FileNode* node = julietapp_project.c_files.first; node != NULL; node = node->next)
|
||||||
{
|
{
|
||||||
char backslash_path[512];
|
char backslash_path[512];
|
||||||
strncpy_s(backslash_path, sizeof(backslash_path), node->path, _TRUNCATE);
|
strncpy_s(backslash_path, sizeof(backslash_path), node->path, _TRUNCATE);
|
||||||
normalize_path_slashes_backward(backslash_path);
|
normalize_path_slashes_backward(backslash_path);
|
||||||
|
|
||||||
const char* filter = strstr(node->path, "core/") ? "core" : "appbin";
|
const char* filter = strstr(node->path, "core/") ? "core" : "julietapp";
|
||||||
f_offset += snprintf(filters_buf + f_offset, buf_cap - f_offset,
|
f_offset += snprintf(filters_buf + f_offset, buf_cap - f_offset,
|
||||||
" <ClCompile Include=\"..\\%s\">\n"
|
" <ClCompile Include=\"..\\%s\">\n"
|
||||||
" <Filter>%s</Filter>\n"
|
" <Filter>%s</Filter>\n"
|
||||||
@@ -887,13 +967,13 @@ static void generate_vs_files(void)
|
|||||||
}
|
}
|
||||||
f_offset += snprintf(filters_buf + f_offset, buf_cap - f_offset, " </ItemGroup>\n <ItemGroup>\n");
|
f_offset += snprintf(filters_buf + f_offset, buf_cap - f_offset, " </ItemGroup>\n <ItemGroup>\n");
|
||||||
|
|
||||||
for (FileNode* node = appbin_project.h_files.first; node != NULL; node = node->next)
|
for (FileNode* node = julietapp_project.h_files.first; node != NULL; node = node->next)
|
||||||
{
|
{
|
||||||
char backslash_path[512];
|
char backslash_path[512];
|
||||||
strncpy_s(backslash_path, sizeof(backslash_path), node->path, _TRUNCATE);
|
strncpy_s(backslash_path, sizeof(backslash_path), node->path, _TRUNCATE);
|
||||||
normalize_path_slashes_backward(backslash_path);
|
normalize_path_slashes_backward(backslash_path);
|
||||||
|
|
||||||
const char* filter = strstr(node->path, "core/") ? "core" : "appbin";
|
const char* filter = strstr(node->path, "core/") ? "core" : "julietapp";
|
||||||
f_offset += snprintf(filters_buf + f_offset, buf_cap - f_offset,
|
f_offset += snprintf(filters_buf + f_offset, buf_cap - f_offset,
|
||||||
" <ClInclude Include=\"..\\%s\">\n"
|
" <ClInclude Include=\"..\\%s\">\n"
|
||||||
" <Filter>%s</Filter>\n"
|
" <Filter>%s</Filter>\n"
|
||||||
@@ -919,8 +999,8 @@ static void generate_vs_files(void)
|
|||||||
|
|
||||||
f_offset += snprintf(filters_buf + f_offset, buf_cap - f_offset, "</Project>\n");
|
f_offset += snprintf(filters_buf + f_offset, buf_cap - f_offset, "</Project>\n");
|
||||||
|
|
||||||
write_entire_file("vs\\appbin.vcxproj.filters", filters_buf, f_offset);
|
write_entire_file("vs\\julietapp.vcxproj.filters", filters_buf, f_offset);
|
||||||
printf("[SUCCESS] Generated vs\\appbin.vcxproj.filters\n");
|
printf("[SUCCESS] Generated vs\\julietapp.vcxproj.filters\n");
|
||||||
free(filters_buf);
|
free(filters_buf);
|
||||||
|
|
||||||
// 3. Generate vs/new_Juliet.sln
|
// 3. Generate vs/new_Juliet.sln
|
||||||
@@ -930,7 +1010,7 @@ static void generate_vs_files(void)
|
|||||||
"# Visual Studio Version 17\n"
|
"# Visual Studio Version 17\n"
|
||||||
"VisualStudioVersion = 17.0.31903.59\n"
|
"VisualStudioVersion = 17.0.31903.59\n"
|
||||||
"MinimumVisualStudioVersion = 10.0.40219.1\n"
|
"MinimumVisualStudioVersion = 10.0.40219.1\n"
|
||||||
"Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"appbin\", \"appbin.vcxproj\", \"{%s}\"\n"
|
"Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"julietapp\", \"julietapp.vcxproj\", \"{%s}\"\n"
|
||||||
"EndProject\n"
|
"EndProject\n"
|
||||||
"Global\n"
|
"Global\n"
|
||||||
" GlobalSection(SolutionConfigurationPlatforms) = preSolution\n"
|
" GlobalSection(SolutionConfigurationPlatforms) = preSolution\n"
|
||||||
@@ -947,17 +1027,17 @@ static void generate_vs_files(void)
|
|||||||
" HideSolutionNode = FALSE\n"
|
" HideSolutionNode = FALSE\n"
|
||||||
" EndGlobalSection\n"
|
" EndGlobalSection\n"
|
||||||
"EndGlobal\n",
|
"EndGlobal\n",
|
||||||
appbin_project.guid,
|
julietapp_project.guid,
|
||||||
appbin_project.guid,
|
julietapp_project.guid,
|
||||||
appbin_project.guid,
|
julietapp_project.guid,
|
||||||
appbin_project.guid,
|
julietapp_project.guid,
|
||||||
appbin_project.guid);
|
julietapp_project.guid);
|
||||||
|
|
||||||
write_entire_file("vs\\new_Juliet.sln", sln_buf, s_offset);
|
write_entire_file("vs\\new_Juliet.sln", sln_buf, s_offset);
|
||||||
printf("[SUCCESS] Generated vs\\new_Juliet.sln\n");
|
printf("[SUCCESS] Generated vs\\new_Juliet.sln\n");
|
||||||
|
|
||||||
file_list_free(&appbin_project.c_files);
|
file_list_free(&julietapp_project.c_files);
|
||||||
file_list_free(&appbin_project.h_files);
|
file_list_free(&julietapp_project.h_files);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
|||||||
Reference in new issue
Block a user