Skip to content

Commit

Permalink
Cherry-pick Update libyaml (#4583) (#4585)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryfu-msft committed Jun 26, 2024
1 parent 45202ed commit 290222a
Show file tree
Hide file tree
Showing 21 changed files with 303 additions and 36 deletions.
2 changes: 1 addition & 1 deletion cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"git": {
"repositoryUrl": "https://github.com/yaml/libyaml.git",
"commitHash": "2c891fc7a770e8ba2fec34fc6b545c672beb37e6"
"commitHash": "840b65c40675e2d06bf40405ad3f12dec7f35923"
}
}
},
Expand Down
28 changes: 28 additions & 0 deletions src/YamlCppLib/libyaml/.github/workflows/dist.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: dist

on:
push:
branches: [ release/* ]

jobs:
dist:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: env | sort

- name: Get image
run: |
time docker pull yamlio/libyaml-dev
docker images | grep libyaml
- run: |
make -C pkg/docker libyaml-dist-ci
ls -l pkg/docker/output
- uses: actions/upload-artifact@v2
with:
name: release
path: pkg/docker/output/yaml-0*

19 changes: 7 additions & 12 deletions src/YamlCppLib/libyaml/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:

build:

env:
CC: ${{ matrix.compiler }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -21,16 +23,15 @@ jobs:
- macOS-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- run: env | sort
- name: Install software
if: ${{ matrix.os == 'macOS-latest' }}
run: |
if [[ '${{ matrix.os }}' == macOS-latest ]]; then
brew install automake bash coreutils make
echo ::add-path::/usr/local/opt/coreutils/libexec/gnubin
echo ::add-path::/usr/local/opt/make/libexec/gnubin
fi
brew install automake bash coreutils make libtool
echo "/usr/local/opt/coreutils/libexec/gnubin" >> $GITHUB_PATH
echo "/usr/local/opt/make/libexec/gnubin" >> $GITHUB_PATH
- name: Fetch branches
run: |
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
Expand All @@ -48,12 +49,6 @@ jobs:
- name: Compiler version
run: ${{ matrix.compiler }} --version
env:
CC: ${{ matrix.compiler }}
- run: cmake .
env:
CC: ${{ matrix.compiler }}
- run: make
env:
CC: ${{ matrix.compiler }}
- run: make test
1 change: 0 additions & 1 deletion src/YamlCppLib/libyaml/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ config.h*
/configure
stamp-h1
!config/config.h.in
/packaging/
/tests/run-dumper
/tests/run-emitter
/tests/run-emitter-test-suite
Expand Down
2 changes: 2 additions & 0 deletions src/YamlCppLib/libyaml/.makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ MAKE_TARGETS := \
all \
all-am \
all-recursive \
docker-build \
docker-dist \
install \
test \
test-all \
Expand Down
13 changes: 5 additions & 8 deletions src/YamlCppLib/libyaml/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ maintainer-clean-local:
-find ${builddir} -name Makefile.in -exec rm -f '{}' ';'

distclean-local:
rm -fr tests/run-test-suite packaging
rm -fr tests/run-test-suite
-git worktree prune

.PHONY: bootstrap
Expand All @@ -43,12 +43,9 @@ ifeq ($(LIBYAML_TEST_SUITE_RUN_REPO),$(LIBYAML_TEST_SUITE_RUN_REPO_DEFAULT))
git clone --branch $(LIBYAML_TEST_SUITE_RUN_BRANCH) $(LIBYAML_TEST_SUITE_RUN_REPO) $@
endif

packaging:
-git branch --track $@ origin/$@
git worktree add --force $@ $@
docker-build:
make -C pkg/docker build

docker-dist: packaging
make -C $</docker libyaml-dist
docker-dist:
make -C pkg/docker libyaml-dist

docker-test-pyyaml: packaging
make -C $</docker test-pyyaml
2 changes: 1 addition & 1 deletion src/YamlCppLib/libyaml/examples/strings.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
unqouted: string
unquoted: string
literal-block: |
This entire block of text will be the value of the 'literal-block' key,
with line breaks being preserved.
Expand Down
22 changes: 18 additions & 4 deletions src/YamlCppLib/libyaml/include/yaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ typedef struct yaml_parser_s {
yaml_error_type_t error;
/** Error description. */
const char *problem;
/** The byte about which the problem occured. */
/** The byte about which the problem occurred. */
size_t problem_offset;
/** The problematic value (@c -1 is none). */
int problem_value;
Expand Down Expand Up @@ -1335,7 +1335,7 @@ yaml_parser_delete(yaml_parser_t *parser);
* Set a string input.
*
* Note that the @a input pointer must be valid while the @a parser object
* exists. The application is responsible for destroing @a input after
* exists. The application is responsible for destroying @a input after
* destroying the @a parser.
*
* @param[in,out] parser A parser object.
Expand Down Expand Up @@ -1456,6 +1456,20 @@ yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event);
YAML_DECLARE(int)
yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document);

/**
* Set the maximum depth of nesting.
*
* Default: 1000
*
* Each nesting level increases the stack and the number of previous
* starting events that the parser has to check.
*
* @param[in] max The maximum number of allowed nested events
*/

YAML_DECLARE(void)
yaml_set_max_nest_level(int max);

/** @} */

/**
Expand Down Expand Up @@ -1734,7 +1748,7 @@ typedef struct yaml_emitter_s {
size_t length;
/** Does the scalar contain line breaks? */
int multiline;
/** Can the scalar be expessed in the flow plain style? */
/** Can the scalar be expressed in the flow plain style? */
int flow_plain_allowed;
/** Can the scalar be expressed in the block plain style? */
int block_plain_allowed;
Expand Down Expand Up @@ -1950,7 +1964,7 @@ yaml_emitter_close(yaml_emitter_t *emitter);
/**
* Emit a YAML document.
*
* The documen object may be generated using the yaml_parser_load() function
* The document object may be generated using the yaml_parser_load() function
* or the yaml_document_initialize() function. The emitter takes the
* responsibility for the document object and destroys its content after
* it is emitted. The document object is destroyed even if the function fails.
Expand Down
77 changes: 77 additions & 0 deletions src/YamlCppLib/libyaml/pkg/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# How to Make a `libyaml` Release

## Versioning

Update libyaml version in:
* announcement.msg
* Changes
* CMakeLists.txt
* `YAML_VERSION_MAJOR`, `YAML_VERSION_MINOR`, `YAML_VERSION_PATCH`
* .appveyor.yml
* configure.ac
* `YAML_MAJOR`, `YAML_MINOR`, `YAML_PATCH`, `YAML_RELEASE`, `YAML_CURRENT`, `YAML_REVISION`

Commit and push everything to `release/0.x.y`.

## Test and Create Release Archives

### GitHub Actions Automation

The github workflow:

.github/workflows/dist.yaml

will do this automatically for you.

#### .github/workflows/dist.yaml

This workflow will create release archives (`tar.gz` and `zip`).

### Manually

Make sure you have a clean git repository (no changed files).
The following process will clone your current git directory.

This will need the docker image `yamlio/libyaml-dev`.
You can either pull it, or create it yourself:

make docker-build

### Create dist archives

Run:

make docker-dist

It will run `make dist` in the container to create a tarball written to
`pkg/docker/output`.
It will also create a zipfile.

## Update master

git merge release/0.x.y
git tag -a 0.x.y
# <Editor opens>
# Paste the corresponding entry from the Changes file
# Look at an earlier release for how it should look like:
# git show 0.2.3
git push origin master 0.x.y

## Create a GitHub release

Go to "Releases" and click on "Draft a new release".

Fill in the tag you just created in the previous step.

Fill in the release title: v0.x.y

Paste the changelog into the description field.

Upload the tar.gz and .zip file.

You can "Save draft" and publish later, or directly click on "Publish release".

## Update pyyaml.org

See <https://github.com/yaml/pyyaml.org/blob/master/ReadMe.md>.

3 changes: 3 additions & 0 deletions src/YamlCppLib/libyaml/pkg/docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output/*
!Makefile
!output/ReadMe
32 changes: 32 additions & 0 deletions src/YamlCppLib/libyaml/pkg/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM ubuntu:18.04

RUN apt-get update \
&& apt-get install -y \
automake \
bison \
build-essential \
cmake \
curl \
doxygen \
flex \
git \
less \
libtool \
python \
vim \
zip \
&& true

# http://www.doxygen.nl/manual/install.html

RUN curl https://sourceforge.net/projects/doxygen/files/rel-1.8.14/doxygen-1.8.14.src.tar.gz/download \
-L -o /doxygen-1.8.14.src.tar.gz \
&& cd / \
&& tar -xvf doxygen-1.8.14.src.tar.gz \
&& cd doxygen-1.8.14 \
&& mkdir build \
&& cd build \
&& cmake -G "Unix Makefiles" .. \
&& make \
&& make install \
&& true
23 changes: 23 additions & 0 deletions src/YamlCppLib/libyaml/pkg/docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
DOCKER_IMAGE ?= yamlio/libyaml-dev

build:
docker build -t $(DOCKER_IMAGE) .

run: build
docker run -it --rm $(DOCKER_IMAGE) bash

prepare-git:
rm -rf output/libyaml.git
git clone ../../.git output/libyaml.git

libyaml-dist: libyaml-dist-ci

libyaml-dist-ci: prepare-git
docker run --rm -u $$(id -u) \
-v"$$PWD/output:/output" \
-v"$$PWD/scripts:/scripts" \
$(DOCKER_IMAGE) /scripts/libyaml-dist.sh

clean:
rm -rf output/libyaml.git
rm -rf output/yaml-*.*
1 change: 1 addition & 0 deletions src/YamlCppLib/libyaml/pkg/docker/output/ReadMe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Output directory for build files created by docker
23 changes: 23 additions & 0 deletions src/YamlCppLib/libyaml/pkg/docker/scripts/libyaml-dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -ex

cp -r /output/libyaml.git /tmp/
cd /tmp/libyaml.git
./bootstrap
./configure
make dist

# get the tarball filename
tarballs=(yaml-*.tar.gz)
tarball=${tarballs[0]:?}
dirname=${tarball/.tar.gz/}

# Copy to output dir
cp "$tarball" /output

# Create zip archive
cd /tmp
cp "/output/$tarball" .
tar xvf "$tarball"
zip -r "/output/$dirname.zip" "$dirname"
Loading

0 comments on commit 290222a

Please sign in to comment.