From b055c8df6258bc887e121d40979816fa578cc00a Mon Sep 17 00:00:00 2001 From: Harry Cheng Date: Sun, 28 Jul 2019 23:57:54 +0800 Subject: [PATCH] Add Python --- Makefile | 12 ++++++++-- python/Makefile | 55 +++++++++++++++++++++++++++++++++++++++++++ python/src/.gitignore | 1 + 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 python/Makefile create mode 100644 python/src/.gitignore diff --git a/Makefile b/Makefile index 5b6e397..01f1654 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ cmake_build_args += -DCMAKE_BUILD_TYPE=Release endif -.PHONY: all clean build rust ucore biscuit bin busybox nginx redis alpine iperf3 +.PHONY: all clean build rust ucore biscuit bin busybox nginx redis alpine iperf3 python all: build @@ -82,6 +82,14 @@ ifneq ($(shell uname), Darwin) @cp nginx/nginx.conf $(out_dir)/usr/local/nginx/conf endif +python: +ifneq ($(shell uname), Darwin) + @echo Building Python + @mkdir -p $(out_dir) + @cd python && make arch=$(arch) all + @cp -r python/build/$(arch)/target $(out_dir)/python +endif + redis: ifneq ($(shell uname), Darwin) @echo Building redis @@ -120,7 +128,7 @@ ifeq ($(arch), $(filter $(arch), x86_64 aarch64)) @cp -r testsuits_alpine $(out_dir)/test endif -build: rust ucore biscuit $(busybox) nginx redis iperf3 test +build: rust ucore biscuit $(busybox) nginx redis iperf3 python test sfsimg: $(out_qcow2) diff --git a/python/Makefile b/python/Makefile new file mode 100644 index 0000000..5ece4d7 --- /dev/null +++ b/python/Makefile @@ -0,0 +1,55 @@ +python_version := 3.7.0 +python_tarball := Python-$(python_version).tar.xz +python_tarball_path := src/$(python_tarball) +build_dir := build/$(arch) +python_dir := $(build_dir)/Python-$(python_version) +prefix := $(arch)-linux-musl- +prefix_dir := build/$(arch)/target +bin_unstripped := $(prefix_dir)/bin/python3.7_unstripped +bin := $(prefix_dir)/bin/python3.7 + + +ifeq ($(arch), mipsel) + prefix := mipsel-linux-musln32- +endif + +cc := $(prefix)gcc +strip := $(prefix)strip + +$(python_tarball_path): + wget https://www.python.org/ftp/python/$(python_version)/$(python_tarball) -O $(python_tarball_path) + +$(python_dir): $(python_tarball_path) + mkdir -p $(build_dir) + cd $(build_dir) && tar xvf ../../$(python_tarball_path) + +$(bin): $(python_dir) + cd $(python_dir) && ./configure \ + CC=$(cc) \ + --host=$(arch)-linux-musl \ + --target=$(arch)-linux-musl \ + --build=x86_64-linux-gnu \ + --disable-ipv6 \ + --without-ensurepip \ + ac_cv_file__dev_ptmx=no \ + ac_cv_file__dev_ptc=no \ + ac_cv_have_long_long_format=yes \ + --prefix=`realpath ../target` + + cd $(python_dir) && make -j8 build_all + mkdir -p $(prefix_dir) + cd $(python_dir) && make -j8 altinstall + +# $(bin_unstripped): $(prefix_dir)/bin/python3.7 +# cp $(bin) $(bin_unstripped) + +# $(bin): $(bin_unstripped) +# cp $(bin_unstripped) $(bin) +# $(strip) $(bin) + +.PHONY: all clean + +all: $(bin) + +clean: + rm -rf build/$(arch) diff --git a/python/src/.gitignore b/python/src/.gitignore new file mode 100644 index 0000000..554cde0 --- /dev/null +++ b/python/src/.gitignore @@ -0,0 +1 @@ +*.tar.xz \ No newline at end of file