diff --git a/.github/actions/initialize-windows-env/action.yml b/.github/actions/initialize-windows-env/action.yml new file mode 100644 index 000000000..60e8673fd --- /dev/null +++ b/.github/actions/initialize-windows-env/action.yml @@ -0,0 +1,9 @@ +name: initialize-env +description: Initialize environment +runs: + using: 'composite' + steps: + - name: Setup Ninja + uses: ashutoshvarma/setup-ninja@v1.1 + with: + version: 1.10.0 diff --git a/.github/workflows/build-asy-main.yml b/.github/workflows/build-asy-main.yml index 2f50521b4..19c2e5d08 100644 --- a/.github/workflows/build-asy-main.yml +++ b/.github/workflows/build-asy-main.yml @@ -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" diff --git a/.github/workflows/build-asy-windows.yml b/.github/workflows/build-asy-windows.yml index 4f85ae7b9..058ad3ac1 100644 --- a/.github/workflows/build-asy-windows.yml +++ b/.github/workflows/build-asy-windows.yml @@ -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 diff --git a/cmake-scripts/generated-files.cmake b/cmake-scripts/generated-files.cmake index 694558d6d..3518bddce 100644 --- a/cmake-scripts/generated-files.cmake +++ b/cmake-scripts/generated-files.cmake @@ -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} )