コード例 #1
0
ファイル: image.cpp プロジェクト: paulfitz/cycles_hack
void ImageManager::device_update(Device *device, DeviceScene *dscene, Progress& progress)
{
	if(!need_update)
		return;

	for(size_t slot = 0; slot < images.size(); slot++) {
		if(images[slot]) {
			if(images[slot]->users == 0) {
				device_free_image(device, dscene, slot);
			}
			else if(images[slot]->need_load) {
				string name = path_filename(images[slot]->filename);
				progress.set_status("Updating Images", "Loading " + name);
				device_load_image(device, dscene, slot);
				images[slot]->need_load = false;
			}

			if(progress.get_cancel()) return;
		}
	}

	for(size_t slot = 0; slot < float_images.size(); slot++) {
		if(float_images[slot]) {
			if(float_images[slot]->users == 0) {
				device_free_image(device, dscene, slot + TEX_IMAGE_FLOAT_START);
			}
			else if(float_images[slot]->need_load) {
				string name = path_filename(float_images[slot]->filename);
				progress.set_status("Updating Images", "Loading " + name);
				device_load_image(device, dscene, slot + TEX_IMAGE_FLOAT_START);
				float_images[slot]->need_load = false;
			}

			if(progress.get_cancel()) return;
		}
	}

	need_update = false;
}
コード例 #2
0
ファイル: path.c プロジェクト: EEmmanuel7/bam
int lf_path_filename(lua_State *L)
{
	int n = lua_gettop(L);
	const char *path = 0;
	if(n < 1)
		luaL_error(L, "path_filename: incorrect number of arguments");

	path = lua_tostring(L, 1);

	if(!path)
		luaL_error(L, "path_filename: null name");

	lua_pushstring(L, path_filename(path));
	return 1;
}
コード例 #3
0
ファイル: util_path.cpp プロジェクト: UPBGE/blender
void path_cache_clear_except(const string& name, const set<string>& except)
{
	string dir = path_user_get("cache");

	if(path_exists(dir)) {
		directory_iterator it(dir), it_end;

		for(; it != it_end; ++it) {
			string filename = path_filename(it->path());

			if(string_startswith(filename, name.c_str()))
				if(except.find(filename) == except.end())
					path_remove(it->path());
		}
	}

}
コード例 #4
0
static const char * output_entries_list (FILE * out,
                                         const database_t * db,
                                         version_t * const * vv,
                                         const file_t * f,
                                         const char * last_path)
{
    if (entries_name == NULL || *entries_name == 0)
        return last_path;

    if (last_path != NULL && same_directory (last_path, f->path))
        return last_path;

    // Find the range of files in the same directory.
    bool directory_is_live = false;
    const file_t * start = f;
    while (start != db->files && same_directory (start[-1].path, f->path)) {
        --start;
        directory_is_live = directory_is_live
            || version_live (vv[start - db->files]);
    }
    const file_t * end = f;
    do {
        directory_is_live = directory_is_live
            || version_live (vv[end - db->files]);
        ++end;
    }
    while (end != db->files_end && same_directory (end->path, f->path));

    if (!directory_is_live) {
        fprintf (out, "D %.*s%s\n",
                 path_dirlen (f->path), f->path, entries_name);
        return f->path;
    }
    fprintf (out, "M 644 inline %.*s%s\n",
             path_dirlen (f->path), f->path, entries_name);
    fprintf (out, "data <<EOF\n");
    for (const file_t * f = start; f != end; ++f)
        if (version_live (vv[f - db->files]))
            fprintf (out, "%s %s\n",
                     vv[f - db->files]->version, path_filename (f->path));
    fprintf (out, "EOF\n");
    return f->path;
}
コード例 #5
0
ファイル: image.cpp プロジェクト: vanangamudi/blender-main
void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int slot, Progress *progress)
{
	if(progress->get_cancel())
		return;
	if(osl_texture_system)
		return;

	Image *img;
	bool is_float;

	if(slot < TEX_IMAGE_FLOAT_START) {
		img = images[slot];
		is_float = false;
	}
	else {
		img = float_images[slot - TEX_IMAGE_FLOAT_START];
		is_float = true;
	}

	if(is_float) {
		string filename = path_filename(float_images[slot - TEX_IMAGE_FLOAT_START]->filename);
		progress->set_status("Updating Images", "Loading " + filename);

		device_vector<float4>& tex_img = dscene->tex_float_image[slot - TEX_IMAGE_FLOAT_START];

		if(tex_img.device_pointer)
			device->tex_free(tex_img);

		if(!file_load_float_image(img, tex_img)) {
			/* on failure to load, we set a 1x1 pixels pink image */
			float *pixels = (float*)tex_img.resize(1, 1);

			pixels[0] = TEX_IMAGE_MISSING_R;
			pixels[1] = TEX_IMAGE_MISSING_G;
			pixels[2] = TEX_IMAGE_MISSING_B;
			pixels[3] = TEX_IMAGE_MISSING_A;
		}

		string name;

		if(slot >= 10) name = string_printf("__tex_image_float_0%d", slot);
		else name = string_printf("__tex_image_float_00%d", slot);

		if(!pack_images)
			device->tex_alloc(name.c_str(), tex_img, true, true);
	}
	else {
		string filename = path_filename(images[slot]->filename);
		progress->set_status("Updating Images", "Loading " + filename);

		device_vector<uchar4>& tex_img = dscene->tex_image[slot];

		if(tex_img.device_pointer)
			device->tex_free(tex_img);

		if(!file_load_image(img, tex_img)) {
			/* on failure to load, we set a 1x1 pixels pink image */
			uchar *pixels = (uchar*)tex_img.resize(1, 1);

			pixels[0] = (TEX_IMAGE_MISSING_R * 255);
			pixels[1] = (TEX_IMAGE_MISSING_G * 255);
			pixels[2] = (TEX_IMAGE_MISSING_B * 255);
			pixels[3] = (TEX_IMAGE_MISSING_A * 255);
		}

		string name;

		if(slot >= 10) name = string_printf("__tex_image_0%d", slot);
		else name = string_printf("__tex_image_00%d", slot);

		if(!pack_images)
			device->tex_alloc(name.c_str(), tex_img, true, true);
	}

	img->need_load = false;
}
コード例 #6
0
ファイル: image.cpp プロジェクト: mgschwan/blensor
void ImageManager::device_load_image(Device *device,
                                     Scene *scene,
                                     ImageDataType type,
                                     int slot,
                                     Progress *progress)
{
	if(progress->get_cancel())
		return;

	Image *img = images[type][slot];

	if(osl_texture_system && !img->builtin_data)
		return;

	string filename = path_filename(images[type][slot]->filename);
	progress->set_status("Updating Images", "Loading " + filename);

	const int texture_limit = scene->params.texture_limit;

	/* Slot assignment */
	int flat_slot = type_index_to_flattened_slot(slot, type);
	img->mem_name = string_printf("__tex_image_%s_%03d", name_from_type(type).c_str(), flat_slot);

	/* Free previous texture in slot. */
	if(img->mem) {
		thread_scoped_lock device_lock(device_mutex);
		delete img->mem;
		img->mem = NULL;
	}

	/* Create new texture. */
	if(type == IMAGE_DATA_TYPE_FLOAT4) {
		device_vector<float4> *tex_img
			= new device_vector<float4>(device, img->mem_name.c_str(), MEM_TEXTURE);

		if(!file_load_image<TypeDesc::FLOAT, float>(img,
		                                            type,
		                                            texture_limit,
		                                            *tex_img))
		{
			/* on failure to load, we set a 1x1 pixels pink image */
			thread_scoped_lock device_lock(device_mutex);
			float *pixels = (float*)tex_img->alloc(1, 1);

			pixels[0] = TEX_IMAGE_MISSING_R;
			pixels[1] = TEX_IMAGE_MISSING_G;
			pixels[2] = TEX_IMAGE_MISSING_B;
			pixels[3] = TEX_IMAGE_MISSING_A;
		}

		img->mem = tex_img;
		img->mem->interpolation = img->interpolation;
		img->mem->extension = img->extension;

		thread_scoped_lock device_lock(device_mutex);
		tex_img->copy_to_device();
	}
	else if(type == IMAGE_DATA_TYPE_FLOAT) {
		device_vector<float> *tex_img
			= new device_vector<float>(device, img->mem_name.c_str(), MEM_TEXTURE);

		if(!file_load_image<TypeDesc::FLOAT, float>(img,
		                                            type,
		                                            texture_limit,
		                                            *tex_img))
		{
			/* on failure to load, we set a 1x1 pixels pink image */
			thread_scoped_lock device_lock(device_mutex);
			float *pixels = (float*)tex_img->alloc(1, 1);

			pixels[0] = TEX_IMAGE_MISSING_R;
		}

		img->mem = tex_img;
		img->mem->interpolation = img->interpolation;
		img->mem->extension = img->extension;

		thread_scoped_lock device_lock(device_mutex);
		tex_img->copy_to_device();
	}
	else if(type == IMAGE_DATA_TYPE_BYTE4) {
		device_vector<uchar4> *tex_img
			= new device_vector<uchar4>(device, img->mem_name.c_str(), MEM_TEXTURE);

		if(!file_load_image<TypeDesc::UINT8, uchar>(img,
		                                            type,
		                                            texture_limit,
		                                            *tex_img))
		{
			/* on failure to load, we set a 1x1 pixels pink image */
			thread_scoped_lock device_lock(device_mutex);
			uchar *pixels = (uchar*)tex_img->alloc(1, 1);

			pixels[0] = (TEX_IMAGE_MISSING_R * 255);
			pixels[1] = (TEX_IMAGE_MISSING_G * 255);
			pixels[2] = (TEX_IMAGE_MISSING_B * 255);
			pixels[3] = (TEX_IMAGE_MISSING_A * 255);
		}

		img->mem = tex_img;
		img->mem->interpolation = img->interpolation;
		img->mem->extension = img->extension;

		thread_scoped_lock device_lock(device_mutex);
		tex_img->copy_to_device();
	}
	else if(type == IMAGE_DATA_TYPE_BYTE) {
		device_vector<uchar> *tex_img
			= new device_vector<uchar>(device, img->mem_name.c_str(), MEM_TEXTURE);

		if(!file_load_image<TypeDesc::UINT8, uchar>(img,
		                                            type,
		                                            texture_limit,
		                                            *tex_img)) {
			/* on failure to load, we set a 1x1 pixels pink image */
			thread_scoped_lock device_lock(device_mutex);
			uchar *pixels = (uchar*)tex_img->alloc(1, 1);

			pixels[0] = (TEX_IMAGE_MISSING_R * 255);
		}

		img->mem = tex_img;
		img->mem->interpolation = img->interpolation;
		img->mem->extension = img->extension;

		thread_scoped_lock device_lock(device_mutex);
		tex_img->copy_to_device();
	}
	else if(type == IMAGE_DATA_TYPE_HALF4) {
		device_vector<half4> *tex_img
			= new device_vector<half4>(device, img->mem_name.c_str(), MEM_TEXTURE);

		if(!file_load_image<TypeDesc::HALF, half>(img,
		                                          type,
		                                          texture_limit,
		                                          *tex_img)) {
			/* on failure to load, we set a 1x1 pixels pink image */
			thread_scoped_lock device_lock(device_mutex);
			half *pixels = (half*)tex_img->alloc(1, 1);

			pixels[0] = TEX_IMAGE_MISSING_R;
			pixels[1] = TEX_IMAGE_MISSING_G;
			pixels[2] = TEX_IMAGE_MISSING_B;
			pixels[3] = TEX_IMAGE_MISSING_A;
		}

		img->mem = tex_img;
		img->mem->interpolation = img->interpolation;
		img->mem->extension = img->extension;

		thread_scoped_lock device_lock(device_mutex);
		tex_img->copy_to_device();
	}
	else if(type == IMAGE_DATA_TYPE_HALF) {
		device_vector<half> *tex_img
			= new device_vector<half>(device, img->mem_name.c_str(), MEM_TEXTURE);

		if(!file_load_image<TypeDesc::HALF, half>(img,
		                                          type,
		                                          texture_limit,
		                                          *tex_img)) {
			/* on failure to load, we set a 1x1 pixels pink image */
			thread_scoped_lock device_lock(device_mutex);
			half *pixels = (half*)tex_img->alloc(1, 1);

			pixels[0] = TEX_IMAGE_MISSING_R;
		}

		img->mem = tex_img;
		img->mem->interpolation = img->interpolation;
		img->mem->extension = img->extension;

		thread_scoped_lock device_lock(device_mutex);
		tex_img->copy_to_device();
	}

	img->need_load = false;
}
コード例 #7
0
ファイル: image.cpp プロジェクト: diekev/blender
void ImageManager::device_load_image(Device *device, DeviceScene *dscene, ImageDataType type, int slot, Progress *progress)
{
	if(progress->get_cancel())
		return;
	
	Image *img = images[type][slot];

	if(osl_texture_system && !img->builtin_data)
		return;

	string filename = path_filename(images[type][slot]->filename);
	progress->set_status("Updating Images", "Loading " + filename);

	/* Slot assignment */
	int flat_slot = type_index_to_flattened_slot(slot, type);

	string name;
	if(flat_slot >= 100)
		name = string_printf("__tex_image_%s_%d", name_from_type(type).c_str(), flat_slot);
	else if(flat_slot >= 10)
		name = string_printf("__tex_image_%s_0%d", name_from_type(type).c_str(), flat_slot);
	else
		name = string_printf("__tex_image_%s_00%d", name_from_type(type).c_str(), flat_slot);

	if(type == IMAGE_DATA_TYPE_FLOAT4) {
		device_vector<float4>& tex_img = dscene->tex_float4_image[slot];

		if(tex_img.device_pointer) {
			thread_scoped_lock device_lock(device_mutex);
			device->tex_free(tex_img);
		}

		if(!file_load_float_image(img, type, tex_img)) {
			/* on failure to load, we set a 1x1 pixels pink image */
			float *pixels = (float*)tex_img.resize(1, 1);

			pixels[0] = TEX_IMAGE_MISSING_R;
			pixels[1] = TEX_IMAGE_MISSING_G;
			pixels[2] = TEX_IMAGE_MISSING_B;
			pixels[3] = TEX_IMAGE_MISSING_A;
		}

		if(!pack_images) {
			thread_scoped_lock device_lock(device_mutex);
			device->tex_alloc(name.c_str(),
			                  tex_img,
			                  img->interpolation,
			                  img->extension);
		}
	}
	else if(type == IMAGE_DATA_TYPE_FLOAT) {
		device_vector<float>& tex_img = dscene->tex_float_image[slot];

		if(tex_img.device_pointer) {
			thread_scoped_lock device_lock(device_mutex);
			device->tex_free(tex_img);
		}

		if(!file_load_float_image(img, type, tex_img)) {
			/* on failure to load, we set a 1x1 pixels pink image */
			float *pixels = (float*)tex_img.resize(1, 1);

			pixels[0] = TEX_IMAGE_MISSING_R;
		}

		if(!pack_images) {
			thread_scoped_lock device_lock(device_mutex);
			device->tex_alloc(name.c_str(),
			                  tex_img,
			                  img->interpolation,
			                  img->extension);
		}
	}
	else if(type == IMAGE_DATA_TYPE_BYTE4) {
		device_vector<uchar4>& tex_img = dscene->tex_byte4_image[slot];

		if(tex_img.device_pointer) {
			thread_scoped_lock device_lock(device_mutex);
			device->tex_free(tex_img);
		}

		if(!file_load_byte_image(img, type, tex_img)) {
			/* on failure to load, we set a 1x1 pixels pink image */
			uchar *pixels = (uchar*)tex_img.resize(1, 1);

			pixels[0] = (TEX_IMAGE_MISSING_R * 255);
			pixels[1] = (TEX_IMAGE_MISSING_G * 255);
			pixels[2] = (TEX_IMAGE_MISSING_B * 255);
			pixels[3] = (TEX_IMAGE_MISSING_A * 255);
		}

		if(!pack_images) {
			thread_scoped_lock device_lock(device_mutex);
			device->tex_alloc(name.c_str(),
			                  tex_img,
			                  img->interpolation,
			                  img->extension);
		}
	}
	else if(type == IMAGE_DATA_TYPE_BYTE){
		device_vector<uchar>& tex_img = dscene->tex_byte_image[slot];

		if(tex_img.device_pointer) {
			thread_scoped_lock device_lock(device_mutex);
			device->tex_free(tex_img);
		}

		if(!file_load_byte_image(img, type, tex_img)) {
			/* on failure to load, we set a 1x1 pixels pink image */
			uchar *pixels = (uchar*)tex_img.resize(1, 1);

			pixels[0] = (TEX_IMAGE_MISSING_R * 255);
		}

		if(!pack_images) {
			thread_scoped_lock device_lock(device_mutex);
			device->tex_alloc(name.c_str(),
			                  tex_img,
			                  img->interpolation,
			                  img->extension);
		}
	}
	else if(type == IMAGE_DATA_TYPE_HALF4){
		device_vector<half4>& tex_img = dscene->tex_half4_image[slot];

		if(tex_img.device_pointer) {
			thread_scoped_lock device_lock(device_mutex);
			device->tex_free(tex_img);
		}

		if(!file_load_half_image(img, type, tex_img)) {
			/* on failure to load, we set a 1x1 pixels pink image */
			half *pixels = (half*)tex_img.resize(1, 1);

			pixels[0] = TEX_IMAGE_MISSING_R;
			pixels[1] = TEX_IMAGE_MISSING_G;
			pixels[2] = TEX_IMAGE_MISSING_B;
			pixels[3] = TEX_IMAGE_MISSING_A;
		}

		if(!pack_images) {
			thread_scoped_lock device_lock(device_mutex);
			device->tex_alloc(name.c_str(),
			                  tex_img,
			                  img->interpolation,
			                  img->extension);
		}
	}
	else if(type == IMAGE_DATA_TYPE_HALF){
		device_vector<half>& tex_img = dscene->tex_half_image[slot];

		if(tex_img.device_pointer) {
			thread_scoped_lock device_lock(device_mutex);
			device->tex_free(tex_img);
		}

		if(!file_load_half_image(img, type, tex_img)) {
			/* on failure to load, we set a 1x1 pixels pink image */
			half *pixels = (half*)tex_img.resize(1, 1);

			pixels[0] = TEX_IMAGE_MISSING_R;
		}

		if(!pack_images) {
			thread_scoped_lock device_lock(device_mutex);
			device->tex_alloc(name.c_str(),
			                  tex_img,
			                  img->interpolation,
			                  img->extension);
		}
	}

	img->need_load = false;
}
コード例 #8
0
ファイル: midlc.c プロジェクト: OpenSharp/NDceRpc
static int
run(int argc, char **argv,
		const char *filename,
		const char *outname,
		const char *type,
		const char *symtabpath,
		struct hashmap *macros,
		int verbose)
{
	struct idl idl;
	struct sym iface;
	unsigned char _outname[PATH_MAX];

	memset(&idl, 0, sizeof(idl));
	idl.argc = argc;
	idl.argv = argv;
	idl.type = type;
	idl.macros = macros;
	idl.verbose = verbose;
	idl.al = NULL;
	if ((idl.syms = hashmap_new(hash_str, cmp_str, NULL, idl.al)) == NULL ||
				(idl.consts = hashmap_new(hash_str, cmp_str, NULL, idl.al)) == NULL ||
				(idl.tmp = hashmap_new(hash_str, cmp_str, NULL, idl.al)) == NULL) {
		AMSG("");
		return -1;
	}
	if (symload(&idl, symtabpath) == -1) {
		if (errno != ENOENT || symload(&idl, path_filename(symtabpath)) == -1) {
			AMSG("");
			return -1;
		}
	}
                                            /* generate parse tree in iface */
	syminit(&iface, idl.al);
	if (idl_process_file(&idl, filename, &iface) == -1) {
		AMSG("");
		return -1;
	}

	if (idl.verbose > 1) {
		print_tree(&idl, &iface, 0);                     /* print everything */
	} else if (idl.verbose) {
		iter_t iter;
		struct sym *mem;
	
		linkedlist_iterate(&iface.mems, &iter);
		while ((mem = linkedlist_next(&iface.mems, &iter))) {
			if (IS_OPERATION(mem) == 0) {
				continue;
			}
			print_tree(&idl, mem, 0); /* only print operations and their params */
		}
	}
	if (idl.verbose)
		fprintf(stderr, " No Flg   Type            Ptr   Name      OutType       NdrType Siz Aln Off Attributes\n");

	mkoutname(_outname, outname ? outname : filename, "");
	idl.outname = dupstr(path_filename(_outname), NULL);

	if (strcmp(type, "jcifs") == 0) {
		mkoutname(_outname, outname ? outname : filename, ".java");
		if (run_one(&idl, &iface, _outname, emit_stub_jcifs) == -1) {
			AMSG("");
			return -1;
		}
	} else if (strcmp(type, "java") == 0) {
		mkoutname(_outname, outname ? outname : filename, ".java");
		if (run_one(&idl, &iface, _outname, emit_stub_java) == -1) {
			AMSG("");
			return -1;
		}
	} else if (*type == 's') {
		mkoutname(_outname, outname ? outname : filename, ".c");
		if (run_one(&idl, &iface, _outname, emit_stub_samba) == -1) {
			AMSG("");
			return -1;
		}
	} else if (*type == 'c') {
		mkoutname(_outname, outname ? outname : filename, ".h");
		if (run_one(&idl, &iface, _outname, emit_hdr_c) == -1) {
			AMSG("");
			return -1;
		}
		mkoutname(_outname, outname ? outname : filename, "_s.c");
		if (run_one(&idl, &iface, _outname, emit_svr_stub_c) == -1) {
			AMSG("");
			return -1;
		}
		mkoutname(_outname, outname ? outname : filename, "_c.c");
	}

	return 0;
}
コード例 #9
0
ファイル: main.c プロジェクト: SijmenSchoon/bam
static int bam_setup(struct CONTEXT *context, const char *scriptfile, const char **targets, int num_targets)
{
	/* */	
	if(session.verbose)
		printf("%s: setup started\n", session.name);
	
	/* set filename */
	context->filename = scriptfile;
	context->filename_short = path_filename(scriptfile);
	
	/* set global timestamp to the script file */
	context->globaltimestamp = file_timestamp(scriptfile);
	
	/* fetch script directory */
	{
		char cwd[MAX_PATH_LENGTH];
		char path[MAX_PATH_LENGTH];

		if(!getcwd(cwd, sizeof(cwd)))
		{
			printf("%s: error: couldn't get current working directory\n", session.name);
			return -1;
		}
		
		if(path_directory(context->filename, path, sizeof(path)))
		{
			printf("%s: error: path too long '%s'\n", session.name, path);
			return -1;
		}
		
		if(path_join(cwd, -1, path, -1, context->script_directory, sizeof(context->script_directory)))
		{
			printf("%s: error: path too long when joining '%s' and '%s'\n", session.name, cwd, path);
			return -1;
		}
	}
	
	/* register all functions */
	if(register_lua_globals(context) != 0)
	{
		printf("%s: error: registering of lua functions failed\n", session.name);
		return -1;
	}

	/* load script */	
	if(session.verbose)
		printf("%s: reading script from '%s'\n", session.name, scriptfile);
		
	/* push error function to stack and load the script */
	lua_getglobal(context->lua, "errorfunc");
	switch(luaL_loadfile(context->lua, scriptfile))
	{
		case 0: break;
		case LUA_ERRSYNTAX:
			lf_errorfunc(context->lua);
			return -1;
		case LUA_ERRMEM: 
			printf("%s: memory allocation error\n", session.name);
			return -1;
		case LUA_ERRFILE:
			printf("%s: error opening '%s'\n", session.name, scriptfile);
			return -1;
		default:
			printf("%s: unknown error\n", session.name);
			return -1;
	}

	/* call the code chunk */	
	if(lua_pcall(context->lua, 0, LUA_MULTRET, -2) != 0)
	{
		printf("%s: script error (-t for more detail)\n", session.name);
		return -1;
	}
	
	/* run deferred functions */
	if(run_deferred_functions(context) != 0)
		return -1;
		
	/* */	
	if(session.verbose)
		printf("%s: making build target\n", session.name);
	
	/* make build target */
	{
		struct NODE *node;
		int all_target = 0;
		int i;

		if(node_create(&context->target, context->graph, "_bam_buildtarget", NULL))
			return -1;
		node_set_pseudo(context->target);
			
		if(num_targets)
		{
			/* search for all target */
			for(i = 0; i < num_targets; i++)
			{
				if(strcmp(targets[i], "all") == 0)
				{
					all_target = 1;
					break;
				}
			}
		}
		
		/* default too all if we have no targets or default target */
		if(num_targets == 0 && !context->defaulttarget)
			all_target = 1;
		
		if(all_target)
		{
			/* build the all target */
			for(node = context->graph->first; node; node = node->next)
			{
				if(node->firstparent == NULL && node != context->target)
				{
					if(!node_add_dependency_withnode(context->target, node))
						return -1;
				}
			}
		}
		else
		{
			if(num_targets)
			{
				for(i = 0; i < num_targets; i++)
				{
					struct NODE *node = node_find(context->graph, targets[i]);
					if(!node)
					{
						printf("%s: target '%s' not found\n", session.name, targets[i]);
						return -1;
					}
					
					if(option_dependent)
					{
						/* TODO: this should perhaps do a reverse walk up in the tree to
							find all dependent node with commandline */
						struct NODELINK *parent;
						for(parent = node->firstparent; parent; parent = parent->next)
						{
							if(!node_add_dependency_withnode(context->target, parent->node))
								return -1;
						}
								
					}
					else
					{
						if(!node_add_dependency_withnode(context->target, node))
							return -1;
					}
				}
			}
			else
			{
				if(!node_add_dependency_withnode(context->target, context->defaulttarget))
					return -1;
			}

		}
	}
	
	/* */	
	if(session.verbose)
		printf("%s: setup done\n", session.name);
	
	
	/* return success */
	return 0;
}