naiveproxy: add package
This commit is contained in:
parent
a3ea5e5076
commit
4b440d539c
21
package/ctcgfw/luci-app-naiveproxy/Makefile
Normal file
21
package/ctcgfw/luci-app-naiveproxy/Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
# Copyright (C) 2020 Openwrt.org
|
||||
#
|
||||
# This is a free software, use it under GNU General Public License v3.0.
|
||||
#
|
||||
# Created By [CTCGFW]Project-OpenWrt
|
||||
# https://github.com/project-openwrt
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-naiveproxy
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=1
|
||||
LUCI_TITLE:=LuCI support for NaiveProxy
|
||||
LUCI_DEPENDS:=+naiveproxy
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_MAINTAINER:=CN_SZTL <cnsztl@project-openwrt.eu.org>
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
@ -0,0 +1,23 @@
|
||||
-- This is a free software, use it under GNU General Public License v3.0.
|
||||
-- Created By [CTCGFW]Project OpenWRT
|
||||
-- https://github.com/project-openwrt
|
||||
|
||||
module("luci.controller.naiveproxy", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/naiveproxy") then
|
||||
return
|
||||
end
|
||||
|
||||
local page
|
||||
page = entry({"admin", "services", "naiveproxy"}, cbi("naiveproxy"), _("NaiveProxy"), 100)
|
||||
page.dependent = true
|
||||
entry({"admin", "services", "naiveproxy", "status"},call("act_status")).leaf=true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e={}
|
||||
e.running=luci.sys.call("pgrep naive >/dev/null")==0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
@ -0,0 +1,28 @@
|
||||
-- Created By [CTCGFW]Project-OpenWrt
|
||||
-- https://github.com/project-openwrt
|
||||
|
||||
mp = Map("naiveproxy", translate("NaiveProxy"))
|
||||
mp.description = translate("NaïveProxy uses Chrome's network stack to camouflage traffic with strong censorship resistance and low detectability. Reusing Chrome's stack also ensures best practices in performance and security.")
|
||||
|
||||
mp:section(SimpleSection).template = "naiveproxy/naiveproxy_status"
|
||||
|
||||
s = mp:section(TypedSection, "naiveproxy")
|
||||
s.anonymous=true
|
||||
s.addremove=false
|
||||
|
||||
enable = s:option(Flag, "enable", translate("Enable"))
|
||||
enable.default = 0
|
||||
enable.rmempty = false
|
||||
|
||||
listen_addr = s:option(Value, "listen_addr", translate("Listen Address"))
|
||||
listen_addr.description = translate("proto://[addr][:port]")
|
||||
listen_addr.rmempty = false
|
||||
|
||||
server_addr = s:option(Value, "server_addr", translate("Server Address"))
|
||||
server_addr.description = translate("proto://user:pass@hostname[:port]")
|
||||
server_addr.rmempty = false
|
||||
|
||||
extra_command = s:option(Value, "extra_command", translate("Extra Argument"))
|
||||
extra_command.description = translate("Appends extra argument to NaiveProxy")
|
||||
|
||||
return mp
|
||||
@ -0,0 +1,22 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[naiveproxy]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('gost_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<em><b><font color=green>NaiveProxy <%:RUNNING%></font></b></em>';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<em><b><font color=red>NaiveProxy <%:NOT RUNNING%></font></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="gost_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
||||
26
package/ctcgfw/luci-app-naiveproxy/po/en/naiveproxy.po
Normal file
26
package/ctcgfw/luci-app-naiveproxy/po/en/naiveproxy.po
Normal file
@ -0,0 +1,26 @@
|
||||
msgid "NaiveProxy"
|
||||
msgstr ""
|
||||
|
||||
msgid "NaïveProxy uses Chrome's network stack to camouflage traffic with strong censorship resistance and low detectability. Reusing Chrome's stack also ensures best practices in performance and security."
|
||||
msgstr ""
|
||||
|
||||
msgid "RUNNING"
|
||||
msgstr ""
|
||||
|
||||
msgid "NOT RUNNING"
|
||||
msgstr ""
|
||||
|
||||
msgid "Enable"
|
||||
msgstr ""
|
||||
|
||||
msgid "Listen Address"
|
||||
msgstr ""
|
||||
|
||||
msgid "Server Address"
|
||||
msgstr ""
|
||||
|
||||
msgid "Extra Argument"
|
||||
msgstr ""
|
||||
|
||||
msgid "Appends extra argument to NaiveProxy"
|
||||
msgstr ""
|
||||
26
package/ctcgfw/luci-app-naiveproxy/po/zh_Hans/naiveproxy.po
Normal file
26
package/ctcgfw/luci-app-naiveproxy/po/zh_Hans/naiveproxy.po
Normal file
@ -0,0 +1,26 @@
|
||||
msgid "NaiveProxy"
|
||||
msgstr "NaiveProxy"
|
||||
|
||||
msgid "NaïveProxy uses Chrome's network stack to camouflage traffic with strong censorship resistance and low detectability. Reusing Chrome's stack also ensures best practices in performance and security."
|
||||
msgstr "NaïveProxy 使用 Chrome 网络堆栈强大的反审查功能和低可检测性来伪装流量,同时确保在性能和安全方面达到最佳。"
|
||||
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Listen Address"
|
||||
msgstr "监听地址"
|
||||
|
||||
msgid "Server Address"
|
||||
msgstr "服务器地址"
|
||||
|
||||
msgid "Extra Argument"
|
||||
msgstr "额外参数"
|
||||
|
||||
msgid "Appends extra argument to NaiveProxy"
|
||||
msgstr "追加额外参数到 NaiveProxy"
|
||||
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@naiveproxy[-1]
|
||||
add ucitrack naiveproxy
|
||||
set ucitrack.@naiveproxy[-1].init=naiveproxy
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-naiveproxy": {
|
||||
"description": "Grant UCI access for luci-app-naiveproxy",
|
||||
"read": {
|
||||
"uci": [ "naiveproxy" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "naiveproxy" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
90
package/ctcgfw/naiveproxy/Makefile
Normal file
90
package/ctcgfw/naiveproxy/Makefile
Normal file
@ -0,0 +1,90 @@
|
||||
#
|
||||
# Copyright (C) 2020 Project OpenWrt
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=naiveproxy
|
||||
PKG_VERSION:=84.0.4147.89-2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/klzgrad/naiveproxy/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=f18fbb77dfb5326e97aff8340d42d327ec8572a82e5611e405e375454fe37b29
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=CN_SZTL <cnsztl@project-openwrt.eu.org>
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_BUILD_DEPENDS:=ninja/host python3/host
|
||||
PKG_USE_MIPS16:=0
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
ifneq ($(CONFIG_CPU_TYPE)," ")
|
||||
CPU_TYPE:=$(word 1, $(subst +," ,$(CONFIG_CPU_TYPE)))
|
||||
CPU_SUBTYPE:=$(word 2, $(subst +, ",$(CONFIG_CPU_TYPE)))
|
||||
ifeq ($(CPU_SUBTYPE),)
|
||||
CPU_SUBTYPE:=""
|
||||
endif
|
||||
else
|
||||
CPU_TYPE:=""
|
||||
CPU_SUBTYPE:=""
|
||||
endif
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/naiveproxy
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Web Servers/Proxies
|
||||
URL:=https://github.com/klzgrad/naiveproxy
|
||||
TITLE:=Make a fortune quietly
|
||||
DEPENDS:=@!(arc||armeb||powerpc) +libatomic +libnss
|
||||
endef
|
||||
|
||||
define Package/naiveproxy/description
|
||||
NaïveProxy uses Chrome's network stack to camouflage traffic with strong
|
||||
censorship resistance and low detectability. Reusing Chrome's stack also
|
||||
ensures best practices in performance and security.
|
||||
endef
|
||||
|
||||
ifneq ($(CONFIG_CCACHE),)
|
||||
export CCACHE_SLOPPINESS=time_macros
|
||||
export CCACHE_BASEDIR=$(PKG_BUILD_DIR)/src
|
||||
export CCACHE_CPP2=yes
|
||||
export naive_ccache_flags=cc_wrapper="ccache"
|
||||
endif
|
||||
|
||||
define Build/Compile
|
||||
( \
|
||||
cd $(PKG_BUILD_DIR) ; \
|
||||
./tools/import-upstream.sh ; \
|
||||
. ./init_env.sh "$(ARCH)" "$(BOARD)" $(CPU_TYPE) $(CPU_SUBTYPE) "$(TOOLCHAIN_DIR)" "$(DL_DIR)"; \
|
||||
export naive_flags="$$$${naive_flags} $$$${naive_ccache_flags}" ; \
|
||||
export OP_STAGING_DIR="$(STAGING_DIR)" ; \
|
||||
mkdir -p out ; \
|
||||
./gn/out/gn gen "out/Release" --args="$$$${naive_flags}" --script-executable="$(STAGING_DIR_HOSTPKG)/bin/python3" ; \
|
||||
$(STAGING_DIR_HOSTPKG)/bin/ninja -C "out/Release" naive ; \
|
||||
)
|
||||
endef
|
||||
|
||||
define Package/naiveproxy/conffiles
|
||||
/etc/chromium/policies/managed/proxy.json
|
||||
/etc/config/naiveproxy
|
||||
endef
|
||||
|
||||
define Package/naiveproxy/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/out/Release/naive $(1)/usr/bin/naive
|
||||
$(INSTALL_DIR) $(1)/etc/chromium/policies/managed
|
||||
$(INSTALL_CONF) $(CURDIR)/files/proxy.json $(1)/etc/chromium/policies/managed/proxy.json
|
||||
$(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d
|
||||
$(INSTALL_CONF) $(CURDIR)/files/naiveproxy.config $(1)/etc/config/naiveproxy
|
||||
$(INSTALL_BIN) $(CURDIR)/files/naiveproxy.init $(1)/etc/init.d/naiveproxy
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,naiveproxy))
|
||||
6
package/ctcgfw/naiveproxy/files/naiveproxy.config
Normal file
6
package/ctcgfw/naiveproxy/files/naiveproxy.config
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
config naiveproxy 'config'
|
||||
option enable '0'
|
||||
option listen_addr ''
|
||||
option server_addr ''
|
||||
option extra_argument ''
|
||||
47
package/ctcgfw/naiveproxy/files/naiveproxy.init
Normal file
47
package/ctcgfw/naiveproxy/files/naiveproxy.init
Normal file
@ -0,0 +1,47 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2010 [CTCGFW] Project OpenWRT
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/procd.sh
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
|
||||
init_conf() {
|
||||
config_load "naiveproxy"
|
||||
config_get "enable" "config" "enable" "0"
|
||||
config_get "listen_addr" "config" "listen_addr"
|
||||
config_get "server_addr" "config" "server_addr"
|
||||
config_get "extra_argument" "config" "extra_argument"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
init_conf
|
||||
[ "${enable}" == "1" ] || exit 0
|
||||
|
||||
procd_open_instance naiveproxy
|
||||
|
||||
procd_set_param command naive
|
||||
procd_append_param command --listen="${listen_addr}"
|
||||
procd_append_param command --proxy="${server_addr}"
|
||||
[ -n "${extra_argument}" ] && procd_append_param command "${extra_argument}"
|
||||
|
||||
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
|
||||
procd_set_param limits core="unlimited"
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
reload_service()
|
||||
{
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "naiveproxy"
|
||||
}
|
||||
1
package/ctcgfw/naiveproxy/files/proxy.json
Normal file
1
package/ctcgfw/naiveproxy/files/proxy.json
Normal file
@ -0,0 +1 @@
|
||||
{ "MaxConnectionsPerProxy": 99 }
|
||||
@ -0,0 +1,33 @@
|
||||
From 5b476d92f8dbee8b83061faa8cd18a46e5ab4aae Mon Sep 17 00:00:00 2001
|
||||
From: CN_SZTL <cnsztl@project-openwrt.eu.org>
|
||||
Date: Tue, 18 Aug 2020 20:36:39 +0000
|
||||
Subject: [PATCH 1/3] build: add OpenWrt staging libraries
|
||||
|
||||
---
|
||||
src/build/config/posix/BUILD.gn | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/build/config/posix/BUILD.gn b/src/build/config/posix/BUILD.gn
|
||||
index 9ccb89f27..de9e5501d 100644
|
||||
--- a/src/build/config/posix/BUILD.gn
|
||||
+++ b/src/build/config/posix/BUILD.gn
|
||||
@@ -28,6 +28,9 @@ config("runtime_library") {
|
||||
if (!is_mac && !is_ios && sysroot != "") {
|
||||
# Pass the sysroot to all C compiler variants, the assembler, and linker.
|
||||
sysroot_flags = [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
|
||||
+ sysroot_flags += [ "-I" + getenv("OP_STAGING_DIR") + "/usr/include" ]
|
||||
+ sysroot_flags += [ "-I" + getenv("OP_STAGING_DIR") + "/usr/include/nss" ]
|
||||
+ sysroot_flags += [ "-I" + getenv("OP_STAGING_DIR") + "/usr/include/nspr" ]
|
||||
if (is_linux) {
|
||||
# This is here so that all files get recompiled after a sysroot roll and
|
||||
# when turning the sysroot on or off. (defines are passed via the command
|
||||
@@ -57,6 +60,7 @@ config("runtime_library") {
|
||||
cflags_objcc += sysroot_flags
|
||||
|
||||
# Need to get some linker flags out of the sysroot.
|
||||
+ ldflags += [ "-L" + getenv("OP_STAGING_DIR") + "/usr/lib" ]
|
||||
ld_paths = exec_script("sysroot_ld_path.py",
|
||||
[
|
||||
rebase_path("//build/linux/sysroot_ld_path.sh",
|
||||
--
|
||||
2.17.1
|
||||
@ -0,0 +1,79 @@
|
||||
From fd4f8c65ecbbdd15d71a04d213314de056107a31 Mon Sep 17 00:00:00 2001
|
||||
From: CN_SZTL <cnsztl@project-openwrt.eu.org>
|
||||
Date: Tue, 18 Aug 2020 20:47:40 +0000
|
||||
Subject: [PATCH 2/3] build: add mips & x86 OpenWrt toolchain definitions
|
||||
|
||||
---
|
||||
src/build/toolchain/linux/BUILD.gn | 42 ++++++++++++++++++++++++++++++
|
||||
1 file changed, 42 insertions(+)
|
||||
|
||||
diff --git a/src/build/toolchain/linux/BUILD.gn b/src/build/toolchain/linux/BUILD.gn
|
||||
index 2e7913a4f..cc8084eac 100644
|
||||
--- a/src/build/toolchain/linux/BUILD.gn
|
||||
+++ b/src/build/toolchain/linux/BUILD.gn
|
||||
@@ -95,6 +95,18 @@ clang_toolchain("clang_x86") {
|
||||
}
|
||||
}
|
||||
|
||||
+clang_toolchain("clang_x86_openwrt") {
|
||||
+ # Output linker map files for binary size analysis.
|
||||
+ enable_linker_map = true
|
||||
+ extra_cppflags = "--target=i386-openwrt-linux-musl -D_LIBCPP_HAS_MUSL_LIBC -D__UCLIBC__"
|
||||
+ extra_ldflags = "--target=i386-openwrt-linux-musl"
|
||||
+
|
||||
+ toolchain_args = {
|
||||
+ current_cpu = "x86"
|
||||
+ current_os = "linux"
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
clang_toolchain("clang_x86_v8_arm") {
|
||||
toolchain_args = {
|
||||
current_cpu = "x86"
|
||||
@@ -203,6 +215,26 @@ gcc_toolchain("x64") {
|
||||
}
|
||||
}
|
||||
|
||||
+clang_toolchain("clang_mips_openwrt") {
|
||||
+ extra_cppflags = "--target=mips-openwrt-linux-musl -D_LIBCPP_HAS_MUSL_LIBC -D__UCLIBC__"
|
||||
+ extra_ldflags = "--target=mips-openwrt-linux-musl"
|
||||
+
|
||||
+ toolchain_args = {
|
||||
+ current_cpu = "mips"
|
||||
+ current_os = "linux"
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+clang_toolchain("clang_mips64_openwrt") {
|
||||
+ extra_cppflags = "--target=mips64-openwrt-linux-musl -D_LIBCPP_HAS_MUSL_LIBC -D__UCLIBC__"
|
||||
+ extra_ldflags = "--target=mips64-openwrt-linux-musl"
|
||||
+
|
||||
+ toolchain_args = {
|
||||
+ current_cpu = "mips64"
|
||||
+ current_os = "linux"
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
clang_toolchain("clang_mipsel") {
|
||||
toolchain_args = {
|
||||
current_cpu = "mipsel"
|
||||
@@ -227,6 +259,16 @@ clang_toolchain("clang_mips64el") {
|
||||
}
|
||||
}
|
||||
|
||||
+clang_toolchain("clang_mips64el_openwrt") {
|
||||
+ extra_cppflags = "--target=mips64el-openwrt-linux-musl -D_LIBCPP_HAS_MUSL_LIBC -D__UCLIBC__"
|
||||
+ extra_ldflags = "--target=mips64el-openwrt-linux-musl"
|
||||
+
|
||||
+ toolchain_args = {
|
||||
+ current_cpu = "mips64el"
|
||||
+ current_os = "linux"
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
gcc_toolchain("mipsel") {
|
||||
toolprefix = "mipsel-linux-gnu-"
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
From dd07b78f561914ccc6cbe076ae66c380304bf92c Mon Sep 17 00:00:00 2001
|
||||
From: CN_SZTL <cnsztl@project-openwrt.eu.org>
|
||||
Date: Wed, 19 Aug 2020 12:42:45 +0000
|
||||
Subject: [PATCH 3/3] build: drop useless deps simd_asm
|
||||
|
||||
libjpeg_turbo itself has alreadly set the dependency "simd_asm",
|
||||
and this will cause cross-compile failed:
|
||||
```
|
||||
ERROR Unresolved dependencies.
|
||||
//:gn_all(//build/toolchain/linux:clang_arm64_openwrt)
|
||||
needs //third_party/libjpeg_turbo:simd_asm(//build/toolchain/linux:clang_arm64_openwrt)
|
||||
```
|
||||
So, let's drop it in global build file.
|
||||
---
|
||||
src/BUILD.gn | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/src/BUILD.gn b/src/BUILD.gn
|
||||
index 97494c0a0..daddf5213 100644
|
||||
--- a/src/BUILD.gn
|
||||
+++ b/src/BUILD.gn
|
||||
@@ -746,7 +746,6 @@ group("gn_all") {
|
||||
if (enable_nacl) {
|
||||
deps += [ "//native_client/src/trusted/platform_qualify:vcpuid" ]
|
||||
}
|
||||
- deps += [ "//third_party/libjpeg_turbo:simd_asm" ]
|
||||
}
|
||||
if (is_linux && current_toolchain == host_toolchain) {
|
||||
deps += [ "//v8:v8_shell" ]
|
||||
--
|
||||
2.17.1
|
||||
|
||||
113
package/ctcgfw/naiveproxy/src/init_env.sh
Executable file
113
package/ctcgfw/naiveproxy/src/init_env.sh
Executable file
@ -0,0 +1,113 @@
|
||||
#!/bin/bash
|
||||
# [CTCGFW] Project-OpenWrt
|
||||
# Use it under GPLv3.
|
||||
# --------------------------------------------------------
|
||||
# Init build dependencies for naiveproxy
|
||||
|
||||
# Read args from shell
|
||||
target_arch="$1"
|
||||
target_board="$2"
|
||||
cpu_type="$3"
|
||||
cpu_subtype="$4"
|
||||
toolchain_dir="$5"
|
||||
dl_dir="$6"
|
||||
|
||||
# Set arch info
|
||||
naive_arch="${target_arch}"
|
||||
[ "${target_arch}" == "i386" ] && naive_arch="x86"
|
||||
[ "${target_arch}" == "x86_64" ] && naive_arch="x64"
|
||||
[ "${target_arch}" == "aarch64" ] && naive_arch="arm64"
|
||||
ldso_path="/lib/$(find "${toolchain_dir}/" | grep -Eo "ld-musl-[a-z0-9_-]+\\.so\\.1")"
|
||||
|
||||
# OS detection
|
||||
[ "$(uname)" != "Linux" -o "$(uname -m)" != "x86_64" ] && { echo -e "Support Linux AMD64 only."; exit 1; }
|
||||
|
||||
cd "$PWD/src"
|
||||
|
||||
# AFDO profile
|
||||
[ ! -f "chrome/android/profiles/afdo.prof" ] && {
|
||||
AFDO_NAME="$(cat "chrome/android/profiles/newest.txt")"
|
||||
[ ! -f "${dl_dir}/${AFDO_NAME}" ] && curl -L "https://storage.googleapis.com/chromeos-prebuilt/afdo-job/llvm/${AFDO_NAME}" -o "${dl_dir}/${AFDO_NAME}"
|
||||
bzip2 -cd > "chrome/android/profiles/afdo.prof" < "${dl_dir}/${AFDO_NAME}"
|
||||
}
|
||||
|
||||
# Download Clang
|
||||
[ ! -d "third_party/llvm-build/Release+Asserts/bin" ] && {
|
||||
mkdir -p "third_party/llvm-build/Release+Asserts"
|
||||
CLANG_REVISION="$(python3 "tools/clang/scripts/update.py" --print-revision)"
|
||||
[ ! -f "${dl_dir}/clang-${CLANG_REVISION}.tgz" ] && curl -L "https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64/clang-${CLANG_REVISION}.tgz" -o "${dl_dir}/clang-${CLANG_REVISION}.tgz"
|
||||
tar -xzf "${dl_dir}/clang-${CLANG_REVISION}.tgz" -C "third_party/llvm-build/Release+Asserts"
|
||||
}
|
||||
|
||||
# Download GN tool
|
||||
[ ! -f "gn/out/gn" ] && {
|
||||
mkdir -p "gn/out"
|
||||
GN_VERSION="$(grep "'gn_version':" "buildtools/DEPS" | cut -d"'" -f4)"
|
||||
[ ! -f "${dl_dir}/gn-${GN_VERSION}.zip" ] && curl -L "https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/${GN_VERSION}" -o "${dl_dir}/gn-${GN_VERSION}.zip"
|
||||
unzip -o "${dl_dir}/gn-${GN_VERSION}.zip" -d "gn/out"
|
||||
}
|
||||
|
||||
# Set ENV
|
||||
export DEPOT_TOOLS_WIN_TOOLCHAIN=0
|
||||
export naive_flags="
|
||||
is_official_build=true
|
||||
exclude_unwind_tables=true
|
||||
enable_resource_whitelist_generation=false
|
||||
symbol_level=0
|
||||
is_clang=true
|
||||
use_sysroot=false
|
||||
|
||||
use_allocator=\"none\"
|
||||
use_allocator_shim=false
|
||||
|
||||
fatal_linker_warnings=false
|
||||
treat_warnings_as_errors=false
|
||||
|
||||
fieldtrial_testing_like_official_build=true
|
||||
|
||||
enable_nacl=false
|
||||
enable_print_preview=false
|
||||
enable_remoting=false
|
||||
use_alsa=false
|
||||
use_cups=false
|
||||
use_dbus=false
|
||||
use_gio=false
|
||||
use_platform_icu_alternatives=true
|
||||
use_gtk=false
|
||||
use_system_libdrm=false
|
||||
use_gnome_keyring=false
|
||||
use_libpci=false
|
||||
use_pangocairo=false
|
||||
use_aura=false
|
||||
use_glib=false
|
||||
use_pulseaudio=false
|
||||
use_udev=false
|
||||
|
||||
disable_file_support=true
|
||||
enable_websockets=false
|
||||
disable_ftp_support=true
|
||||
use_kerberos=false
|
||||
enable_mdns=false
|
||||
enable_reporting=false
|
||||
include_transport_security_state_preload_list=false
|
||||
rtc_use_pipewire=false
|
||||
|
||||
use_xkbcommon=false
|
||||
use_ozone=true
|
||||
ozone_auto_platforms=false
|
||||
ozone_platform=\"headless\"
|
||||
ozone_platform_headless=true
|
||||
|
||||
current_os=\"linux\"
|
||||
current_cpu=\"${naive_arch}\"
|
||||
sysroot=\"${toolchain_dir}\"
|
||||
custom_toolchain=\"//build/toolchain/linux:clang_${naive_arch}_openwrt\"
|
||||
ldso_path=\"${ldso_path}\""
|
||||
[ "${target_arch}" == "arm" ] && {
|
||||
naive_flags="${naive_flags} arm_version=0 arm_cpu=\"${cpu_type}\""
|
||||
[ -n "${cpu_subtype}" ] && { echo "${cpu_subtype}" | grep -q "neon" && neon_flag="arm_use_neon=true" || neon_flag="arm_use_neon=false"; naive_flags="${naive_flags} arm_fpu=\"${cpu_subtype}\" arm_float_abi=\"hard\" ${neon_flag}"; } || naive_flags="${naive_flags} arm_float_abi=\"soft\" arm_use_neon=false"
|
||||
}
|
||||
[[ "mips mips64 mipsel mips64el" =~ (^|[[:space:]])"${target_arch}"($|[[:space:]]) ]] && {
|
||||
naive_flags="${naive_flags} use_gold=false is_cfi=false use_cfi_icall=false use_thin_lto=false mips_arch_variant=\"r2\""
|
||||
[[ "${target_arch}" =~ ^"mips"$|^"mipsel"$ ]] && naive_flags="mips_float_abi=\"soft\" mips_tune=\"${cpu_type}\""
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user