osmith has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-dev/+/37344?usp=email )
Change subject: gen_makefile: indent whole file with spaces
......................................................................
gen_makefile: indent whole file with spaces
Use spaces as indent for the Makefile snippets and replace them with
tabs just before writing the Makefile. This way we can indent the whole
file with spaces. Instead of mixing spaces and tabs, and frequently
having spaces where tabs would need to be by accident, which then
results in a broken Makefile.
Use two spaces for the tabs, as in the vim modeline at the bottom.
Change-Id: I42eb2dda0f1f48d4a8ea2e1e59f9cfd8df7af800
---
M gen_makefile.py
1 file changed, 115 insertions(+), 94 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/44/37344/1
diff --git a/gen_makefile.py b/gen_makefile.py
index 76c81f8..f730c59 100755
--- a/gen_makefile.py
+++ b/gen_makefile.py
@@ -179,33 +179,33 @@
if proj == "osmocom-bb_layer23":
return f'''
.make.{proj}.clone: .make.osmocom-bb.clone
- @echo -e "\\n\\n\\n===== $@\\n"
- test -L {src_proj} || ln -s osmocom-bb/src/host/layer23 {src_proj}
- touch $@
+ @echo -e "\\n\\n\\n===== $@\\n"
+ test -L {src_proj} || ln -s osmocom-bb/src/host/layer23 {src_proj}
+ touch $@
'''
if proj == "osmocom-bb_virtphy":
return f'''
.make.{proj}.clone: .make.osmocom-bb.clone
- @echo -e "\\n\\n\\n===== $@\\n"
- test -L {src_proj} || ln -s osmocom-bb/src/host/virt_phy {src_proj}
- touch $@
+ @echo -e "\\n\\n\\n===== $@\\n"
+ test -L {src_proj} || ln -s osmocom-bb/src/host/virt_phy {src_proj}
+ touch $@
'''
if proj == "osmocom-bb_trxcon":
return f'''
.make.{proj}.clone: .make.osmocom-bb.clone
- @echo -e "\\n\\n\\n===== $@\\n"
- test -L {src_proj} || ln -s osmocom-bb/src/host/trxcon {src_proj}
- touch $@
+ @echo -e "\\n\\n\\n===== $@\\n"
+ test -L {src_proj} || ln -s osmocom-bb/src/host/trxcon {src_proj}
+ touch $@
'''
if proj == "simtrace2_host":
return f'''
.make.{proj}.clone: .make.simtrace2.clone
- @echo -e "\\n\\n\\n===== $@\\n"
- test -L {src_proj} || ln -s simtrace2/host {src_proj}
- touch $@
+ @echo -e "\\n\\n\\n===== $@\\n"
+ test -L {src_proj} || ln -s simtrace2/host {src_proj}
+ touch $@
'''
if proj in projects_urls:
@@ -220,11 +220,11 @@
return f'''
.make.{proj}.clone:
- @echo -e "\\n\\n\\n===== $@\\n"
- test -d {src} || mkdir -p {src}
- test -d {src_proj} || ( {cmd_clone} && {cmd_set_push_url} )
- sync
- touch $@
+ @echo -e "\\n\\n\\n===== $@\\n"
+ test -d {src} || mkdir -p {src}
+ test -d {src_proj} || ( {cmd_clone} && {cmd_set_push_url} )
+ sync
+ touch $@
'''
def gen_makefile_autoconf(proj, src_proj, distclean_cond):
@@ -232,12 +232,12 @@
if buildsystem == "autotools":
return f'''
.make.{proj}.autoconf: .make.{proj}.clone {src_proj}/configure.ac
- if {distclean_cond}; then $(MAKE) {proj}-distclean; fi
- @echo -e "\\n\\n\\n===== $@\\n"
- -rm -f {src_proj}/.version
- cd {src_proj}; autoreconf -fi
- sync
- touch $@
+ if {distclean_cond}; then $(MAKE) {proj}-distclean; fi
+ @echo -e "\\n\\n\\n===== $@\\n"
+ -rm -f {src_proj}/.version
+ cd {src_proj}; autoreconf -fi
+ sync
+ touch $@
'''
elif buildsystem == "meson":
return ""
@@ -251,28 +251,28 @@
if buildsystem == "autotools":
return f'''
.make.{proj}.configure: .make.{proj}.autoconf {deps_installed} $({proj}_configure_files)
- if {distclean_cond}; then $(MAKE) {proj}-distclean .make.{proj}.autoconf; fi
- @echo -e "\\n\\n\\n===== $@\\n"
- -chmod -R ug+w {build_proj}
- -rm -rf {build_proj}
- mkdir -p {build_proj}
- cd {build_proj}; {cflags}{docker_cmd}{build_to_src}/configure \\
- --prefix {shlex.quote(args.install_prefix)} \\
- {configure_opts}
- sync
- touch $@
+ if {distclean_cond}; then $(MAKE) {proj}-distclean .make.{proj}.autoconf; fi
+ @echo -e "\\n\\n\\n===== $@\\n"
+ -chmod -R ug+w {build_proj}
+ -rm -rf {build_proj}
+ mkdir -p {build_proj}
+ cd {build_proj}; {cflags}{docker_cmd}{build_to_src}/configure \\
+ --prefix {shlex.quote(args.install_prefix)} \\
+ {configure_opts}
+ sync
+ touch $@
'''
elif buildsystem == "meson":
return f'''
.make.{proj}.configure: .make.{proj}.clone {deps_installed} $({proj}_configure_files)
- @echo -e "\\n\\n\\n===== $@\\n"
- -chmod -R ug+w {build_proj}
- -rm -rf {build_proj}
- mkdir -p {build_proj}
- cd {build_proj}; {cflags}{docker_cmd}meson setup {build_to_src} . \\
- --prefix {shlex.quote(args.install_prefix)}
- sync
- touch $@
+ @echo -e "\\n\\n\\n===== $@\\n"
+ -chmod -R ug+w {build_proj}
+ -rm -rf {build_proj}
+ mkdir -p {build_proj}
+ cd {build_proj}; {cflags}{docker_cmd}meson setup {build_to_src} . \\
+ --prefix {shlex.quote(args.install_prefix)}
+ sync
+ touch $@
'''
else:
assert False, f"unknown buildsystem: {buildsystem}"
@@ -284,11 +284,11 @@
if buildsystem == "autotools":
return f'''
.make.{proj}.build: .make.{proj}.configure $({proj}_files)
- if {distclean_cond}; then $(MAKE) {proj}-distclean .make.{proj}.configure; fi
- @echo -e "\\n\\n\\n===== $@\\n"
- {docker_cmd}$(MAKE) -C {build_proj} -j {jobs} {check}
- sync
- touch $@
+ if {distclean_cond}; then $(MAKE) {proj}-distclean .make.{proj}.configure; fi
+ @echo -e "\\n\\n\\n===== $@\\n"
+ {docker_cmd}$(MAKE) -C {build_proj} -j {jobs} {check}
+ sync
+ touch $@
'''
elif buildsystem == "meson":
target = "test" if check else "compile"
@@ -298,11 +298,11 @@
# test_line = f"{docker_cmd}meson test -C {build_proj} -v"
return f'''
.make.{proj}.build: .make.{proj}.configure $({proj}_files)
- @echo -e "\\n\\n\\n===== $@\\n"
- {docker_cmd}meson compile -C {build_proj} -j {jobs}
- {test_line}
- sync
- touch $@
+ @echo -e "\\n\\n\\n===== $@\\n"
+ {docker_cmd}meson compile -C {build_proj} -j {jobs}
+ {test_line}
+ sync
+ touch $@
'''
else:
assert False, f"unknown buildsystem: {buildsystem}"
@@ -313,20 +313,20 @@
if buildsystem == "autotools":
return f'''
.make.{proj}.install: .make.{proj}.build
- @echo -e "\\n\\n\\n===== $@\\n"
- {docker_cmd}{sudo_make_install}$(MAKE) -C {build_proj} install
- {no_ldconfig}{sudo_ldconfig}ldconfig
- sync
- touch $@
+ @echo -e "\\n\\n\\n===== $@\\n"
+ {docker_cmd}{sudo_make_install}$(MAKE) -C {build_proj} install
+ {no_ldconfig}{sudo_ldconfig}ldconfig
+ sync
+ touch $@
'''
elif buildsystem == "meson":
return f'''
.make.{proj}.install: .make.{proj}.build
- @echo -e "\\n\\n\\n===== $@\\n"
- {docker_cmd}{sudo_make_install}ninja -C {build_proj} install
- {no_ldconfig}{sudo_ldconfig}ldconfig
- sync
- touch $@
+ @echo -e "\\n\\n\\n===== $@\\n"
+ {docker_cmd}{sudo_make_install}ninja -C {build_proj} install
+ {no_ldconfig}{sudo_ldconfig}ldconfig
+ sync
+ touch $@
'''
else:
assert False, f"unknown buildsystem: {buildsystem}"
@@ -336,25 +336,25 @@
return f'''
.PHONY: {proj}-reinstall
{proj}-reinstall: {deps_reinstall}
- {sudo_make_install}$(MAKE) -C {build_proj} install
+ {sudo_make_install}$(MAKE) -C {build_proj} install
'''
def gen_makefile_clean(proj, build_proj):
return f'''
.PHONY: {proj}-clean
{proj}-clean:
- @echo -e "\\n\\n\\n===== $@\\n"
- -chmod -R ug+w {build_proj}
- -rm -rf {build_proj}
- -rm -rf .make.{proj}.*
+ @echo -e "\\n\\n\\n===== $@\\n"
+ -chmod -R ug+w {build_proj}
+ -rm -rf {build_proj}
+ -rm -rf .make.{proj}.*
'''
def gen_makefile_distclean(proj, src_proj):
return f'''
.PHONY: {proj}-distclean
{proj}-distclean: {proj}-clean
- @echo -e "\\n\\n\\n===== $@\\n"
- $(MAKE) -C {src_proj} distclean
+ @echo -e "\\n\\n\\n===== $@\\n"
+ $(MAKE) -C {src_proj} distclean
'''
def gen_make(proj, deps, configure_opts, jobs, make_dir, src_dir, build_dir, url,
push_url, sudo_make_install, no_ldconfig, ldconfig_without_sudo, make_check):
@@ -481,21 +481,21 @@
#
.PHONY: cn
cn: \
- osmo-ggsn \
- osmo-hlr \
- osmo-iuh \
- osmo-mgw \
- osmo-msc \
- osmo-sgsn \
- osmo-sip-connector \
- osmo-smlc \
- $(NULL)
+ osmo-ggsn \
+ osmo-hlr \
+ osmo-iuh \
+ osmo-mgw \
+ osmo-msc \
+ osmo-sgsn \
+ osmo-sip-connector \
+ osmo-smlc \
+ $(NULL)
.PHONY: cn-bsc
cn-bsc: \
- cn \
- osmo-bsc \
- $(NULL)
+ cn \
+ osmo-bsc \
+ $(NULL)
.PHONY: cn-bsc-nat
cn-bsc-nat: \
@@ -509,10 +509,10 @@
.PHONY: usrp
usrp: \
- cn-bsc \
- osmo-bts \
- osmo-trx \
- $(NULL)
+ cn-bsc \
+ osmo-bts \
+ osmo-trx \
+ $(NULL)
#
# Convenience targets for components in subdirs of repositories
@@ -531,20 +531,20 @@
#
.PHONY: all_debug
all_debug:
- $(MAKE) --dry-run -d all | grep "is newer than target"
- $(MAKE) all
+ $(MAKE) --dry-run -d all | grep "is newer than target"
+ $(MAKE) all
# regenerate this Makefile, in case the deps or opts changed
.PHONY: regen
regen:
- {script} \
- {configure_opts} \
- --output {makefile} \
- --src-dir {src_dir} \
- --make-dir {make_dir} \
- --build-dir {build_dir} \
- --jobs {jobs} \
- --url
"{url}"{push_url}{sudo_make_install}{no_ldconfig}{ldconfig_without_sudo}{make_check}{docker_cmd}{build_debug}{auto_distclean}
+ {script} \
+ {configure_opts} \
+ --output {makefile} \
+ --src-dir {src_dir} \
+ --make-dir {make_dir} \
+ --build-dir {build_dir} \
+ --jobs {jobs} \
+ --url
"{url}"{push_url}{sudo_make_install}{no_ldconfig}{ldconfig_without_sudo}{make_check}{docker_cmd}{build_debug}{auto_distclean}
'''.format(
script=os.path.relpath(sys.argv[0], make_dir),
@@ -585,6 +585,10 @@
args.sudo_make_install, args.no_ldconfig,
args.ldconfig_without_sudo, args.make_check)
+# Replace spaces with tabs to avoid the common pitfall of inserting spaces
+# instead of tabs by accident into the Makefile (as the python code is indented
+# with spaces), which results in a broken Makefile.
+content = content.replace(" ", " ")
output = os.path.join(make_dir, args.output)
print('Writing to %r' % output)
--
To view, visit
https://gerrit.osmocom.org/c/osmo-dev/+/37344?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: I42eb2dda0f1f48d4a8ea2e1e59f9cfd8df7af800
Gerrit-Change-Number: 37344
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: newchange