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

Meson build writes to the source directory (issue #3507 ) #3508

Merged
merged 5 commits into from
Mar 24, 2022

Conversation

aneejit1
Copy link
Contributor

@aneejit1 aneejit1 commented Mar 24, 2022

The meson build is writing files into the source directory which causes a build failure if the source is read-only. The Python scripts "src/gen-hb-version.py" and "src/gen-harfbuzzcc.py" have been amended so a copy back to the source tree is only performed if the generated files differ from the baselined files (this should therefore only happen when something does
actually change as part of the development process).

Remove writes to the source directory which cause a meson build failure
if the source directory is read-only. Delete the generated files from
the repository.
Remove writes to the source directory which cause a meson build failure
if the source directory is read-only. Delete the generated files from
the repository.
@khaledhosny
Copy link
Collaborator

As you can see, this copying is intentional and we depend on it. Basically, we want to be able to build HarfBuzz from git checkout without using the build system at all, and some large HarfBuzz consumers depend on this.

@khaledhosny
Copy link
Collaborator

What we can do is to check that the files are the same and skip the copying since the copying is only needed when one modifies HarfBuzz source.

@aneejit1
Copy link
Contributor Author

aneejit1 commented Mar 24, 2022

OK, maybe I'm overthinking this but, would this do? (it's lost the formatting)

# copy it also to the source tree, but only if it has changed
with open(os.path.join (CURRENT_SOURCE_DIR, os.path.basename (OUTPUT)), "r", encoding='utf-8') as baseline:
        fromlines = baseline.readlines()
with open(OUTPUT) as generated:
        tolines = generated.readlines()

diff = difflib.unified_diff(fromlines, tolines)
if next(diff, None) is not None:
        shutil.copyfile (OUTPUT, os.path.join (CURRENT_SOURCE_DIR, os.path.basename (OUTPUT)))

@khaledhosny
Copy link
Collaborator

khaledhosny commented Mar 24, 2022

baseline.read() != generated.read() should be enough.

@aneejit1
Copy link
Contributor Author

Hmm! Well the checks seem to be a bit happier about that.

src/gen-harfbuzzcc.py Outdated Show resolved Hide resolved
src/gen-hb-version.py Outdated Show resolved Hide resolved
Remove writes to the source directory which cause a meson build failure
if the source directory is read-only. The scripts src/gen-harfbuzzcc.py
and src/gen-hb-version.py have been modified so a copy back to the
source tree is only performed if the generated files differ from the
baselined files (this should therefore only happen when something does
actually change as part of the development process).
Copy link
Collaborator

@khaledhosny khaledhosny left a comment

Choose a reason for hiding this comment

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

Please squash all the commits into one, thanks.

@behdad
Copy link
Member

behdad commented Mar 24, 2022

Please squash all the commits into one, thanks.

Github merge can do that.

@behdad behdad merged commit a55a424 into harfbuzz:main Mar 24, 2022
@khaledhosny khaledhosny added the meson meson build system label Mar 24, 2022
@aneejit1 aneejit1 deleted the meson-source-dir-writes branch March 24, 2022 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meson meson build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants