Chromium Android source code compilation stepping process (shadowsocks + ubuntu)

After more than a week, I used my spare time to step on countless pits, and finally successfully compiled the source code of chromium android. It is really difficult in retrospect, and now I will share this process so that others will not make detours.

First, I would like to highlight 3 key factors:

  1. There must be a perfect ladder. It is best if you have already overcome the wall, such as studying abroad, immigrating, or even traveling abroad. If you can't do this, you can only use the over-the-wall tool. Regarding this, because I have not used vpn for many years, I have switched to shadowsocks, but I have only been using ss with GUI on mac before, but on Linux However, you have to use the command line to configure it yourself, which is cumbersome and error-prone. It can be said that most of the time is spent on the ladder. In addition, if you buy paid shadowsocks, you must pay attention to the traffic quota and billing method. I just accidentally used a very expensive node, which caused me to use up a month's traffic in one go, and spent dozens more. Dollars to recharge traffic.
  2. You must use linux, and you must use it proficiently. Before, I just read a document compiled on the chromium pc side on the google official website, saying that it supports mac compilation, so I eagerly took the mac to download the code, but the result was unsuccessful. Later, after reading the documentation of chromium android, I found that only linux can be used. But I am really unfamiliar with linux, and many operations have to go to Baidu on-site, which wastes a lot of time.
  3. Don't imagine that it can be done with saucy operations, you must honestly follow the steps of the official website step by step, and then consider improving it in other ways when this road is clear. At first, I read someone on Zhihu who said that they had set up an Alibaba Cloud in the United States, and then took the code back to compile it locally. Do the same. I started to find that Alibaba Cloud is really fast. I downloaded more than a dozen gigabytes of code, and it took 2 or 3 hours to get it done. Then I compressed a package and copied it to my computer overnight. The copy method took another few hours, I started thinking about setting up an ftp by myself, and later found that rsync can do it), and decompressed it for a few hours, but found that it could not be compiled. I thought it was a problem with the code, so I compiled it directly on Alibaba Cloud. I didn't expect that I applied for too few CPUs, so it took 8 or 9 hours to compile, but the compilation was successful. As a result, it took a lot of effort to repackage the code, download it locally, and decompress it, but the compilation still failed. I always thought it was a lack of files, and I went to great lengths to compare and try again, until I finally gave up. Later, I saw that someone used the domestic mirror of code aurora to replace the code of Google's official website, so I tried again, but I didn't know the reason. The code synchronization could not be completed, and finally returned without success.

So first of all, let me talk about how I used shadowsocks to build a ladder on linux.

  1. Go to www.shadowsocks.com to buy a service, there are many packages, I use it by myself, the starter mode is enough. After purchasing, pay attention to the server address, password and encryption method. Especially the encryption method, which is now chacha20-ietf-poly1305. This encryption method directly causes several linux versions of shadowsocks clients to be unavailable, only shadowsocks-libev can be used.
  2. Next, install shadowsocks-libev, refer to the instructions on the official website https://github.com/shadowsocks/shadowsocks-libev , mine is ubuntu 16.04, and I am too lazy to compile from the source code, so install it directly through the package:
    sudo apt-get install software-properties-common -y
    sudo add-apt-repository ppa:max-c-lv/shadowsocks-libev -y
    sudo apt-get update
    sudo apt install shadowsocks-libev

    After installation, modify the configuration file, usually only need to modify the three items of server, password and method

    # Edit the configuration file
    sudo vim /etc/shadowsocks-libev/config.json
    {
        "server":"服务器地址",
        "server_port":14005,      
        "local_port":1080,
        "password":"密码",
        "timeout":60,
        "method":"加密算法"
    }

    After modification, start the service first

    # Start the service
    sudo /etc/init.d/shadowsocks-libev start    # for sysvinit, or
    sudo systemctl start shadowsocks-libev      # for systemd

    Restart the client

    ss-local -c /etc/shadowsocks-libev/config.json

     

  3. Verify that your ladder is built successfully. First, see if you can access google, configure firefox, and set up a network proxy

Then set the proxy mode and port number,

Note: SOCKS Host, Port, and SOCKS v5 must be the same.

Even if this step of verification passes, don't be too happy, because the code is not downloaded through the browser. So you also have to verify:

  • Can git go over the wall? Because the download code will use git, it is necessary to set the git proxy, as follows:
    git config --global http.proxy 'socks5://127.0.0.1:1080' 
    git config --global https.proxy 'socks5://127.0.0.1:1080'

    If you want to turn off the proxy:

    git config --global --unset http.proxy
    git config --global --unset https.proxy

    How to verify? In the case of no proxy set, the clone code is to time out:

    root@yihao-MR-X5:/media/root/work# git clone https://chromium.googlesource.com/external/webrtc
    正克隆到 'webrtc'...
    fatal: unable to access 'https://chromium.googlesource.com/external/webrtc/': Failed to connect to chromium.googlesource.com port 443: 连接超时
    

    After setting up the proxy, you can start clone normally:

    root@yihao-MR-X5:/media/root/work# git clone https://chromium.googlesource.com/external/webrtc
    正克隆到 'webrtc'...
    remote: Sending approximately 188.21 MiB ...
    remote: Counting objects: 90, done
    remote: Finding sources: 100% (89/89)

     

  • Can the command line go over the wall? This is mainly to configure the proxy globally, because in the process of downloading the code, you will also go to google to download some tools, which may be through curl or the built-in cipd_client (it seems that this thing is based on go). Specifically how to do it, first download a tool called polipo:
    sudo apt-get install polipo  

    Then modify the configuration parameters:

    logSyslog = true:
    logFile = "/var/log/polipo/polipo.log"
    
    socksParentProxy = "127.0.0.1:1080"  #这是socks代理的地址和端口
    socksProxyType = socks5
    
    chunkHighMark = 50331648
    objectHighMark = 16384
    
    serverMaxSlots = 64
    serverSlots = 16
    serverSlots1 = 32
    
    proxyAddress = "127.0.0.1" #这是本代理的地址端口 
    proxyPort = 8123
    

    Restart the polipo service

    sudo service polipo restart  

    Then go to set environment variables

    export http_proxy="http://127.0.0.1:8123"  
    export https_proxy="https://127.0.0.1:8123"  

    Note that this command is only valid in the current terminal window. If you want to make each window work, you can add it to ~/.bashrc, and then verify it with the following command. If it returns, it means success

    curl https://www.google.com

So far, all the ladders have been built. Let's start to enter the actual code download steps.

After you have the ladder, you can go directly to the official website to see the compilation manual https://chromium.googlesource.com/chromium/src/+/master/docs/android_build_instructions.md As long as you read its instructions carefully, the following process will be easier. If the process of downloading the source code is interrupted, just enter gclient sync again and it will resume the download from the current progress.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324458925&siteId=291194637
Recommended