Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to generate tz-coords.h as part of the build process. #405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SparkyBluefang
Copy link
Contributor

Allow distros to optionally re-generate the tz-coords.h header, on build, with their packaged version of timezone-data/tzdata.

I would have updated the csd-night-light code to dynamically parse the zone db, but I haven't done anything significant in C for quite some time.

This is a happy medium, which will make it easier for Gentoo to trigger a rebuild of cinnamon-settings-daemon whenever the zone db gets updated.

Comment on lines -13 to +24
res = re.search(r"([A-Z]{2})\s([0-9-+]+)\s([\w/_\-]+)\s", line)
code, coords, tz = res.groups()

res = re.search(r"([+-]{1})([0-9]+)([+-]{1})([0-9]+)", coords)
lat_sign, lat_val, long_sign, long_val = res.groups()
coords, tz = line.split('\t')[1:3]
lat_sign, lat_val, long_sign, long_val = COORDS_RE.search(coords).groups()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file is tab delimited, so simplify the parsing a bit. Also pre-compile the remaining regex.

Comment on lines -32 to +39
const char *timezone;
const gchar *timezone;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to match the committed file.

Comment on lines +3 to +14
if get_option('generate_tz_coords')
prog_python = find_program('python3')

tz_coords_h = custom_target(
'tz_coords_h',
input: get_option('zone_tab'),
output: 'tz-coords.h',
command: [prog_python, '@CURRENT_SOURCE_DIR@/generate-tz-header.py', '-i', '@INPUT@', '-o', '@OUTPUT@']
)
else
tz_coords_h = files('tz-coords.h')
endif
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the generate_tz_coords option to maintain existing behavior. However, I don't think it would be unreasonable to make this unconditional and delete the pre-generated file.

Comment on lines -35 to +47
sources + built_sources,
sources + built_sources + [tz_coords_h],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The brackets seem to be needed for meson <= 0.60.0

WARNING: Project targets '>=0.56.0' but uses feature introduced in '0.60.0': list.<plus>. The right hand operand was not a list.

@clefebvre clefebvre changed the title Add option to generate tz-coords.h as part of the build process. [Next] Add option to generate tz-coords.h as part of the build process. Jan 6, 2025
@clefebvre clefebvre changed the title [Next] Add option to generate tz-coords.h as part of the build process. Add option to generate tz-coords.h as part of the build process. Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant