Skip to content

Commit

Permalink
Merge pull request #3 from jamievlin/ci-windows-impl
Browse files Browse the repository at this point in the history
CI: Add windows CI workflow implementation.
jamievlin authored Dec 30, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
sirtoobii Tobias Bossert
2 parents 977b8d3 + 5176b7c commit 93553dc
Showing 4 changed files with 162 additions and 87 deletions.
9 changes: 9 additions & 0 deletions .github/actions/initialize-windows-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: initialize-env
description: Initialize environment
runs:
using: 'composite'
steps:
- name: Setup Ninja
uses: ashutoshvarma/[email protected]
with:
version: 1.10.0
4 changes: 4 additions & 0 deletions .github/workflows/build-asy-main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name: build-asy-cxx
on:
workflow_dispatch:
pull_request:
branches:
- "master"
- "a/*"
push:
branches:
- msvc-support
jobs:
configure-linux-release-x64:
runs-on: "ubuntu-22.04"
69 changes: 65 additions & 4 deletions .github/workflows/build-asy-windows.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,79 @@
name: build-asy-cxx-windows
on:
workflow_dispatch:
pull_request:
branches:
- "master"
- "a/*"
push:
branches:
- msvc-support
jobs:
configure-windows-msvc-x64:
runs-on: "windows-2022"
steps:
- shell: pwsh
run: Write-Output "hi"
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: ./.github/actions/initialize-windows-env
- name: Cache Vcpkg
id: cache-vcpkg
uses: actions/cache@v3
with:
path: ~\AppData\Local\vcpkg\archives
key: ${{ runner.os }}-vcpkg-cache
- name: Configure MSVC-Release
shell: pwsh
run: |
$VsInfo = Get-CimInstance MSFT_VSInstance -Namespace root/cimv2/vs
& "$($VsInfo.InstallLocation)\\Common7\\Tools\\Launch-VsDevShell.ps1" -Arch amd64 -HostArch amd64 -SkipAutomaticLocation
$env:VCPKG_ROOT = "$env:VCPKG_INSTALLATION_ROOT"
cmake --preset msvc/release
- name: zip cmake configuration
shell: pwsh
# Compress-Archive cmdlet does not support hidden files
run: |
$loc = Get-Location
[System.IO.Compression.ZipFile]::CreateFromDirectory(`
"$($loc.Path)\cmake-build-msvc",`
"$($loc.Path)\cmake-msvc-x64-release-cfg.zip",`
[System.IO.Compression.CompressionLevel]::NoCompression,`
$true`
)
- name: Upload configuration artifacts
uses: actions/upload-artifact@v3
with:
name: cmake-msvc-x64-release-cfg-zip
path: cmake-msvc-x64-release-cfg.zip
build-windows-msvc-x64:
needs: configure-windows-msvc-x64
runs-on: "windows-2022"
steps:
- shell: pwsh
run: Write-Output "hi"
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: ./.github/actions/initialize-windows-env
- name: Download configuration artifacts
uses: actions/download-artifact@v3
with:
name: cmake-msvc-x64-release-cfg-zip
- name: Unzip configuration artifact
run: |
Expand-Archive `
-Path cmake-msvc-x64-release-cfg.zip `
-DestinationPath .
- name: Build asymptote on windows
run: |
$VsInfo = Get-CimInstance MSFT_VSInstance -Namespace root/cimv2/vs
& "$($VsInfo.InstallLocation)\\Common7\\Tools\\Launch-VsDevShell.ps1" -Arch amd64 -HostArch amd64 -SkipAutomaticLocation
$env:VCPKG_ROOT = "$env:VCPKG_INSTALLATION_ROOT"
cmake --build --preset msvc/release --target asy-with-basefiles -j
- name: Archive Asymptote build
uses: actions/upload-artifact@v3
with:
name: asy-win-x64-buildfiles
path: |
cmake-build-msvc/release/asy.exe
cmake-build-msvc/release/base
cmake-build-msvc/release/CTestTestfile.cmake
cmake-build-msvc/release/*.dll
167 changes: 84 additions & 83 deletions cmake-scripts/generated-files.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# generated include directories
set(GENERATED_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated/include")
file(MAKE_DIRECTORY ${GENERATED_INCLUDE_DIR})

# directory for auxilliary files
set(GENERATED_AUX_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated/auxiliary")
file(MAKE_DIRECTORY ${GENERATED_AUX_DIR})

# generated sources
set(GENERATED_SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated/src")
file(MAKE_DIRECTORY ${GENERATED_SRC_DIR})


# opsymbols.h
add_custom_command(
OUTPUT ${GENERATED_INCLUDE_DIR}/opsymbols.h
@@ -14,14 +24,9 @@ add_custom_command(

list(APPEND ASYMPTOTE_INCLUDES ${GENERATED_INCLUDE_DIR})
list(APPEND ASYMPTOTE_GENERATED_HEADERS ${GENERATED_INCLUDE_DIR}/opsymbols.h)

# generated sources
set(GENERATED_SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated/src")
file(MAKE_DIRECTORY ${GENERATED_SRC_DIR})

list(APPEND ASYMPTOTE_SYM_PROCESS_NEEDED_HEADERS ${GENERATED_INCLUDE_DIR}/opsymbols.h)

# run-* files

function(_int_add_runtime_file runtime_file)
set(RUNTIME_FILE_IN_BASE ${ASY_SRC_TEMPLATES_DIR}/${runtime_file})
set(RUNTIME_FILES_OUT ${GENERATED_SRC_DIR}/${runtime_file}.cc ${GENERATED_INCLUDE_DIR}/${runtime_file}.h)
@@ -47,24 +52,85 @@ macro(add_runtime_file runtime_file)
list(APPEND ASY_GENERATED_BUILD_SOURCES
${GENERATED_SRC_DIR}/${runtime_file}.cc
)
list(APPEND ASYMPTOTE_GENERATED_HEADERS
${GENERATED_INCLUDE_DIR}/${runtime_file}.h)
set(_ASY_GENERATED_HEADER_NAME ${GENERATED_INCLUDE_DIR}/${runtime_file}.h)
list(APPEND ASYMPTOTE_GENERATED_HEADERS ${_ASY_GENERATED_HEADER_NAME})
list(APPEND ASYMPTOTE_SYM_PROCESS_NEEDED_HEADERS ${_ASY_GENERATED_HEADER_NAME})
endmacro()

foreach(RUNTIME_FILE ${RUNTIME_BUILD_FILES})
add_runtime_file(${RUNTIME_FILE})
endforeach()

# keywords.h
set(KEYWORDS_HEADER_OUT ${GENERATED_INCLUDE_DIR}/keywords.h)
add_custom_command(
OUTPUT ${KEYWORDS_HEADER_OUT}
COMMAND ${PERL_INTERPRETER} ${ASY_SCRIPTS_DIR}/keywords.pl
--camplfile ${ASY_RESOURCE_DIR}/camp.l
--output ${GENERATED_INCLUDE_DIR}/keywords.h
--process-file ${ASY_SRC_DIR}/process.cc
MAIN_DEPENDENCY ${ASY_RESOURCE_DIR}/camp.l
DEPENDS ${ASY_SCRIPTS_DIR}/keywords.pl ${ASY_SRC_DIR}/process.cc
)

# allsymbols.h
# directory for auxilliary files
set(GENERATED_AUX_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated/auxiliary")
file(MAKE_DIRECTORY ${GENERATED_AUX_DIR})
list(APPEND ASYMPTOTE_GENERATED_HEADERS ${KEYWORDS_HEADER_OUT})
list(APPEND ASYMPTOTE_SYM_PROCESS_NEEDED_HEADERS ${KEYWORDS_HEADER_OUT})

# generating preprocessed files
set(camp_lex_output ${GENERATED_SRC_DIR}/lex.yy.cc)
set(camp_l_file ${ASY_RESOURCE_DIR}/camp.l)

set(FINDSYM_FILE ${ASY_SCRIPTS_DIR}/findsym.pl)
if (WIN32)
list(APPEND FLEX_ARGS --wincompat)
endif()

# flex + bison

# flex
add_custom_command(
OUTPUT ${camp_lex_output}
COMMAND ${FLEX_EXECUTABLE} ${FLEX_ARGS} -o ${camp_lex_output} ${camp_l_file}
MAIN_DEPENDENCY ${camp_l_file}
)

list(APPEND ASY_GENERATED_BUILD_SOURCES ${camp_lex_output})

# bison
set(bison_output ${GENERATED_SRC_DIR}/camp.tab.cc)
set(bison_header ${GENERATED_INCLUDE_DIR}/camp.tab.h)
set(bison_input ${ASY_RESOURCE_DIR}/camp.y)
add_custom_command(
OUTPUT ${bison_output} ${bison_header}
COMMAND ${BISON_EXECUTABLE} -t --header=${bison_header} -o ${bison_output} ${bison_input}
MAIN_DEPENDENCY ${bison_input}
)

list(APPEND ASY_GENERATED_BUILD_SOURCES ${bison_output})
list(APPEND ASYMPTOTE_GENERATED_HEADERS ${bison_header})
list(APPEND ASYMPTOTE_SYM_PROCESS_NEEDED_HEADERS ${bison_header})

# generate enums from csv
foreach(csv_enum_file ${ASY_CSV_ENUM_FILES})
set(generated_header_file ${GENERATED_INCLUDE_DIR}/${csv_enum_file}.h)

add_custom_command(
OUTPUT ${generated_header_file}
COMMAND ${PY3_INTERPRETER} ${ASY_SCRIPTS_DIR}/generate_enums.py
--language cpp
--name ${csv_enum_file}
--input ${ASY_RESOURCE_DIR}/${csv_enum_file}.csv
--output ${generated_header_file}
--xopt namespace=camp
MAIN_DEPENDENCY ${ASY_RESOURCE_DIR}/${csv_enum_file}.csv
DEPENDS ${ASY_SCRIPTS_DIR}/generate_enums.py
)

list(APPEND ASYMPTOTE_GENERATED_HEADERS ${generated_header_file})
list(APPEND ASYMPTOTE_SYM_PROCESS_NEEDED_HEADERS ${generated_header_file})
endforeach ()

# raw.i files
# generating preprocessed files
set(FINDSYM_FILE ${ASY_SCRIPTS_DIR}/findsym.pl)
# combine all files into allsymbols.h
function(symfile_preprocess src_dir symfile symfile_raw_output_varname header_output_varname)
set(symfile_raw_output_var ${symfile_raw_output_varname})
@@ -98,7 +164,9 @@ function(symfile_preprocess src_dir symfile symfile_raw_output_varname header_ou
${msvc_flag}
DEPFILE ${GENERATED_AUX_DIR}/${symfile}.d
BYPRODUCTS ${GENERATED_AUX_DIR}/${symfile}.d
DEPENDS ${src_dir}/${symfile}.cc ${ASY_SCRIPTS_DIR}/gen_preprocessed_depfile.py
DEPENDS ${src_dir}/${symfile}.cc
${ASY_SCRIPTS_DIR}/gen_preprocessed_depfile.py
${ASYMPTOTE_SYM_PROCESS_NEEDED_HEADERS}
VERBATIM
)
# *.symbols.h file
@@ -112,12 +180,9 @@ function(symfile_preprocess src_dir symfile symfile_raw_output_varname header_ou
${processed_output_file}
MAIN_DEPENDENCY ${processed_output_file}
)


endfunction()

# preprocess each individual symbol files

foreach(SYM_FILE ${SYMBOL_STATIC_BUILD_FILES})
symfile_preprocess(${ASY_SRC_DIR} ${SYM_FILE} SYMFILE_OUT HEADER_OUT)
list(APPEND SYMFILE_OUT_LIST ${SYMFILE_OUT})
@@ -130,6 +195,7 @@ foreach(SYM_FILE ${RUNTIME_BUILD_FILES})
list(APPEND ASYMPTOTE_GENERATED_HEADERS ${HEADER_OUT})
endforeach ()

# allsymbols.h
add_custom_command(
OUTPUT ${GENERATED_INCLUDE_DIR}/allsymbols.h
COMMAND ${PERL_INTERPRETER} ${FINDSYM_FILE}
@@ -140,77 +206,12 @@ add_custom_command(

list(APPEND ASYMPTOTE_GENERATED_HEADERS ${GENERATED_INCLUDE_DIR}/allsymbols.h)

# keywords.h

add_custom_command(
OUTPUT ${GENERATED_INCLUDE_DIR}/keywords.h
COMMAND ${PERL_INTERPRETER} ${ASY_SCRIPTS_DIR}/keywords.pl
--camplfile ${ASY_RESOURCE_DIR}/camp.l
--output ${GENERATED_INCLUDE_DIR}/keywords.h
--process-file ${ASY_SRC_DIR}/process.cc
MAIN_DEPENDENCY ${ASY_RESOURCE_DIR}/camp.l
DEPENDS ${ASY_SCRIPTS_DIR}/keywords.pl ${ASY_SRC_DIR}/process.cc
)

list(APPEND ASYMPTOTE_GENERATED_HEADERS ${GENERATED_INCLUDE_DIR}/keywords.h)

set(camp_lex_output ${GENERATED_SRC_DIR}/lex.yy.cc)
set(camp_l_file ${ASY_RESOURCE_DIR}/camp.l)

if (WIN32)
list(APPEND FLEX_ARGS --wincompat)
endif()

# flex + bison
add_custom_command(
OUTPUT ${camp_lex_output}
COMMAND ${FLEX_EXECUTABLE} ${FLEX_ARGS} -o ${camp_lex_output} ${camp_l_file}
MAIN_DEPENDENCY ${camp_l_file}
)

list(APPEND ASY_GENERATED_BUILD_SOURCES ${camp_lex_output})

# bison

set(bison_output ${GENERATED_SRC_DIR}/camp.tab.cc)
set(bison_header ${GENERATED_INCLUDE_DIR}/camp.tab.h)
set(bison_input ${ASY_RESOURCE_DIR}/camp.y)
add_custom_command(
OUTPUT ${bison_output} ${bison_header}
COMMAND ${BISON_EXECUTABLE} -t --header=${bison_header} -o ${bison_output} ${bison_input}
MAIN_DEPENDENCY ${bison_input}
)

list(APPEND ASY_GENERATED_BUILD_SOURCES ${bison_output})
list(APPEND ASYMPTOTE_GENERATED_HEADERS ${bison_header})

# macro files
message(STATUS "Generating revision.cc file")
set(revision_cc_file ${GENERATED_SRC_DIR}/revision.cc)
configure_file(${ASY_RESOURCE_DIR}/template_rev.cc.in ${revision_cc_file})
list(APPEND ASY_GENERATED_BUILD_SOURCES ${revision_cc_file})

# generate enums from csv


foreach(csv_enum_file ${ASY_CSV_ENUM_FILES})
set(generated_header_file ${GENERATED_INCLUDE_DIR}/${csv_enum_file}.h)

add_custom_command(
OUTPUT ${generated_header_file}
COMMAND ${PY3_INTERPRETER} ${ASY_SCRIPTS_DIR}/generate_enums.py
--language cpp
--name ${csv_enum_file}
--input ${ASY_RESOURCE_DIR}/${csv_enum_file}.csv
--output ${generated_header_file}
--xopt namespace=camp
MAIN_DEPENDENCY ${ASY_RESOURCE_DIR}/${csv_enum_file}.csv
DEPENDS ${ASY_SCRIPTS_DIR}/generate_enums.py
)

list(APPEND ASYMPTOTE_GENERATED_HEADERS ${generated_header_file})
endforeach ()

add_custom_target(asy_gen_headers
DEPENDS ${ASYMPTOTE_GENERATED_HEADERS}
)

0 comments on commit 93553dc

Please sign in to comment.