auto make_link()

in include/poac/util/stroite/core/builder.hpp [289:339]


        auto make_link() {
            namespace fs = boost::filesystem;
            namespace yaml = poac::io::file::yaml;
            namespace naming = poac::core::naming;

            std::vector<std::string> library_search_path;
            std::vector<std::string> static_link_libs;
            std::vector<std::string> library_path;

            if (deps_node) {
                for (const auto& [name, next_node] : *deps_node) {
                    const auto[src, name2] = naming::get_source(name);
                    const std::string version = naming::get_version(next_node, src);

                    if (src != "poac") {
                        const std::string pkgname = naming::to_cache(src, name2, version);
                        const fs::path pkgpath = poac::io::file::path::current_deps_dir / pkgname;

                        // TODO: できればlockファイルに書かれたパッケージの./depsディレクトリのpoac.ymlを読むのが好ましい
                        if (const fs::path lib_dir = pkgpath / "lib"; fs::exists(lib_dir)) {
                            library_search_path.push_back(lib_dir.string());

                            if (const auto link = yaml::get<std::vector<std::string>>(next_node, "link", "include")) {
                                for (const auto &l : *link) {
                                    static_link_libs.push_back(l);
                                }
                            }
                            else {
                                static_link_libs.push_back(pkgname);
                            }
                        }
                    }

                    // TODO: 上がpoacがソースでないために,./deps/pkg/lib にlibが存在する
                    // TODO: 下がpoacがソースであるために,./deps/pkg/_build/lib に存在する
                    // TODO: しかし,library_search_path.push_back(lib_dir.string()); 以降の文では,
                    // TODO: poacがソースの場合,ユーザーが選択する必要は無いと判断する.(あとで直す?)

                    else {
                        const std::string pkgname = name2;
                        const fs::path pkgpath = poac::io::file::path::current_build_lib_dir / pkgname;

                        // TODO: dynamic libを指定できるように
                        if (const auto lib_dir = pkgpath.string() + ".a"; fs::exists(lib_dir)) {
                            library_path.push_back(lib_dir);
                        }
                    }
                }
            }
            return std::make_tuple(library_search_path, static_link_libs, library_path);
        }