refactor(make): always use _name instead of __name (#329)
Just consistency. There was no clear semantic regarding why sometimes I was using __name and sometimes _name. So prefer _name everywhere. Occurred to me while working on https://github.com/ooni/probe/issues/1466.
This commit is contained in:
parent
eb43c7994a
commit
6a998545e9
238
make
238
make
|
@ -183,7 +183,7 @@ class ConfigFromCLI:
|
||||||
# to print a very clear and detailed usage string. (But the same
|
# to print a very clear and detailed usage string. (But the same
|
||||||
# could be obtained quite likely w/ argparse.)
|
# could be obtained quite likely w/ argparse.)
|
||||||
|
|
||||||
__usage_string = """\
|
_usage_string = """\
|
||||||
usage: ./make [--disable-embedding-psiphon-config] [-nvx] -t target
|
usage: ./make [--disable-embedding-psiphon-config] [-nvx] -t target
|
||||||
./make -l
|
./make -l
|
||||||
./make [--help|-h]
|
./make [--help|-h]
|
||||||
|
@ -208,7 +208,7 @@ The third form of the command prints this help screen.
|
||||||
def _usage(cls, err: str = "", exitcode: int = 0) -> NoReturn:
|
def _usage(cls, err: str = "", exitcode: int = 0) -> NoReturn:
|
||||||
if err:
|
if err:
|
||||||
sys.stderr.write("error: {}\n".format(err))
|
sys.stderr.write("error: {}\n".format(err))
|
||||||
sys.stderr.write(cls.__usage_string)
|
sys.stderr.write(cls._usage_string)
|
||||||
sys.exit(exitcode)
|
sys.exit(exitcode)
|
||||||
|
|
||||||
def _parse(self, targets: List[str]):
|
def _parse(self, targets: List[str]):
|
||||||
|
@ -481,35 +481,35 @@ class SDKGolangGo:
|
||||||
# We download a golang SDK from upstream to make sure we
|
# We download a golang SDK from upstream to make sure we
|
||||||
# are always using a specific version of golang/go.
|
# are always using a specific version of golang/go.
|
||||||
|
|
||||||
__name = os.path.join(cachedir(), "SDK", "golang")
|
_name = os.path.join(cachedir(), "SDK", "golang")
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def binpath(self) -> str:
|
def binpath(self) -> str:
|
||||||
return os.path.join(self.__name, "go", "bin")
|
return os.path.join(self._name, "go", "bin")
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isdir(self.__name) and not options.dry_run():
|
if os.path.isdir(self._name) and not options.dry_run():
|
||||||
log("\n./make: {}: already built".format(self.__name))
|
log("\n./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
log("\n./make: building {}...".format(self.__name))
|
log("\n./make: building {}...".format(self._name))
|
||||||
engine.require("mkdir", "curl", "shasum", "rm", "tar", "echo")
|
engine.require("mkdir", "curl", "shasum", "rm", "tar", "echo")
|
||||||
filename = "go{}.{}-{}.tar.gz".format(goversion(), goos(), goarch())
|
filename = "go{}.{}-{}.tar.gz".format(goversion(), goos(), goarch())
|
||||||
url = "https://golang.org/dl/{}".format(filename)
|
url = "https://golang.org/dl/{}".format(filename)
|
||||||
engine.run(["mkdir", "-p", self.__name])
|
engine.run(["mkdir", "-p", self._name])
|
||||||
filepath = os.path.join(self.__name, filename)
|
filepath = os.path.join(self._name, filename)
|
||||||
engine.run(["curl", "-fsSLo", filepath, url])
|
engine.run(["curl", "-fsSLo", filepath, url])
|
||||||
sha256file = os.path.join(cachedir(), "SDK", "SHA256")
|
sha256file = os.path.join(cachedir(), "SDK", "SHA256")
|
||||||
engine.echo_to_file("{} {}".format(gosha256sum(), filepath), sha256file)
|
engine.echo_to_file("{} {}".format(gosha256sum(), filepath), sha256file)
|
||||||
engine.run(["shasum", "--check", sha256file])
|
engine.run(["shasum", "--check", sha256file])
|
||||||
engine.run(["rm", sha256file])
|
engine.run(["rm", sha256file])
|
||||||
engine.run(["tar", "-xf", filename], cwd=self.__name)
|
engine.run(["tar", "-xf", filename], cwd=self._name)
|
||||||
engine.run(["rm", filepath])
|
engine.run(["rm", filepath])
|
||||||
|
|
||||||
def goroot(self):
|
def goroot(self):
|
||||||
"""goroot returns the goroot."""
|
"""goroot returns the goroot."""
|
||||||
return os.path.join(self.__name, "go")
|
return os.path.join(self._name, "go")
|
||||||
|
|
||||||
|
|
||||||
class SDKOONIGo:
|
class SDKOONIGo:
|
||||||
|
@ -518,21 +518,21 @@ class SDKOONIGo:
|
||||||
# We use a private fork of golang/go on Android as a
|
# We use a private fork of golang/go on Android as a
|
||||||
# workaround for https://github.com/ooni/probe/issues/1444
|
# workaround for https://github.com/ooni/probe/issues/1444
|
||||||
|
|
||||||
__name = os.path.join(cachedir(), "SDK", "oonigo")
|
_name = os.path.join(cachedir(), "SDK", "oonigo")
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def binpath(self) -> str:
|
def binpath(self) -> str:
|
||||||
return os.path.join(self.__name, "bin")
|
return os.path.join(self._name, "bin")
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isdir(self.__name) and not options.dry_run():
|
if os.path.isdir(self._name) and not options.dry_run():
|
||||||
log("\n./make: {}: already built".format(self.__name))
|
log("\n./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
golang_go = SDKGolangGo()
|
golang_go = SDKGolangGo()
|
||||||
golang_go.build(engine, options)
|
golang_go.build(engine, options)
|
||||||
log("\n./make: building {}...".format(self.__name))
|
log("\n./make: building {}...".format(self._name))
|
||||||
engine.require("git", "bash")
|
engine.require("git", "bash")
|
||||||
engine.run(
|
engine.run(
|
||||||
[
|
[
|
||||||
|
@ -544,42 +544,42 @@ class SDKOONIGo:
|
||||||
"--depth",
|
"--depth",
|
||||||
"8",
|
"8",
|
||||||
"https://github.com/ooni/go",
|
"https://github.com/ooni/go",
|
||||||
self.__name,
|
self._name,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
with Environ(engine, "GOROOT_BOOTSTRAP", golang_go.goroot()):
|
with Environ(engine, "GOROOT_BOOTSTRAP", golang_go.goroot()):
|
||||||
engine.run(
|
engine.run(
|
||||||
["./make.bash"],
|
["./make.bash"],
|
||||||
cwd=os.path.join(self.__name, "src"),
|
cwd=os.path.join(self._name, "src"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SDKAndroid:
|
class SDKAndroid:
|
||||||
"""SDKAndroid creates ${cachedir}/SDK/android."""
|
"""SDKAndroid creates ${cachedir}/SDK/android."""
|
||||||
|
|
||||||
__name = os.path.join(cachedir(), "SDK", "android")
|
_name = os.path.join(cachedir(), "SDK", "android")
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def home(self) -> str:
|
def home(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def ndk_home(self) -> str:
|
def ndk_home(self) -> str:
|
||||||
return os.path.join(self.home(), "ndk", android_ndk_version())
|
return os.path.join(self.home(), "ndk", android_ndk_version())
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isdir(self.__name) and not options.dry_run():
|
if os.path.isdir(self._name) and not options.dry_run():
|
||||||
log("\n./make: {}: already built".format(self.__name))
|
log("\n./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
log("\n./make: building {}...".format(self.__name))
|
log("\n./make: building {}...".format(self._name))
|
||||||
engine.require("mkdir", "curl", "echo", "shasum", "rm", "unzip", "mv", "java")
|
engine.require("mkdir", "curl", "echo", "shasum", "rm", "unzip", "mv", "java")
|
||||||
filename = "commandlinetools-{}-{}_latest.zip".format(
|
filename = "commandlinetools-{}-{}_latest.zip".format(
|
||||||
android_cmdlinetools_os(), android_cmdlinetools_version()
|
android_cmdlinetools_os(), android_cmdlinetools_version()
|
||||||
)
|
)
|
||||||
url = "https://dl.google.com/android/repository/{}".format(filename)
|
url = "https://dl.google.com/android/repository/{}".format(filename)
|
||||||
engine.run(["mkdir", "-p", self.__name])
|
engine.run(["mkdir", "-p", self._name])
|
||||||
filepath = os.path.join(self.__name, filename)
|
filepath = os.path.join(self._name, filename)
|
||||||
engine.run(["curl", "-fsSLo", filepath, url])
|
engine.run(["curl", "-fsSLo", filepath, url])
|
||||||
sha256file = os.path.join(cachedir(), "SDK", "SHA256")
|
sha256file = os.path.join(cachedir(), "SDK", "SHA256")
|
||||||
engine.echo_to_file(
|
engine.echo_to_file(
|
||||||
|
@ -587,21 +587,21 @@ class SDKAndroid:
|
||||||
)
|
)
|
||||||
engine.run(["shasum", "--check", sha256file])
|
engine.run(["shasum", "--check", sha256file])
|
||||||
engine.run(["rm", sha256file])
|
engine.run(["rm", sha256file])
|
||||||
engine.run(["unzip", filename], cwd=self.__name)
|
engine.run(["unzip", filename], cwd=self._name)
|
||||||
engine.run(["rm", filepath])
|
engine.run(["rm", filepath])
|
||||||
# See https://stackoverflow.com/a/61176718 to understand why
|
# See https://stackoverflow.com/a/61176718 to understand why
|
||||||
# we need to reorganize the directories like this:
|
# we need to reorganize the directories like this:
|
||||||
engine.run(
|
engine.run(
|
||||||
["mv", "cmdline-tools", android_cmdlinetools_version()], cwd=self.__name
|
["mv", "cmdline-tools", android_cmdlinetools_version()], cwd=self._name
|
||||||
)
|
)
|
||||||
engine.run(["mkdir", "cmdline-tools"], cwd=self.__name)
|
engine.run(["mkdir", "cmdline-tools"], cwd=self._name)
|
||||||
engine.run(
|
engine.run(
|
||||||
["mv", android_cmdlinetools_version(), "cmdline-tools"], cwd=self.__name
|
["mv", android_cmdlinetools_version(), "cmdline-tools"], cwd=self._name
|
||||||
)
|
)
|
||||||
engine.run(
|
engine.run(
|
||||||
sdkmanager_install_cmd(
|
sdkmanager_install_cmd(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
self.__name,
|
self._name,
|
||||||
"cmdline-tools",
|
"cmdline-tools",
|
||||||
android_cmdlinetools_version(),
|
android_cmdlinetools_version(),
|
||||||
"bin",
|
"bin",
|
||||||
|
@ -617,10 +617,10 @@ class OONIProbePrivate:
|
||||||
# We use this private repository to copy the psiphon configuration
|
# We use this private repository to copy the psiphon configuration
|
||||||
# file to embed into the ooniprobe binaries
|
# file to embed into the ooniprobe binaries
|
||||||
|
|
||||||
__name = os.path.join(cachedir(), "github.com", "ooni", "probe-private")
|
_name = os.path.join(cachedir(), "github.com", "ooni", "probe-private")
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def copyfiles(self, engine: Engine, options: Options) -> None:
|
def copyfiles(self, engine: Engine, options: Options) -> None:
|
||||||
"""copyfiles copies psiphon config to the repository."""
|
"""copyfiles copies psiphon config to the repository."""
|
||||||
|
@ -630,33 +630,33 @@ class OONIProbePrivate:
|
||||||
engine.run(
|
engine.run(
|
||||||
[
|
[
|
||||||
"cp",
|
"cp",
|
||||||
os.path.join(self.__name, "psiphon-config.json.age"),
|
os.path.join(self._name, "psiphon-config.json.age"),
|
||||||
os.path.join("internal", "engine"),
|
os.path.join("internal", "engine"),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
engine.run(
|
engine.run(
|
||||||
[
|
[
|
||||||
"cp",
|
"cp",
|
||||||
os.path.join(self.__name, "psiphon-config.key"),
|
os.path.join(self._name, "psiphon-config.key"),
|
||||||
os.path.join("internal", "engine"),
|
os.path.join("internal", "engine"),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isdir(self.__name) and not options.dry_run():
|
if os.path.isdir(self._name) and not options.dry_run():
|
||||||
log("\n./make: {}: already built".format(self.__name))
|
log("\n./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
if options.disable_embedding_psiphon_config():
|
if options.disable_embedding_psiphon_config():
|
||||||
log("\n./make: {}: disabled by command line flags".format(self.__name))
|
log("\n./make: {}: disabled by command line flags".format(self._name))
|
||||||
return
|
return
|
||||||
log("\n./make: building {}...".format(self.__name))
|
log("\n./make: building {}...".format(self._name))
|
||||||
engine.require("git", "cp")
|
engine.require("git", "cp")
|
||||||
engine.run(
|
engine.run(
|
||||||
[
|
[
|
||||||
"git",
|
"git",
|
||||||
"clone",
|
"clone",
|
||||||
"git@github.com:ooni/probe-private",
|
"git@github.com:ooni/probe-private",
|
||||||
self.__name,
|
self._name,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -664,20 +664,20 @@ class OONIProbePrivate:
|
||||||
class OONIMKAllAAR:
|
class OONIMKAllAAR:
|
||||||
"""OONIMKAllAAR creates ./MOBILE/android/oonimkall.aar."""
|
"""OONIMKAllAAR creates ./MOBILE/android/oonimkall.aar."""
|
||||||
|
|
||||||
__name = os.path.join(".", "MOBILE", "android", "oonimkall.aar")
|
_name = os.path.join(".", "MOBILE", "android", "oonimkall.aar")
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def aarfile(self) -> str:
|
def aarfile(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def srcfile(self) -> str:
|
def srcfile(self) -> str:
|
||||||
return os.path.join(".", "MOBILE", "android", "oonimkall-sources.jar")
|
return os.path.join(".", "MOBILE", "android", "oonimkall-sources.jar")
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isfile(self.__name) and not options.dry_run():
|
if os.path.isfile(self._name) and not options.dry_run():
|
||||||
log("\n./make: {}: already built".format(self.__name))
|
log("\n./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
ooprivate = OONIProbePrivate()
|
ooprivate = OONIProbePrivate()
|
||||||
ooprivate.build(engine, options)
|
ooprivate.build(engine, options)
|
||||||
|
@ -685,7 +685,7 @@ class OONIMKAllAAR:
|
||||||
oonigo.build(engine, options)
|
oonigo.build(engine, options)
|
||||||
android = SDKAndroid()
|
android = SDKAndroid()
|
||||||
android.build(engine, options)
|
android.build(engine, options)
|
||||||
log("\n./make: building {}...".format(self.__name))
|
log("\n./make: building {}...".format(self._name))
|
||||||
ooprivate.copyfiles(engine, options)
|
ooprivate.copyfiles(engine, options)
|
||||||
engine.require("sh", "javac")
|
engine.require("sh", "javac")
|
||||||
self._go_get_gomobile(engine, options, oonigo)
|
self._go_get_gomobile(engine, options, oonigo)
|
||||||
|
@ -749,7 +749,7 @@ class OONIMKAllAAR:
|
||||||
cmdline.append("-target")
|
cmdline.append("-target")
|
||||||
cmdline.append("android")
|
cmdline.append("android")
|
||||||
cmdline.append("-o")
|
cmdline.append("-o")
|
||||||
cmdline.append(self.__name)
|
cmdline.append(self._name)
|
||||||
if not options.disable_embedding_psiphon_config():
|
if not options.disable_embedding_psiphon_config():
|
||||||
cmdline.append("-tags")
|
cmdline.append("-tags")
|
||||||
cmdline.append("ooni_psiphon_config")
|
cmdline.append("ooni_psiphon_config")
|
||||||
|
@ -770,18 +770,18 @@ class BundleJAR:
|
||||||
# We upload the bundle.jar file to maven central to bless
|
# We upload the bundle.jar file to maven central to bless
|
||||||
# a new release of the OONI libraries for Android.
|
# a new release of the OONI libraries for Android.
|
||||||
|
|
||||||
__name = os.path.join(".", "MOBILE", "android", "bundle.jar")
|
_name = os.path.join(".", "MOBILE", "android", "bundle.jar")
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isfile(self.__name) and not options.dry_run():
|
if os.path.isfile(self._name) and not options.dry_run():
|
||||||
log("\n./make: {}: already built".format(self.__name))
|
log("\n./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
oonimkall = OONIMKAllAAR()
|
oonimkall = OONIMKAllAAR()
|
||||||
oonimkall.build(engine, options)
|
oonimkall.build(engine, options)
|
||||||
log("\n./make: building {}...".format(self.__name))
|
log("\n./make: building {}...".format(self._name))
|
||||||
engine.require("cp", "gpg", "jar")
|
engine.require("cp", "gpg", "jar")
|
||||||
version = datetime.datetime.now().strftime("%Y.%m.%d-%H%M%S")
|
version = datetime.datetime.now().strftime("%Y.%m.%d-%H%M%S")
|
||||||
engine.run(
|
engine.run(
|
||||||
|
@ -849,20 +849,20 @@ class Android:
|
||||||
class OONIMKAllFramework:
|
class OONIMKAllFramework:
|
||||||
"""OONIMKAllFramework creates ./MOBILE/ios/oonimkall.framework."""
|
"""OONIMKAllFramework creates ./MOBILE/ios/oonimkall.framework."""
|
||||||
|
|
||||||
__name = os.path.join(".", "MOBILE", "ios", "oonimkall.framework")
|
_name = os.path.join(".", "MOBILE", "ios", "oonimkall.framework")
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isfile(self.__name) and not options.dry_run():
|
if os.path.isfile(self._name) and not options.dry_run():
|
||||||
log("\n./make: {}: already built".format(self.__name))
|
log("\n./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
ooprivate = OONIProbePrivate()
|
ooprivate = OONIProbePrivate()
|
||||||
ooprivate.build(engine, options)
|
ooprivate.build(engine, options)
|
||||||
gogo = SDKGolangGo()
|
gogo = SDKGolangGo()
|
||||||
gogo.build(engine, options)
|
gogo.build(engine, options)
|
||||||
log("\n./make: building {}...".format(self.__name))
|
log("\n./make: building {}...".format(self._name))
|
||||||
ooprivate.copyfiles(engine, options)
|
ooprivate.copyfiles(engine, options)
|
||||||
self._go_get_gomobile(engine, options, gogo)
|
self._go_get_gomobile(engine, options, gogo)
|
||||||
self._gomobile_init(engine, gogo)
|
self._gomobile_init(engine, gogo)
|
||||||
|
@ -919,7 +919,7 @@ class OONIMKAllFramework:
|
||||||
cmdline.append("-target")
|
cmdline.append("-target")
|
||||||
cmdline.append("ios")
|
cmdline.append("ios")
|
||||||
cmdline.append("-o")
|
cmdline.append("-o")
|
||||||
cmdline.append(self.__name)
|
cmdline.append(self._name)
|
||||||
if not options.disable_embedding_psiphon_config():
|
if not options.disable_embedding_psiphon_config():
|
||||||
cmdline.append("-tags")
|
cmdline.append("-tags")
|
||||||
cmdline.append("ooni_psiphon_config")
|
cmdline.append("ooni_psiphon_config")
|
||||||
|
@ -935,19 +935,19 @@ class OONIMKAllFramework:
|
||||||
class OONIMKAllFrameworkZip:
|
class OONIMKAllFrameworkZip:
|
||||||
"""OONIMKAllFrameworkZip creates ./MOBILE/ios/oonimkall.framework.zip."""
|
"""OONIMKAllFrameworkZip creates ./MOBILE/ios/oonimkall.framework.zip."""
|
||||||
|
|
||||||
__name = os.path.join(".", "MOBILE", "ios", "oonimkall.framework.zip")
|
_name = os.path.join(".", "MOBILE", "ios", "oonimkall.framework.zip")
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isfile(self.__name) and not options.dry_run():
|
if os.path.isfile(self._name) and not options.dry_run():
|
||||||
log("\n./make: {}: already built".format(self.__name))
|
log("\n./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
engine.require("zip", "rm")
|
engine.require("zip", "rm")
|
||||||
ooframework = OONIMKAllFramework()
|
ooframework = OONIMKAllFramework()
|
||||||
ooframework.build(engine, options)
|
ooframework.build(engine, options)
|
||||||
log("\n./make: building {}...".format(self.__name))
|
log("\n./make: building {}...".format(self._name))
|
||||||
engine.run(
|
engine.run(
|
||||||
[
|
[
|
||||||
"rm",
|
"rm",
|
||||||
|
@ -970,14 +970,14 @@ class OONIMKAllFrameworkZip:
|
||||||
class OONIMKAllPodspec:
|
class OONIMKAllPodspec:
|
||||||
"""OONIMKAllPodspec creates ./MOBILE/ios/oonimkall.podspec."""
|
"""OONIMKAllPodspec creates ./MOBILE/ios/oonimkall.podspec."""
|
||||||
|
|
||||||
__name = os.path.join(".", "MOBILE", "ios", "oonimkall.podspec")
|
_name = os.path.join(".", "MOBILE", "ios", "oonimkall.podspec")
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isfile(self.__name) and not options.dry_run():
|
if os.path.isfile(self._name) and not options.dry_run():
|
||||||
log("./make: {}: already built".format(self.__name))
|
log("./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
engine.require("cat", "sed")
|
engine.require("cat", "sed")
|
||||||
output = engine.backticks("RELEASE", ["git", "describe", "--tags"])
|
output = engine.backticks("RELEASE", ["git", "describe", "--tags"])
|
||||||
|
@ -986,7 +986,7 @@ class OONIMKAllPodspec:
|
||||||
engine.cat_sed_redirect(
|
engine.cat_sed_redirect(
|
||||||
[("@VERSION@", version), ("@RELEASE@", release)],
|
[("@VERSION@", version), ("@RELEASE@", release)],
|
||||||
os.path.join(".", "MOBILE", "template.podspec"),
|
os.path.join(".", "MOBILE", "template.podspec"),
|
||||||
self.__name,
|
self._name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1005,29 +1005,29 @@ class iOS:
|
||||||
|
|
||||||
class MiniOONIDarwinOrWindows:
|
class MiniOONIDarwinOrWindows:
|
||||||
def __init__(self, goos: str, goarch: str):
|
def __init__(self, goos: str, goarch: str):
|
||||||
self.__ext = ".exe" if goos == "windows" else ""
|
self._ext = ".exe" if goos == "windows" else ""
|
||||||
self.__name = os.path.join(".", "CLI", goos, goarch, "miniooni" + self.__ext)
|
self._name = os.path.join(".", "CLI", goos, goarch, "miniooni" + self._ext)
|
||||||
self.__os = goos
|
self._os = goos
|
||||||
self.__arch = goarch
|
self._arch = goarch
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isfile(self.__name) and not options.dry_run():
|
if os.path.isfile(self._name) and not options.dry_run():
|
||||||
log("\n./make: {}: already built".format(self.__name))
|
log("\n./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
ooprivate = OONIProbePrivate()
|
ooprivate = OONIProbePrivate()
|
||||||
ooprivate.build(engine, options)
|
ooprivate.build(engine, options)
|
||||||
gogo = SDKGolangGo()
|
gogo = SDKGolangGo()
|
||||||
gogo.build(engine, options)
|
gogo.build(engine, options)
|
||||||
log("\n./make: building {}...".format(self.__name))
|
log("\n./make: building {}...".format(self._name))
|
||||||
ooprivate.copyfiles(engine, options)
|
ooprivate.copyfiles(engine, options)
|
||||||
cmdline = [
|
cmdline = [
|
||||||
"go",
|
"go",
|
||||||
"build",
|
"build",
|
||||||
"-o",
|
"-o",
|
||||||
self.__name,
|
self._name,
|
||||||
"-ldflags=-s -w",
|
"-ldflags=-s -w",
|
||||||
]
|
]
|
||||||
if options.debugging():
|
if options.debugging():
|
||||||
|
@ -1037,8 +1037,8 @@ class MiniOONIDarwinOrWindows:
|
||||||
if not options.disable_embedding_psiphon_config():
|
if not options.disable_embedding_psiphon_config():
|
||||||
cmdline.append("-tags=ooni_psiphon_config")
|
cmdline.append("-tags=ooni_psiphon_config")
|
||||||
cmdline.append("./internal/cmd/miniooni")
|
cmdline.append("./internal/cmd/miniooni")
|
||||||
with Environ(engine, "GOOS", self.__os):
|
with Environ(engine, "GOOS", self._os):
|
||||||
with Environ(engine, "GOARCH", self.__arch):
|
with Environ(engine, "GOARCH", self._arch):
|
||||||
with Environ(engine, "CGO_ENABLED", "0"):
|
with Environ(engine, "CGO_ENABLED", "0"):
|
||||||
with AugmentedPath(engine, gogo.binpath()):
|
with AugmentedPath(engine, gogo.binpath()):
|
||||||
engine.require("go")
|
engine.require("go")
|
||||||
|
@ -1047,23 +1047,23 @@ class MiniOONIDarwinOrWindows:
|
||||||
|
|
||||||
class MiniOONILinux:
|
class MiniOONILinux:
|
||||||
def __init__(self, goarch: str):
|
def __init__(self, goarch: str):
|
||||||
self.__name = os.path.join(".", "CLI", "linux", goarch, "miniooni")
|
self._name = os.path.join(".", "CLI", "linux", goarch, "miniooni")
|
||||||
self.__arch = goarch
|
self._arch = goarch
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isfile(self.__name) and not options.dry_run():
|
if os.path.isfile(self._name) and not options.dry_run():
|
||||||
log("\n./make: {}: already built".format(self.__name))
|
log("\n./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
ooprivate = OONIProbePrivate()
|
ooprivate = OONIProbePrivate()
|
||||||
ooprivate.build(engine, options)
|
ooprivate.build(engine, options)
|
||||||
gogo = SDKGolangGo()
|
gogo = SDKGolangGo()
|
||||||
gogo.build(engine, options)
|
gogo.build(engine, options)
|
||||||
log("\n./make: building {}...".format(self.__name))
|
log("\n./make: building {}...".format(self._name))
|
||||||
ooprivate.copyfiles(engine, options)
|
ooprivate.copyfiles(engine, options)
|
||||||
if self.__arch == "arm":
|
if self._arch == "arm":
|
||||||
with Environ(engine, "GOARM", "7"):
|
with Environ(engine, "GOARM", "7"):
|
||||||
self._build(engine, options, gogo)
|
self._build(engine, options, gogo)
|
||||||
else:
|
else:
|
||||||
|
@ -1074,7 +1074,7 @@ class MiniOONILinux:
|
||||||
"go",
|
"go",
|
||||||
"build",
|
"build",
|
||||||
"-o",
|
"-o",
|
||||||
os.path.join("CLI", "linux", self.__arch, "miniooni"),
|
os.path.join("CLI", "linux", self._arch, "miniooni"),
|
||||||
"-ldflags=-s -w -extldflags -static",
|
"-ldflags=-s -w -extldflags -static",
|
||||||
]
|
]
|
||||||
if options.debugging():
|
if options.debugging():
|
||||||
|
@ -1087,7 +1087,7 @@ class MiniOONILinux:
|
||||||
cmdline.append(tags)
|
cmdline.append(tags)
|
||||||
cmdline.append("./internal/cmd/miniooni")
|
cmdline.append("./internal/cmd/miniooni")
|
||||||
with Environ(engine, "GOOS", "linux"):
|
with Environ(engine, "GOOS", "linux"):
|
||||||
with Environ(engine, "GOARCH", self.__arch):
|
with Environ(engine, "GOARCH", self._arch):
|
||||||
with Environ(engine, "CGO_ENABLED", "0"):
|
with Environ(engine, "CGO_ENABLED", "0"):
|
||||||
with AugmentedPath(engine, gogo.binpath()):
|
with AugmentedPath(engine, gogo.binpath()):
|
||||||
engine.require("go")
|
engine.require("go")
|
||||||
|
@ -1110,10 +1110,10 @@ MINIOONI_TARGETS: List[Target] = [
|
||||||
class MiniOONI:
|
class MiniOONI:
|
||||||
"""MiniOONI is the top-level 'miniooni' target."""
|
"""MiniOONI is the top-level 'miniooni' target."""
|
||||||
|
|
||||||
__name = "miniooni"
|
_name = "miniooni"
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
for target in MINIOONI_TARGETS:
|
for target in MINIOONI_TARGETS:
|
||||||
|
@ -1124,19 +1124,19 @@ class OONIProbeLinux:
|
||||||
"""OONIProbeLinux builds ooniprobe for Linux."""
|
"""OONIProbeLinux builds ooniprobe for Linux."""
|
||||||
|
|
||||||
def __init__(self, goarch: str):
|
def __init__(self, goarch: str):
|
||||||
self.__name = os.path.join(".", "CLI", "linux", goarch, "ooniprobe")
|
self._name = os.path.join(".", "CLI", "linux", goarch, "ooniprobe")
|
||||||
self.__arch = goarch
|
self._arch = goarch
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isfile(self.__name) and not options.dry_run():
|
if os.path.isfile(self._name) and not options.dry_run():
|
||||||
log("\n./make: {}: already built".format(self.__name))
|
log("\n./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
ooprivate = OONIProbePrivate()
|
ooprivate = OONIProbePrivate()
|
||||||
ooprivate.build(engine, options)
|
ooprivate.build(engine, options)
|
||||||
log("\n./make: building {}...".format(self.__name))
|
log("\n./make: building {}...".format(self._name))
|
||||||
ooprivate.copyfiles(engine, options)
|
ooprivate.copyfiles(engine, options)
|
||||||
engine.require("docker")
|
engine.require("docker")
|
||||||
# make sure we have the latest version of the container image
|
# make sure we have the latest version of the container image
|
||||||
|
@ -1145,7 +1145,7 @@ class OONIProbeLinux:
|
||||||
"docker",
|
"docker",
|
||||||
"pull",
|
"pull",
|
||||||
"--platform",
|
"--platform",
|
||||||
"linux/{}".format(self.__arch),
|
"linux/{}".format(self._arch),
|
||||||
"golang:{}-alpine".format(goversion()),
|
"golang:{}-alpine".format(goversion()),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@ -1154,9 +1154,9 @@ class OONIProbeLinux:
|
||||||
"docker",
|
"docker",
|
||||||
"run",
|
"run",
|
||||||
"--platform",
|
"--platform",
|
||||||
"linux/{}".format(self.__arch),
|
"linux/{}".format(self._arch),
|
||||||
"-e",
|
"-e",
|
||||||
"GOARCH={}".format(self.__arch),
|
"GOARCH={}".format(self._arch),
|
||||||
"-it",
|
"-it",
|
||||||
"-v",
|
"-v",
|
||||||
"{}:/ooni".format(os.getcwd()),
|
"{}:/ooni".format(os.getcwd()),
|
||||||
|
@ -1180,34 +1180,34 @@ class OONIProbeWindows:
|
||||||
"""OONIProbeWindows builds ooniprobe for Windows."""
|
"""OONIProbeWindows builds ooniprobe for Windows."""
|
||||||
|
|
||||||
def __init__(self, goarch: str):
|
def __init__(self, goarch: str):
|
||||||
self.__name = os.path.join(".", "CLI", "windows", goarch, "ooniprobe.exe")
|
self._name = os.path.join(".", "CLI", "windows", goarch, "ooniprobe.exe")
|
||||||
self.__arch = goarch
|
self._arch = goarch
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def _gcc(self) -> str:
|
def _gcc(self) -> str:
|
||||||
if self.__arch == "amd64":
|
if self._arch == "amd64":
|
||||||
return "x86_64-w64-mingw32-gcc"
|
return "x86_64-w64-mingw32-gcc"
|
||||||
if self.__arch == "386":
|
if self._arch == "386":
|
||||||
return "i686-w64-mingw32-gcc"
|
return "i686-w64-mingw32-gcc"
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isfile(self.__name) and not options.dry_run():
|
if os.path.isfile(self._name) and not options.dry_run():
|
||||||
log("\n./make: {}: already built".format(self.__name))
|
log("\n./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
ooprivate = OONIProbePrivate()
|
ooprivate = OONIProbePrivate()
|
||||||
ooprivate.build(engine, options)
|
ooprivate.build(engine, options)
|
||||||
gogo = SDKGolangGo()
|
gogo = SDKGolangGo()
|
||||||
gogo.build(engine, options)
|
gogo.build(engine, options)
|
||||||
log("\n./make: building {}...".format(self.__name))
|
log("\n./make: building {}...".format(self._name))
|
||||||
ooprivate.copyfiles(engine, options)
|
ooprivate.copyfiles(engine, options)
|
||||||
cmdline = [
|
cmdline = [
|
||||||
"go",
|
"go",
|
||||||
"build",
|
"build",
|
||||||
"-o",
|
"-o",
|
||||||
self.__name,
|
self._name,
|
||||||
"-ldflags=-s -w",
|
"-ldflags=-s -w",
|
||||||
]
|
]
|
||||||
if options.debugging():
|
if options.debugging():
|
||||||
|
@ -1218,7 +1218,7 @@ class OONIProbeWindows:
|
||||||
cmdline.append("-tags=ooni_psiphon_config")
|
cmdline.append("-tags=ooni_psiphon_config")
|
||||||
cmdline.append("./cmd/ooniprobe")
|
cmdline.append("./cmd/ooniprobe")
|
||||||
with Environ(engine, "GOOS", "windows"):
|
with Environ(engine, "GOOS", "windows"):
|
||||||
with Environ(engine, "GOARCH", self.__arch):
|
with Environ(engine, "GOARCH", self._arch):
|
||||||
with Environ(engine, "CGO_ENABLED", "1"):
|
with Environ(engine, "CGO_ENABLED", "1"):
|
||||||
with Environ(engine, "CC", self._gcc()):
|
with Environ(engine, "CC", self._gcc()):
|
||||||
with AugmentedPath(engine, gogo.binpath()):
|
with AugmentedPath(engine, gogo.binpath()):
|
||||||
|
@ -1230,27 +1230,27 @@ class OONIProbeDarwin:
|
||||||
"""OONIProbeDarwin builds ooniprobe for macOS."""
|
"""OONIProbeDarwin builds ooniprobe for macOS."""
|
||||||
|
|
||||||
def __init__(self, goarch: str):
|
def __init__(self, goarch: str):
|
||||||
self.__name = os.path.join(".", "CLI", "darwin", goarch, "ooniprobe")
|
self._name = os.path.join(".", "CLI", "darwin", goarch, "ooniprobe")
|
||||||
self.__arch = goarch
|
self._arch = goarch
|
||||||
|
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self.__name
|
return self._name
|
||||||
|
|
||||||
def build(self, engine: Engine, options: Options) -> None:
|
def build(self, engine: Engine, options: Options) -> None:
|
||||||
if os.path.isfile(self.__name) and not options.dry_run():
|
if os.path.isfile(self._name) and not options.dry_run():
|
||||||
log("\n./make: {}: already built".format(self.__name))
|
log("\n./make: {}: already built".format(self._name))
|
||||||
return
|
return
|
||||||
ooprivate = OONIProbePrivate()
|
ooprivate = OONIProbePrivate()
|
||||||
ooprivate.build(engine, options)
|
ooprivate.build(engine, options)
|
||||||
gogo = SDKGolangGo()
|
gogo = SDKGolangGo()
|
||||||
gogo.build(engine, options)
|
gogo.build(engine, options)
|
||||||
log("\n./make: building {}...".format(self.__name))
|
log("\n./make: building {}...".format(self._name))
|
||||||
ooprivate.copyfiles(engine, options)
|
ooprivate.copyfiles(engine, options)
|
||||||
cmdline = [
|
cmdline = [
|
||||||
"go",
|
"go",
|
||||||
"build",
|
"build",
|
||||||
"-o",
|
"-o",
|
||||||
self.__name,
|
self._name,
|
||||||
"-ldflags=-s -w",
|
"-ldflags=-s -w",
|
||||||
]
|
]
|
||||||
if options.debugging():
|
if options.debugging():
|
||||||
|
@ -1261,7 +1261,7 @@ class OONIProbeDarwin:
|
||||||
cmdline.append("-tags=ooni_psiphon_config")
|
cmdline.append("-tags=ooni_psiphon_config")
|
||||||
cmdline.append("./cmd/ooniprobe")
|
cmdline.append("./cmd/ooniprobe")
|
||||||
with Environ(engine, "GOOS", "darwin"):
|
with Environ(engine, "GOOS", "darwin"):
|
||||||
with Environ(engine, "GOARCH", self.__arch):
|
with Environ(engine, "GOARCH", self._arch):
|
||||||
with Environ(engine, "CGO_ENABLED", "1"):
|
with Environ(engine, "CGO_ENABLED", "1"):
|
||||||
with AugmentedPath(engine, gogo.binpath()):
|
with AugmentedPath(engine, gogo.binpath()):
|
||||||
engine.require("gcc", "go")
|
engine.require("gcc", "go")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user