返回> 网站首页 

编译Apache subversion

yoours2024-10-09 20:11:38 阅读 1463

简介一边听听音乐,一边写写文章。

一、编译openssl-3.3.2

    https://openssl-library.org/source/

    1. 安装 ActivePerl

    https://www.activestate.com/products/perl/

    2. 下载nasm

    https://www.nasm.us/

    3. 打开准备编译环境

       a) 打开VS2019命令行,x86 Native Tools Command Prompt for VS 2019

        b) 增加配置搜索路径输入:

            set PATH=%PATH%;E:\Nasm;C:\Users\Administrator\AppData\Local\ActiveState\cache\bin

        c) 进入openssl目录创建编译信息

            cd openssl-openssl-3.3.2

            perl Configure VC-WIN32

        d) 编译

            nmake

            nmake install

    4. 其他

    python

    pip install regex


二、编译libexpat

    下载

    https://github.com/libexpat/libexpat

    libexpat-R_2_6_3.zip

    使用CMake GUI配置VS2019编译

    编译成功后,将expat头文件以及库文件拷贝至apr-util\xml\expat\lib


三、编译apr

    下载

    https://apr.apache.org/download.cgi

        apr-1.7.5-win32-src.zip

        apr-util-1.6.3-win32-src.zip

        apr-iconv-1.2.2-win32-src.zip

        在apr\include文件夹下找到apr.hw文件,以文本方式打开,找到宏定义“#define _WIN32_WINNT 0x0501”,将0x0501改为0x0600。

        方法一:

            使用CMake GUI配置VS2019编译

        方法二:

            解压目录名字去掉版本号,且在同一级目录下面。打开 aprutil.dsw 工程,编译即可。

        编译提示xml.lib则改为libexpat.lib


四、下载编译zlib

    http://www.zlib.net/

    zlib131.zip


五、下载sqlite无需编译

    https://www.sqlite.org/download.html

    sqlite-amalgamation-3460100.zip


六、编译serf

    下载

    https://serf.apache.org/download

    serf-1.3.10.zip

    安装环境依赖

    pip install scons -i https://mirrors.aliyun.com/pypi/simple/

    scons APR=..\apr APU=..\apr-util  OPENSSL=..\OpenSSL ZLIB=..\zlib-1.3.1


七、编译apache_subversion

    下载

    https://subversion.apache.org/source-code.html

    apache_subversion-1.14.3

    编译

    python gen-make.py -t vcproj --with-openssl=..\openssl-openssl-3.3.2 --with-zlib=..\deps\zlib-1.3.1 --with-apr=..\deps\apr --with-apr-util=..\deps\apr-util --with-apr-iconv=..\deps\apr-iconv --with-sqlite=..\deps\sqlite-amalgamation --with-serf=..\serf-1.3.10


八、示例

#include <stdio.h>

#include "svn_client.h"

#include "svn_cmdline.h"

#include "svn_pools.h"

#include "svn_config.h"

#include "svn_fs.h"


static svn_error_t* prompt_and_read_line(const char* prompt, char* buffer, size_t max)

{

    int len;

    printf("%s: ", prompt);

    if (fgets(buffer, max, stdin) == NULL)

        return svn_error_create(0, NULL, "error reading stdin");

    len = strlen(buffer);

    if (len > 0 && buffer[len - 1] == '\n')

        buffer[len - 1] = 0;

    return SVN_NO_ERROR;

}


static svn_error_t* my_simple_prompt_callback(svn_auth_cred_simple_t** cred, void* baton, const char* realm, const char* username, svn_boolean_t may_save, apr_pool_t* pool)

{

    svn_auth_cred_simple_t* ret = (svn_auth_cred_simple_t*)apr_pcalloc(pool, sizeof(*ret));

    char answerbuf[100];

    if (realm)

    {

        printf("Authentication realm: %s\n", realm);

    }


    if (username)

        ret->username = apr_pstrdup(pool, username);

    else {

        SVN_ERR(prompt_and_read_line("Username", answerbuf, sizeof(answerbuf)));

        ret->username = apr_pstrdup(pool, answerbuf);

    }


    SVN_ERR(prompt_and_read_line("Password", answerbuf, sizeof(answerbuf)));

    ret->password = apr_pstrdup(pool, answerbuf);


    *cred = ret;

    return SVN_NO_ERROR;

}


static svn_error_t* my_username_prompt_callback(svn_auth_cred_username_t** cred, void* baton, const char* realm, svn_boolean_t may_save, apr_pool_t* pool)

{

    svn_auth_cred_username_t* ret = (svn_auth_cred_username_t*)apr_pcalloc(pool, sizeof(*ret));

    char answerbuf[100];

    if (realm)

    {

        printf("Authentication realm: %s\n", realm);

    }


    SVN_ERR(prompt_and_read_line("Username", answerbuf, sizeof(answerbuf)));

    ret->username = apr_pstrdup(pool, answerbuf);


    *cred = ret;

    return SVN_NO_ERROR;

}


int main(int argc, char** argv)

{

    apr_pool_t* pool;

    svn_error_t* err;

    svn_opt_revision_t revision;

    apr_hash_t* dirents;

    apr_hash_index_t* hi;

    svn_client_ctx_t* ctx;

    const char* URL;


    printf("URL:  %s \n", argv[1]);

    if (argc <= 1)

    {

        return EXIT_FAILURE;

    }

    else

        URL = argv[1];


    if (svn_cmdline_init("minimal_client", stderr) != EXIT_SUCCESS)

        return EXIT_FAILURE;


    pool = svn_pool_create(NULL);

    err = svn_fs_initialize(pool);

    if (err)

    {

        svn_handle_error2(err, stderr, FALSE, "minimal_client: ");

        return EXIT_FAILURE;

    }


    err = svn_config_ensure(NULL, pool);

    if (err)

    {

        svn_handle_error2(err, stderr, FALSE, "minimal_client: ");

        return EXIT_FAILURE;

    }


    {

        if ((err = svn_client_create_context(&ctx, pool)))

        {

            svn_handle_error2(err, stderr, FALSE, "minimal_client: ");

            return EXIT_FAILURE;

        }


        if ((err = svn_config_get_config(&(ctx->config), NULL, pool)))

        {

            svn_handle_error2(err, stderr, FALSE, "minimal_client: ");

            return EXIT_FAILURE;

        }


#ifdef WIN32

        if (getenv("SVN_ASP_DOT_NET_HACK"))

        {

            err = svn_wc_set_adm_dir("_svn", pool);

            if (err)

            {

                svn_handle_error2(err, stderr, FALSE, "minimal_client: ");

                return EXIT_FAILURE;

            }

        }

#endif

        {

            svn_auth_provider_object_t* provider;

            apr_array_header_t* providers = apr_array_make(pool, 4, sizeof(svn_auth_provider_object_t*));


            svn_auth_get_simple_prompt_provider(&provider, my_simple_prompt_callback, NULL, 2, pool);

            APR_ARRAY_PUSH(providers, svn_auth_provider_object_t*) = provider;


            svn_auth_get_username_prompt_provider(&provider,my_username_prompt_callback,NULL,2, pool);

            APR_ARRAY_PUSH(providers, svn_auth_provider_object_t*) = provider;

            svn_auth_open(&ctx->auth_baton, providers, pool);

        }

    }

    revision.kind = svn_opt_revision_head;

    err = svn_client_ls(&dirents, URL, &revision,FALSE,ctx, pool);

    if (err)

    {

        svn_handle_error2(err, stderr, FALSE, "minimal_client: ");

        return EXIT_FAILURE;

    }


    for (hi = apr_hash_first(pool, dirents); hi; hi = apr_hash_next(hi))

    {

        const char* entryname;

        svn_dirent_t* val;

        apr_hash_this(hi, (const void**)&entryname, NULL, (void**)&val);

        printf("   %s\n", entryname);

    }


    // CheckOut

    svn_opt_revision_t rev;

    svn_opt_revision_t peg_rev;

    const char* wc_path = "./output";

    rev.kind = svn_opt_revision_head;

    peg_rev.kind = svn_opt_revision_unspecified;

    svn_client_checkout3(NULL, URL, wc_path, &peg_rev, &rev, svn_depth_infinity, TRUE, FALSE, ctx, pool);

    return EXIT_SUCCESS;

}


微信小程序扫码登陆

文章评论

1463人参与,0条评论