History

Small patch to allow for the TCC.EXE (and TCCLIB.DLL) to reside in a (directory under) a "bin/" directory at the same level where the "include/" and "lib/" directories are. This allows one to set the PATH to the (proper) binaries directory and TCC will then "find" itself there. Tested under Windows 7, Windows 8.1 (ARM) and Windows 10+11, but should also be workable for Linux and macOS.

waltje committed 3 years ago

Commit da3a7631 parent a46372e1 file · +38 −0Browse files

Unified · Split

libtcc.c+38−0
@@ -99,12 +99,50 @@ BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved) · 98 unmodified lines
99/* on win32, we suppose the lib and includes are at the location of 'tcc.exe' */99/* on win32, we suppose the lib and includes are at the location of 'tcc.exe' */
100static inline char *config_tccdir_w32(char *path)100static inline char *config_tccdir_w32(char *path)
101{101{
102 char temp[1024];
103 char try[1024];
102 char *p;104 char *p;
105 int c;
103 GetModuleFileName(tcc_module, path, MAX_PATH);106 GetModuleFileName(tcc_module, path, MAX_PATH);
104 p = tcc_basename(normalize_slashes(strlwr(path)));107 p = tcc_basename(normalize_slashes(strlwr(path)));
105 if (p > path)108 if (p > path)
106 --p;109 --p;
110
107 *p = 0;111 *p = 0;
112
113 /*
114 * See if we are perhaps in a "bin/" subfolder of the
115 * installation path, in which case the real root of
116 * the installation is one level up. We can test this
117 * by looking for the 'include' folder.
118 */
119 strncpy(temp, path, sizeof(temp)-1);
120 strcat(temp, "/include");
121
122 if (_access(temp, 0) != 0) {
123 /* No 'include' folder found, so go up one level. */
124 strncpy(temp, path, sizeof(temp)-1);
125
126 for (c = 0; c < 4; c++) {
127 p = tcc_basename(temp);
128 if (p > temp) {
129 --p;
130 *p = '\0';
131 }
132
133 strncpy(try, temp, sizeof(try)-1);
134 strcat(try, "/include");
135
136 if (_access(try, 0) == 0) {
137 if (p != NULL)
138 p = '\0';
139 path = tcc_malloc(strlen(temp)+1);
140 strcpy(path, temp);
141 break;
142 }
143 }
144 }
145
108 return path;146 return path;
109}147}
110#define CONFIG_TCCDIR config_tccdir_w32(alloca(MAX_PATH))148#define CONFIG_TCCDIR config_tccdir_w32(alloca(MAX_PATH))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t