⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 非常好用的可移植的多平台C/C++源代码编辑器
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include "depslib.h"

#if 0
void test(const char *path)
{
	PATHSPLIT f;
	char buf[1024];

	printf("> %s\n", path);
	path_split(path, &f);
	path_print(&f);
	path_normalize(&f, NULL);
	path_tostring(&f, buf);
	printf("< %s\n", buf);
}
#endif

void depsOK(void)
{
	int error = depsError();

	if (error) exit(error);
}

int main(void)
{
	char *SEARCH1[] = {
		"include",
		0
	};

	char *sources1[] = {
		"src/foo.c",
		"src/main.c",
		"utils/bar.c",
		0
	};

#ifdef DEPSLIB_WINDOWS
	char *cwd1 = "C:/Programming/jam-test";

	char *SEARCH2[] = {
		"..\\..\\..\\sdk",
		"..\\..\\..\\..\\..\\..\\wxWindows-2.4.2\\include",
		"..\\..\\..\\..\\..\\..\\wxWindows-2.4.2-build\\lib\\wx\\include\\mswd-2.4",
		"..\\..\\..\\..\\..\\..\\wxWindows-2.4.2\\contrib\\include",
		"C:\\cygwin\\usr\\include\\mingw",
		0
	};
	char *sources2[] = {
		"..\\advancedcompileroptionsdlg.cpp",
		"..\\compilerBCC.cpp",
		"..\\compilerDMC.cpp",
		"..\\compilererrors.cpp",
		"..\\compilergcc.cpp",
		"..\\compilermessages.cpp",
		"..\\compilerMINGW.cpp",
		"..\\compilerMSVC.cpp",
		"..\\compileroptionsdlg.cpp",
		"..\\customvars.cpp",
		"..\\depends.cpp",
		"..\\directcommands.cpp",
		"..\\directdeps.cpp",
		"..\\linklibdlg.cpp",
		"..\\makefilegenerator.cpp",
		0
	};

	char *cwd2 = "C:/Programming/codeblocks-cvs/codeblocks/src/plugins/compilergcc/depends";
#endif
#ifdef DEPSLIB_UNIX
	char *cwd1 = "/cygdrive/c/Programming/jam-test";

	char *SEARCH2[] = {
		"../../../sdk",
		"../../../../../../wxWindows-2.4.2/include",
		"../../../../../../wxWindows-2.4.2-build/lib/wx/include/mswd-2.4",
		"../../../../../../wxWindows-2.4.2/contrib/include",
		"/usr/include",
		0
	};
	char *sources2[] = {
		"../advancedcompileroptionsdlg.cpp",
		"../compilerBCC.cpp",
		"../compilerDMC.cpp",
		"../compilererrors.cpp",
		"../compilergcc.cpp",
		"../compilermessages.cpp",
		"../compilerMINGW.cpp",
		"../compilerMSVC.cpp",
		"../compileroptionsdlg.cpp",
		"../customvars.cpp",
		"../depends.cpp",
		"../directcommands.cpp",
		"../directdeps.cpp",
		"../linklibdlg.cpp",
		"../makefilegenerator.cpp",
		0
	};

	char *cwd2 = "/cygdrive/c/Programming/codeblocks-cvs/codeblocks/src/plugins/compilergcc/depends";
#endif

	int i;
	struct depsStats stats;

	char cwd[1024];
#ifdef DEPSLIB_WINDOWS
	_getcwd(cwd, sizeof(cwd)); // let wxWindows handle this nastiness
#endif
#ifdef DEPSLIB_UNIX
	getcwd(cwd, sizeof(cwd)); // let wxWindows handle this nastiness
#endif

#if 0
test("C:/foo/bar/baz");
test("../foo/bar/baz");
test("C:/");
test("C:");
test("/foo/bar/baz");
test("foo/./bar/../baz");
test("../compilergcc.cpp");
test("..\\..\\..\\..\\..\\..\\wxWindows-2.4.2\\include");
return 0;
}
#endif

	depsStart(); depsOK();
	depsSetCWD(cwd1); depsOK();

	depsSearchStart(); depsOK();
	for (i = 0; SEARCH1[i]; i++)
	{
		depsAddSearchDir(SEARCH1[i]); depsOK();
	}

	for (i = 0; sources1[i]; i++)
	{
		depsRef ref = depsScanForHeaders(sources1[i]);
		depsOK();
		if (ref)
		{
			time_t time;
			const char *newest = depsGetNewest(ref, &time);
			depsOK();
			printf("newest %s > %s\n", newest, sources1[i]);
		}
	}

	depsGetStats(&stats); depsOK();
	printf("scanned %d files for #include, cache used %d, cache updated %d\n",
		stats.scanned, stats.cache_used, stats.cache_updated);

	depsDone(); depsOK();

/* ===== */

	depsStart(); depsOK();
	depsSetCWD(cwd2); depsOK();

	depsCacheRead("depends.cache");

	depsSearchStart(); depsOK();
	for (i = 0; SEARCH2[i]; i++)
	{
		depsAddSearchDir(SEARCH2[i]); depsOK();
	}

	for (i = 0; sources2[i]; i++)
	{
		depsRef ref = depsScanForHeaders(sources2[i]);
		depsOK();
		if (ref)
		{
			time_t time;
			const char *newest = depsGetNewest(ref, &time);
			depsOK();
			printf("newest %s > %s\n", newest, sources2[i]);
		}
	}

	depsGetStats(&stats);
	printf("scanned %d files for #include, cache used %d, cache updated %d\n",
		stats.scanned, stats.cache_used, stats.cache_updated);

	depsCacheWrite("depends.cache");

	depsDone(); depsOK();

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -