├── .clang-format ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── question.md └── workflows │ └── sw.yml ├── .gitignore ├── COPYING ├── LICENSE.APLv2 ├── LICENSE.GPLv3 ├── LICENSE.MPLv2 ├── README.md ├── doc ├── comparison.md ├── doxyfile ├── latex │ ├── client.tex │ ├── docpackages.tex │ ├── front.tex │ ├── intro.tex │ ├── layout.tex │ ├── macros.tex │ ├── server.tex │ ├── sm.tex │ ├── styles.tex │ ├── sw.tex │ └── text.tex ├── readme.md └── support.md ├── src └── sw │ ├── builder │ ├── builder.natvis │ ├── command.cpp │ ├── command.h │ ├── command_storage.cpp │ ├── command_storage.h │ ├── concurrent_map.cpp │ ├── concurrent_map.h │ ├── execution_plan.cpp │ ├── execution_plan.h │ ├── execution_plan_serialization.cpp │ ├── file.cpp │ ├── file.h │ ├── file_storage.cpp │ ├── file_storage.h │ ├── inserts.h │ ├── jumppad.cpp │ ├── jumppad.h │ ├── node.cpp │ ├── node.h │ ├── os.cpp │ ├── os.h │ ├── pch.h │ ├── platform.h │ ├── program.cpp │ ├── program.h │ ├── sw_context.cpp │ └── sw_context.h │ ├── builder_distributed │ ├── server.cpp │ └── server.h │ ├── client │ ├── cli │ │ ├── client.cpp │ │ ├── client.ico │ │ ├── client.manifest │ │ └── resource.rc │ ├── common │ │ ├── cl.yml │ │ ├── command │ │ │ ├── abi.cpp │ │ │ ├── alias.cpp │ │ │ ├── build.cpp │ │ │ ├── configure.cpp │ │ │ ├── create.cpp │ │ │ ├── doc.cpp │ │ │ ├── fetch.cpp │ │ │ ├── generate.cpp │ │ │ ├── get.cpp │ │ │ ├── install.cpp │ │ │ ├── integrate.cpp │ │ │ ├── list.cpp │ │ │ ├── mirror.cpp │ │ │ ├── open.cpp │ │ │ ├── override.cpp │ │ │ ├── pack.cpp │ │ │ ├── path.cpp │ │ │ ├── remote.cpp │ │ │ ├── remove.cpp │ │ │ ├── run.cpp │ │ │ ├── run_windows.cpp │ │ │ ├── server.cpp │ │ │ ├── service.cpp │ │ │ ├── setup.cpp │ │ │ ├── test.cpp │ │ │ ├── update.cpp │ │ │ ├── upload.cpp │ │ │ ├── uri.cpp │ │ │ └── verify.cpp │ │ ├── commands.h │ │ ├── commands.inl │ │ ├── generator │ │ │ ├── generator.cpp │ │ │ ├── generator.h │ │ │ ├── generator.inl │ │ │ └── vs │ │ │ │ ├── project_emitter.cpp │ │ │ │ ├── project_emitter.h │ │ │ │ ├── solution_emitter.cpp │ │ │ │ ├── solution_emitter.h │ │ │ │ ├── vs.cpp │ │ │ │ └── vs.h │ │ ├── inserts.h │ │ ├── inserts │ │ │ ├── SWConfig.cmake │ │ │ ├── inserts.cpp │ │ │ └── project_templates.yml │ │ ├── main.cpp │ │ ├── main.h │ │ ├── self_upgrade.cpp │ │ ├── self_upgrade.h │ │ ├── sig.cpp │ │ ├── sig.h │ │ ├── sw_context.cpp │ │ └── sw_context.h │ └── gui │ │ ├── cl_helper.h │ │ ├── client.ico │ │ ├── client.manifest │ │ ├── logwindow.cpp │ │ ├── logwindow.h │ │ ├── main.cpp │ │ ├── mainwindow.cpp │ │ ├── mainwindow.h │ │ ├── packages_model.cpp │ │ ├── packages_model.h │ │ ├── resource.rc │ │ ├── settingswindow.cpp │ │ ├── settingswindow.h │ │ ├── stdvectoredit.h │ │ ├── sw_context.cpp │ │ └── sw_context.h │ ├── core │ ├── build.cpp │ ├── build.h │ ├── command.h │ ├── core.natvis │ ├── driver.cpp │ ├── driver.h │ ├── input.cpp │ ├── input.h │ ├── input_database.cpp │ ├── input_database.h │ ├── inserts.h │ ├── inserts │ │ ├── input_db_schema.sql │ │ └── inserts.cpp │ ├── rule.cpp │ ├── rule.h │ ├── settings.cpp │ ├── settings.h │ ├── settings_serialization.cpp │ ├── specification.cpp │ ├── specification.h │ ├── sw_context.cpp │ ├── sw_context.h │ ├── target.cpp │ └── target.h │ ├── driver │ ├── autotools.cpp │ ├── bazel │ │ ├── bazel.cpp │ │ ├── bazel.h │ │ ├── driver.cpp │ │ ├── driver.h │ │ ├── grammar.yy │ │ └── lexer.ll │ ├── build.cpp │ ├── build.h │ ├── build_self.cpp │ ├── build_settings.cpp │ ├── build_settings.h │ ├── c │ │ ├── c.cpp │ │ ├── c.h │ │ ├── c.hpp │ │ ├── c.types.inl │ │ └── swc.h │ ├── checks.cpp │ ├── checks.h │ ├── checks_storage.h │ ├── cmake.h │ ├── command.cpp │ ├── command.h │ ├── compiler │ │ ├── compiler.cpp │ │ ├── compiler.h │ │ ├── compiler_helpers.h │ │ ├── detect.cpp │ │ ├── detect.h │ │ ├── detect.inl │ │ └── detect_win_sdk.cpp │ ├── dependency.h │ ├── driver.cpp │ ├── driver.h │ ├── driver.natvis │ ├── entry_point.cpp │ ├── entry_point.h │ ├── frontend │ │ ├── cmake │ │ │ ├── cmake.cpp │ │ │ └── cmake_fe.h │ │ ├── cppan │ │ │ ├── bsi.inl │ │ │ ├── cppan.cpp │ │ │ ├── cppan.h │ │ │ ├── project.cpp │ │ │ ├── project.h │ │ │ ├── yaml.cpp │ │ │ └── yaml.h │ │ └── vala │ │ │ └── sw.vapi │ ├── functions.cpp │ ├── functions.h │ ├── inheritance.h │ ├── license.cpp │ ├── license.h │ ├── misc │ │ ├── Setup.Configuration.h │ │ ├── bindexplib.cxx │ │ ├── cmVSSetupHelper.cxx │ │ ├── cmVSSetupHelper.h │ │ ├── delay_load_helper.cpp │ │ └── sw.cpp │ ├── module.cpp │ ├── module.h │ ├── options.cpp │ ├── options.h │ ├── options_cl.cpp │ ├── options_cl.h │ ├── options_cl.yml │ ├── options_cl_vs.cpp │ ├── options_cl_vs.h │ ├── pch.h │ ├── program.h │ ├── program_storage.cpp │ ├── program_storage.h │ ├── program_version_storage.cpp │ ├── program_version_storage.h │ ├── property.h │ ├── source_file.cpp │ ├── source_file.h │ ├── source_file_storage.h │ ├── suffix.h │ ├── sw.h │ ├── sw1.h │ ├── sw_abi_version.h │ ├── sw_check_abi_version.h │ ├── target │ │ ├── all.h │ │ ├── base.cpp │ │ ├── base.h │ │ ├── base_macro.h │ │ ├── base_macro_end.h │ │ ├── cgnustd.inl │ │ ├── common.h │ │ ├── cppstd.inl │ │ ├── cstd.inl │ │ ├── enums.h │ │ ├── fortran.cpp │ │ ├── fortran.h │ │ ├── native.cpp │ │ ├── native.h │ │ ├── native1.h │ │ ├── other.cpp │ │ ├── other.h │ │ ├── std.inl │ │ ├── target2.cpp │ │ ├── target2.h │ │ ├── vala.cpp │ │ └── vala.h │ ├── tools │ │ ├── cl_generator.cpp │ │ ├── cl_generator.h │ │ └── self_builder.cpp │ ├── types.cpp │ └── types.h │ ├── manager │ ├── api.cpp │ ├── api.h │ ├── api_protobuf.h │ ├── database.cpp │ ├── database.h │ ├── database_pps.h │ ├── inserts.h │ ├── inserts │ │ ├── inserts.cpp │ │ └── packages_db_schema.sql │ ├── manager.natvis │ ├── package.cpp │ ├── package.h │ ├── package_database.h │ ├── pch.h │ ├── remote.cpp │ ├── remote.h │ ├── settings.cpp │ ├── settings.h │ ├── stamp.cpp │ ├── stamp.h │ ├── storage.cpp │ ├── storage.h │ ├── storage_remote.cpp │ ├── storage_remote.h │ ├── sw_context.cpp │ ├── sw_context.h │ ├── yaml.cpp │ └── yaml.h │ ├── protocol │ ├── api.proto │ ├── build.proto │ └── grpc_helpers.h │ ├── support │ ├── enums.cpp │ ├── enums.h │ ├── exceptions.cpp │ ├── exceptions.h │ ├── filesystem.cpp │ ├── filesystem.h │ ├── hash.cpp │ ├── hash.h │ ├── package.cpp │ ├── package.h │ ├── package_data.cpp │ ├── package_data.h │ ├── package_id.cpp │ ├── package_id.h │ ├── package_path.cpp │ ├── package_path.h │ ├── package_path.inl │ ├── package_unresolved.h │ ├── package_version_map.h │ ├── serialization.h │ ├── source.cpp │ ├── source.h │ ├── specification.cpp │ ├── specification.h │ ├── storage.cpp │ ├── storage.h │ ├── storage_directories.inl │ ├── version.cpp │ └── version.h │ └── tools │ └── mirror.cpp ├── sw.cpp ├── test ├── .gitignore ├── build │ ├── .gitignore │ ├── CMakeLists.txt │ ├── ada │ │ ├── hello.adb │ │ └── sw.cpp │ ├── c │ │ ├── api │ │ │ ├── exe.cpp │ │ │ ├── lib1.c │ │ │ ├── lib1.h │ │ │ └── sw.cpp │ │ └── exe │ │ │ ├── 1.h │ │ │ ├── build.c │ │ │ ├── f.c │ │ │ └── x.c │ ├── cmake │ │ ├── CMakeLists.txt │ │ ├── CMakeProject1.cpp │ │ ├── CMakeProject1.h │ │ ├── CMakeProject2.cpp │ │ ├── CMakeProject3.cpp │ │ ├── lib1.cpp │ │ ├── lib1.h │ │ ├── lib2.cpp │ │ ├── lib2.h │ │ ├── lib3.cpp │ │ ├── lib3.h │ │ ├── lib4.cpp │ │ └── lib4.h │ ├── cpp │ │ ├── complex │ │ │ └── 1 │ │ │ │ ├── main.cpp │ │ │ │ └── sw.cpp │ │ ├── dep │ │ │ ├── boost │ │ │ │ └── system │ │ │ │ │ └── main.cpp │ │ │ ├── circular │ │ │ │ ├── dll │ │ │ │ │ ├── a.cpp │ │ │ │ │ └── b.cpp │ │ │ │ ├── exe │ │ │ │ │ ├── a.cpp │ │ │ │ │ └── b.cpp │ │ │ │ └── exe_dll │ │ │ │ │ ├── a.cpp │ │ │ │ │ └── b.cpp │ │ │ ├── exe_dll │ │ │ │ ├── a.cpp │ │ │ │ ├── a.h │ │ │ │ └── main.cpp │ │ │ ├── exe_dll_dll │ │ │ │ ├── a.cpp │ │ │ │ ├── a.h │ │ │ │ ├── b.cpp │ │ │ │ ├── b.h │ │ │ │ └── main.cpp │ │ │ ├── exe_lib │ │ │ │ ├── a.cpp │ │ │ │ ├── a.h │ │ │ │ └── main.cpp │ │ │ └── exe_lib_st_sh │ │ │ │ ├── a.cpp │ │ │ │ ├── a.h │ │ │ │ └── main.cpp │ │ ├── dll │ │ │ └── build.cpp │ │ ├── exe │ │ │ ├── 1 │ │ │ │ ├── 1.txt │ │ │ │ ├── 2.h │ │ │ │ └── x.cpp │ │ │ ├── 1.h │ │ │ ├── 1.txt │ │ │ ├── build.cpp │ │ │ └── x.cpp │ │ ├── exe2 │ │ │ ├── 1.h │ │ │ └── main.cpp │ │ ├── lib │ │ │ └── build.cpp │ │ ├── modules │ │ │ ├── complex │ │ │ │ ├── 1.h │ │ │ │ ├── Source.cpp │ │ │ │ ├── m.ixx │ │ │ │ ├── m2.cpp │ │ │ │ ├── main.cpp │ │ │ │ ├── old_header.h │ │ │ │ ├── old_header2.h │ │ │ │ └── sw.cpp │ │ │ ├── includes │ │ │ │ ├── m.cpp │ │ │ │ ├── main.cpp │ │ │ │ ├── old_header.h │ │ │ │ ├── old_header2.h │ │ │ │ └── sw.cpp │ │ │ └── simple │ │ │ │ ├── m.cpp │ │ │ │ ├── main.cpp │ │ │ │ └── sw.cpp │ │ ├── multiconf │ │ │ ├── cygwin2macos_clang.cpp │ │ │ ├── cygwin2macos_gcc.cpp │ │ │ ├── multiconf.bat │ │ │ ├── src │ │ │ │ ├── 1.h │ │ │ │ ├── 1.txt │ │ │ │ ├── 2.h │ │ │ │ ├── lib5.cpp │ │ │ │ ├── lib6.cpp │ │ │ │ ├── lib6.h │ │ │ │ ├── lib7.c │ │ │ │ ├── lib7.h │ │ │ │ ├── main.cpp │ │ │ │ ├── main2.cpp │ │ │ │ ├── main3.cpp │ │ │ │ ├── main5.cpp │ │ │ │ └── main6.cpp │ │ │ └── sw.cpp │ │ ├── pch │ │ │ ├── src │ │ │ │ ├── 2 │ │ │ │ │ └── 2.h │ │ │ │ ├── 1.h │ │ │ │ ├── main.cpp │ │ │ │ ├── main2.cpp │ │ │ │ └── main3.cpp │ │ │ └── sw.cpp │ │ ├── png │ │ │ ├── CMakeLists.txt │ │ │ ├── png.cpp │ │ │ └── sw.cpp │ │ ├── pp │ │ │ ├── src │ │ │ │ ├── 1.h │ │ │ │ └── main.cpp │ │ │ └── sw.cpp │ │ ├── pragma_sw_require │ │ │ └── sw.cpp │ │ ├── settings │ │ │ ├── src │ │ │ │ ├── lib.cpp │ │ │ │ ├── lib.h │ │ │ │ └── main.cpp │ │ │ └── sw.cpp │ │ ├── spaces_and_unicode │ │ │ ├── src │ │ │ │ ├── main with spaces.cpp │ │ │ │ └── main 與 unicōde привет, мир!.cpp │ │ │ └── sw.cpp │ │ └── static │ │ │ ├── exe.cpp │ │ │ ├── lib1.cpp │ │ │ ├── lib1.h │ │ │ ├── lib2.cpp │ │ │ ├── lib2.h │ │ │ ├── lib3.cpp │ │ │ ├── lib3.h │ │ │ └── sw.cpp │ ├── cross │ │ ├── main.cpp │ │ └── sw.cpp │ ├── cross1 │ │ ├── f.cpp │ │ ├── main.cpp │ │ └── sw.cpp │ ├── cross2 │ │ ├── exceptions.cpp │ │ ├── exceptions.h │ │ ├── main.cpp │ │ └── sw.cpp │ ├── d │ │ ├── a.d │ │ ├── b.d │ │ ├── c.d │ │ └── sw.cpp │ ├── dlopen │ │ ├── dlopen.cpp │ │ ├── f.cpp │ │ ├── main.c │ │ ├── main.cpp │ │ └── sw.cpp │ ├── fortran │ │ ├── main.f │ │ └── sw.cpp │ ├── inline │ │ ├── png.c │ │ └── png.cpp │ ├── java │ │ ├── App.java │ │ ├── HelloWorld.java │ │ └── sw.cpp │ ├── kotlin │ │ ├── hello.kt │ │ └── sw.cpp │ ├── mixed │ │ ├── 1 │ │ │ ├── 1.cs │ │ │ ├── 2.cs │ │ │ ├── App.java │ │ │ ├── HelloWorld.java │ │ │ ├── hello.kt │ │ │ ├── main.cpp │ │ │ ├── main.cs │ │ │ ├── main.f │ │ │ ├── main.go │ │ │ ├── main.rs │ │ │ └── sw.cpp │ │ └── 2 │ │ │ ├── Cargo.toml │ │ │ ├── src │ │ │ └── main.rs │ │ │ └── sw.cpp │ ├── objc │ │ ├── main.cpp │ │ └── main.mm │ ├── pascal │ │ ├── hello.pas │ │ └── sw.cpp │ ├── rules │ │ └── simple │ │ │ ├── main.cpp │ │ │ └── sw.cpp │ ├── rust │ │ └── 1 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ └── main.rs │ ├── simple │ │ ├── 1.h │ │ ├── main.c │ │ ├── main.cpp │ │ ├── main3.cpp │ │ ├── sw.c │ │ ├── sw.cpp │ │ └── sw.vala │ ├── sw.cpp │ ├── vala │ │ ├── exe1.vala │ │ ├── exe2.vala │ │ ├── hw.vala │ │ ├── lib1.vala │ │ ├── sh.vala │ │ └── sw.cpp │ └── yasm │ │ ├── common.asm │ │ ├── host.json │ │ └── sw.cpp ├── integrations │ ├── CMakeLists.txt │ ├── cmake │ │ └── tess │ │ │ ├── CMakeLists.txt │ │ │ └── main.cpp │ ├── png.cpp │ ├── sqlite3.cpp │ └── wscript └── unit │ ├── api.cpp │ ├── path.cpp │ ├── property.cpp │ └── sources.cpp └── utils ├── build ├── linux.sh └── macos.sh └── cc ├── cygwin2macos.cpp ├── win2android.cpp └── win2macos.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | UseTab: Never 2 | IndentWidth: 4 3 | BreakBeforeBraces: Allman 4 | AllowShortIfStatementsOnASingleLine: false 5 | IndentCaseLabels: false 6 | ColumnLimit: 0 7 | AccessModifierOffset: -4 8 | AllowShortFunctionsOnASingleLine: false 9 | 10 | AlignTrailingComments: true 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report any issue here 4 | title: '' 5 | labels: 'bug' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | Before you start, ensure you have the latest sw client (run `sw --self-upgrade`) and the bug is present there. 13 | 14 | **Expected behavior** 15 | A clear and concise description of what you expected to happen. 16 | 17 | **To Reproduce** 18 | Steps to reproduce the behavior: 19 | 1. ... 20 | 21 | **Information:** 22 | - Paste `sw --version` output. 23 | - Write OS, its version (host/target) 24 | - Describe your compiler, its version 25 | - (optional, nix systems) Post backtrace if you know how to (using gdb, lldb). 26 | - (optional) Post sw logs using `-trace` parameter. 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: 'enhancement' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Ask something about this project 4 | title: '' 5 | labels: 'question' 6 | assignees: '' 7 | 8 | --- 9 | -------------------------------------------------------------------------------- /.github/workflows/sw.yml: -------------------------------------------------------------------------------- 1 | name: sw 2 | 3 | on: 4 | push: 5 | pull_request: 6 | schedule: 7 | # every day 8 | - cron: 0 0 * * * 9 | 10 | jobs: 11 | windows: 12 | runs-on: windows-2022 13 | steps: 14 | - uses: actions/checkout@v1 15 | - uses: egorpugin/sw-action@master 16 | - run: ./sw -static build 17 | - uses: actions/upload-artifact@v4 18 | with: 19 | name: sw-windows 20 | path: .sw/out/**/*.exe 21 | 22 | linux: 23 | runs-on: ubuntu-22.04 24 | container: fedora:latest 25 | steps: 26 | - uses: actions/checkout@v1 27 | - name: prepare 28 | run: | 29 | sudo dnf -y update 30 | sudo dnf -y install flex bison cmake which gcc clang clang-tools-extra lld git 31 | - uses: egorpugin/sw-action@master 32 | - run: ./sw -static build -compiler gcc 33 | - uses: actions/upload-artifact@v4 34 | with: 35 | name: sw-linux 36 | path: .sw/out 37 | 38 | macos: 39 | runs-on: macos-latest 40 | steps: 41 | - uses: actions/checkout@v1 42 | - uses: egorpugin/sw-action@master 43 | - name: install 44 | run: | 45 | brew update 46 | brew install flex bison gcc llvm 47 | - name: build 48 | run: | 49 | export PATH="/opt/homebrew/opt/bison/bin:$PATH" 50 | export PATH="/opt/homebrew/opt/flex/bin:$PATH" 51 | export PATH="/opt/homebrew/opt/llvm/bin:$PATH" 52 | export PATH="/opt/homebrew/opt/gcc/bin:$PATH" 53 | ./sw -static build -compiler appleclang 54 | - uses: actions/upload-artifact@v4 55 | with: 56 | name: sw-macos 57 | path: .sw/out 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # tex generated files 2 | *.log 3 | *.synctex.gz 4 | *.aux 5 | *.toc 6 | *.pdf 7 | *.blg 8 | *.tar*.* 9 | 10 | # build files and directories 11 | /build* 12 | /temp* 13 | /cmake-* 14 | CMakeL* 15 | bin* 16 | 17 | .build 18 | .cppan 19 | .sw 20 | .s 21 | 22 | .cache 23 | .idea 24 | .vscode 25 | 26 | *.bat 27 | *.sh 28 | *.sw 29 | 30 | *~ 31 | *.user 32 | 33 | *.sln 34 | *.aps 35 | *.exe 36 | *.dll 37 | *.lnk 38 | *.pdb 39 | 40 | *.diff 41 | *.patch 42 | 43 | ddl2cpp 44 | doc/build 45 | cppan-build* 46 | 47 | sw.config 48 | sw.creator 49 | sw.files 50 | sw.includes 51 | 52 | compile_commands.json 53 | 54 | *.lock* 55 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Different parts of SW project (this repository) are subject to different licences. 2 | 3 | core libraries: GPLv3+ (src/sw/[manager,builder,core]) 4 | client library and tools: AGPLv3+ (src/sw/client) 5 | server code: AGPLv3+ (src/sw/server) 6 | small libs: MPLv2 (src/sw/[protocol,support]) 7 | utilities, helpers: APLv2 8 | 9 | See specific files for detailed information about their license. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Software Network (SW)](https://software-network.org/) 2 | 3 | 4 | 5 | ![Build status](https://github.com/SoftwareNetwork/sw/workflows/sw/badge.svg) 6 | 7 | ## Resources 8 | 9 | - Homepage: https://software-network.org/ 10 | - Documentation: https://software-network.org/client/sw.pdf 11 | - Download: https://software-network.org/client/ 12 | - Issue tracking: https://github.com/SoftwareNetwork/sw/issues 13 | - Forum: https://groups.google.com/forum/#!forum/software-network 14 | 15 | ## Build 16 | 17 | ### Using SW (self build) 18 | 19 | 1. Download client from https://software-network.org/client/ 20 | 2. Unpack, add to PATH 21 | 3. Run 22 | ``` 23 | git clone https://github.com/SoftwareNetwork/sw 24 | cd sw 25 | sw build -static 26 | ``` 27 | 28 | (optional) Run `sw generate -static` to generate VS solution. 29 | 30 | (optional) Run `sw override org.sw` for smooth development. 31 | 32 | 35 | -------------------------------------------------------------------------------- /doc/comparison.md: -------------------------------------------------------------------------------- 1 | # Build System & Package Manager comparison 2 | 3 | ## General 4 | 5 | | Feature | sw | conan | vcpkg | build2 | cmake | b2 (boost) | meson | 6 | |---|---|---|---|---|---|---|---| 7 | | package manager | ![](https://img.shields.io/badge/yes-brightgreen.svg) | ![](https://img.shields.io/badge/yes-brightgreen.svg) | ![](https://img.shields.io/badge/yes-brightgreen.svg) | ![](https://img.shields.io/badge/yes-brightgreen.svg) |![](https://img.shields.io/badge/no-red.svg) |![](https://img.shields.io/badge/no-red.svg) | ![](https://img.shields.io/badge/yes-brightgreen.svg) | 8 | | build system | ![](https://img.shields.io/badge/yes-brightgreen.svg) | ![](https://img.shields.io/badge/no-red.svg) | ![](https://img.shields.io/badge/no-red.svg) | ![](https://img.shields.io/badge/yes-brightgreen.svg) |![](https://img.shields.io/badge/yes-brightgreen.svg) |![](https://img.shields.io/badge/yes-brightgreen.svg) | ![](https://img.shields.io/badge/yes-brightgreen.svg) | 9 | | multilang | ![](https://img.shields.io/badge/yes-brightgreen.svg) |![](https://img.shields.io/badge/yes-brightgreen.svg) |![](https://img.shields.io/badge/yes-brightgreen.svg) |![](https://img.shields.io/badge/yes-brightgreen.svg) |![](https://img.shields.io/badge/yes-brightgreen.svg) |![](https://img.shields.io/badge/no-red.svg) |![](https://img.shields.io/badge/yes-brightgreen.svg) | 10 | 11 | ## Compilers & OSes 12 | 13 | | Feature | 14 | |---| 15 | | | 16 | 17 | 18 | ## Native fetures (ASM/C/C++) 19 | 20 | | Feature | 21 | |---| 22 | | shared pchs | 23 | 24 | ## Other Languages 25 | -------------------------------------------------------------------------------- /doc/latex/docpackages.tex: -------------------------------------------------------------------------------- 1 | % !TEX root = sw.tex 2 | % !TeX spellcheck = en_US 3 | 4 | \usepackage{polyglossia} 5 | \usepackage{fontspec} 6 | %\usepackage[T1]{fontenc} 7 | \setmainlanguage{english} 8 | 9 | \usepackage{graphicx} 10 | \usepackage[final] 11 | {listings} % code listings 12 | \usepackage{longtable} % auto-breaking tables 13 | \usepackage{ltcaption} % fix captions for long tables 14 | \usepackage{relsize} % provide relative font size changes 15 | \usepackage{textcomp} % provide \text{l,r}angle 16 | \usepackage{underscore} % remove special status of '_' in ordinary text 17 | \usepackage{parskip} % handle non-indented paragraphs "properly" 18 | \usepackage{array} % new column definitions for tables 19 | \usepackage[normalem]{ulem} 20 | \usepackage{enumitem} 21 | \usepackage{color} % define colors for strikeouts and underlines 22 | \usepackage{amsmath} % additional math symbols 23 | \usepackage{mathrsfs} % mathscr font 24 | \usepackage[final]{microtype} 25 | \usepackage{multicol} 26 | \usepackage{lmodern} 27 | %\usepackage{listingsutf8} 28 | \usepackage{xcolor} 29 | \usepackage{xparse} 30 | \usepackage[most]{tcolorbox} 31 | 32 | \usepackage[unicode, 33 | pdftitle={Software Management}, 34 | pdfsubject={Software Management}, 35 | pdfcreator={Egor Pugin}, 36 | bookmarks=true, 37 | bookmarksnumbered=true, 38 | pdfpagelabels=true, 39 | pdfpagemode=UseOutlines, 40 | pdfstartview=FitH, 41 | linktocpage=true, 42 | colorlinks=true, 43 | linkcolor=blue, 44 | plainpages=false, 45 | pdfstartpage=2, 46 | ]{hyperref} 47 | 48 | \usepackage{expl3} 49 | \usepackage{xparse} 50 | -------------------------------------------------------------------------------- /doc/latex/front.tex: -------------------------------------------------------------------------------- 1 | % !TEX root = sw.tex 2 | % !TeX spellcheck = en_US 3 | 4 | %%-------------------------------------------------- 5 | %% Title page for the SW 6 | 7 | \pagestyle{empty} 8 | 9 | \vspace*{2.5cm} 10 | 11 | \begin{center} 12 | \textbf{\Huge 13 | Software Management} 14 | 15 | \vspace{2cm} 16 | 17 | Egor Pugin 18 | 19 | \end{center} 20 | 21 | \vspace{14cm} 22 | 23 | 24 | 25 | 26 | \begin{center} 27 | \today 28 | \end{center} 29 | 30 | \vfill 31 | 32 | 33 | \textbf{Note: this is an early draft. It's known to be outdated, incomplet and 34 | incorrekt, and it has lots of 35 | b\kern-1.2pta\kern1ptd\hspace{1.5em}for\kern-3ptmat\kern0.6ptti\raise0.15ex\hbox{n}g.} 36 | 37 | Please, report any issues to author. 38 | Contributions are welcome. 39 | 40 | \vspace{1em} 41 | 42 | \begin{tabular}{ll} 43 | Homepage & 44 | \url{https://software-network.org/} 45 | \\ 46 | Git Repository (client tool) & 47 | \url{https://github.com/SoftwareNetwork/sw} 48 | \\ 49 | The latest version of this document & 50 | \url{https://software-network.org/client/sw.pdf} 51 | \end{tabular} 52 | 53 | \newpage 54 | -------------------------------------------------------------------------------- /doc/latex/macros.tex: -------------------------------------------------------------------------------- 1 | % !TEX root = sw.tex 2 | % !TeX spellcheck = en_US 3 | 4 | \tcbset{common/.style={before upper = {\topskip0pt \maxdepth=0pt}, 5 | enhanced, 6 | listing only, 7 | breakable = unlimited, 8 | top = 0em, 9 | bottom = 0em, 10 | left = 0pt, 11 | right = 0pt, 12 | arc = 0em, 13 | outer arc = 0em, 14 | boxsep = 0em, 15 | boxrule = 1pt, 16 | titlerule = 0em, 17 | colback = white, 18 | size = fbox, 19 | } 20 | } 21 | 22 | \newtcblisting{command}[1][]{common, 23 | title=Shell, 24 | listing only, 25 | listing options={ 26 | basicstyle=\ttfamily\scriptsize, 27 | tabsize=2, 28 | inputencoding=utf8 29 | }, 30 | #1 31 | } 32 | 33 | \newtcblisting{cmake}[1][]{common, 34 | title=CMake, 35 | listing only, 36 | listing options={ 37 | basicstyle=\ttfamily\scriptsize, 38 | tabsize=2, 39 | inputencoding=utf8 40 | }, 41 | #1 42 | } 43 | 44 | \newtcblisting{swcpp}[1][]{common, 45 | title=sw.cpp, 46 | listing only, 47 | listing options={ 48 | basicstyle=\ttfamily\scriptsize, 49 | tabsize=2, 50 | inputencoding=utf8 51 | }, 52 | #1 53 | } 54 | 55 | \newtcblisting{cppan}[1][]{common, 56 | title=cppan.yml, 57 | listing only, 58 | listing options={ 59 | basicstyle=\ttfamily\scriptsize, 60 | tabsize=2, 61 | inputencoding=utf8 62 | }, 63 | #1 64 | } 65 | -------------------------------------------------------------------------------- /doc/latex/sm.tex: -------------------------------------------------------------------------------- 1 | % !TEX root = sw.tex 2 | % !TeX spellcheck = en_US 3 | 4 | 5 | \chapter{Software Management} 6 | 7 | \section{Features} 8 | 9 | Goals: 10 | 11 | \begin{enumerate} 12 | \item 13 | Reliability. 14 | \item 15 | Correctness. 16 | \item 17 | Repeatability. 18 | \item 19 | Robustness. 20 | \item 21 | Scalability. 22 | \item 23 | Performance. This one is mostly provided by language of implementation (C++). 24 | \end{enumerate} 25 | 26 | Features: 27 | 28 | \begin{enumerate} 29 | \item 30 | Build System is integrated with Package Manager in one program. This allows us to have more information on both ends. User does not need any external tools except sw itself. 31 | \item 32 | Describe your builds directly in C++(17). 33 | \item 34 | Different frontends. Do not like C++? Write you build configuration in declarative YAML, JSON, Python, LUA and even on good old CMake etc. Currently only basic YAML frontend is implemented. Contributions are welcome. 35 | SW itself is written in modern C++ (C++17). 36 | \item 37 | Easy crosscompilation. 38 | \item 39 | Generators for different IDEs (WIP, contributions are welcome). 40 | \item 41 | Integrations with other tools (CMake etc.). 42 | \end{enumerate} 43 | 44 | 45 | 46 | 47 | 48 | 49 | \section{Package Id} 50 | 51 | \subsection{Path} 52 | 53 | \subsection{Version} 54 | 55 | 56 | \section{Drivers} 57 | 58 | \section{Frontends} 59 | 60 | Main frontend - C++. 61 | 62 | Second frontend - CPPAN (v1) YAML-based frontend. 63 | 64 | 65 | \section{Security} 66 | 67 | SW security is based on GPG digital signatures. 68 | 69 | TBD 70 | 71 | 72 | -------------------------------------------------------------------------------- /doc/latex/styles.tex: -------------------------------------------------------------------------------- 1 | % !TEX root = sw.tex 2 | %% styles.tex -- set styles for: 3 | % chapters 4 | % pages 5 | % footnotes 6 | 7 | %%-------------------------------------------------- 8 | %% set section numbering limit, toc limit 9 | \maxsecnumdepth{subparagraph} 10 | \setcounter{tocdepth}{5} 11 | -------------------------------------------------------------------------------- /doc/latex/sw.tex: -------------------------------------------------------------------------------- 1 | % !TeX spellcheck = en_US 2 | 3 | %% main file for the SW and Software Management documentation 4 | %% 5 | 6 | %%-------------------------------------------------- 7 | %% basics 8 | \documentclass[a4paper,10pt,oneside,openany,final]{memoir} 9 | 10 | \input{docpackages.tex} 11 | \input{layout.tex} 12 | \input{styles.tex} 13 | \input{macros.tex} 14 | 15 | %%-------------------------------------------------- 16 | \begin{document} 17 | 18 | \input{front.tex} 19 | \tableofcontents 20 | 21 | \input{intro.tex} 22 | \input{sm.tex} 23 | \input{client.tex} 24 | \input{server.tex} 25 | 26 | \end{document} 27 | -------------------------------------------------------------------------------- /doc/readme.md: -------------------------------------------------------------------------------- 1 | # [Software Network (SW)](https://software-network.org/) Documentation 2 | 3 | ## Quick Start 4 | 5 | 1. Download the latest client application, unpack and put it to PATH. 6 | 1. (optional) Run once `sw setup` from any directory to perform extended configuration. Requires administartor rights. 7 | 1. Create project config or build script named `sw.cpp`. 8 | 9 | Report if anything goes wrong with this workflow! 10 | 11 | ## Recommended and tested setups 12 | 13 | ### Windows 14 | 15 | Make sure you are running the latest Visual Studio (2022). 16 | 17 | 1. VS2022. 18 | 19 | ### *nix 20 | 21 | Both of clang/gcc works fine. 22 | 23 | ## More links 24 | 25 | Find more info on [SW Wiki](https://github.com/SoftwareNetwork/sw/wiki) 26 | -------------------------------------------------------------------------------- /doc/support.md: -------------------------------------------------------------------------------- 1 | # Support Software Network 2 | 3 | Currently SW server exists on my own funds almost for three years already and development goes only in my spare time. 4 | 5 | Feel free to support the project and its development if you like it. 6 | 7 | 16 | 17 | 20 | -------------------------------------------------------------------------------- /src/sw/builder/builder.natvis: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {name} 7 | 8 | 9 | 10 | 11 | 12 | {file} 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/sw/builder/concurrent_map.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SoftwareNetwork/sw/d156861fce5ae5d1a8bb4af59d25426b1995b5b9/src/sw/builder/concurrent_map.cpp -------------------------------------------------------------------------------- /src/sw/builder/file_storage.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SW - Build System and Package Manager 3 | * Copyright (C) 2017-2020 Egor Pugin 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "file_storage.h" 20 | 21 | #include "file.h" 22 | #include "sw_context.h" 23 | 24 | #include 25 | DECLARE_STATIC_LOGGER(logger, "file_storage"); 26 | 27 | namespace sw 28 | { 29 | 30 | void FileStorage::clear() 31 | { 32 | files.clear(); 33 | } 34 | 35 | void FileStorage::reset() 36 | { 37 | for (const auto &[k, f] : files) 38 | f.reset(); 39 | } 40 | 41 | FileData &FileStorage::registerFile(const path &in_f) 42 | { 43 | auto p = normalize_path(in_f); 44 | auto d = files.insert(p); 45 | if (d.second) 46 | d.first->refresh(in_f); 47 | return *d.first; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/sw/builder/file_storage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SW - Build System and Package Manager 3 | * Copyright (C) 2017-2020 Egor Pugin 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "concurrent_map.h" 22 | 23 | #include 24 | 25 | namespace sw 26 | { 27 | 28 | struct FileData; 29 | struct SwBuilderContext; 30 | 31 | struct SW_BUILDER_API FileStorage 32 | { 33 | using FileDataHashMap = ConcurrentHashMap; 34 | 35 | FileDataHashMap files; 36 | 37 | void clear(); // remove? 38 | void reset(); // remove? 39 | 40 | FileData ®isterFile(const path &f); 41 | }; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/sw/builder/inserts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SW - Build System and Package Manager 3 | * Copyright (C) 2017-2020 Egor Pugin 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | #define DECLARE_TEXT_VAR(x) extern const std::string x 22 | 23 | DECLARE_TEXT_VAR(cppan_cpp); 24 | DECLARE_TEXT_VAR(sql_db_local); 25 | 26 | #undef DECLARE_TEXT_VAR 27 | -------------------------------------------------------------------------------- /src/sw/builder/jumppad.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SW - Build System and Package Manager 3 | * Copyright (C) 2017-2020 Egor Pugin 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "jumppad.h" 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | namespace sw 27 | { 28 | 29 | int jumppad_call(const path &module, const String &name, int version, const Strings &s) 30 | { 31 | auto n = STRINGIFY(SW_JUMPPAD_PREFIX) + name; 32 | boost::dll::shared_library lib(module.u8string(), 33 | boost::dll::load_mode::rtld_now | boost::dll::load_mode::rtld_global); 34 | return lib.get(n.c_str())(s); 35 | } 36 | 37 | int jumppad_call(const Strings &s) 38 | { 39 | int i = 3; 40 | if (s.size() < i++) 41 | throw SW_RUNTIME_ERROR("No module name was provided"); 42 | if (s.size() < i++) 43 | throw SW_RUNTIME_ERROR("No function name was provided"); 44 | if (s.size() < i++) 45 | throw SW_RUNTIME_ERROR("No function version was provided"); 46 | // converting version to int is doubtful, but might help in removing leading zeroes (0002) 47 | return jumppad_call(s[2], s[3], std::stoi(s[4]), Strings{s.begin() + 5, s.end()}); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/sw/builder/node.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SW - Build System and Package Manager 3 | * Copyright (C) 2017-2020 Egor Pugin 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "node.h" 20 | 21 | #include 22 | 23 | namespace sw 24 | { 25 | 26 | ICastable::~ICastable() 27 | { 28 | } 29 | 30 | void detail::Executable::execute() const 31 | { 32 | if (auto c = getCommand()) 33 | return c->execute(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/sw/builder/program.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SW - Build System and Package Manager 3 | * Copyright (C) 2017-2020 Egor Pugin 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "program.h" 20 | 21 | #include "command.h" 22 | #include "file_storage.h" 23 | #include "sw_context.h" 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | namespace sw 34 | { 35 | 36 | Program::Program() 37 | { 38 | } 39 | 40 | Program::Program(const Program &rhs) 41 | : file(rhs.file) 42 | { 43 | } 44 | 45 | Program &Program::operator=(const Program &rhs) 46 | { 47 | file = rhs.file; 48 | return *this; 49 | } 50 | 51 | Program &PredefinedProgram::getProgram() 52 | { 53 | if (!program) 54 | throw SW_RUNTIME_ERROR("Program was not set"); 55 | return *program; 56 | } 57 | 58 | const Program &PredefinedProgram::getProgram() const 59 | { 60 | if (!program) 61 | throw SW_RUNTIME_ERROR("Program was not set"); 62 | return *program; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/sw/builder/sw_context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SW - Build System and Package Manager 3 | * Copyright (C) 2017-2020 Egor Pugin 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "concurrent_map.h" 22 | #include "os.h" 23 | 24 | #include 25 | 26 | struct Executor; 27 | 28 | namespace sw 29 | { 30 | 31 | struct CommandStorage; 32 | struct FileStorage; 33 | 34 | namespace builder::detail { struct ResolvableCommand; } 35 | 36 | struct SW_BUILDER_API SwBuilderContext 37 | { 38 | SwBuilderContext(); 39 | ~SwBuilderContext(); 40 | 41 | FileStorage &getFileStorage() const; 42 | Executor &getFileStorageExecutor() const; 43 | CommandStorage &getCommandStorage(const path &root) const; 44 | 45 | void clearFileStorages(); 46 | void clearCommandStorages(); 47 | 48 | private: 49 | // keep order 50 | mutable std::unordered_map> command_storages; 51 | mutable std::unique_ptr file_storage; 52 | std::unique_ptr file_storage_executor; // after everything! 53 | 54 | mutable std::mutex csm; 55 | }; 56 | 57 | } // namespace sw 58 | -------------------------------------------------------------------------------- /src/sw/builder_distributed/server.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #include "server.h" 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | DECLARE_STATIC_LOGGER(logger, "builder.distributed.server"); 13 | 14 | // move this just into builder itself? 15 | 16 | namespace sw::builder::distributed 17 | { 18 | 19 | DEFINE_SERVICE_METHOD(DistributedBuildService, ExecuteCommand, ::sw::api::build::Command, ::sw::api::build::CommandResult) 20 | { 21 | // fan mode: send to workers in round robin mode 22 | 23 | Command c; 24 | c.in.file = fs::u8path(request->in().file()); 25 | c.in.file = fs::u8path(request->in().file()); 26 | c.in.file = fs::u8path(request->in().file()); 27 | 28 | c.execute(); 29 | 30 | GRPC_RETURN_OK(); 31 | } 32 | 33 | Server::Server() 34 | { 35 | } 36 | 37 | Server::~Server() 38 | { 39 | } 40 | 41 | void Server::start(const String &server_address/*, const String &cert*/) 42 | { 43 | grpc::SslServerCredentialsOptions ssl_options; 44 | //if (!cert.empty()) 45 | //ssl_options.pem_key_cert_pairs.push_back({ read_file("server.key"), read_file("server.crt") }); 46 | 47 | grpc::ServerBuilder builder; 48 | //if (sw::settings().grpc_use_ssl) 49 | //builder.AddListeningPort(server_address, grpc::SslServerCredentials(ssl_options)); 50 | //else 51 | builder.AddListeningPort(server_address, grpc::InsecureServerCredentials()); 52 | 53 | builder.RegisterService(&dbs); 54 | server = builder.BuildAndStart(); 55 | if (!server) 56 | throw SW_RUNTIME_ERROR("Cannot start grpc server"); 57 | } 58 | 59 | void Server::wait() 60 | { 61 | if (!server) 62 | throw SW_RUNTIME_ERROR("Server not started"); 63 | server->Wait(); 64 | } 65 | 66 | void Server::stop() 67 | { 68 | if (!server) 69 | throw SW_RUNTIME_ERROR("Server not started"); 70 | server->Shutdown(); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/sw/builder_distributed/server.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | namespace sw::builder::distributed 16 | { 17 | 18 | class DistributedBuildServiceImpl : public ::sw::api::build::DistributedBuildService::Service 19 | { 20 | DECLARE_SERVICE_METHOD(ExecuteCommand, ::sw::api::build::Command, ::sw::api::build::CommandResult); 21 | }; 22 | 23 | struct SW_BUILDER_DISTRIBUTED_API Client 24 | { 25 | 26 | }; 27 | 28 | struct SW_BUILDER_DISTRIBUTED_API Session 29 | { 30 | std::unique_ptr client; 31 | }; 32 | 33 | struct SW_BUILDER_DISTRIBUTED_API Worker 34 | { 35 | 36 | }; 37 | 38 | struct SW_BUILDER_DISTRIBUTED_API Server 39 | { 40 | std::unique_ptr server; 41 | DistributedBuildServiceImpl dbs; 42 | std::vector> sessions; 43 | std::vector> workers; 44 | 45 | Server(); 46 | ~Server(); 47 | 48 | void start(const String &endpoint/*, const String &cert = {}*/); 49 | void wait(); 50 | void stop(); 51 | }; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/sw/client/cli/client.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SoftwareNetwork/sw/d156861fce5ae5d1a8bb4af59d25426b1995b5b9/src/sw/client/cli/client.ico -------------------------------------------------------------------------------- /src/sw/client/cli/client.manifest: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/sw/client/cli/resource.rc: -------------------------------------------------------------------------------- 1 | MAINICON ICON "client.ico" 2 | -------------------------------------------------------------------------------- /src/sw/client/common/command/configure.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2017-2019 Egor Pugin 3 | 4 | #include "../commands.h" 5 | 6 | SUBCOMMAND_DECL(configure) 7 | { 8 | auto b = createBuildAndPrepare({ getOptions().options_configure.build_arg_configure }); 9 | b->saveExecutionPlan(); 10 | } 11 | -------------------------------------------------------------------------------- /src/sw/client/common/command/doc.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #include "../commands.h" 5 | 6 | #ifdef _WIN32 7 | #include 8 | #include 9 | #include 10 | #include 11 | #endif 12 | 13 | #include 14 | DECLARE_STATIC_LOGGER(logger, "command.doc"); 15 | 16 | void open_url(const String &); 17 | 18 | SUBCOMMAND_DECL(doc) 19 | { 20 | open_url(SW_DOC_URL); 21 | } 22 | -------------------------------------------------------------------------------- /src/sw/client/common/command/get.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #include "../commands.h" 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | DECLARE_STATIC_LOGGER(logger, "get"); 11 | 12 | SUBCOMMAND_DECL(get) 13 | { 14 | auto &args = getOptions().options_get.args; 15 | if (args.empty()) 16 | throw SW_RUNTIME_ERROR("Empty args"); 17 | if (args.at(0) == "storage-dir") 18 | { 19 | LOG_INFO(logger, to_printable_string(getContext(false).getLocalStorage().storage_dir)); 20 | return; 21 | } 22 | throw SW_RUNTIME_ERROR("Unknown command"); 23 | } 24 | -------------------------------------------------------------------------------- /src/sw/client/common/command/install.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2017-2019 Egor Pugin 3 | 4 | #include "../commands.h" 5 | 6 | #include 7 | 8 | SUBCOMMAND_DECL(install) 9 | { 10 | sw::UnresolvedPackages pkgs; 11 | getOptions().options_install.install_args.push_back(getOptions().options_install.install_arg); 12 | for (auto &p : getOptions().options_install.install_args) 13 | pkgs.insert(sw::extractFromString(p)); 14 | auto m = getContext().install(pkgs); 15 | for (auto &[p1, d] : m) 16 | { 17 | //for (auto &p2 : install_args) 18 | //if (p1 == p2) 19 | //d.installed = true; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/sw/client/common/command/mirror.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #include "../commands.h" 5 | 6 | SUBCOMMAND_DECL(mirror) 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /src/sw/client/common/command/path.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #include "../commands.h" 5 | 6 | #include 7 | DECLARE_STATIC_LOGGER(logger, "command.path"); 8 | 9 | SUBCOMMAND_DECL(path) 10 | { 11 | auto m = getContext(false).install(sw::UnresolvedPackages{getOptions().options_path.path_arg}); 12 | auto i = m.find(getOptions().options_path.path_arg); 13 | if (i == m.end()) 14 | return; 15 | auto &p = i->second; 16 | 17 | if (getOptions().options_path.type == "sdir") 18 | { 19 | LOG_INFO(logger, to_string(normalize_path(p.getDirSrc2()))); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/sw/client/common/command/remove.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2017-2019 Egor Pugin 3 | 4 | #include "../commands.h" 5 | 6 | #include 7 | 8 | #include 9 | DECLARE_STATIC_LOGGER(logger, "remove"); 10 | 11 | static sw::PackageIdSet getMatchingPackagesSet(const sw::StorageWithPackagesDatabase &s, const String &unresolved_pkg) 12 | { 13 | sw::PackageIdSet p; 14 | for (auto &[ppath, versions] : getMatchingPackages(s, unresolved_pkg)) 15 | { 16 | for (auto &v : versions) 17 | p.emplace(ppath, v); 18 | } 19 | return p; 20 | } 21 | 22 | SUBCOMMAND_DECL(remove) 23 | { 24 | for (auto &a : getOptions().options_remove.remove_arg) 25 | { 26 | for (auto &p : getMatchingPackagesSet(getContext().getLocalStorage(), a)) 27 | { 28 | LOG_INFO(logger, "Removing " << p.toString()); 29 | getContext().getLocalStorage().remove(sw::LocalPackage(getContext().getLocalStorage(), p)); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/sw/client/common/command/server.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #include "../commands.h" 5 | 6 | #include 7 | 8 | SUBCOMMAND_DECL(server) 9 | { 10 | if (getOptions().options_server.distributed_builder) 11 | { 12 | sw::builder::distributed::Server s; 13 | s.start(getOptions().options_server.endpoint); 14 | s.wait(); 15 | // TODO: handle interrupts properly 16 | s.stop(); 17 | return; 18 | } 19 | 20 | SW_UNIMPLEMENTED; 21 | } 22 | -------------------------------------------------------------------------------- /src/sw/client/common/command/test.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2017-2019 Egor Pugin 3 | 4 | #include "../commands.h" 5 | 6 | SUBCOMMAND_DECL(test) 7 | { 8 | auto b = createBuildAndPrepare(getInputs()); 9 | b->test(); 10 | } 11 | -------------------------------------------------------------------------------- /src/sw/client/common/command/update.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2017-2019 Egor Pugin 3 | 4 | #include "../commands.h" 5 | 6 | SUBCOMMAND_DECL(update) 7 | { 8 | // see https://doc.rust-lang.org/cargo/commands/cargo-update.html 9 | auto b = createBuild(getOptions().options_update.build_arg_update); 10 | auto bs = b->getSettings(); 11 | if (!getOptions().options_update.packages.empty()) 12 | { 13 | for (auto &p : getOptions().options_update.packages) 14 | bs["update_lock_file_packages"][p]; 15 | } 16 | else 17 | bs["update_lock_file"] = "true"; // update all 18 | b->setSettings(bs); 19 | b->loadInputs(); 20 | b->setTargetsToBuild(); 21 | b->resolvePackages(); 22 | } 23 | -------------------------------------------------------------------------------- /src/sw/client/common/commands.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2017-2019 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "sw_context.h" 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #define SW_DOC_URL "https://software-network.org/client/sw.pdf" 15 | 16 | namespace sw 17 | { 18 | struct StorageWithPackagesDatabase; 19 | } 20 | 21 | #include 22 | 23 | #define SUBCOMMAND_DECL(n) void SwClientContext::command_##n() 24 | 25 | sw::PackageDescriptionMap getPackages(const sw::SwBuild &, const sw::support::SourceDirMap & = {}, std::map> * = nullptr); 26 | std::map getMatchingPackages(const sw::StorageWithPackagesDatabase &, const String &unresolved_arg); 27 | 28 | // create command 29 | struct ProjectTemplate 30 | { 31 | String name; 32 | String desc; 33 | String target; 34 | FilesMap config; 35 | FilesMap files; 36 | FilesMap other_files; 37 | StringSet dependencies; 38 | }; 39 | 40 | struct ProjectTemplates 41 | { 42 | std::map templates; 43 | std::map files; 44 | }; 45 | 46 | SW_CLIENT_COMMON_API 47 | const ProjectTemplates &getProjectTemplates(); 48 | -------------------------------------------------------------------------------- /src/sw/client/common/commands.inl: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2017-2019 Egor Pugin 3 | 4 | #ifndef COMMA 5 | #define COMMA 6 | #define SW_COMMA_SELF 7 | #endif 8 | 9 | /* 10 | commands are: 11 | 12 | test file/dir profile - test something. profile - test actions, default - test 13 | profiles: all, bench, test, ..., doc? ... 14 | 15 | run file/dir/pkg - run the selected program or an executable package directly, 16 | run knows how to run pkg (e.g. if we run python package it will select py interpreter with correct version) 17 | 18 | update - update packages db 19 | upgrade - upgrade installed pkgs 20 | self-upgrade - upgrade the client. implement via upgrade? 21 | */ 22 | 23 | SUBCOMMAND(abi) COMMA // rename? move to --option? 24 | SUBCOMMAND(alias) COMMA 25 | SUBCOMMAND(build) COMMA 26 | //SUBCOMMAND(b) COMMA // alias for build 27 | SUBCOMMAND(configure) COMMA 28 | SUBCOMMAND(create) COMMA 29 | SUBCOMMAND(doc) COMMA // invokes documentation (hopefully) 30 | SUBCOMMAND(generate) COMMA 31 | // rename to query? 32 | SUBCOMMAND(get) COMMA // returns different information 33 | SUBCOMMAND(fetch) COMMA 34 | SUBCOMMAND(install) COMMA 35 | //SUBCOMMAND(i) COMMA // alias for install 36 | SUBCOMMAND(integrate) COMMA 37 | SUBCOMMAND(list) COMMA 38 | SUBCOMMAND(open) COMMA 39 | SUBCOMMAND(override) COMMA 40 | SUBCOMMAND(mirror) COMMA 41 | SUBCOMMAND(pack) COMMA 42 | SUBCOMMAND(path) COMMA 43 | SUBCOMMAND(remote) COMMA 44 | SUBCOMMAND(remove) COMMA 45 | SUBCOMMAND(run) COMMA 46 | SUBCOMMAND(server) COMMA 47 | SUBCOMMAND(service) COMMA // some service commands 48 | SUBCOMMAND(setup) COMMA 49 | SUBCOMMAND(test) COMMA 50 | SUBCOMMAND(update) COMMA // update lock file? 51 | SUBCOMMAND(upload) COMMA 52 | SUBCOMMAND(verify) COMMA 53 | SUBCOMMAND(uri) COMMA 54 | 55 | #ifdef SW_COMMA_SELF 56 | #undef COMMA 57 | #undef SW_COMMA_SELF 58 | #endif 59 | -------------------------------------------------------------------------------- /src/sw/client/common/generator/generator.inl: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | 3 | #ifndef GENERATOR2 4 | #define GENERATOR2(x) GENERATOR(x, #x) 5 | #define GENERATOR2_DEFINED 6 | #endif 7 | 8 | // everything 9 | GENERATOR2(Batch) 10 | GENERATOR2(CMake) 11 | GENERATOR(CompilationDatabase, "Compilation Database") 12 | GENERATOR(FastBuild, "Fast Build") 13 | GENERATOR2(Make) 14 | GENERATOR2(NMake) 15 | GENERATOR2(Ninja) 16 | GENERATOR(RawBootstrapBuild, "Raw Bootstrap Build") 17 | GENERATOR2(QMake) 18 | GENERATOR2(Shell) 19 | // sw 20 | GENERATOR(SwExecutionPlan, "Sw Execution Plan") 21 | GENERATOR(SwBuildDescription, "Sw Build Description") 22 | // IDE 23 | GENERATOR(CodeBlocks, "Code Blocks") 24 | GENERATOR(VisualStudio, "Visual Studio") 25 | GENERATOR2(Xcode) 26 | // qt creator? 27 | 28 | #ifdef GENERATOR2_DEFINED 29 | #undef GENERATOR2 30 | #undef GENERATOR2_DEFINED 31 | #endif 32 | -------------------------------------------------------------------------------- /src/sw/client/common/generator/vs/solution_emitter.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2017-2019 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | 10 | struct Directory; 11 | struct Project; 12 | struct Solution; 13 | 14 | // https://docs.microsoft.com/en-us/visualstudio/extensibility/internals/solution-dot-sln-file?view=vs-2019 15 | struct SolutionEmitter : primitives::Emitter 16 | { 17 | sw::Version version; 18 | 19 | SolutionEmitter(); 20 | 21 | void printVersion(); 22 | 23 | void addDirectory(const Directory &); 24 | 25 | void beginProject(const Project &); 26 | void endProject(); 27 | 28 | void beginBlock(const String &s); 29 | void endBlock(const String &s); 30 | 31 | void beginGlobalSection(const String &name, const String &post); 32 | void endGlobalSection(); 33 | 34 | void beginGlobal(); 35 | void endGlobal(); 36 | 37 | void setSolutionConfigurationPlatforms(const Solution &); 38 | void addProjectConfigurationPlatforms(const Project &, bool build); 39 | 40 | void addKeyValue(const String &k, const String &v); 41 | 42 | void beginProjectSection(const String &n, const String &disposition); 43 | void endProjectSection(); 44 | }; 45 | 46 | static const path vs_project_dir = "projects"; 47 | static const String vs_project_ext = ".vcxproj"; 48 | -------------------------------------------------------------------------------- /src/sw/client/common/inserts.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2017-2019 Egor Pugin 3 | 4 | #include 5 | 6 | extern const std::string sw_config_cmake; 7 | extern const std::string project_templates; 8 | -------------------------------------------------------------------------------- /src/sw/client/common/inserts/inserts.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2017-2019 Egor Pugin 3 | 4 | #include "../inserts.h" 5 | 6 | #include 7 | 8 | #define DECLARE_TEXT_VAR_BEGIN(x) const uint8_t _##x[] = { 9 | #define DECLARE_TEXT_VAR_END(x) }; const std::string x = (const char *)&_##x[0]; 10 | 11 | DECLARE_TEXT_VAR_BEGIN(sw_config_cmake) 12 | #include 13 | DECLARE_TEXT_VAR_END(sw_config_cmake); 14 | 15 | DECLARE_TEXT_VAR_BEGIN(project_templates) 16 | #include 17 | DECLARE_TEXT_VAR_END(project_templates); 18 | 19 | #undef DECLARE_TEXT_VAR_BEGIN 20 | #undef DECLARE_TEXT_VAR_END 21 | -------------------------------------------------------------------------------- /src/sw/client/common/main.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | struct Options; 13 | struct ClOptions; 14 | 15 | struct SW_CLIENT_COMMON_API StartupData 16 | { 17 | using UserFunction = std::function; 18 | 19 | int argc; 20 | char **argv; 21 | 22 | String program_short_name; // used in updater 23 | String overview; 24 | Strings args; 25 | Strings args_expanded; 26 | String version; 27 | std::unique_ptr cloptions; 28 | std::unique_ptr options; 29 | std::optional exit_code; 30 | 31 | UserFunction after_create_options; 32 | UserFunction after_setup; 33 | 34 | StartupData(int argc, char **argv); 35 | ~StartupData(); 36 | 37 | // meta call 38 | int run(); 39 | 40 | // call in this order 41 | void prepareArgs(); 42 | void parseArgs(); 43 | void createOptions(); 44 | void setup(); 45 | void sw_main(); 46 | 47 | Options &getOptions(); 48 | ClOptions &getClOptions(); 49 | 50 | private: 51 | int exit(int); 52 | int builtinCall(); 53 | void initLogger(); 54 | void setWorkingDir(); 55 | void setHttpSettings(); 56 | }; 57 | -------------------------------------------------------------------------------- /src/sw/client/common/self_upgrade.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2017-2019 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | SW_CLIENT_COMMON_API 9 | void self_upgrade(const String &progname); 10 | 11 | void self_upgrade_copy(const path &dst); 12 | -------------------------------------------------------------------------------- /src/sw/client/common/sig.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #include 5 | 6 | //void ds_sign_file(const path &fn, const path &pkey_fn); 7 | //void ds_verify_file(const path &fn, const path &sigfn, const String &pubkey); 8 | //void ds_verify_file(const path &fn, const path &sigfn, const path &pubkey_fn); 9 | void ds_verify_sw_file(const path &fn, const String &algo, const String &sig); 10 | -------------------------------------------------------------------------------- /src/sw/client/gui/client.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SoftwareNetwork/sw/d156861fce5ae5d1a8bb4af59d25426b1995b5b9/src/sw/client/gui/client.ico -------------------------------------------------------------------------------- /src/sw/client/gui/client.manifest: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/sw/client/gui/main.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2019-2020 Egor Pugin 3 | 4 | #include "mainwindow.h" 5 | 6 | #include 7 | #include "sw_context.h" 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | #include 19 | 20 | #ifdef WIN32 21 | #include 22 | #endif 23 | 24 | void win32_hacks(); 25 | 26 | int main(int argc, char *argv[]) 27 | { 28 | // cli mode 29 | if (argc > 1) 30 | { 31 | StartupData sd(argc, argv); 32 | sd.program_short_name = SHORT_PROGRAM_NAME; 33 | return sd.run(); 34 | } 35 | 36 | win32_hacks(); 37 | srand(time(0)); 38 | 39 | QThread t(0); 40 | QApplication a(argc, argv); 41 | 42 | #ifdef _WIN32 43 | auto hIcon = (HICON)LoadImage(GetModuleHandle(nullptr), MAKEINTRESOURCE(100), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADTRANSPARENT); 44 | if (hIcon) { 45 | auto i = QImage::fromHICON(hIcon); 46 | auto pix = QPixmap::fromImage(i); 47 | QApplication::setWindowIcon(pix); 48 | } 49 | ::DestroyIcon(hIcon); 50 | #endif 51 | 52 | try 53 | { 54 | ClOptions cloptions; 55 | Options options(cloptions); 56 | SwGuiContext swctx(options); 57 | MainWindow w(swctx); 58 | w.show(); 59 | return a.exec(); 60 | } 61 | catch (std::exception &e) 62 | { 63 | QMessageBox::critical(0, "Error", e.what(), "Ok"); 64 | } 65 | catch (...) 66 | { 67 | QMessageBox::critical(0, "Error", "Unknown error.", "Ok"); 68 | } 69 | return 1; 70 | } 71 | 72 | void win32_hacks() 73 | { 74 | #ifdef WIN32 75 | //SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); 76 | #endif 77 | } 78 | 79 | EXPORT_FROM_EXECUTABLE 80 | std::string getProgramName() 81 | { 82 | return PACKAGE_NAME_CLEAN; 83 | } 84 | -------------------------------------------------------------------------------- /src/sw/client/gui/mainwindow.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2019-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #define SHORT_PROGRAM_NAME "swgui" 10 | 11 | struct SwGuiContext; 12 | namespace sw { struct PackagesDatabase; } 13 | 14 | class MainWindow : public QMainWindow 15 | { 16 | Q_OBJECT 17 | public: 18 | MainWindow(SwGuiContext &swctx, QWidget *parent = 0); 19 | 20 | private: 21 | SwGuiContext &swctx; 22 | sw::PackagesDatabase *remote_db = nullptr; 23 | 24 | void setupUi(); 25 | 26 | void setupGeneral(QWidget *parent); 27 | void setupConfiguration(QWidget *parent); 28 | 29 | void createMenus(); 30 | }; 31 | -------------------------------------------------------------------------------- /src/sw/client/gui/packages_model.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2019-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class PackagesModel : public QAbstractItemModel 12 | { 13 | Q_OBJECT 14 | public: 15 | bool single_column_mode = true; 16 | int limit = 0; 17 | 18 | PackagesModel(sw::PackagesDatabase &, bool lazy = false); 19 | 20 | void init(); 21 | void setFilter(const QString & = {}); 22 | 23 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; 24 | QModelIndex parent(const QModelIndex &index) const override; 25 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; 26 | int columnCount(const QModelIndex &parent = QModelIndex()) const override; 27 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 28 | 29 | private: 30 | sw::PackagesDatabase &s; 31 | std::vector pkgs; 32 | }; 33 | 34 | class PackagesLineEdit : public QLineEdit 35 | { 36 | Q_OBJECT 37 | public: 38 | PackagesLineEdit(PackagesModel *completion_model, QWidget *parent = nullptr); 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /src/sw/client/gui/resource.rc: -------------------------------------------------------------------------------- 1 | 100 ICON "client.ico" 2 | -------------------------------------------------------------------------------- /src/sw/client/gui/settingswindow.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2019-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | struct ValueFlusherBase 12 | { 13 | using OnChange = std::function; 14 | 15 | virtual ~ValueFlusherBase() {} 16 | 17 | virtual void flush() const = 0; 18 | }; 19 | 20 | template 21 | struct ValueFlusher : ValueFlusherBase 22 | { 23 | T &var; 24 | T temp_var; 25 | OnChange on_change; 26 | 27 | ValueFlusher(T &in, OnChange f = {}) : var(in), temp_var(in), on_change(f) {} 28 | void flush() const override { var = temp_var; } 29 | void set(const T &in) 30 | { 31 | if (temp_var == in) 32 | return; 33 | temp_var = in; 34 | if (on_change) 35 | on_change(); 36 | } 37 | }; 38 | 39 | struct SwGuiContext; 40 | 41 | class SettingsWindow : public QMainWindow 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | SettingsWindow(SwGuiContext &swctx, QWidget *parent = 0); 47 | 48 | private: 49 | SwGuiContext &swctx; 50 | std::vector> settings; 51 | 52 | void save(); 53 | }; 54 | -------------------------------------------------------------------------------- /src/sw/client/gui/sw_context.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2019-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | struct SwGuiContext : SwClientContext 10 | { 11 | using Base = SwClientContext; 12 | 13 | SwGuiContext(const Options &options); 14 | 15 | void command_build() override; 16 | void command_create() override; 17 | void command_generate() override; 18 | void command_open() override; 19 | void command_test() override; 20 | 21 | private: 22 | bool running = false; 23 | 24 | void run_with_log(const QString &title, std::function f); 25 | bool check_running() const; 26 | }; 27 | -------------------------------------------------------------------------------- /src/sw/core/command.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "settings.h" 7 | 8 | #include 9 | 10 | namespace sw 11 | { 12 | 13 | TargetSettings commandToTargetSettings(const primitives::Command &); 14 | // builder::command? 15 | //TargetSettings targetSettingsToCommand(const primitives::Command &); 16 | 17 | } // namespace sw 18 | -------------------------------------------------------------------------------- /src/sw/core/core.natvis: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | empty 7 | 8 | 9 | {value._Tail._Head} 10 | 11 | 12 | {value._Tail._Tail._Head} 13 | 14 | 15 | {value._Tail._Tail._Tail._Head} 16 | 17 | 18 | {value} 19 | 20 | 21 | 22 | value._Tail._Tail._Head 23 | 24 | 25 | value._Tail._Tail._Tail._Head 26 | 27 | 28 | 29 | 30 | 31 | 32 | empty 33 | 34 | 35 | {settings} 36 | 37 | 38 | settings 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/sw/core/driver.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2019-2020 Egor Pugin 3 | 4 | #include "driver.h" 5 | 6 | namespace sw 7 | { 8 | 9 | IDriver::~IDriver() 10 | { 11 | } 12 | 13 | } // namespace sw 14 | -------------------------------------------------------------------------------- /src/sw/core/driver.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace sw 9 | { 10 | 11 | struct Input; 12 | struct SwContext; 13 | enum class InputType : uint8_t; 14 | 15 | struct SW_CORE_API IDriver 16 | { 17 | virtual ~IDriver(); 18 | 19 | /// Detect available inputs on path. 20 | //virtual std::vector> detectInputs(const path &abspath) const = 0; 21 | 22 | /// Detect available inputs of specified type on path. 23 | virtual std::vector> detectInputs(const path &abspath, InputType) const = 0; 24 | 25 | /// Optimized input loading in a batch. 26 | /// Inputs are unique and non null. 27 | /// Inputs will receive their entry points. 28 | virtual void loadInputsBatch(const std::set &) const = 0; 29 | 30 | /// returns driver capabilities 31 | //virtual uint64_t getCapabilities() const { return 0; } 32 | }; 33 | 34 | } // namespace sw 35 | -------------------------------------------------------------------------------- /src/sw/core/input_database.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #include "input_database.h" 5 | 6 | #include "specification.h" 7 | 8 | #include 9 | #include "inserts.h" 10 | #include 11 | #include 12 | #include 13 | 14 | #include // memcpy 15 | 16 | namespace sw 17 | { 18 | 19 | InputDatabase::InputDatabase(const path &p) 20 | : Database(p, inputs_db_schema) 21 | { 22 | } 23 | 24 | size_t InputDatabase::getFileHash(const path &p) const 25 | { 26 | const ::db::inputs::File file{}; 27 | 28 | bool update_db = false; 29 | auto lwt = fs::last_write_time(p); 30 | auto np = to_string(normalize_path(p)); 31 | 32 | auto q = (*db)( 33 | select(file.hash, file.lastWriteTime) 34 | .from(file) 35 | .where(file.path == np)); 36 | if (!q.empty()) 37 | { 38 | if (memcmp(q.front().lastWriteTime.value().data(), &lwt, sizeof(lwt)) == 0) 39 | return q.front().hash.value(); 40 | update_db = true; 41 | } 42 | 43 | auto c = read_file(p); 44 | auto h = std::hash()(c); 45 | 46 | std::vector lwtdata(sizeof(lwt)); 47 | memcpy(lwtdata.data(), &lwt, lwtdata.size()); 48 | if (update_db) 49 | { 50 | (*db)(update(file).set( 51 | file.hash = h, 52 | file.lastWriteTime = lwtdata 53 | ).where(file.path == np)); 54 | } 55 | else 56 | { 57 | (*db)(insert_into(file).set( 58 | file.path = np, 59 | file.hash = h, 60 | file.lastWriteTime = lwtdata 61 | )); 62 | } 63 | 64 | return h; 65 | } 66 | 67 | } // namespace sw 68 | -------------------------------------------------------------------------------- /src/sw/core/input_database.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace sw 9 | { 10 | 11 | // we store: 12 | // - path 13 | // - contents hash 14 | // - last write time 15 | struct SW_CORE_API InputDatabase : Database 16 | { 17 | InputDatabase(const path &dbfn); 18 | 19 | size_t getFileHash(const path &) const; 20 | }; 21 | 22 | } // namespace sw 23 | -------------------------------------------------------------------------------- /src/sw/core/inserts.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2019-2020 Egor Pugin 3 | 4 | #include 5 | 6 | extern const std::string inputs_db_schema; 7 | -------------------------------------------------------------------------------- /src/sw/core/inserts/input_db_schema.sql: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- SPDX-License-Identifier: GPL-3.0-or-later 3 | -- Copyright (C) 2020 Egor Pugin 4 | -------------------------------------------------------------------------------- 5 | 6 | -------------------------------------------------------------------------------- 7 | -- 8 | -- 9 | -- IMPORTANT! 10 | -- When making changes here, do not forget to add patch scripts 11 | -- at the end of the file! 12 | -- 13 | -- 14 | -------------------------------------------------------------------------------- 15 | 16 | -------------------------------------------------------------------------------- 17 | -- sqlite3 schema 18 | -------------------------------------------------------------------------------- 19 | 20 | CREATE TABLE file ( 21 | file_id INTEGER PRIMARY KEY, 22 | path TEXT(4096) NOT NULL COLLATE NOCASE, 23 | hash INTEGER NOT NULL, 24 | -- different size on systems (macos has 128 bits, others 64 bits) 25 | last_write_time BLOB NOT NULL 26 | ); 27 | CREATE UNIQUE INDEX ux_file ON file (path ASC); 28 | 29 | -------------------------------------------------------------------------------- 30 | -- 31 | -------------------------------------------------------------------------------- 32 | 33 | -------------------------------------------------------------------------------- 34 | -- % split - merge '%' and 'split' together when patches are available 35 | -------------------------------------------------------------------------------- 36 | -------------------------------------------------------------------------------- /src/sw/core/inserts/inserts.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2018-2020 Egor Pugin 3 | 4 | #include 5 | 6 | #include 7 | 8 | #define DECLARE_TEXT_VAR_BEGIN(x) const uint8_t _##x[] = { 9 | #define DECLARE_TEXT_VAR_END(x) }; const std::string x = (const char *)&_##x[0]; 10 | 11 | DECLARE_TEXT_VAR_BEGIN(inputs_db_schema) 12 | #include 13 | DECLARE_TEXT_VAR_END(inputs_db_schema); 14 | 15 | #undef DECLARE_TEXT_VAR_BEGIN 16 | #undef DECLARE_TEXT_VAR_END 17 | -------------------------------------------------------------------------------- /src/sw/core/rule.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #include "rule.h" 5 | 6 | namespace sw 7 | { 8 | 9 | IRule::~IRule() = default; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/sw/core/rule.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace sw 9 | { 10 | 11 | struct SW_CORE_API IRule : ICastable 12 | { 13 | virtual ~IRule() = 0; 14 | 15 | // get commands for ... (building?) 16 | /// 17 | virtual Commands getCommands() const = 0; 18 | }; 19 | 20 | } // namespace sw 21 | -------------------------------------------------------------------------------- /src/sw/core/settings_serialization.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include "settings.h" 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | // last 18 | #include 19 | 20 | #ifdef _MSC_VER 21 | #pragma warning(push) 22 | #pragma warning(disable : 4005) // warning C4005: 'XXX': macro redefinition 23 | #endif 24 | 25 | namespace sw 26 | { 27 | 28 | TargetSettings loadSettings(const path &archive_fn, int type) 29 | { 30 | return deserialize(archive_fn, type); 31 | } 32 | 33 | void saveSettings(const path &archive_fn, const TargetSettings &s, int type) 34 | { 35 | serialize(archive_fn, s, type); 36 | } 37 | 38 | } // namespace sw 39 | -------------------------------------------------------------------------------- /src/sw/core/specification.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | 12 | namespace sw 13 | { 14 | 15 | struct InputDatabase; 16 | struct SwContext; 17 | 18 | // Represents set of specification files for single input. 19 | // It may be set of sw (make, cmake, qmake etc.) files. 20 | // 21 | // must store one of: 22 | // - set of files (including virtual) 23 | // - single directory 24 | struct SW_CORE_API Specification 25 | { 26 | Specification(const SpecificationFiles &); 27 | Specification(const path &dir); 28 | 29 | // One spec differs from the other by its hash. 30 | // We only need to test it locally and do not care about portability between systems. 31 | // Hash is combination of rel paths and contents. 32 | size_t getHash(const InputDatabase &) const; 33 | 34 | bool isOutdated(const fs::file_time_type &) const; 35 | 36 | //const String &getFileContents(const path &relpath); 37 | //const String &getFileContents(const path &relpath) const; 38 | 39 | // returns absolute paths of files 40 | Files getFiles() const; 41 | 42 | String getName() const; 43 | 44 | void read(); 45 | 46 | //private: // temporarily (TODO: update upload) 47 | SpecificationFiles files; 48 | path dir; 49 | }; 50 | 51 | } // namespace sw 52 | -------------------------------------------------------------------------------- /src/sw/driver/bazel/bazel.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace bazel 12 | { 13 | 14 | using Name = std::string; 15 | using Value = std::string; 16 | using Values = std::set; 17 | 18 | struct Parameter 19 | { 20 | Name name; 21 | Values values; 22 | 23 | void trimQuotes(); 24 | }; 25 | 26 | using Parameters = std::vector; 27 | 28 | struct Function 29 | { 30 | Name name; 31 | Parameters parameters; 32 | 33 | void trimQuotes(); 34 | }; 35 | 36 | using Functions = std::vector; 37 | 38 | struct File 39 | { 40 | Functions functions; 41 | std::unordered_map parameters; 42 | 43 | void trimQuotes(); 44 | Values getFiles(const Name &name, const std::string &bazel_target_function = std::string()) const; 45 | }; 46 | 47 | File parse(const std::string &s); 48 | 49 | } // namespace bazel 50 | -------------------------------------------------------------------------------- /src/sw/driver/bazel/driver.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2020 Egor Pugin 3 | 4 | #include "driver.h" 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | int ll_bazellex_init(void **scanner); 13 | int ll_bazellex_destroy(void *yyscanner); 14 | struct yy_buffer_state *ll_bazel_scan_string(const char *yy_str, void *yyscanner); 15 | yy_bazel::parser::symbol_type ll_bazellex(void *yyscanner, yy_bazel::location &loc); 16 | 17 | BazelParserDriver::BazelParserDriver() 18 | { 19 | } 20 | 21 | yy_bazel::parser::symbol_type BazelParserDriver::lex() 22 | { 23 | auto ret = ll_bazellex(scanner, location); 24 | return ret; 25 | } 26 | 27 | int BazelParserDriver::parse(const std::string &s) 28 | { 29 | parseMode = Mode::String; 30 | 31 | ll_bazellex_init(&scanner); 32 | ll_bazel_scan_string(s.c_str(), scanner); 33 | auto res = parse(); 34 | ll_bazellex_destroy(scanner); 35 | 36 | return res; 37 | } 38 | 39 | int BazelParserDriver::parse() 40 | { 41 | yy_bazel::parser parser(*this); 42 | parser.set_debug_level(debug); 43 | int res = parser.parse(); 44 | return res; 45 | } 46 | 47 | void BazelParserDriver::error(const yy_bazel::location &l, const std::string &m) 48 | { 49 | std::ostringstream ss; 50 | ss << l << " " << m << "\n"; 51 | if (!can_throw) 52 | std::cerr << ss.str(); 53 | else 54 | throw SW_RUNTIME_ERROR("Error during bazel parse: " + ss.str()); 55 | } 56 | 57 | void BazelParserDriver::error(const std::string& m) 58 | { 59 | std::ostringstream ss; 60 | ss << m << "\n"; 61 | if (!can_throw) 62 | std::cerr << ss.str(); 63 | else 64 | throw SW_RUNTIME_ERROR("Error during bazel parse: " + ss.str()); 65 | } 66 | 67 | void BazelParserDriver::debug_printline(const char *line) const 68 | { 69 | 70 | } -------------------------------------------------------------------------------- /src/sw/driver/bazel/driver.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "bazel.h" 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | class BazelParserDriver 14 | { 15 | enum class Mode 16 | { 17 | String, 18 | Tokens, 19 | }; 20 | 21 | public: 22 | bazel::File bazel_file; 23 | bool debug = false; 24 | bool can_throw = true; 25 | 26 | BazelParserDriver(); 27 | 28 | yy_bazel::parser::symbol_type lex(); 29 | int parse(const std::string &s); 30 | 31 | void error(const yy_bazel::location &l, const std::string &m); 32 | void error(const std::string &m); 33 | 34 | void debug_printline(const char *) const; 35 | 36 | // lex & parse 37 | private: 38 | void *scanner; 39 | yy_bazel::location location; 40 | Mode parseMode; 41 | 42 | int parse(); 43 | }; 44 | -------------------------------------------------------------------------------- /src/sw/driver/build.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "checks_storage.h" 7 | #include "command.h" 8 | #include "target/base.h" 9 | 10 | #include 11 | #include 12 | 13 | namespace sw 14 | { 15 | 16 | struct Build; 17 | namespace driver::cpp { struct Driver; } 18 | struct Module; 19 | struct ModuleStorage; 20 | struct SwContext; 21 | 22 | struct ModuleSwappableData 23 | { 24 | PackageIdSet known_targets; 25 | TargetSettings current_settings; 26 | std::vector added_targets; 27 | }; 28 | 29 | struct DriverData 30 | { 31 | support::SourceDirMap source_dirs_by_source; 32 | std::unordered_map source_dirs_by_package; 33 | support::SourcePtr force_source; 34 | }; 35 | 36 | struct SW_DRIVER_CPP_API Test : driver::CommandBuilder 37 | { 38 | using driver::CommandBuilder::CommandBuilder; 39 | 40 | Test(const Test &) = default; 41 | Test &operator=(const Test &) = default; 42 | Test(const driver::CommandBuilder &b) 43 | : driver::CommandBuilder(b) 44 | {} 45 | 46 | void prepare(const Build &s) 47 | { 48 | // todo? 49 | } 50 | 51 | void skip(bool b) { getCommand()->skip = true; } 52 | }; 53 | 54 | struct SW_DRIVER_CPP_API SimpleBuild : TargetBase 55 | { 56 | // public functions for sw frontend 57 | }; 58 | 59 | struct SW_DRIVER_CPP_API Build : SimpleBuild 60 | { 61 | using Base = SimpleBuild; 62 | 63 | ModuleSwappableData module_data; 64 | DriverData *dd = nullptr; 65 | Checker checker; 66 | 67 | // 68 | Build(SwBuild &); 69 | 70 | bool isKnownTarget(const LocalPackage &p) const; 71 | path getSourceDir(const LocalPackage &p) const; 72 | std::optional getSourceDir(const Source &s, const Version &v) const; 73 | 74 | const TargetSettings &getExternalVariables() const; 75 | }; 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/sw/driver/build_self.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #include "entry_point.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | DECLARE_STATIC_LOGGER(logger, "build.self"); 13 | 14 | #include "sw_abi_version.h" 15 | // this allows to export builtin functions from deps (like mime_preprocess_file from qt) 16 | #define SW_PACKAGE_API SW_EXPORT 17 | #include "sw.h" 18 | 19 | #ifdef _MSC_VER 20 | #pragma warning(push) 21 | #pragma warning(disable : 4005) // warning C4005: 'XXX': macro redefinition 22 | #endif 23 | 24 | namespace sw 25 | { 26 | 27 | struct BuiltinInput : Input 28 | { 29 | size_t h; 30 | 31 | BuiltinInput(SwContext &swctx, const IDriver &d, size_t hash) 32 | : Input(swctx, d, std::make_unique(SpecificationFiles{})), h(hash) 33 | {} 34 | 35 | bool isParallelLoadable() const { return true; } 36 | size_t getHash() const override { return h; } 37 | EntryPointPtr load1(SwContext &) override { SW_UNREACHABLE; } 38 | }; 39 | 40 | using BuiltinInputs = std::unordered_map; 41 | 42 | } 43 | 44 | #include 45 | 46 | namespace sw 47 | { 48 | 49 | PackageIdSet load_builtin_packages(SwContext &swctx) 50 | { 51 | static const UnresolvedPackages required_packages 52 | { 53 | #include 54 | }; 55 | 56 | auto m = swctx.install(required_packages); 57 | 58 | PackageIdSet builtin_packages; 59 | for (auto &p : required_packages) 60 | builtin_packages.insert(m.find(p)->second); 61 | return builtin_packages; 62 | } 63 | 64 | } // namespace sw 65 | -------------------------------------------------------------------------------- /src/sw/driver/build_settings.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "compiler/compiler.h" 7 | 8 | #include 9 | #include 10 | 11 | namespace sw 12 | { 13 | 14 | struct SW_DRIVER_CPP_API BuildSettings 15 | { 16 | OS TargetOS; 17 | NativeToolchain Native; 18 | 19 | // other langs? 20 | // make polymorphic? 21 | 22 | BuildSettings() = default; 23 | BuildSettings(const TargetSettings &); 24 | 25 | String getTargetTriplet() const; 26 | TargetSettings getTargetSettings() const; 27 | }; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/sw/driver/c/c.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "c.h" 7 | #include "../driver.h" 8 | 9 | namespace sw 10 | { 11 | 12 | /*struct SW_DRIVER_CPP_API CDriver : IDriver 13 | { 14 | using create_driver = sw_driver_t(*)(void); 15 | 16 | CDriver(create_driver cd); 17 | virtual ~CDriver(); 18 | 19 | PackageId getPackageId() const override; 20 | bool canLoad(RawInputData &) const override; 21 | EntryPointsVector createEntryPoints(SwContext &, const std::vector &) const override; 22 | 23 | private: 24 | sw_driver_t d; 25 | };*/ 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/sw/driver/c/c.types.inl: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | 3 | TYPE(Build, build) 4 | 5 | TYPE(Executable, executable_target) 6 | TYPE(Library, library_target) 7 | TYPE(StaticLibrary, static_library_target) 8 | TYPE(SharedLibrary, shared_library_target) 9 | TYPE(Target, target) 10 | -------------------------------------------------------------------------------- /src/sw/driver/c/swc.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | // C public routines 5 | 6 | #ifndef _SWC_H_ 7 | #define _SWC_H_ 8 | 9 | /// everything for building 10 | SW_PACKAGE_API 11 | void build(sw_build_t *); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/sw/driver/checks_storage.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "checks.h" 7 | 8 | #include 9 | 10 | namespace sw 11 | { 12 | 13 | struct ChecksStorage 14 | { 15 | std::unordered_map all_checks; 16 | std::unordered_map manual_checks; 17 | bool loaded = false; 18 | bool new_manual_checks_loaded = false; 19 | 20 | void load(const path &fn); 21 | void load_manual(const path &fn); 22 | void save(const path &fn) const; 23 | 24 | void add(const Check &c); 25 | }; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/sw/driver/cmake.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "sw.h" 7 | 8 | #define SOLUTION_VAR _solution 9 | 10 | #define PRIVATE .Private += 11 | #define PUBLIC .Public += 12 | #define INTERFACE .Interface += 13 | 14 | #define add_library(t) auto &t = SOLUTION_VAR.addLibrary(#t) 15 | #define add_executable(t) auto &t = SOLUTION_VAR.addExecutable(#t) 16 | 17 | #define target_sources(t, ...) t __VA_ARGS__ 18 | #define target_include_directories(t, ...) t __VA_ARGS__ 19 | #define target_link_libraries(t, ...) t __VA_ARGS__ 20 | -------------------------------------------------------------------------------- /src/sw/driver/compiler/compiler_helpers.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2018 Egor Pugin 3 | 4 | #pragma once 5 | 6 | namespace sw 7 | { 8 | 9 | template 10 | static void getCommandLineOptions(driver::Command *c, const CommandLineOptions &t, const String prefix = "", bool end_options = false) 11 | { 12 | for (auto &o : t) 13 | { 14 | if (o.manual_handling) 15 | continue; 16 | if (end_options != o.place_at_the_end) 17 | continue; 18 | auto cmd = o.getCommandLine(c); 19 | for (auto &c2 : cmd) 20 | { 21 | if (!prefix.empty()) 22 | c->arguments.push_back(prefix); 23 | c->arguments.push_back(c2); 24 | } 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/sw/driver/compiler/detect.inl: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | // ASM/C/C++ 5 | DETECT(Native) 6 | 7 | DETECT(Ada) 8 | DETECT(CSharp) 9 | DETECT(D) 10 | DETECT(Fortran) 11 | DETECT(Go) 12 | DETECT(Java) 13 | DETECT(Kotlin) 14 | DETECT(Pascal) 15 | DETECT(Rust) 16 | -------------------------------------------------------------------------------- /src/sw/driver/driver.natvis: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {pkg} 7 | 8 | 9 | 10 | 11 | 12 | {package} 13 | 14 | 15 | 16 | 17 | 18 | {target->pkg} 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/sw/driver/frontend/cmake/cmake_fe.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | class cmake; 9 | class cmTarget; 10 | class cmMakefile; 11 | 12 | namespace sw 13 | { 14 | struct CheckSet; 15 | } 16 | 17 | namespace sw::driver::cpp 18 | { 19 | 20 | struct CmakeTargetEntryPoint : NativeTargetEntryPoint 21 | { 22 | using Base = NativeTargetEntryPoint; 23 | 24 | mutable std::unique_ptr cm; 25 | mutable SwBuild *b = nullptr; 26 | mutable TargetSettings ts; 27 | mutable NativeCompiledTarget *t = nullptr; 28 | mutable CheckSet *cs = nullptr; 29 | 30 | CmakeTargetEntryPoint(const path &fn); 31 | ~CmakeTargetEntryPoint(); 32 | 33 | [[nodiscard]] 34 | std::vector loadPackages(SwBuild &, const TargetSettings &, const PackageIdSet &pkgs, const PackagePath &prefix) const override; 35 | 36 | private: 37 | path rootfn; 38 | 39 | void init() const; 40 | void loadPackages1(Build &) const override; 41 | 42 | static NativeCompiledTarget *addTarget(Build &, cmTarget &); 43 | void setupTarget(cmMakefile &, cmTarget &, NativeCompiledTarget &, const StringSet &list_of_targets) const; 44 | }; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/sw/driver/frontend/cppan/bsi.inl: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2020 Egor Pugin 3 | 4 | BSI(pre_project) 5 | BSI(post_project) 6 | BSI(pre_sources) 7 | BSI(post_sources) 8 | BSI(post_target) 9 | BSI(post_alias) 10 | -------------------------------------------------------------------------------- /src/sw/driver/frontend/cppan/cppan.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace sw 9 | { 10 | 11 | struct Build; 12 | struct NativeCompiledTarget; 13 | 14 | namespace driver::cpp::frontend::cppan 15 | { 16 | 17 | std::vector cppan_load(Build &, yaml &root, const String &root_name = {}); 18 | 19 | } // namespace driver::cpp::frontend::cppan 20 | 21 | } // namespace sw 22 | -------------------------------------------------------------------------------- /src/sw/driver/frontend/cppan/yaml.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | 10 | namespace sw::cppan 11 | { 12 | 13 | yaml load_yaml_config(const path &p); 14 | yaml load_yaml_config(const String &s); 15 | yaml load_yaml_config(yaml &root); 16 | 17 | void dump_yaml_config(const path &p, const yaml &root); 18 | String dump_yaml_config(const yaml &root); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/sw/driver/frontend/vala/sw.vapi: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | 3 | // https://wiki.gnome.org/Projects/Vala/ManualBindings 4 | 5 | [CCode] 6 | namespace sw { 7 | [CCode (cname = "sw_build_t", has_type_id = false)] 8 | public struct Build {} 9 | 10 | public void* add_executable(Build? b, string name); 11 | public void set_target_property(void* t, string property, string value); 12 | public void add_target_source(void* t, string filename); 13 | } 14 | -------------------------------------------------------------------------------- /src/sw/driver/functions.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace sw 10 | { 11 | 12 | SW_DRIVER_CPP_API 13 | void writeFileOnce(const path &fn, const String &content, const path &lock_dir); 14 | 15 | SW_DRIVER_CPP_API 16 | void writeFileSafe(const path &fn, const String &content, const path &lock_dir); 17 | 18 | SW_DRIVER_CPP_API 19 | void replaceInFileOnce(const path &fn, const String &from, const String &to, const path &lock_dir); 20 | 21 | SW_DRIVER_CPP_API 22 | void pushFrontToFileOnce(const path &fn, const String &text, const path &lock_dir); 23 | 24 | SW_DRIVER_CPP_API 25 | void pushBackToFileOnce(const path &fn, const String &text, const path &lock_dir); 26 | 27 | SW_DRIVER_CPP_API 28 | bool patch(const path &fn, const String &text, const path &lock_dir); 29 | 30 | SW_DRIVER_CPP_API 31 | void downloadFile(const String &url, const path &fn, int64_t file_size_limit = 1_MB); 32 | 33 | SW_DRIVER_CPP_API 34 | path getProgramLocation(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/sw/driver/misc/delay_load_helper.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017-2020 Egor Pugin 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | // Replace fake dll dependency with currently running program. 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | FARPROC WINAPI delayLoadHook(unsigned dliNotify, PDelayLoadInfo pdli) 14 | { 15 | // fix library name to current executable 16 | if (dliNotify == dliNotePreLoadLibrary && strcmp(pdli->szDll, IMPORT_LIBRARY) == 0) 17 | return (FARPROC)GetModuleHandle(0); 18 | return NULL; 19 | } 20 | 21 | const PfnDliHook __pfnDliNotifyHook2 = delayLoadHook; 22 | 23 | BOOL WINAPI DllMain(HINSTANCE h, DWORD reason, LPVOID) 24 | { 25 | if (reason == DLL_PROCESS_ATTACH) 26 | { 27 | // load all imports on startup 28 | auto hr = __HrLoadAllImportsForDll(IMPORT_LIBRARY); 29 | if (FAILED(hr)) 30 | { 31 | _com_error err(hr); 32 | auto errMsg = err.ErrorMessage(); 33 | 34 | printf("Failed on snap load of " IMPORT_LIBRARY ", exiting: %ws\n", errMsg); 35 | return FALSE; 36 | } 37 | } 38 | return TRUE; 39 | } 40 | -------------------------------------------------------------------------------- /src/sw/driver/misc/sw.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | // used for preprocessing only 5 | // move this file to frontend/sw or frontend/cpp dir? 6 | 7 | #include 8 | -------------------------------------------------------------------------------- /src/sw/driver/module.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace sw 11 | { 12 | 13 | struct Build; 14 | struct Checker; 15 | 16 | struct SW_DRIVER_CPP_API Module 17 | { 18 | using DynamicLibrary = boost::dll::experimental::smart_library; 19 | 20 | template 21 | struct LibraryCall 22 | { 23 | using function_type = F; 24 | using std_function_type = std::function; 25 | 26 | String name; 27 | const Build *s = nullptr; 28 | const Module *m = nullptr; 29 | std_function_type f; 30 | 31 | LibraryCall &operator=(std::function f) 32 | { 33 | this->f = f; 34 | return *this; 35 | } 36 | 37 | template 38 | typename std_function_type::result_type operator()(Args &&... args) const; 39 | 40 | bool isRequired() const { return Required; } 41 | }; 42 | 43 | Module(std::unique_ptr, bool do_not_remove_bad_module); 44 | 45 | // api 46 | void build(Build &s) const; 47 | void configure(Build &s) const; 48 | void check(Build &s, Checker &c) const; 49 | int sw_get_module_abi_version() const; 50 | 51 | private: 52 | std::unique_ptr module; 53 | bool do_not_remove_bad_module; 54 | 55 | mutable LibraryCall build_; 56 | mutable LibraryCall configure_; 57 | mutable LibraryCall check_; 58 | mutable LibraryCall sw_get_module_abi_version_; 59 | 60 | path getLocation() const; 61 | }; 62 | 63 | std::unique_ptr loadSharedLibrary(const path &dll, const FilesOrdered &PATH, bool do_not_remove_bad_module); 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/sw/driver/program.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2019-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace sw 9 | { 10 | 11 | struct Build; 12 | struct SourceFile; 13 | struct Target; 14 | 15 | /*enum class TransformType 16 | { 17 | Unspecified, 18 | 19 | FileToFile, // 1-to-1 (compilers) 20 | FilesToFile, // many-to-1 (linkers) 21 | };*/ 22 | 23 | struct SW_DRIVER_CPP_API TransformProgram : Program 24 | { 25 | //TransformType type = TransformType::Unspecified; 26 | //StringSet input_extensions; 27 | 28 | using Program::Program; 29 | }; 30 | 31 | struct SW_DRIVER_CPP_API FileToFileTransformProgram : TransformProgram 32 | { 33 | using TransformProgram::TransformProgram; 34 | 35 | virtual std::shared_ptr createSourceFile(const Target &t, const path &input) const = 0; 36 | }; 37 | 38 | using FileToFileTransformProgramPtr = std::shared_ptr; 39 | 40 | struct ProgramGroup : Program 41 | { 42 | using Program::Program; 43 | 44 | std::shared_ptr getCommand() const override { return nullptr; } 45 | //Version &getVersion() override { SW_UNIMPLEMENTED; } 46 | 47 | virtual void activate(Build &s) const = 0; 48 | }; 49 | 50 | using ProgramGroupPtr = std::shared_ptr; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/sw/driver/program_storage.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "options.h" 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | namespace sw 14 | { 15 | 16 | struct Target; 17 | 18 | struct SW_DRIVER_CPP_API ProgramStorage 19 | { 20 | // make type polymorphic for dyncasts 21 | virtual ~ProgramStorage(); 22 | 23 | // late resolving registration with potential activation 24 | //void setExtensionProgram(const String &ext, const PackageId &); 25 | void setExtensionProgram(const String &ext, const UnresolvedPackage &); 26 | void setExtensionProgram(const String &ext, const DependencyPtr &); 27 | void setExtensionProgram(const String &ext, const ProgramPtr &); 28 | 29 | bool hasExtension(const String &ext) const; 30 | std::optional getExtPackage(const String &ext) const; 31 | Program *getProgram(const String &ext) const; 32 | 33 | void clearExtensions(); 34 | void removeExtension(const String &ext); 35 | 36 | private: 37 | std::map> extensions; 38 | }; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/sw/driver/program_version_storage.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace sw 9 | { 10 | 11 | struct SwManagerContext; 12 | 13 | struct ProgramVersionStorage 14 | { 15 | struct ProgramInfo 16 | { 17 | String output; 18 | Version v; 19 | fs::file_time_type t; 20 | 21 | operator Version&() { return v; } 22 | }; 23 | 24 | path fn; 25 | std::map versions; 26 | 27 | ProgramVersionStorage(const path &fn); 28 | ~ProgramVersionStorage(); 29 | 30 | void addVersion(const path &p, const Version &v, const String &output); 31 | }; 32 | 33 | ProgramVersionStorage &getVersionStorage(const SwManagerContext &); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/sw/driver/sw1.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | /// everything for building 7 | SW_PACKAGE_API 8 | void build(Solution &s); 9 | 10 | /// everything for configuring 11 | //SW_PACKAGE_API 12 | //void configure(Build &s); 13 | 14 | /// checker 15 | SW_PACKAGE_API 16 | void check(Checker &c); 17 | 18 | // void setup() - current config? 19 | // void fetch() - fetch sources 20 | // void self(); // for self build instructions? why? 21 | // void test(); // ? 22 | // custom steps like in waf? 23 | -------------------------------------------------------------------------------- /src/sw/driver/sw_abi_version.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2022 Egor Pugin 3 | 4 | #pragma once 5 | 6 | // 23: remove virtual method 7 | // 24: add virtual method to core.target 8 | // 25: core.target virtual methods update 9 | // 26: C++20 transition 10 | // 27: change OS::Version field to optional<> 11 | // 28: Program::clone() result shared -> unique ptr 12 | // 29: Add modules data to native target 13 | // 30: Add mingw/wasm/android 14 | // 31: PathBase::operator == and < api changes 15 | // 32: Some new APIs. ABI increase just for safety and clients update. 16 | // 33: Recurse prevention in Target::getInterfaceSettings() 17 | // 34: Add ForceIncludes 18 | // 35: Add loader 19 | // 36: Add PublicBinaryDir flag 20 | #define SW_MODULE_ABI_VERSION 36 21 | -------------------------------------------------------------------------------- /src/sw/driver/sw_check_abi_version.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "sw_abi_version.h" 7 | 8 | #ifndef SW_PACKAGE_API 9 | #define SW_PACKAGE_API 10 | #define INLINE inline 11 | #endif 12 | 13 | #ifndef INLINE 14 | #define INLINE 15 | #endif 16 | 17 | SW_PACKAGE_API 18 | INLINE int sw_get_module_abi_version() 19 | { 20 | return SW_MODULE_ABI_VERSION; 21 | } 22 | 23 | #undef INLINE 24 | -------------------------------------------------------------------------------- /src/sw/driver/target/all.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "base.h" 7 | #include "fortran.h" 8 | #include "native.h" 9 | #include "other.h" 10 | #include "vala.h" 11 | -------------------------------------------------------------------------------- /src/sw/driver/target/base_macro_end.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #undef ASSIGN_WRAPPER 5 | #undef ASSIGN_OP 6 | #undef ASSIGN_OP_ACTION 7 | #undef ASSIGN_TYPES_NO_REMOVE 8 | #undef ASSIGN_TYPES 9 | #undef ASSIGN_TYPES_AND_EXCLUDE 10 | -------------------------------------------------------------------------------- /src/sw/driver/target/cgnustd.inl: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | 3 | #define STD(x) C_GNU_MACRO(x, c) 4 | #include STD_INCLUDE 5 | #undef STD 6 | 7 | #define STD(x) C_GNU_MACRO(x, gnu) 8 | #include STD_INCLUDE 9 | #undef STD 10 | -------------------------------------------------------------------------------- /src/sw/driver/target/common.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "base.h" 7 | 8 | #include "sw/driver/compiler/detect.h" 9 | 10 | #include 11 | 12 | namespace sw 13 | { 14 | 15 | template 16 | static std::shared_ptr activateCompiler(Target &t, const UnresolvedPackage &id, const StringSet &exts) 17 | { 18 | auto &cld = t.getMainBuild().getTargets(); 19 | 20 | TargetSettings oss; // empty for now 21 | auto i = cld.find(id, oss); 22 | if (!i) 23 | { 24 | i = t.getContext().getPredefinedTargets().find(id, oss); 25 | if (!i) 26 | { 27 | for (auto &e : exts) 28 | t.setExtensionProgram(e, id); 29 | return {}; 30 | } 31 | } 32 | auto prog = i->as(); 33 | if (!prog) 34 | throw SW_RUNTIME_ERROR("Target without PredefinedProgram: " + i->getPackage().toString()); 35 | 36 | auto set_compiler_type = [&t, &id, &exts](const auto &c) 37 | { 38 | for (auto &e : exts) 39 | t.setExtensionProgram(e, c->clone()); 40 | }; 41 | 42 | auto c1 = prog->getProgram().clone(); 43 | if (auto c = dynamic_cast(c1.get())) 44 | { 45 | set_compiler_type(c); 46 | return {}; 47 | } 48 | 49 | bool created = false; 50 | auto create_command = [&prog, &created, &t](auto &c) 51 | { 52 | if (created) 53 | return; 54 | c->file = prog->getProgram().file; 55 | auto C = c->createCommand(t.getMainBuild()); 56 | static_cast(*C) = *prog->getProgram().getCommand(); 57 | created = true; 58 | }; 59 | 60 | auto compiler = std::make_shared(); 61 | create_command(compiler); 62 | set_compiler_type(compiler); 63 | return compiler; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/sw/driver/target/cppstd.inl: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | 3 | STD(98) 4 | STD(03) 5 | STD(11) 6 | STD(14) 7 | STD(17) 8 | STD(20) 9 | STD(23) 10 | STD(26) 11 | 12 | STD(0x) 13 | STD(1y) 14 | STD(1z) 15 | STD(2a) 16 | STD(2b) 17 | STD(2c) 18 | 19 | STD(latest) 20 | -------------------------------------------------------------------------------- /src/sw/driver/target/cstd.inl: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | 3 | STD(ansi) 4 | STD(89) 5 | STD(90) 6 | STD(95) 7 | STD(99) 8 | STD(11) 9 | STD(17) 10 | STD(18) 11 | 12 | STD(2x) 13 | 14 | STD(latest) 15 | -------------------------------------------------------------------------------- /src/sw/driver/target/enums.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | namespace sw 7 | { 8 | 9 | // ? (re)move? 10 | enum class TargetScope 11 | { 12 | Analyze, 13 | Benchmark, 14 | Build, 15 | Coverage, 16 | Documentation, 17 | Example, 18 | Format, 19 | Helper, // same as tool? 20 | Profile, 21 | Sanitize, 22 | Tool, 23 | Test, 24 | UnitTest, 25 | Valgrind, 26 | }; 27 | 28 | enum class CallbackType 29 | { 30 | CreateTarget, 31 | BeginPrepare, 32 | EndPrepare, 33 | 34 | // std::vector PreBuild; 35 | // addCustomCommand()? 36 | // preBuild? 37 | // postBuild? 38 | // postLink? 39 | }; 40 | 41 | // passed (serialized) via strings 42 | enum class TargetType : int 43 | { 44 | Unspecified, 45 | 46 | Project, // explicitly created 47 | Directory, // implicitly created? 48 | 49 | NativeLibrary, 50 | NativeHeaderOnlyLibrary, 51 | NativeStaticLibrary, 52 | NativeSharedLibrary, 53 | NativeObjectLibrary, 54 | NativeExecutable, 55 | 56 | // remove below? 57 | CSharpLibrary, 58 | CSharpExecutable, 59 | 60 | RustLibrary, 61 | RustExecutable, 62 | 63 | GoLibrary, 64 | GoExecutable, 65 | 66 | FortranLibrary, 67 | FortranExecutable, 68 | 69 | // add/replace with java jar? 70 | JavaLibrary, 71 | JavaExecutable, 72 | 73 | // add/replace with java jar? 74 | KotlinLibrary, 75 | KotlinExecutable, 76 | 77 | DLibrary, 78 | DStaticLibrary, 79 | DSharedLibrary, 80 | DExecutable, 81 | }; 82 | 83 | // enforcement rules apply to target to say how many checks it should perform 84 | enum class EnforcementType 85 | { 86 | CheckFiles, 87 | CheckRegexes, 88 | }; 89 | 90 | } // namespace sw 91 | -------------------------------------------------------------------------------- /src/sw/driver/target/fortran.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "native1.h" 7 | 8 | namespace sw 9 | { 10 | 11 | // Fortran 12 | 13 | struct SW_DRIVER_CPP_API FortranTarget : Target 14 | , NativeTargetOptionsGroup 15 | { 16 | std::shared_ptr compiler; 17 | 18 | FortranTarget(TargetBase &parent, const PackageId &); 19 | 20 | SW_TARGET_USING_ASSIGN_OPS(NativeTargetOptionsGroup); 21 | 22 | TargetType getType() const override { return TargetType::FortranLibrary; } 23 | 24 | bool init() override; 25 | DependenciesType gatherDependencies() const override { return NativeTargetOptionsGroup::gatherDependencies(); } 26 | Files gatherAllFiles() const override { return NativeTargetOptionsGroup::gatherAllFiles(); } 27 | 28 | protected: 29 | Commands getCommands1() const override; 30 | }; 31 | 32 | struct SW_DRIVER_CPP_API FortranLibrary : FortranTarget 33 | { 34 | using Base = FortranTarget; 35 | using Base::Base; 36 | }; 37 | 38 | struct SW_DRIVER_CPP_API FortranStaticLibrary : FortranLibrary 39 | { 40 | using Base = FortranLibrary; 41 | using Base::Base; 42 | 43 | private: 44 | Commands getCommands1() const override; 45 | }; 46 | 47 | struct SW_DRIVER_CPP_API FortranSharedLibrary : FortranLibrary 48 | { 49 | using Base = FortranLibrary; 50 | using Base::Base; 51 | 52 | private: 53 | Commands getCommands1() const override; 54 | }; 55 | 56 | struct SW_DRIVER_CPP_API FortranExecutable : FortranTarget 57 | { 58 | using Base = FortranTarget; 59 | using Base::Base; 60 | TargetType getType() const override { return TargetType::FortranExecutable; } 61 | }; 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/sw/driver/target/native1.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "base.h" 7 | 8 | namespace sw 9 | { 10 | 11 | namespace detail 12 | { 13 | 14 | #define STD_MACRO(x, p) static struct __sw_ ## p ## x {} p ## x; 15 | #include "std.inl" 16 | #undef STD_MACRO 17 | 18 | struct PrecompiledHeader 19 | { 20 | path header; 21 | path source; 22 | FilesOrdered files; 23 | 24 | // 25 | path name; // base filename 26 | String fancy_name; 27 | // 28 | path dir; 29 | path obj; // obj file (msvc) 30 | path pdb; // pdb file (msvc) 31 | path pch; // file itself 32 | 33 | path get_base_pch_path() const 34 | { 35 | return dir / name; 36 | } 37 | }; 38 | 39 | } 40 | 41 | enum class ConfigureFlags 42 | { 43 | Empty = 0x0, 44 | 45 | AtOnly = 0x1, // @ 46 | CopyOnly = 0x2, 47 | EnableUndefReplacements = 0x4, 48 | AddToBuild = 0x8, 49 | ReplaceUndefinedVariablesWithZeros = 0x10, 50 | 51 | Default = Empty, //AddToBuild, 52 | }; 53 | 54 | /** 55 | * \brief Native Target is a binary target that produces binary files (probably executables). 56 | */ 57 | struct SW_DRIVER_CPP_API NativeTarget : Target 58 | //,protected NativeOptions 59 | { 60 | using Target::Target; 61 | 62 | virtual path getOutputFile() const; 63 | 64 | // 65 | virtual void setupCommand(builder::Command &c) const {} 66 | // move to runnable target? since we might have data only targets 67 | virtual void setupCommandForRun(builder::Command &c) const { setupCommand(c); } // for Launch? 68 | 69 | protected: 70 | // 71 | path OutputDir; // output subdir 72 | virtual path getOutputFileName(const path &root) const; 73 | virtual path getOutputFileName2(const path &subdir) const; 74 | 75 | virtual void setOutputFile(); 76 | virtual NativeLinker *getSelectedTool() const = 0; 77 | virtual bool isStaticLibrary() const = 0; 78 | }; 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/sw/driver/target/std.inl: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | 3 | #define STD_INCLUDE "cstd.inl" 4 | #define C_GNU_MACRO(x, l) STD_MACRO(x, l) 5 | #include "cgnustd.inl" 6 | #undef C_GNU_MACRO 7 | #undef STD_INCLUDE 8 | 9 | #define STD_INCLUDE "cppstd.inl" 10 | #define C_GNU_MACRO(x, l) STD_MACRO(x, l ## pp) 11 | #include "cgnustd.inl" 12 | #undef C_GNU_MACRO 13 | #undef STD_INCLUDE 14 | -------------------------------------------------------------------------------- /src/sw/driver/target/target2.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #include "target2.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace sw 11 | { 12 | 13 | struct MsvcRule : IRule 14 | { 15 | Commands getCommands() const override 16 | { 17 | return {}; 18 | } 19 | }; 20 | 21 | std::unique_ptr PredefinedTargetWithRule::getRule() const 22 | { 23 | return std::make_unique(); 24 | } 25 | 26 | Target2::Target2(TargetBase &parent, const PackageId &id) 27 | : Target(parent, id), NativeTargetOptionsGroup((Target &)*this) 28 | { 29 | 30 | } 31 | 32 | Commands Target2::getCommands1() const 33 | { 34 | auto it = getMainBuild().getContext().getPredefinedTargets().find(UnresolvedPackage{ "msvc" }); 35 | if (it == getMainBuild().getContext().getPredefinedTargets().end()) 36 | throw SW_RUNTIME_ERROR("no rule found"); 37 | if (it->second.empty()) 38 | throw SW_RUNTIME_ERROR("no rules inside pkg"); 39 | 40 | auto r = (*it->second.begin())->getRule(); 41 | if (!r) 42 | throw SW_RUNTIME_ERROR("empty rule"); 43 | 44 | return r->getCommands(); 45 | } 46 | 47 | } // namespace sw 48 | -------------------------------------------------------------------------------- /src/sw/driver/target/target2.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "base.h" 7 | 8 | namespace sw 9 | { 10 | 11 | struct PredefinedTargetWithRule : PredefinedTarget 12 | { 13 | using PredefinedTarget::PredefinedTarget; 14 | 15 | std::unique_ptr getRule() const override; 16 | }; 17 | 18 | struct SW_DRIVER_CPP_API Target2 : Target 19 | , NativeTargetOptionsGroup 20 | { 21 | Files files; 22 | 23 | Target2(TargetBase &parent, const PackageId &); 24 | 25 | private: 26 | Commands getCommands1() const override; 27 | }; 28 | 29 | } // namespace sw 30 | -------------------------------------------------------------------------------- /src/sw/driver/target/vala.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "native.h" 7 | 8 | // vala.CompilerOptions? vala.copts? 9 | #define VALA_OPTIONS_NAME "vala" 10 | 11 | namespace sw 12 | { 13 | 14 | namespace detail 15 | { 16 | 17 | struct SW_DRIVER_CPP_API ValaBase 18 | { 19 | virtual ~ValaBase(); 20 | 21 | void init(); 22 | void prepare(); 23 | 24 | path getOutputCCodeFileName(const path &valasrc) const; 25 | 26 | protected: 27 | DependencyPtr d; 28 | std::shared_ptr compiler; 29 | path OutputDir; 30 | NativeCompiledTarget *t_ = nullptr; 31 | void getCommands1(Commands &) const; 32 | }; 33 | 34 | } 35 | 36 | #define VALA_TYPE(t) \ 37 | struct SW_DRIVER_CPP_API Vala##t : t##Target, detail::ValaBase \ 38 | { \ 39 | using Base = t##Target; \ 40 | using Base::Base; \ 41 | bool init() override; \ 42 | bool prepare() override; \ 43 | \ 44 | private: \ 45 | Commands getCommands1() const override; \ 46 | } 47 | 48 | VALA_TYPE(Library); 49 | VALA_TYPE(StaticLibrary); 50 | VALA_TYPE(SharedLibrary); 51 | VALA_TYPE(Executable); 52 | 53 | #undef VALA_TYPE 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/sw/driver/tools/cl_generator.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | #include 4 | 5 | struct EnumValue 6 | { 7 | String name; 8 | }; 9 | 10 | struct Flag 11 | { 12 | String name; 13 | String flag; 14 | String ns; // c++ namespace 15 | String type; 16 | String default_value; 17 | String function; 18 | String function_current; 19 | String struct_; 20 | StringSet properties; 21 | int order = 0; 22 | StringMap enum_vals; 23 | bool disabled = false; 24 | 25 | String getTypeWithNs() const; 26 | 27 | void printDecl(primitives::CppEmitter &) const; 28 | void printEnum(primitives::CppEmitter &) const; 29 | void printStruct(primitives::CppEmitter &) const; 30 | void printStructFunction(primitives::CppEmitter &) const; 31 | void printCommandLine(primitives::CppEmitter &) const; 32 | }; 33 | 34 | using Flags = std::map; 35 | 36 | struct Type 37 | { 38 | String name; 39 | String parent; 40 | Flags flags; 41 | 42 | mutable bool printed = false; 43 | 44 | void print(primitives::CppEmitter &h, primitives::CppEmitter &cpp) const; 45 | 46 | private: 47 | void printH(primitives::CppEmitter &) const; 48 | void printCpp(primitives::CppEmitter &) const; 49 | std::vector sortFlags() const; 50 | }; 51 | 52 | using Types = std::map; 53 | 54 | struct File 55 | { 56 | Flags flags; 57 | Types types; 58 | 59 | void print(primitives::CppEmitter &h, primitives::CppEmitter &cpp) const; 60 | 61 | private: 62 | void print_type(const Type &t, primitives::CppEmitter &h, primitives::CppEmitter &cpp) const; 63 | }; 64 | -------------------------------------------------------------------------------- /src/sw/manager/api.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "package.h" 7 | 8 | #include 9 | #include 10 | 11 | namespace sw 12 | { 13 | 14 | struct IStorage; 15 | 16 | struct Api 17 | { 18 | virtual ~Api() = 0; 19 | 20 | virtual ResolveResult resolvePackages( 21 | const UnresolvedPackages &pkgs, 22 | UnresolvedPackages &unresolved_pkgs, 23 | std::unordered_map &data, const IStorage &) const = 0; 24 | virtual void addVersion(const PackagePath &prefix, const PackageDescriptionMap &pkgs, const SpecificationFiles &) const = 0; 25 | }; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/sw/manager/api_protobuf.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "remote.h" 7 | 8 | #include 9 | 10 | #include 11 | 12 | namespace sw 13 | { 14 | 15 | struct Remote; 16 | 17 | struct ProtobufApi : Api 18 | { 19 | ProtobufApi(const Remote &); 20 | 21 | ResolveResult resolvePackages( 22 | const UnresolvedPackages &pkgs, UnresolvedPackages &unresolved_pkgs, 23 | std::unordered_map &data, const IStorage &) const override; 24 | void addVersion(const PackagePath &prefix, const PackageDescriptionMap &pkgs, const SpecificationFiles &) const override; 25 | 26 | void addVersion(const PackagePath &prefix, const String &script); 27 | void addVersion(PackagePath p, const Version &vnew, const std::optional &vold = {}); 28 | void updateVersion(PackagePath p, const Version &v); 29 | void removeVersion(PackagePath p, const Version &v); 30 | 31 | void getNotifications(int n = 10); 32 | void clearNotifications(); 33 | 34 | private: 35 | const Remote &r; 36 | GrpcChannel c; 37 | std::unique_ptr api_; 38 | std::unique_ptr user_; 39 | 40 | std::unique_ptr getContext() const; 41 | std::unique_ptr getContextWithAuth() const; 42 | }; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/sw/manager/database.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2019 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace sw 16 | { 17 | 18 | struct SW_MANAGER_API Database 19 | { 20 | std::unique_ptr db; 21 | path fn; 22 | 23 | Database(const path &db_name, const String &schema); 24 | ~Database(); 25 | 26 | void open(bool read_only = false, bool in_memory = false); 27 | 28 | int getIntValue(const String &key); 29 | void setIntValue(const String &key, int v); 30 | 31 | protected: 32 | // 33 | template 34 | std::optional getValue(const String &key) const; 35 | 36 | template 37 | T getValue(const String &key, const T &default_) const; 38 | 39 | template 40 | void setValue(const String &key, const T &v) const; 41 | }; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/sw/manager/database_pps.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2019 Egor Pugin 3 | 4 | #pragma once 5 | 6 | namespace 7 | { 8 | 9 | const auto pkgs = ::db::packages::Package{}; 10 | const auto pkg_ver = ::db::packages::PackageVersion{}; 11 | const auto pkg_deps = ::db::packages::PackageVersionDependency{}; 12 | const auto configs = ::db::packages::Config{}; 13 | const auto t_files = ::db::packages::File{}; 14 | const auto t_pkg_ver_files = ::db::packages::PackageVersionFile{}; 15 | 16 | template 17 | using PreparedStatement = decltype(((sql::connection*)nullptr)->prepare(*((SelectType*)nullptr))); 18 | 19 | auto selectPackageVersionData = []() 20 | { 21 | return 22 | select(pkg_ver.packageVersionId, pkg_ver.flags, pkg_ver.prefix, pkg_ver.sdir) 23 | .from(pkg_ver) 24 | .where(pkg_ver.packageId == parameter(pkg_ver.packageId) && pkg_ver.version == parameter(pkg_ver.version)); 25 | }; 26 | 27 | } 28 | 29 | namespace sw 30 | { 31 | 32 | struct PreparedStatements 33 | { 34 | PreparedStatement packageVersionData; 35 | 36 | PreparedStatements(sql::connection &db) 37 | : packageVersionData(db.prepare(selectPackageVersionData())) 38 | { 39 | } 40 | }; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/sw/manager/inserts.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2019 Egor Pugin 3 | 4 | #include 5 | 6 | extern const std::string packages_db_schema; 7 | -------------------------------------------------------------------------------- /src/sw/manager/inserts/inserts.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2018 Egor Pugin 3 | 4 | #include 5 | 6 | #include 7 | 8 | #define DECLARE_TEXT_VAR_BEGIN(x) const uint8_t _##x[] = { 9 | #define DECLARE_TEXT_VAR_END(x) }; const std::string x = (const char *)&_##x[0]; 10 | 11 | DECLARE_TEXT_VAR_BEGIN(packages_db_schema) 12 | #include 13 | DECLARE_TEXT_VAR_END(packages_db_schema); 14 | 15 | #undef DECLARE_TEXT_VAR_BEGIN 16 | #undef DECLARE_TEXT_VAR_END 17 | -------------------------------------------------------------------------------- /src/sw/manager/package.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2019 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace sw 10 | { 11 | 12 | struct IStorage; 13 | struct LocalStorage; 14 | struct OverriddenPackagesStorage; 15 | 16 | struct SW_MANAGER_API LocalPackage : Package 17 | { 18 | LocalPackage(const LocalStorage &, const PackageId &); 19 | 20 | LocalPackage(const LocalPackage &) = default; 21 | LocalPackage &operator=(const LocalPackage &) = delete; 22 | LocalPackage(LocalPackage &&) = default; 23 | LocalPackage &operator=(LocalPackage &&) = delete; 24 | virtual ~LocalPackage() = default; 25 | 26 | virtual std::unique_ptr clone() const { return std::make_unique(*this); } 27 | 28 | bool isOverridden() const; 29 | std::optional getOverriddenDir() const; 30 | 31 | /// main package dir 32 | path getDir() const; 33 | 34 | /// source archive root 35 | path getDirSrc() const; 36 | /// actual sources root 37 | path getDirSrc2() const; 38 | 39 | // 40 | path getDirObj() const; 41 | path getDirObj(const String &cfg) const; 42 | 43 | //path getDirObjWdir() const; 44 | path getDirInfo() const; 45 | 46 | path getStampFilename() const; 47 | String getStampHash() const; 48 | 49 | void remove() const; 50 | 51 | const LocalStorage &getStorage() const; 52 | 53 | private: 54 | path getDir(const path &root) const; 55 | }; 56 | 57 | using LocalPackagePtr = std::unique_ptr; 58 | 59 | } 60 | 61 | namespace std 62 | { 63 | 64 | template<> struct hash<::sw::LocalPackage> 65 | { 66 | size_t operator()(const ::sw::LocalPackage &p) const 67 | { 68 | return std::hash<::sw::Package>()(p); 69 | } 70 | }; 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/sw/manager/stamp.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #include "stamp.h" 5 | 6 | const std::string cppan_stamp = 7 | #ifdef CPPAN_INCLUDE_ASSEMBLED 8 | #include 9 | #else 10 | "" 11 | #endif 12 | ; 13 | -------------------------------------------------------------------------------- /src/sw/manager/stamp.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | extern const std::string cppan_stamp; 9 | -------------------------------------------------------------------------------- /src/sw/manager/sw_context.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2019 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "package.h" 7 | 8 | #include 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | namespace sw 17 | { 18 | 19 | struct IResolvableStorage; 20 | struct CachedStorage; 21 | struct LocalStorage; 22 | struct ResolveResultWithDependencies; 23 | 24 | // sw_context_t? 25 | /*struct SW_MANAGER_API ISwContext 26 | { 27 | virtual ~ISwContext() = 0; 28 | 29 | virtual Package resolve(const UnresolvedPackage &) const = 0; 30 | };*/ 31 | 32 | struct SW_MANAGER_API SwManagerContext// : ISwContext 33 | { 34 | std::unique_ptr executor; 35 | 36 | SwManagerContext(const path &local_storage_root_dir, bool allow_network); 37 | virtual ~SwManagerContext(); 38 | 39 | LocalStorage &getLocalStorage(); 40 | const LocalStorage &getLocalStorage() const; 41 | std::vector getRemoteStorages() const; 42 | 43 | // 44 | std::unordered_map install(const UnresolvedPackages &, bool use_cache = true) const; 45 | LocalPackage install(const Package &) const; 46 | 47 | ResolveResultWithDependencies resolve(const UnresolvedPackages &, bool use_cache = true) const; 48 | LocalPackage resolve(const UnresolvedPackage &) const; 49 | ResolveResultWithDependencies resolve(const UnresolvedPackages &, const std::vector &) const; 50 | 51 | // lock file related 52 | void setCachedPackages(const std::unordered_map &) const; 53 | 54 | private: 55 | int cache_storage_id; 56 | int local_storage_id; 57 | int first_remote_storage_id; 58 | std::vector> storages; 59 | mutable std::mutex resolve_mutex; 60 | 61 | CachedStorage &getCachedStorage() const; 62 | }; 63 | 64 | } // namespace sw 65 | -------------------------------------------------------------------------------- /src/sw/manager/yaml.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #include "yaml.h" 5 | 6 | #include 7 | 8 | void prepare_config_for_reading(yaml &root) 9 | { 10 | // can be all node checks from config, project, settings moved here? 11 | 12 | // no effect 13 | if (!root.IsMap()) 14 | return; 15 | } 16 | 17 | yaml load_yaml_config(const path &p) 18 | { 19 | auto s = read_file(p); 20 | return load_yaml_config(s); 21 | } 22 | 23 | yaml load_yaml_config(const String &s) 24 | { 25 | auto root = YAML::Load(s); 26 | prepare_config_for_reading(root); 27 | return root; 28 | } 29 | 30 | void dump_yaml_config(const path &p, const yaml &root) 31 | { 32 | write_file(p, dump_yaml_config(root)); 33 | } 34 | 35 | String dump_yaml_config(const yaml &root) 36 | { 37 | using namespace YAML; 38 | 39 | if (!root.IsMap()) 40 | return Dump(root); 41 | 42 | Emitter e; 43 | e.SetIndent(4); 44 | e << BeginMap; 45 | 46 | auto emit = [&e](auto root, const String &k, bool literal = false) 47 | { 48 | e << Key << k; 49 | e << Value; 50 | if (literal) 51 | { 52 | e << Literal; 53 | e << boost::trim_copy(root[k].template as()); 54 | } 55 | else 56 | e << root[k]; 57 | e << Newline << Newline; 58 | }; 59 | 60 | auto print_rest = [&emit](auto root) 61 | { 62 | for (auto n : root) 63 | { 64 | auto k = n.first.template as(); 65 | emit(root, k); 66 | } 67 | }; 68 | 69 | print_rest(root); 70 | 71 | e << EndMap; 72 | return e.c_str(); 73 | } 74 | -------------------------------------------------------------------------------- /src/sw/manager/yaml.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-or-later 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | 10 | yaml load_yaml_config(const path &p); 11 | yaml load_yaml_config(const String &s); 12 | 13 | void dump_yaml_config(const path &p, const yaml &root); 14 | String dump_yaml_config(const yaml &root); 15 | -------------------------------------------------------------------------------- /src/sw/protocol/build.proto: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | // Copyright (C) 2019 Egor Pugin 3 | 4 | syntax = "proto3"; 5 | 6 | package sw.api.build; 7 | 8 | //import "google/protobuf/empty.proto"; 9 | 10 | message IOStream { 11 | string file = 1; 12 | string text = 2; 13 | bool inherit = 3; 14 | } 15 | 16 | message Command { 17 | repeated string arguments = 1; 18 | string working_directory = 2; 19 | map environment = 3; 20 | 21 | IOStream in = 8; 22 | IOStream out = 9; 23 | IOStream err = 10; 24 | } 25 | 26 | // CommandResponse? 27 | message CommandResult { 28 | int64 exit_code = 1; 29 | // pid? 30 | 31 | string out = 9; 32 | string err = 10; 33 | } 34 | 35 | // add execution plan? 36 | 37 | service DistributedBuildService { 38 | rpc ExecuteCommand(Command) returns (CommandResult); 39 | } 40 | -------------------------------------------------------------------------------- /src/sw/protocol/grpc_helpers.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #define SW_GRPC_METADATA_AUTH_USER "auth-user" 8 | #define SW_GRPC_METADATA_AUTH_TOKEN "auth-token" 9 | -------------------------------------------------------------------------------- /src/sw/support/enums.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #include "enums.h" 5 | 6 | namespace sw 7 | { 8 | 9 | String toString(StorageFileType t) 10 | { 11 | switch (t) 12 | { 13 | case StorageFileType::SourceArchive: 14 | return "Source Archive"; 15 | case StorageFileType::BinaryArchive: 16 | return "Binary Archive"; 17 | default: 18 | return "Unknown source type"; 19 | } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/sw/support/exceptions.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #include "exceptions.h" 5 | 6 | using namespace std::string_literals; 7 | 8 | namespace sw::support 9 | { 10 | 11 | ExceptionVector::ExceptionVector(const std::vector &v) 12 | : v(v) 13 | { 14 | } 15 | 16 | const char *ExceptionVector::what() const noexcept 17 | { 18 | if (!s.empty()) 19 | return s.c_str(); 20 | for (auto &e : v) 21 | { 22 | try { std::rethrow_exception(e); } 23 | catch (std::exception &e2) { s += e2.what() + "\n"s; } 24 | catch (...) { s += "Unhandled exception\n"; } 25 | } 26 | s += "Total errors: " + std::to_string(v.size()) + "\n"; 27 | return s.c_str(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/sw/support/exceptions.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #define TYPED_EXCEPTION_WITH_STD_PARENT(x, p) \ 12 | struct x : public std::p \ 13 | { \ 14 | using std::p::p; \ 15 | x() : p("") {} \ 16 | } 17 | 18 | #define TYPED_EXCEPTION(x) TYPED_EXCEPTION_WITH_STD_PARENT(x, runtime_error) 19 | 20 | namespace sw::support 21 | { 22 | 23 | using traced_exception = boost::error_info; 24 | 25 | template 26 | void throw_with_trace(const E &e) 27 | { 28 | boost::stacktrace::stacktrace t(2, -1); 29 | throw boost::enable_error_info(e) << traced_exception(t); 30 | } 31 | 32 | struct SW_SUPPORT_API ExceptionVector : std::exception 33 | { 34 | ExceptionVector(const std::vector &v); 35 | ExceptionVector(const ExceptionVector &v) = default; 36 | virtual ~ExceptionVector() = default; 37 | 38 | const char *what() const noexcept override; 39 | 40 | private: 41 | std::vector v; 42 | mutable std::string s; 43 | }; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/sw/support/filesystem.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | 10 | // replace with .swb? .sw.b? .swbin? .swbuild? 11 | // so we leave .sw for some misc but important files to include into repositories 12 | #define SW_BINARY_DIR ".sw" 13 | 14 | namespace sw::support 15 | { 16 | 17 | SW_SUPPORT_API 18 | path get_root_directory(); 19 | 20 | SW_SUPPORT_API 21 | path get_config_filename(); 22 | 23 | SW_SUPPORT_API 24 | path temp_directory_path(const path &subdir = path()); 25 | 26 | SW_SUPPORT_API 27 | path get_temp_filename(const path &subdir = path()); 28 | 29 | SW_SUPPORT_API 30 | path get_ca_certs_filename(); 31 | 32 | SW_SUPPORT_API 33 | String make_archive_name(const String &fn = String()); 34 | 35 | SW_SUPPORT_API 36 | path findRootDirectory(const path &p); 37 | 38 | // cached version 39 | SW_SUPPORT_API 40 | void create_directories(const path &p); 41 | 42 | // will not shrink if old limit is lower 43 | // return old limit? 44 | SW_SUPPORT_API 45 | int set_max_open_files_limit(int newlimit); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/sw/support/hash.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #include "hash.h" 5 | 6 | namespace sw::support 7 | { 8 | 9 | String get_file_hash(const path &fn) 10 | { 11 | return strong_file_hash_file(fn); 12 | } 13 | 14 | bool check_file_hash(const path &fn, const String &hash) 15 | { 16 | return hash == get_file_hash(fn); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/sw/support/hash.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace sw::support 10 | { 11 | 12 | SW_SUPPORT_API 13 | String get_file_hash(const path &fn); 14 | 15 | SW_SUPPORT_API 16 | bool check_file_hash(const path &fn, const String &hash); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/sw/support/package_id.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | // Copyright (C) 2016-2019 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "enums.h" 7 | #include "package_unresolved.h" 8 | 9 | namespace sw 10 | { 11 | 12 | struct SW_SUPPORT_API PackageId 13 | { 14 | // try to extract from string 15 | PackageId(const String &); 16 | PackageId(const PackagePath &, const Version &); 17 | 18 | PackagePath getPath() const { return ppath; } 19 | Version getVersion() const { return version; } 20 | 21 | bool operator<(const PackageId &rhs) const { return std::tie(ppath, version) < std::tie(rhs.ppath, rhs.version); } 22 | bool operator==(const PackageId &rhs) const { return std::tie(ppath, version) == std::tie(rhs.ppath, rhs.version); } 23 | bool operator!=(const PackageId &rhs) const { return !operator==(rhs); } 24 | 25 | String getVariableName() const; 26 | 27 | String toString() const; 28 | String toString(const String &delim) const; 29 | String toString(Version::Level, const String &delim = "-") const; 30 | 31 | private: 32 | PackagePath ppath; 33 | Version version; 34 | }; 35 | 36 | using PackageIdSet = std::unordered_set; 37 | 38 | SW_SUPPORT_API 39 | PackageId extractPackageIdFromString(const String &target); 40 | 41 | } 42 | 43 | namespace std 44 | { 45 | 46 | template<> struct hash<::sw::PackageId> 47 | { 48 | size_t operator()(const ::sw::PackageId &p) const 49 | { 50 | auto h = std::hash<::sw::PackagePath>()(p.getPath()); 51 | return hash_combine(h, std::hash<::sw::Version>()(p.getVersion())); 52 | } 53 | }; 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/sw/support/package_path.inl: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | 3 | PACKAGE_PATH(loc) // local repos 4 | PACKAGE_PATH(org) // public org repos (open-source license and source only) 5 | PACKAGE_PATH(pub) // public repos (source only) 6 | PACKAGE_PATH(com) // org repos (proprietary licenses including binary only) 7 | PACKAGE_PATH(pvt) // private user repos including binary only 8 | // enc(rypted)? 9 | // sys(tem)? - OS specific, OS purposes 10 | // arh(archive)? - files 11 | -------------------------------------------------------------------------------- /src/sw/support/package_unresolved.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | // Copyright (C) 2016-2019 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include "package_path.h" 7 | #include "version.h" 8 | 9 | #include 10 | 11 | namespace sw 12 | { 13 | 14 | struct PackageId; 15 | 16 | struct SW_SUPPORT_API UnresolvedPackage 17 | { 18 | PackagePath ppath; 19 | VersionRange range; 20 | 21 | UnresolvedPackage() = default; 22 | UnresolvedPackage(const PackagePath &p, const VersionRange &r); 23 | UnresolvedPackage(const String &s); 24 | UnresolvedPackage(const PackageId &); 25 | 26 | UnresolvedPackage &operator=(const String &s); 27 | 28 | PackagePath getPath() const { return ppath; } 29 | VersionRange getRange() const { return range; } 30 | 31 | std::optional toPackageId() const; 32 | String toString(const String &delim = "-") const; 33 | bool canBe(const PackageId &id) const; 34 | 35 | bool operator<(const UnresolvedPackage &rhs) const { return std::tie(ppath, range) < std::tie(rhs.ppath, rhs.range); } 36 | bool operator==(const UnresolvedPackage &rhs) const { return std::tie(ppath, range) == std::tie(rhs.ppath, rhs.range); } 37 | bool operator!=(const UnresolvedPackage &rhs) const { return !operator==(rhs); } 38 | }; 39 | 40 | using UnresolvedPackages = std::unordered_set; 41 | 42 | SW_SUPPORT_API 43 | UnresolvedPackage extractFromString(const String &target); 44 | 45 | } 46 | 47 | namespace std 48 | { 49 | 50 | template<> struct hash<::sw::UnresolvedPackage> 51 | { 52 | size_t operator()(const ::sw::UnresolvedPackage &p) const 53 | { 54 | auto h = std::hash<::sw::PackagePath>()(p.ppath); 55 | return hash_combine(h, std::hash<::sw::VersionRange>()(p.range)); 56 | } 57 | }; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/sw/support/specification.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | // Copyright (C) 2017-2020 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | namespace sw 12 | { 13 | 14 | struct SW_SUPPORT_API SpecificationFile 15 | { 16 | path absolute_path; 17 | std::optional contents; 18 | 19 | //SpecificationFile(const String &contents); 20 | //SpecificationFile(const path &abspath, const String &); 21 | 22 | void read(); 23 | const String &getContents(); 24 | const String &getContents() const; 25 | void setContents(const String &contents); 26 | 27 | private: 28 | static String read(const path &); 29 | }; 30 | 31 | struct SW_SUPPORT_API SpecificationFiles 32 | { 33 | using relative_path = path; 34 | 35 | // For inline spec we may pass virtual file name and actual contents 36 | // that cannot be read from fs. 37 | // Example, inline cppan.yml: addFile(someroot, "cppan.yml", extracted yml contents from comments); 38 | // relative_path - path relative to package root, may be virtual, but valid! 39 | // absolute_path - path on disk, may differ from relative, example: main.cpp where we take inline cppan.yml from 40 | void addFile(const path &relpath, const path &abspath, const std::optional &contents = std::optional{}); 41 | void addFile(const path &relpath, const String &contents); 42 | 43 | auto &getData() { return data; } 44 | const auto &getData() const { return data; } 45 | fs::file_time_type getLastWriteTime() const; 46 | void read(); 47 | void write(const path &rootdir) const; 48 | 49 | nlohmann::json toJson() const; 50 | nlohmann::json toJsonWithoutContents() const; 51 | static SpecificationFiles fromJson(nlohmann::json &); 52 | static SpecificationFiles fromJson(nlohmann::json &, const path &rootdir); 53 | 54 | private: 55 | std::map data; 56 | }; 57 | 58 | } // namespace sw 59 | -------------------------------------------------------------------------------- /src/sw/support/storage_directories.inl: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | 3 | //DIR(arh) // archive storage (mirrors etc.)? 4 | //DIR(bin) // files are moved to pkg dir 5 | //DIR(cfg) // moved to etc/sw/checks 6 | //DIR(dat) 7 | DIR(etc) 8 | //DIR(lib) // files are moved to pkg dir 9 | #ifdef _WIN32 10 | //DIR(lnk) // use sw open ... 11 | #endif 12 | //DIR(obj) // files are moved to pkg dir 13 | DIR(pkg) 14 | DIR(tmp) 15 | //DIR(usr) 16 | -------------------------------------------------------------------------------- /src/sw/support/version.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #include "version.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace sw 11 | { 12 | 13 | std::optional VersionRange::getMinSatisfyingVersion(const VersionSet &s) const 14 | { 15 | // add policies? 16 | 17 | if (!s.empty_releases()) 18 | { 19 | for (auto &v : s.releases()) 20 | { 21 | if (hasVersion(v)) 22 | return v; 23 | } 24 | } 25 | 26 | return Base::getMinSatisfyingVersion(s); 27 | } 28 | 29 | std::optional VersionRange::getMaxSatisfyingVersion(const VersionSet &s) const 30 | { 31 | // add policies? 32 | 33 | if (!s.empty_releases()) 34 | { 35 | for (auto i = s.rbegin_releases(); i != s.rend_releases(); ++i) 36 | { 37 | if (hasVersion(*i)) 38 | return *i; 39 | } 40 | } 41 | 42 | return Base::getMaxSatisfyingVersion(s); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/sw/support/version.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MPL-2.0 2 | // Copyright (C) 2016-2018 Egor Pugin 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | 10 | namespace sw 11 | { 12 | 13 | namespace db 14 | { 15 | 16 | using PackageId = int64_t; 17 | using PackageVersionId = int64_t; 18 | using FileId = int64_t; 19 | 20 | } 21 | 22 | using primitives::version::Version; 23 | using primitives::version::VersionSet; 24 | using primitives::version::VersionMap; 25 | using primitives::version::UnorderedVersionMap; 26 | 27 | struct SW_SUPPORT_API VersionRange : primitives::version::VersionRange 28 | { 29 | using Base = primitives::version::VersionRange; 30 | 31 | using Base::Base; 32 | 33 | std::optional getMinSatisfyingVersion(const VersionSet &) const; 34 | std::optional getMaxSatisfyingVersion(const VersionSet &) const; 35 | }; 36 | 37 | } 38 | 39 | namespace std 40 | { 41 | 42 | template<> struct hash 43 | { 44 | size_t operator()(const sw::VersionRange &v) const 45 | { 46 | return hash()(v); 47 | } 48 | }; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | build_waf 2 | waf* 3 | win* 4 | mingw* 5 | ninja* 6 | *.bat 7 | *.sh 8 | -------------------------------------------------------------------------------- /test/build/.gitignore: -------------------------------------------------------------------------------- 1 | target -------------------------------------------------------------------------------- /test/build/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(basic) 4 | 5 | file(GLOB_RECURSE src "build/c/exe/*") 6 | add_executable(exe_c ${src}) 7 | 8 | file(GLOB_RECURSE src "build/cpp/exe/*") 9 | add_executable(exe ${src}) 10 | target_compile_definitions(exe PUBLIC 11 | AND_MY_STRING="" 12 | ) 13 | 14 | file(GLOB_RECURSE src "build/cpp/dll/*") 15 | add_library(mydll SHARED ${src}) 16 | 17 | file(GLOB_RECURSE src "build/cpp/lib/*") 18 | add_library(mylib ${src}) 19 | 20 | 21 | 22 | 23 | project(deps) 24 | 25 | file(GLOB_RECURSE src "build/cpp/dep/exe_dll/main.cpp") 26 | add_executable(exe1 ${src}) 27 | target_link_libraries(exe1 dll1) 28 | 29 | file(GLOB_RECURSE src "build/cpp/dep/exe_dll/a*") 30 | add_library(dll1 SHARED ${src}) 31 | set(def "MY_API=__declspec(dllexport)") 32 | set(def2 "MY_API=__declspec(dllimport)") 33 | target_compile_definitions(dll1 34 | PRIVATE ${def} 35 | INTERFACE ${def2} 36 | ) 37 | 38 | file(GLOB_RECURSE src "build/cpp/dep/exe_lib/main.cpp") 39 | add_executable(exe2 ${src}) 40 | target_link_libraries(exe2 lib2) 41 | 42 | file(GLOB_RECURSE src "build/cpp/dep/exe_lib/a*") 43 | add_library(lib2 ${src}) 44 | set(def "MY_API=") 45 | target_compile_definitions(lib2 46 | PUBLIC ${def} 47 | ) 48 | 49 | file(GLOB_RECURSE src "build/cpp/dep/exe_dll_dll/main.cpp") 50 | add_executable(exe3 ${src}) 51 | target_link_libraries(exe3 dll3a dll3b) 52 | 53 | file(GLOB_RECURSE src "build/cpp/dep/exe_dll_dll/a*") 54 | add_library(dll3a SHARED ${src}) 55 | set(def "A_API=__declspec(dllexport)") 56 | set(def2 "A_API=__declspec(dllimport)") 57 | target_compile_definitions(dll3a 58 | PRIVATE ${def} 59 | INTERFACE ${def2} 60 | ) 61 | 62 | file(GLOB_RECURSE src "build/cpp/dep/exe_dll_dll/b*") 63 | add_library(dll3b SHARED ${src}) 64 | set(def "B_API=__declspec(dllexport)") 65 | set(def2 "B_API=__declspec(dllimport)") 66 | target_compile_definitions(dll3b 67 | PRIVATE ${def} 68 | INTERFACE ${def2} 69 | ) 70 | 71 | 72 | -------------------------------------------------------------------------------- /test/build/ada/hello.adb: -------------------------------------------------------------------------------- 1 | with Ada.Text_IO; use Ada.Text_IO; 2 | procedure Hello is 3 | begin 4 | Put_Line ("Hello, world!"); 5 | end Hello; 6 | -------------------------------------------------------------------------------- /test/build/ada/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &t = s.addTarget("x"); 4 | t += "hello.adb"; 5 | } 6 | -------------------------------------------------------------------------------- /test/build/c/api/exe.cpp: -------------------------------------------------------------------------------- 1 | extern "C" 2 | { 3 | #include "lib1.h" 4 | } 5 | int main() {lib1();} -------------------------------------------------------------------------------- /test/build/c/api/lib1.c: -------------------------------------------------------------------------------- 1 | #include "lib1.h" 2 | void lib1(){} -------------------------------------------------------------------------------- /test/build/c/api/lib1.h: -------------------------------------------------------------------------------- 1 | LIB1_API 2 | void lib1(); 3 | -------------------------------------------------------------------------------- /test/build/c/api/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &lib1 = s.addLibrary("lib1"); 4 | lib1.ApiName = "LIB1_API"; 5 | lib1 += "lib1.*"_rr; 6 | 7 | auto &exe1 = s.addExecutable("exe1"); 8 | exe1 += "exe.*"_rr; 9 | exe1 += lib1; 10 | } 11 | -------------------------------------------------------------------------------- /test/build/c/exe/1.h: -------------------------------------------------------------------------------- 1 | void f(); 2 | void g(); 3 | -------------------------------------------------------------------------------- /test/build/c/exe/build.c: -------------------------------------------------------------------------------- 1 | #include "1.h" 2 | 3 | int main() 4 | { 5 | f(); 6 | g(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /test/build/c/exe/f.c: -------------------------------------------------------------------------------- 1 | #include "1.h" 2 | #include 3 | void f() 4 | { 5 | printf("Hello, World!\n"); 6 | } 7 | -------------------------------------------------------------------------------- /test/build/c/exe/x.c: -------------------------------------------------------------------------------- 1 | #include "1.h" 2 | #include 3 | void g() 4 | { 5 | printf("Hello, World 2!\n"); 6 | } 7 | -------------------------------------------------------------------------------- /test/build/cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMakeList.txt : CMake project for CMakeProject1, include source and define 2 | # project specific logic here. 3 | # 4 | cmake_minimum_required (VERSION 3.8) 5 | 6 | project ("CMakeProject1") 7 | 8 | # Add source to this project's executable. 9 | add_executable (CMakeProject1 "CMakeProject1.cpp" "CMakeProject1.h") 10 | add_executable (CMakeProject2 "CMakeProject1.cpp" "CMakeProject1.h") 11 | add_executable (CMakeProject3 "CMakeProject1.cpp" "CMakeProject1.h") 12 | add_executable (CMakeProject4 "CMakeProject2.cpp") 13 | add_executable (CMakeProject5 "CMakeProject3.cpp") 14 | 15 | # 16 | set(src lib1.cpp) 17 | add_library(lib1 ${src} lib1.h) 18 | 19 | # 20 | add_library(lib2) 21 | target_sources(lib2 PRIVATE lib2.h lib2.cpp) 22 | target_link_libraries(lib2 PRIVATE lib1) 23 | 24 | # 25 | add_library(lib3 STATIC lib3.cpp lib3.h) 26 | target_link_libraries(lib3 PRIVATE lib2) 27 | 28 | # 29 | add_library(lib4 STATIC lib4.cpp lib4.h) 30 | target_link_libraries(CMakeProject4 PRIVATE lib4) 31 | 32 | # 33 | target_link_libraries(CMakeProject5 PRIVATE lib3) 34 | -------------------------------------------------------------------------------- /test/build/cmake/CMakeProject1.cpp: -------------------------------------------------------------------------------- 1 | #include "CMakeProject1.h" 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << "Hello CMake." << endl; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /test/build/cmake/CMakeProject1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /test/build/cmake/CMakeProject2.cpp: -------------------------------------------------------------------------------- 1 | #include "lib4.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() 8 | { 9 | lib4(); 10 | cout << "Hello CMake." << endl; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /test/build/cmake/CMakeProject3.cpp: -------------------------------------------------------------------------------- 1 | #include "lib3.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() 8 | { 9 | lib3(); 10 | cout << "Hello CMake." << endl; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /test/build/cmake/lib1.cpp: -------------------------------------------------------------------------------- 1 | #include "lib1.h" 2 | #include 3 | void lib1(){std::cout<<1<<"\n";} -------------------------------------------------------------------------------- /test/build/cmake/lib1.h: -------------------------------------------------------------------------------- 1 | void lib1(); 2 | -------------------------------------------------------------------------------- /test/build/cmake/lib2.cpp: -------------------------------------------------------------------------------- 1 | #include "lib1.h" 2 | #include "lib2.h" 3 | #include 4 | void lib2(){lib1();std::cout<<2<<"\n";} 5 | -------------------------------------------------------------------------------- /test/build/cmake/lib2.h: -------------------------------------------------------------------------------- 1 | void lib2(); 2 | -------------------------------------------------------------------------------- /test/build/cmake/lib3.cpp: -------------------------------------------------------------------------------- 1 | #include "lib2.h" 2 | #include "lib3.h" 3 | #include 4 | void lib3(){lib2();std::cout<<3<<"\n";} 5 | -------------------------------------------------------------------------------- /test/build/cmake/lib3.h: -------------------------------------------------------------------------------- 1 | void lib3(); 2 | -------------------------------------------------------------------------------- /test/build/cmake/lib4.cpp: -------------------------------------------------------------------------------- 1 | #include "lib4.h" 2 | #include 3 | void lib4(){std::cout<<4<<"\n";} 4 | -------------------------------------------------------------------------------- /test/build/cmake/lib4.h: -------------------------------------------------------------------------------- 1 | void lib4(); 2 | -------------------------------------------------------------------------------- /test/build/cpp/complex/1/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | png_malloc(0,0); 6 | } 7 | -------------------------------------------------------------------------------- /test/build/cpp/complex/1/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &p = s.addProject("xa", "1.0.0"); 4 | auto &d = p.addDirectory("xb"); 5 | auto &t = d.addTarget("x"); 6 | t += "main.cpp"; 7 | t += "org.sw.demo.glennrp.png"_dep; 8 | } 9 | -------------------------------------------------------------------------------- /test/build/cpp/dep/boost/system/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | boost::error_code ec; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /test/build/cpp/dep/circular/dll/a.cpp: -------------------------------------------------------------------------------- 1 | MY_B_API void b(); 2 | MY_A_API void a() 3 | { 4 | b(); 5 | } 6 | -------------------------------------------------------------------------------- /test/build/cpp/dep/circular/dll/b.cpp: -------------------------------------------------------------------------------- 1 | MY_A_API void a(); 2 | MY_B_API void b() 3 | { 4 | a(); 5 | } 6 | -------------------------------------------------------------------------------- /test/build/cpp/dep/circular/exe/a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | MY_A_API int a(int b) 4 | { 5 | return b + 2; 6 | } 7 | MY_B_API int b(int); 8 | 9 | int main() 10 | { 11 | auto r = a(5); 12 | r = b(r); 13 | std::cout << r; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /test/build/cpp/dep/circular/exe/b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | MY_B_API int b(int a) 4 | { 5 | return a * 2; 6 | } 7 | MY_A_API int a(int); 8 | 9 | int main() 10 | { 11 | auto r = b(5); 12 | r = a(r); 13 | std::cout << r; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /test/build/cpp/dep/circular/exe_dll/a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | MY_A_API int a(int b) 4 | { 5 | return b + 2; 6 | } 7 | MY_B_API int b(int); 8 | 9 | int main() 10 | { 11 | auto r = a(5); 12 | r = b(r); 13 | std::cout << r; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /test/build/cpp/dep/circular/exe_dll/b.cpp: -------------------------------------------------------------------------------- 1 | MY_A_API int a(int); 2 | MY_B_API int b(int aa) 3 | { 4 | return a(aa) * 2; 5 | } 6 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_dll/a.cpp: -------------------------------------------------------------------------------- 1 | #include "a.h" 2 | 3 | #include 4 | 5 | MY_API void f() 6 | { 7 | std::cout << "Hello, World!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_dll/a.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | MY_API void f(); 4 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_dll/main.cpp: -------------------------------------------------------------------------------- 1 | #include "a.h" 2 | 3 | int main() 4 | { 5 | f(); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_dll_dll/a.cpp: -------------------------------------------------------------------------------- 1 | #include "a.h" 2 | 3 | #include 4 | 5 | A_API void a() 6 | { 7 | std::cout << "Hello, World from A!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_dll_dll/a.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | A_API void a(); 4 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_dll_dll/b.cpp: -------------------------------------------------------------------------------- 1 | #include "b.h" 2 | 3 | #include 4 | 5 | B_API void b() 6 | { 7 | std::cout << "Hello, World from B!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_dll_dll/b.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | B_API void b(); 4 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_dll_dll/main.cpp: -------------------------------------------------------------------------------- 1 | #include "a.h" 2 | #include "b.h" 3 | 4 | int main() 5 | { 6 | a(); 7 | b(); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_lib/a.cpp: -------------------------------------------------------------------------------- 1 | #include "a.h" 2 | 3 | #include 4 | 5 | MY_API void f() 6 | { 7 | std::cout << "Hello, World!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_lib/a.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | MY_API void f(); 4 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_lib/main.cpp: -------------------------------------------------------------------------------- 1 | #include "a.h" 2 | 3 | int main() 4 | { 5 | f(); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_lib_st_sh/a.cpp: -------------------------------------------------------------------------------- 1 | #include "a.h" 2 | 3 | #include 4 | 5 | MY_API void f() 6 | { 7 | std::cout << "Hello, World!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_lib_st_sh/a.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | MY_API void f(); 4 | -------------------------------------------------------------------------------- /test/build/cpp/dep/exe_lib_st_sh/main.cpp: -------------------------------------------------------------------------------- 1 | #include "a.h" 2 | 3 | int main() 4 | { 5 | f(); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /test/build/cpp/dll/build.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | __declspec(dllexport) 4 | void f() 5 | { 6 | std::cout << "Hello, World!\n"; 7 | } 8 | -------------------------------------------------------------------------------- /test/build/cpp/exe/1.h: -------------------------------------------------------------------------------- 1 | void f(); 2 | void g(); 3 | -------------------------------------------------------------------------------- /test/build/cpp/exe/1.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | std::cout << "Hello, World!\n"; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /test/build/cpp/exe/1/1.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | std::cout << "Hello, World!\n"; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /test/build/cpp/exe/1/2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SoftwareNetwork/sw/d156861fce5ae5d1a8bb4af59d25426b1995b5b9/test/build/cpp/exe/1/2.h -------------------------------------------------------------------------------- /test/build/cpp/exe/1/x.cpp: -------------------------------------------------------------------------------- 1 | #include "../1.h" 2 | #include 3 | void f() 4 | { 5 | std::cout << "Hello, World!\n" << AND_MY_STRING; 6 | } 7 | -------------------------------------------------------------------------------- /test/build/cpp/exe/build.cpp: -------------------------------------------------------------------------------- 1 | #include "1.h" 2 | 3 | int main() 4 | { 5 | f(); 6 | g(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /test/build/cpp/exe/x.cpp: -------------------------------------------------------------------------------- 1 | #include "1.h" 2 | #include 3 | void g() 4 | { 5 | std::cout << "Hello, World 2!\n" << AND_MY_STRING << " 2\n"; 6 | } 7 | -------------------------------------------------------------------------------- /test/build/cpp/exe2/1.h: -------------------------------------------------------------------------------- 1 | void f(){} -------------------------------------------------------------------------------- /test/build/cpp/exe2/main.cpp: -------------------------------------------------------------------------------- 1 | #include "1.h" 2 | 3 | int main() 4 | { 5 | f(); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /test/build/cpp/lib/build.cpp: -------------------------------------------------------------------------------- 1 | //#include 2 | 3 | void f() 4 | { 5 | //std::cout << "Hello, World!\n"; 6 | } 7 | -------------------------------------------------------------------------------- /test/build/cpp/modules/complex/1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int ggg(); 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/build/cpp/modules/complex/Source.cpp: -------------------------------------------------------------------------------- 1 | #include "1.h" 2 | #include 3 | 4 | int ggg(){ return 5;} 5 | -------------------------------------------------------------------------------- /test/build/cpp/modules/complex/m.ixx: -------------------------------------------------------------------------------- 1 | export module MyModule; 2 | 3 | import std.core; 4 | 5 | 6 | export void MyFunc(); 7 | export 8 | void f() { 9 | std::cout << "123\n"; 10 | MyFunc(); 11 | } 12 | 13 | MY_API void exp1(){} 14 | export MY_API void exp2(){} 15 | 16 | 17 | export void ggg2(){} 18 | export void ggg3(){} 19 | export void ggg4(){} 20 | -------------------------------------------------------------------------------- /test/build/cpp/modules/complex/m2.cpp: -------------------------------------------------------------------------------- 1 | module MyModule; 2 | 3 | #include "1.h" 4 | 5 | void MyFunc() { 6 | ggg(); 7 | } 8 | -------------------------------------------------------------------------------- /test/build/cpp/modules/complex/main.cpp: -------------------------------------------------------------------------------- 1 | import std.core; 2 | import MyModule; 3 | 4 | import "old_header.h"; 5 | import ; 6 | 7 | #include "1.h" 8 | 9 | int main() { 10 | f(); 11 | exp2(); 12 | MyFunc(); 13 | ggg(); 14 | ggg2(); 15 | ggg3(); 16 | ggg4(); 17 | //xxx(); 18 | //yyy(); 19 | 20 | x v{3}; 21 | } 22 | -------------------------------------------------------------------------------- /test/build/cpp/modules/complex/old_header.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //inline void xxx(){} 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/build/cpp/modules/complex/old_header2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //inline void yyy(){} 4 | 5 | struct x { 6 | int a = 5; 7 | }; -------------------------------------------------------------------------------- /test/build/cpp/modules/complex/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) { 2 | auto &t = s.addExecutable("test"); 3 | t.UseModules = true; 4 | //t.GenerateWindowsResource = false; 5 | t += cpp23; 6 | t += "MY_API"_api; 7 | t += "main.cpp"; 8 | t += "m2.cpp"; 9 | t += "Source.cpp"; 10 | t += "m.ixx"; 11 | t += "old_header.h"_qhu; 12 | t += "old_header2.h"_ahu; 13 | } 14 | -------------------------------------------------------------------------------- /test/build/cpp/modules/includes/m.cpp: -------------------------------------------------------------------------------- 1 | export module MyModule; 2 | 3 | import ; 4 | 5 | export void f() { 6 | } 7 | -------------------------------------------------------------------------------- /test/build/cpp/modules/includes/main.cpp: -------------------------------------------------------------------------------- 1 | import MyModule; 2 | 3 | import "old_header.h"; 4 | import ; 5 | 6 | int main() { 7 | f(); 8 | 9 | x v{3}; 10 | } 11 | -------------------------------------------------------------------------------- /test/build/cpp/modules/includes/old_header.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //inline void xxx(){} 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/build/cpp/modules/includes/old_header2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //inline void yyy(){} 4 | 5 | struct x { 6 | int a = 5; 7 | }; -------------------------------------------------------------------------------- /test/build/cpp/modules/includes/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) { 2 | auto &t = s.addExecutable("test"); 3 | t.UseModules = true; 4 | //t.GenerateWindowsResource = false; 5 | t += cpp23; 6 | t += "main.cpp"; 7 | t += "m.cpp"; 8 | t += "old_header.h"_qhu; 9 | t += "old_header2.h"_ahu; 10 | } 11 | -------------------------------------------------------------------------------- /test/build/cpp/modules/simple/m.cpp: -------------------------------------------------------------------------------- 1 | export module MyModule; 2 | 3 | export void f() { 4 | } 5 | -------------------------------------------------------------------------------- /test/build/cpp/modules/simple/main.cpp: -------------------------------------------------------------------------------- 1 | import MyModule; 2 | 3 | int main() { 4 | f(); 5 | } 6 | -------------------------------------------------------------------------------- /test/build/cpp/modules/simple/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) { 2 | auto &t = s.addExecutable("test"); 3 | t.UseModules = true; 4 | //t.GenerateWindowsResource = false; 5 | t += cpp23; 6 | t += "main.cpp"; 7 | t += "m.cpp"; 8 | } 9 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/multiconf.bat: -------------------------------------------------------------------------------- 1 | sw ^ 2 | %* ^ 3 | -sfc ^ 4 | -configuration Debug,ReleaseWithDebInfo,MinSizeRel,Release ^ 5 | -platform win32,win64,arm,arm64 ^ 6 | -compiler msvc ^ 7 | -static -shared ^ 8 | -mt -md ^ 9 | build 10 | 11 | :: clangcl does not work for arm 12 | 13 | sw ^ 14 | %* ^ 15 | -sfc ^ 16 | -configuration Debug,ReleaseWithDebInfo,MinSizeRel,Release ^ 17 | -platform win32,win64 ^ 18 | -compiler clangcl ^ 19 | -static -shared ^ 20 | -mt -md ^ 21 | build 22 | 23 | sw ^ 24 | %* ^ 25 | -sfc ^ 26 | -configuration Debug,ReleaseWithDebInfo,MinSizeRel,Release ^ 27 | -platform arm64 ^ 28 | -compiler clangcl ^ 29 | -static -shared ^ 30 | -mt -md ^ 31 | build 32 | 33 | :: clang does not work for x86,arm,aarch64 34 | 35 | sw ^ 36 | %* ^ 37 | -sfc ^ 38 | -configuration Debug,ReleaseWithDebInfo,MinSizeRel,Release ^ 39 | -platform win64 ^ 40 | -compiler clang ^ 41 | -static -shared ^ 42 | -mt -md ^ 43 | build 44 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/src/1.h: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | // 4 | // 5 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/src/1.txt: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | // 4 | // 5 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/src/2.h: -------------------------------------------------------------------------------- 1 | // 2 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/src/lib5.cpp: -------------------------------------------------------------------------------- 1 | L5_API int f() 2 | { 3 | return 42; 4 | } 5 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/src/lib6.cpp: -------------------------------------------------------------------------------- 1 | #include "lib6.h" 2 | 3 | int f() 4 | { 5 | return 42; 6 | } 7 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/src/lib6.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | L6_API int f(); 6 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/src/lib7.c: -------------------------------------------------------------------------------- 1 | #include "lib7.h" 2 | 3 | int var; 4 | 5 | int f() 6 | { 7 | return 42; 8 | } 9 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/src/lib7.h: -------------------------------------------------------------------------------- 1 | extern L7_API int var; 2 | 3 | L7_API int f(); 4 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //#include "1.h" 4 | //#include "2.h" 5 | 6 | int main() 7 | { 8 | printf("Hello, world!\n"); 9 | std::cout << 123; 10 | std::cout << "123"; 11 | } 12 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/src/main2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | printf("Hello, world!\n"); 6 | std::cout << 123; 7 | std::cout << "123"; 8 | } 9 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/src/main3.cpp: -------------------------------------------------------------------------------- 1 | #include "lib6.h" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | f(); 8 | 9 | printf(R"( 10 | #include 11 | 12 | int main() 13 | { 14 | printf("Hello, world!\n"); 15 | std::cout << 123; 16 | std::cout << "123"; 17 | return 0; 18 | } 19 | )"); 20 | } 21 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/src/main5.cpp: -------------------------------------------------------------------------------- 1 | extern "C" 2 | { 3 | #include "lib7.h" 4 | } 5 | 6 | int main() 7 | { 8 | var = 5; 9 | return var; 10 | } 11 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/src/main6.cpp: -------------------------------------------------------------------------------- 1 | #include "main8.inc" 2 | -------------------------------------------------------------------------------- /test/build/cpp/multiconf/sw.cpp: -------------------------------------------------------------------------------- 1 | void configure(Solution &s) 2 | { 3 | //s.Settings.Native.LibrariesType = LibraryType::Static; 4 | //s.Settings.Native.ConfigurationType = ConfigurationType::Debug; 5 | //s.Settings.Native.CompilerType = CompilerType::ClangCl; 6 | //s.Settings.Native.CompilerType = CompilerType::Clang; 7 | } 8 | 9 | void build(Solution &s) 10 | { 11 | auto &t1 = s.addExecutable("test"); 12 | t1 += "src/main.cpp"; 13 | 14 | auto &t2 = s.addExecutable("test2"); 15 | t2 += "src/main2.cpp"; 16 | 17 | auto &l6 = s.addLibrary("lib6"); 18 | l6.ApiName = "L6_API"; 19 | l6 += "src/lib6.*"_rr; 20 | 21 | auto &t3 = s.addExecutable("test3"); 22 | t3.CPPVersion = CPPLanguageStandard::CPP11; 23 | t3 += "src/main3.cpp"; 24 | t3 += l6; 25 | 26 | auto &l5 = s.addLibrary("lib5"); 27 | l5.ApiName = "L5_API"; 28 | l5 += "src/lib5.cpp"; 29 | 30 | auto &t4 = s.addExecutable("test4"); 31 | { 32 | auto c = t4.addCommand(); 33 | c << cmd::prog(t3) 34 | << cmd::std_out("main4.cpp"); 35 | } 36 | 37 | auto &l7 = s.addLibrary("lib7"); 38 | l7.ApiName = "L7_API"; 39 | l7 += "src/lib7.c"; 40 | 41 | auto &t5 = s.addExecutable("test5"); 42 | t5 += "src/main5.cpp"; 43 | t5 += l7; 44 | 45 | // test generated command in dep (t8) executed before main target (t6) 46 | { 47 | auto &t8 = s.addLibrary("lib8"); 48 | { 49 | t8 += "src/1.txt"; 50 | auto c = t8.addCommand(); 51 | c << cmd::prog(t3) 52 | << cmd::std_out("main8.inc"); 53 | } 54 | 55 | auto &t6 = s.addStaticLibrary("test6"); 56 | t6 += "src/main6.cpp"; 57 | t6.Public += t8; 58 | 59 | auto &t7 = s.addStaticLibrary("test7"); 60 | t7 += "src/main6.cpp"; 61 | t7 += t6; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /test/build/cpp/pch/src/1.h: -------------------------------------------------------------------------------- 1 | #include -------------------------------------------------------------------------------- /test/build/cpp/pch/src/2/2.h: -------------------------------------------------------------------------------- 1 | #include -------------------------------------------------------------------------------- /test/build/cpp/pch/src/main.cpp: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | std::cout << "Hello, world!\n"; 4 | } 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/build/cpp/pch/src/main2.cpp: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | std::cout << "Hello, world!\n"; 4 | } 5 | -------------------------------------------------------------------------------- /test/build/cpp/pch/src/main3.cpp: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | printf(R"( 4 | int main() 5 | { 6 | std::fstream f; 7 | std::vector v; 8 | std::cout << "Hello, world!\n"; 9 | return 0; 10 | } 11 | )"); 12 | } 13 | -------------------------------------------------------------------------------- /test/build/cpp/pch/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &t1 = s.add("test"); 4 | t1 += "src/main.cpp"; 5 | t1 += "src/1.h"_pch; // relative 6 | 7 | auto &t2 = s.addExecutable("test2"); 8 | t2 += "src/main2.cpp"; 9 | t2 += PrecompiledHeader(t2.SourceDir / "src/1.h"); // full path 10 | 11 | auto &t3 = s.addExecutable("test3"); 12 | t3.CPPVersion = CPPLanguageStandard::CPP11; 13 | t3 += "src/main3.cpp"; 14 | t3 += "src/1.h"_pch; 15 | 16 | auto &t4 = s.addExecutable("test4"); 17 | { 18 | auto c = t4.addCommand(); 19 | c << cmd::prog(t3) 20 | << cmd::std_out("main4.cpp"); 21 | t4 += "src"_idir; 22 | t4 += "src/2"_idir; 23 | t4 += "<1.h>"_pch; // relative & angle brackets 24 | t4 += "<2.h>"_pch; // relative & angle brackets 25 | t4 += ""_pch; // std header & angle brackets 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/build/cpp/png/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(png CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(SW_BUILD_SHARED_LIBS 1) 7 | set(DEPENDENCIES 8 | org.sw.demo.glennrp.png 9 | ) 10 | 11 | find_package(SW REQUIRED) 12 | sw_add_package(${DEPENDENCIES}) 13 | sw_execute() 14 | 15 | add_executable(${PROJECT_NAME} png.cpp) 16 | target_link_libraries(${PROJECT_NAME} ${DEPENDENCIES}) 17 | 18 | set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME}) 19 | -------------------------------------------------------------------------------- /test/build/cpp/png/png.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | deps: org.sw.demo.glennrp.png 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int main() 9 | { 10 | png_access_version_number(); 11 | zlibVersion(); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /test/build/cpp/png/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &exe1 = s.addExecutable("exe1"); 4 | exe1 += "png.cpp"; 5 | exe1 += "org.sw.demo.glennrp.png"_dep; 6 | } 7 | -------------------------------------------------------------------------------- /test/build/cpp/pp/src/1.h: -------------------------------------------------------------------------------- 1 | #include -------------------------------------------------------------------------------- /test/build/cpp/pp/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "1.h" 2 | 3 | int main() 4 | { 5 | std::cout << "Hello, world!\n"; 6 | } 7 | -------------------------------------------------------------------------------- /test/build/cpp/pp/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &t1 = s.add("test"); 4 | t1 += "src/main.cpp"; 5 | t1.PreprocessStep = true; 6 | } 7 | -------------------------------------------------------------------------------- /test/build/cpp/pragma_sw_require/sw.cpp: -------------------------------------------------------------------------------- 1 | #pragma sw require org.sw.demo.glennrp.png 2 | 3 | #include 4 | 5 | void build(Solution &s) 6 | { 7 | png_access_version_number(); 8 | } 9 | -------------------------------------------------------------------------------- /test/build/cpp/settings/src/lib.cpp: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | 3 | int f1() { return 1; } 4 | 5 | #ifdef FEATURE2 6 | int f2() { return 1; } 7 | #endif 8 | 9 | #ifdef FEATURE3 10 | int f3() { return 1; } 11 | #endif 12 | -------------------------------------------------------------------------------- /test/build/cpp/settings/src/lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int f1(); 4 | 5 | #ifdef FEATURE2 6 | int f2(); 7 | #endif 8 | 9 | #ifdef FEATURE3 10 | int f3(); 11 | #endif 12 | -------------------------------------------------------------------------------- /test/build/cpp/settings/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | int i = 0; 8 | i += f1(); 9 | #ifdef WANT_FEATURE2 10 | i += f2(); 11 | #endif 12 | #ifdef WANT_FEATURE3 13 | i += f3(); 14 | #endif 15 | printf("%d\n", i); 16 | } 17 | -------------------------------------------------------------------------------- /test/build/cpp/settings/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &lib = s.addStaticLibrary("lib"); 4 | { 5 | lib += "src/lib.cpp"; 6 | if (lib.getSettings()["feature2"] == "1") 7 | lib.Public += "FEATURE2"_def; 8 | if (lib.getSettings()["feature3"] == "1") 9 | lib.Public += "FEATURE3"_def; 10 | } 11 | 12 | auto &t1 = s.addExecutable("test1"); 13 | { 14 | t1 += "src/main.cpp"; 15 | t1 += lib; 16 | } 17 | 18 | auto &t2 = s.addExecutable("test2"); 19 | { 20 | t2 += "src/main.cpp"; 21 | t2 += "WANT_FEATURE2"_def; 22 | auto d = t2 + lib; 23 | d->getSettings()["feature2"] = "1"; 24 | d->getSettings()["feature2"].setRequired(); 25 | } 26 | 27 | auto &t3 = s.addExecutable("test3"); 28 | { 29 | t3 += "src/main.cpp"; 30 | t3 += "WANT_FEATURE3"_def; 31 | auto d = t3 + lib; 32 | d->getSettings()["feature3"] = "1"; 33 | d->getSettings()["feature3"].setRequired(); 34 | } 35 | 36 | auto &t4 = s.addExecutable("test4"); 37 | { 38 | t4 += "src/main.cpp"; 39 | t4 += "WANT_FEATURE2"_def; 40 | t4 += "WANT_FEATURE3"_def; 41 | auto d = t4 + lib; 42 | d->getSettings()["feature2"] = "1"; 43 | d->getSettings()["feature2"].setRequired(); 44 | d->getSettings()["feature3"] = "1"; 45 | d->getSettings()["feature3"].setRequired(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /test/build/cpp/spaces_and_unicode/src/main with spaces.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //#include "1.h" 4 | //#include "2.h" 5 | 6 | int main() 7 | { 8 | printf("Hello, world!\n"); 9 | std::cout << 123; 10 | std::cout << "123"; 11 | } 12 | -------------------------------------------------------------------------------- /test/build/cpp/spaces_and_unicode/src/main 與 unicōde привет, мир!.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //#include "1.h" 4 | //#include "2.h" 5 | 6 | int main() 7 | { 8 | printf("Hello, world!\n"); 9 | std::cout << 123; 10 | std::cout << "123"; 11 | } 12 | -------------------------------------------------------------------------------- /test/build/cpp/spaces_and_unicode/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &t1 = s.addExecutable("spaces"); 4 | t1 += "src/main with spaces.cpp"; 5 | 6 | auto &t2 = s.addExecutable("unicode"); 7 | t2 += fs::u8path("src/main 與 unicōde привет, мир!.cpp"); 8 | } 9 | -------------------------------------------------------------------------------- /test/build/cpp/static/exe.cpp: -------------------------------------------------------------------------------- 1 | #include "lib3.h" 2 | int main() {lib3();} -------------------------------------------------------------------------------- /test/build/cpp/static/lib1.cpp: -------------------------------------------------------------------------------- 1 | #include "lib1.h" 2 | void lib1(){} -------------------------------------------------------------------------------- /test/build/cpp/static/lib1.h: -------------------------------------------------------------------------------- 1 | LIB1_API 2 | void lib1(); 3 | -------------------------------------------------------------------------------- /test/build/cpp/static/lib2.cpp: -------------------------------------------------------------------------------- 1 | #include "lib1.h" 2 | #include "lib2.h" 3 | void lib2(){lib1();} 4 | -------------------------------------------------------------------------------- /test/build/cpp/static/lib2.h: -------------------------------------------------------------------------------- 1 | LIB2_API 2 | void lib2(); 3 | -------------------------------------------------------------------------------- /test/build/cpp/static/lib3.cpp: -------------------------------------------------------------------------------- 1 | #include "lib2.h" 2 | #include "lib3.h" 3 | void lib3(){lib2();} 4 | -------------------------------------------------------------------------------- /test/build/cpp/static/lib3.h: -------------------------------------------------------------------------------- 1 | LIB3_API 2 | void lib3(); 3 | -------------------------------------------------------------------------------- /test/build/cpp/static/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &lib1 = s.addLibrary("lib1"); 4 | lib1.ApiName = "LIB1_API"; 5 | lib1 += "lib1.*"_rr; 6 | 7 | auto &lib2 = s.addLibrary("lib2"); 8 | lib2.ApiName = "LIB2_API"; 9 | lib2 += "lib2.*"_rr; 10 | lib2 += lib1; 11 | 12 | auto &lib3 = s.addLibrary("lib3"); 13 | lib3.ApiName = "LIB3_API"; 14 | lib3 += "lib3.*"_rr; 15 | lib3 += lib2; 16 | 17 | auto &exe1 = s.addExecutable("exe1"); 18 | exe1 += "exe.*"_rr; 19 | exe1 += lib3; 20 | } 21 | -------------------------------------------------------------------------------- /test/build/cross/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | try { throw SW_RUNTIME_ERROR("1"); } 9 | catch (sw::RuntimeError) { std::cout << "RuntimeError 1\n"; } 10 | try { throw SW_RUNTIME_ERROR("2"); } 11 | catch (std::runtime_error) { std::cout << "RuntimeError 2\n"; } 12 | try { throw SW_RUNTIME_ERROR("3"); } 13 | catch (std::exception) { std::cout << "RuntimeError 3\n"; } 14 | try { throw SW_RUNTIME_ERROR("4"); } 15 | catch (...) { std::cout << "RuntimeError 4\n"; } 16 | 17 | try { throw 5; } 18 | catch (int) { std::cout << "int\n"; } 19 | try { throw 5.0; } 20 | catch (double) { std::cout << "double\n"; } 21 | struct X {}; 22 | try { throw X{}; } 23 | catch (X) { std::cout << "struct X\n"; } 24 | 25 | try { throw std::runtime_error("x"); } 26 | catch (std::runtime_error &) { std::cout << "Hello, World!\n"; } 27 | catch (std::exception &) {} 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /test/build/cross/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &t = s.addExecutable("test"); 4 | t.PackageDefinitions = true; 5 | t += cpp20; 6 | t += "main.cpp"; 7 | t += "pub.egorpugin.primitives.sw.main"_dep; 8 | } 9 | -------------------------------------------------------------------------------- /test/build/cross1/f.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void f() 4 | { 5 | printf("f()\n"); 6 | std::cout << "f()\n"; 7 | printf("f()\n"); 8 | 9 | try { throw 5; } 10 | catch (int) { printf("int\n"); } 11 | 12 | try { throw std::runtime_error("x"); } 13 | catch (std::runtime_error &) { printf("Hello, World!\n"); } 14 | catch (std::exception &) {} 15 | } 16 | -------------------------------------------------------------------------------- /test/build/cross1/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void f(); 4 | 5 | int main(int argc, char **argv) 6 | { 7 | std::cout << "main()\n"; 8 | 9 | try { throw 5; } 10 | catch (int) { std::cout << "int\n"; } 11 | 12 | try { throw std::runtime_error("x"); } 13 | catch (std::runtime_error &) { printf("Hello, World!\n"); } 14 | catch (std::exception &) {} 15 | 16 | f(); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /test/build/cross1/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &lib = s.addStaticLibrary("lib"); 4 | lib += "f.cpp"; 5 | 6 | auto &t = s.addExecutable("test"); 7 | t += "main.cpp"; 8 | t += lib; 9 | } 10 | -------------------------------------------------------------------------------- /test/build/cross2/exceptions.cpp: -------------------------------------------------------------------------------- 1 | #include "exceptions.h" 2 | 3 | namespace sw 4 | { 5 | 6 | RuntimeError::RuntimeError(const std::string &msg) 7 | : std::runtime_error("") 8 | { 9 | } 10 | 11 | } // namespace sw 12 | -------------------------------------------------------------------------------- /test/build/cross2/exceptions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace sw 7 | { 8 | 9 | struct API RuntimeError : std::runtime_error 10 | { 11 | RuntimeError(const std::string &msg); 12 | }; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/build/cross2/main.cpp: -------------------------------------------------------------------------------- 1 | #include "exceptions.h" 2 | 3 | #include 4 | 5 | void print(const char *s) 6 | { 7 | //printf("\n%s\n\n", s); // works 8 | std::cout << "\n" << s << "\n\n"; // has strong impact, does not work with lld 9 | //try { throw 1; } catch (...) {} 10 | } 11 | 12 | void f() 13 | { 14 | try { throw std::runtime_error(""); } 15 | catch (std::exception&) { print("std::exception&"); } 16 | 17 | try { throw std::runtime_error(""); } 18 | catch (std::exception) { print("std::exception"); } 19 | 20 | 21 | 22 | 23 | 24 | 25 | try { throw 5; } 26 | catch (int) { print("int"); } 27 | 28 | try { throw sw::RuntimeError(""); } 29 | catch (sw::RuntimeError &) { print("sw::RuntimeError&"); } 30 | 31 | try { throw sw::RuntimeError(""); } 32 | catch (sw::RuntimeError) { print("sw::RuntimeError"); } 33 | 34 | try { throw sw::RuntimeError(""); } 35 | catch (std::exception&) { print("sw::RuntimeError std::exception&"); } 36 | 37 | try { throw std::runtime_error(""); } 38 | catch (std::exception) { print("std::exception"); } 39 | 40 | try { throw std::runtime_error(""); } 41 | catch (std::exception&) { print("std::exception&"); } 42 | } 43 | 44 | int main() 45 | { 46 | f(); 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /test/build/cross2/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &lib = s.addStaticLibrary("lib"); 4 | lib.ApiName = "API"; 5 | lib += "exceptions.h"; 6 | lib += "exceptions.cpp"; 7 | 8 | auto &t = s.addExecutable("test"); 9 | t += "main.cpp"; 10 | t += lib; 11 | } 12 | -------------------------------------------------------------------------------- /test/build/d/a.d: -------------------------------------------------------------------------------- 1 | import std.stdio; 2 | import std.conv; 3 | 4 | import b; 5 | 6 | void main() 7 | { 8 | writeln("Hello, World! " ~ to!string(f())); 9 | } 10 | -------------------------------------------------------------------------------- /test/build/d/b.d: -------------------------------------------------------------------------------- 1 | export int f() 2 | { 3 | return 42; 4 | } 5 | -------------------------------------------------------------------------------- /test/build/d/c.d: -------------------------------------------------------------------------------- 1 | export int f() 2 | { 3 | return 42; 4 | } 5 | 6 | import core.sys.windows.windows; 7 | import core.sys.windows.dll; 8 | import core.stdc.time; 9 | 10 | __gshared HINSTANCE g_hInst; 11 | 12 | extern (Windows) 13 | BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) 14 | { 15 | switch (ulReason) 16 | { 17 | case DLL_PROCESS_ATTACH: 18 | g_hInst = hInstance; 19 | dll_process_attach( hInstance, true ); 20 | break; 21 | 22 | case DLL_PROCESS_DETACH: 23 | dll_process_detach( hInstance, true ); 24 | break; 25 | 26 | case DLL_THREAD_ATTACH: 27 | dll_thread_attach( true, true ); 28 | break; 29 | 30 | case DLL_THREAD_DETACH: 31 | dll_thread_detach( true, true ); 32 | break; 33 | 34 | default: 35 | } 36 | return true; 37 | } 38 | -------------------------------------------------------------------------------- /test/build/d/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &exe1 = s.addTarget("exe1"); 4 | exe1 += "a.d"_rr; 5 | exe1 += "b.d"_rr; 6 | 7 | auto &lib = s.addTarget("lib"); 8 | lib += "b.d"_rr; 9 | 10 | auto &dll = s.addTarget("dll"); 11 | dll += "c.d"_rr; 12 | 13 | auto &exe2 = s.addTarget("exe2"); 14 | exe2 += "a.d"_rr; 15 | exe2 += lib; 16 | 17 | return; 18 | // need a way below to create implib on win 19 | 20 | auto &exe3 = s.addTarget("exe3"); 21 | exe3 += "a.d"_rr; 22 | exe3 += dll; 23 | } 24 | -------------------------------------------------------------------------------- /test/build/dlopen/dlopen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | API extern "C" int f() 6 | { 7 | std::cout << "wow f\n"; 8 | return 1; 9 | } 10 | 11 | __attribute__ ((visibility ("default"))) 12 | int g() 13 | { 14 | std::cout << "wow g\n"; 15 | return 2; 16 | } 17 | 18 | int main() 19 | { 20 | auto h = dlopen(0, RTLD_LAZY | RTLD_GLOBAL); 21 | if (!h) 22 | { 23 | std::cout << dlerror() << "\n"; 24 | return 1; 25 | } 26 | 27 | auto f = (int(*)())dlsym(h, "f"); 28 | if (!f) 29 | { 30 | std::cout << dlerror() << "\n"; 31 | //return 2; 32 | } 33 | 34 | if (f) 35 | std::cout << f() << "\n"; 36 | 37 | f = (int(*)())dlsym(h, "_Z1gv"); 38 | if (!f) 39 | { 40 | std::cout << dlerror() << "\n"; 41 | //return 3; 42 | } 43 | 44 | if (f) 45 | std::cout << f() << "\n"; 46 | 47 | dlclose(h); 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /test/build/dlopen/f.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | API 6 | void f() 7 | { 8 | try { throw std::runtime_error("x"); } 9 | catch(std::runtime_error &){ std::cout << "Hello, World!\n"; } 10 | catch(std::exception &){} 11 | } 12 | -------------------------------------------------------------------------------- /test/build/dlopen/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | API 4 | void f(){} 5 | 6 | int main() 7 | { 8 | printf("Hello, World!\n"); 9 | } 10 | -------------------------------------------------------------------------------- /test/build/dlopen/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | API 7 | void f(); 8 | 9 | int main() 10 | { 11 | std::cout << "Hello, World!\n"; 12 | 13 | f(); 14 | std::thread t([] {f(); }); 15 | t.join(); 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /test/build/dlopen/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | 4 | { 5 | auto &e = s.addExecutable("test1"); 6 | e.ApiName = "API"; 7 | e += "main.c"; 8 | } 9 | 10 | { 11 | auto &e = s.addExecutable("test2"); 12 | e.ApiName = "API"; 13 | e += "main.cpp", "f.cpp"; 14 | } 15 | 16 | { 17 | auto &e = s.addExecutable("test3"); 18 | if (!e.getBuildSettings().TargetOS.is(OSType::Linux)) 19 | e.DryRun = true; 20 | e.ApiName = "API"; 21 | e += "dlopen.cpp"; 22 | e += "dl"_slib; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/build/fortran/main.f: -------------------------------------------------------------------------------- 1 | program hello 2 | print *, "Hello World!" 3 | end program hello 4 | -------------------------------------------------------------------------------- /test/build/fortran/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &f = s.addTarget("main.fortran"); 4 | f += "main.f"; 5 | } 6 | -------------------------------------------------------------------------------- /test/build/inline/png.c: -------------------------------------------------------------------------------- 1 | /* 2 | deps: org.sw.demo.glennrp.png 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int main() 9 | { 10 | png_access_version_number(); 11 | zlibVersion(); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /test/build/inline/png.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | deps: org.sw.demo.glennrp.png 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int main() 9 | { 10 | png_access_version_number(); 11 | zlibVersion(); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /test/build/java/App.java: -------------------------------------------------------------------------------- 1 | public class App 2 | { 3 | public static void main(String[] args) 4 | { 5 | var hw = new HelloWorld(); 6 | hw.print(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/build/java/HelloWorld.java: -------------------------------------------------------------------------------- 1 | public class HelloWorld { 2 | public void print() { 3 | // Prints "Hello, World" in the terminal window. 4 | System.out.println("Hello, World"); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/build/java/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &j = s.addTarget("main.java"); 4 | j += ".*\\.java"_r; 5 | } 6 | -------------------------------------------------------------------------------- /test/build/kotlin/hello.kt: -------------------------------------------------------------------------------- 1 | package hello 2 | 3 | fun main() { 4 | println("Hello World") 5 | } 6 | -------------------------------------------------------------------------------- /test/build/kotlin/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &k = s.addTarget("main.kotlin"); 4 | k += "hello.kt"; 5 | } 6 | -------------------------------------------------------------------------------- /test/build/mixed/1/1.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | namespace HelloWorld 4 | { 5 | class One 6 | { 7 | public int f() 8 | { 9 | return 1; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/build/mixed/1/2.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | namespace HelloWorld 4 | { 5 | class Two 6 | { 7 | public int f() 8 | { 9 | return 2; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/build/mixed/1/App.java: -------------------------------------------------------------------------------- 1 | public class App 2 | { 3 | public static void main(String[] args) 4 | { 5 | var hw = new HelloWorld(); 6 | hw.print(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/build/mixed/1/HelloWorld.java: -------------------------------------------------------------------------------- 1 | public class HelloWorld { 2 | public void print() { 3 | // Prints "Hello, World" in the terminal window. 4 | System.out.println("Hello, World"); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/build/mixed/1/hello.kt: -------------------------------------------------------------------------------- 1 | package hello 2 | 3 | fun main() { 4 | println("Hello World") 5 | } 6 | -------------------------------------------------------------------------------- /test/build/mixed/1/main.cpp: -------------------------------------------------------------------------------- 1 | int main(int argc, char **argv) 2 | { 3 | return 0; 4 | } 5 | -------------------------------------------------------------------------------- /test/build/mixed/1/main.cs: -------------------------------------------------------------------------------- 1 | // A Hello World! program in C#. 2 | using System; 3 | 4 | namespace HelloWorld 5 | { 6 | class Hello 7 | { 8 | static void Main() 9 | { 10 | One one = new One(); 11 | Two two = new Two(); 12 | 13 | Console.WriteLine("Hello World! {0}", one.f() + two.f()); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/build/mixed/1/main.f: -------------------------------------------------------------------------------- 1 | program hello 2 | print *, "Hello World!" 3 | end program hello -------------------------------------------------------------------------------- /test/build/mixed/1/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("hello world") 7 | } 8 | -------------------------------------------------------------------------------- /test/build/mixed/1/main.rs: -------------------------------------------------------------------------------- 1 | // This is the main function 2 | fn main() { 3 | // The statements here will be executed when the compiled binary is called 4 | 5 | // Print text to the console 6 | println!("Hello World!"); 7 | } 8 | -------------------------------------------------------------------------------- /test/build/mixed/1/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &cs = s.addTarget("main.cs"); 4 | cs += ".*\\.cs"_r; 5 | 6 | auto &rs = s.addTarget("main.rs"); 7 | rs -= ".*\\.rs"_r; 8 | rs += "main.rs"; // main file 9 | 10 | auto &go = s.addTarget("main.go"); 11 | go += ".*\\.go"_r; 12 | 13 | auto &cpp = s.addTarget("main.cpp"); 14 | cpp += "main.cpp"; 15 | 16 | auto &f = s.addTarget("main.fortran"); 17 | f += "main.f"; 18 | 19 | auto &j = s.addTarget("main.java"); 20 | j += ".*\\.java"_r; 21 | 22 | auto &k = s.addTarget("main.kotlin"); 23 | k += "hello.kt"; 24 | } 25 | -------------------------------------------------------------------------------- /test/build/mixed/2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello_world" 3 | version = "0.0.1" 4 | -------------------------------------------------------------------------------- /test/build/mixed/2/src/main.rs: -------------------------------------------------------------------------------- 1 | // This is the main function 2 | fn main() { 3 | // The statements here will be executed when the compiled binary is called 4 | 5 | // Print text to the console 6 | println!("Hello World!"); 7 | } 8 | -------------------------------------------------------------------------------- /test/build/mixed/2/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &rs = s.addTarget("main.rs"); 4 | rs += "src/.*"_rr; 5 | } 6 | -------------------------------------------------------------------------------- /test/build/objc/main.cpp: -------------------------------------------------------------------------------- 1 | int main(){} -------------------------------------------------------------------------------- /test/build/objc/main.mm: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | int main(void) { 5 | @autoreleasepool 6 | { 7 | NSLog(@"Hello, Objective-C++."); 8 | } 9 | 10 | return EXIT_SUCCESS; 11 | } -------------------------------------------------------------------------------- /test/build/pascal/hello.pas: -------------------------------------------------------------------------------- 1 | program HelloWorld(output); 2 | begin 3 | Write('Hello, World!') 4 | end. -------------------------------------------------------------------------------- /test/build/pascal/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &t = s.addTarget("x"); 4 | t += "hello.pas"; 5 | } 6 | -------------------------------------------------------------------------------- /test/build/rules/simple/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | std::cout << "Hello, World!\n"; 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /test/build/rules/simple/sw.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void build(Solution &s) 4 | { 5 | auto &e = s.add("cpp.test2"); 6 | //e.ApiName = "API"; 7 | e.files.insert("main.cpp"); 8 | } 9 | -------------------------------------------------------------------------------- /test/build/rust/1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello_world" 3 | version = "0.0.1" 4 | -------------------------------------------------------------------------------- /test/build/rust/1/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, world!"); 3 | } 4 | -------------------------------------------------------------------------------- /test/build/simple/1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SoftwareNetwork/sw/d156861fce5ae5d1a8bb4af59d25426b1995b5b9/test/build/simple/1.h -------------------------------------------------------------------------------- /test/build/simple/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | API 4 | void f(){} 5 | 6 | int main() 7 | { 8 | printf("Hello, World!\n"); 9 | } 10 | -------------------------------------------------------------------------------- /test/build/simple/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | std::cout << "Hello, World!\n"; 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /test/build/simple/main3.cpp: -------------------------------------------------------------------------------- 1 | #include "1.h" 2 | 3 | int main() 4 | { 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /test/build/simple/sw.c: -------------------------------------------------------------------------------- 1 | void build(sw_build_t *b) 2 | { 3 | { 4 | sw_target_t *e = sw_add_executable(b, "c.test1"); 5 | sw_set_target_property(e, "API_NAME", "API"); 6 | sw_add_target_source(e, "main.c"); 7 | } 8 | 9 | { 10 | sw_target_t *e = sw_add_executable(b, "c.test2"); 11 | sw_add_target_source(e, "main.cpp"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/build/simple/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | { 4 | auto &e = s.addExecutable("cpp.test1"); 5 | e.ApiName = "API"; 6 | e += "main.c"; 7 | } 8 | 9 | { 10 | auto &e = s.addExecutable("cpp.test2"); 11 | e.ApiName = "API"; 12 | e += "main.cpp"; 13 | } 14 | 15 | { 16 | auto &e = s.addExecutable("cpp.test3"); 17 | e += "main3.cpp"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/build/simple/sw.vala: -------------------------------------------------------------------------------- 1 | using sw; 2 | 3 | public void build(Build? b) 4 | { 5 | { 6 | var t = add_executable(b, "vala.test1"); 7 | set_target_property(t, "API_NAME", "API"); 8 | add_target_source(t, "main.c"); 9 | } 10 | { 11 | var t = add_executable(b, "vala.test2"); 12 | add_target_source(t, "main.cpp"); 13 | } 14 | 15 | // to test PATH dll deps 16 | print(""); 17 | } 18 | -------------------------------------------------------------------------------- /test/build/vala/exe1.vala: -------------------------------------------------------------------------------- 1 | print("Hello from Vala lang: %e\n", Add(1.5, 2.5)); 2 | -------------------------------------------------------------------------------- /test/build/vala/exe2.vala: -------------------------------------------------------------------------------- 1 | public void x() 2 | { 3 | } 4 | -------------------------------------------------------------------------------- /test/build/vala/hw.vala: -------------------------------------------------------------------------------- 1 | print("Hello World!\n"); 2 | -------------------------------------------------------------------------------- /test/build/vala/lib1.vala: -------------------------------------------------------------------------------- 1 | public double Add (double a, double b){ 2 | print("Hello from Vala lang\n"); 3 | return a + b; 4 | } 5 | -------------------------------------------------------------------------------- /test/build/vala/sh.vala: -------------------------------------------------------------------------------- 1 | public double Add (double a, double b){ 2 | print("Hello from Vala lang\n"); 3 | return a + b; 4 | } 5 | -------------------------------------------------------------------------------- /test/build/vala/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &lib1 = s.add("lib1"); 4 | lib1 += "lib1.vala"; 5 | 6 | auto &t = s.add("exe1"); 7 | t += "exe1.vala"; 8 | t += lib1; 9 | 10 | { 11 | auto &t = s.add("st"); 12 | t += "sh.vala"; 13 | } 14 | { 15 | auto &t = s.add("sh"); 16 | t += "sh.vala"; 17 | } 18 | { 19 | auto &t = s.add("shst"); 20 | t += "sh.vala"; 21 | } 22 | { 23 | auto &t = s.add("hw"); 24 | t += "hw.vala"; 25 | } 26 | 27 | { 28 | auto &t = s.add("exe2"); 29 | t += "exe2.vala"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/build/yasm/common.asm: -------------------------------------------------------------------------------- 1 | global main 2 | extern ExitProcess ; external functions in system libraries 3 | extern MessageBoxA 4 | 5 | section .data 6 | title: db 'Win64', 0 7 | msg: db 'Hello world!', 0 8 | 9 | section .text 10 | main: 11 | sub rsp, 28h 12 | mov rcx, 0 ; hWnd = HWND_DESKTOP 13 | lea rdx,[msg] ; LPCSTR lpText 14 | lea r8,[title] ; LPCSTR lpCaption 15 | mov r9d, 0 ; uType = MB_OK 16 | call MessageBoxA 17 | add rsp, 28h 18 | 19 | mov ecx,eax 20 | call ExitProcess 21 | 22 | hlt ; never here 23 | 24 | -------------------------------------------------------------------------------- /test/build/yasm/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "native": { 3 | "stdlib": { 4 | "kernel": "com.Microsoft.Windows.SDK.um-8" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/build/yasm/sw.cpp: -------------------------------------------------------------------------------- 1 | void build(Solution &s) 2 | { 3 | auto &t = s.addExecutable("x"); 4 | { 5 | t.setExtensionProgram(".asm", "org.sw.demo.yasm"_dep); 6 | t += "common.asm"; 7 | t += "user32.lib"_slib; 8 | t.LinkOptions.push_back("/LARGEADDRESSAWARE:NO"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/integrations/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | # Use solution folders. 4 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 5 | set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake Targets") 6 | 7 | project(my C CXX) 8 | 9 | set(SW_BUILD_SHARED_LIBS 1) 10 | find_package(SW REQUIRED) 11 | sw_add_package( 12 | org.sw.demo.sqlite3 13 | org.sw.demo.glennrp.png 14 | ) 15 | sw_execute() 16 | 17 | add_executable(png png.cpp) 18 | target_link_libraries(png 19 | org.sw.demo.glennrp.png 20 | ) 21 | 22 | add_executable(sqlite3 sqlite3.cpp) 23 | target_link_libraries(sqlite3 24 | org.sw.demo.sqlite3 25 | ) 26 | -------------------------------------------------------------------------------- /test/integrations/cmake/tess/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(tess_example CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 20) 6 | set(SW_BUILD_SHARED_LIBS 1) 7 | set(DEPENDENCIES 8 | org.sw.demo.google.tesseract.libtesseract 9 | org.sw.demo.intel.opencv.imgproc 10 | org.sw.demo.intel.opencv.highgui 11 | ) 12 | 13 | find_package(SW REQUIRED) 14 | sw_add_package(${DEPENDENCIES}) 15 | sw_execute() 16 | 17 | add_executable(${PROJECT_NAME} main.cpp) 18 | target_link_libraries(${PROJECT_NAME} ${DEPENDENCIES}) 19 | 20 | set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME}) 21 | -------------------------------------------------------------------------------- /test/integrations/cmake/tess/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include // leptonica main header for image io 5 | #include // tesseract main header 6 | 7 | #include 8 | #include 9 | 10 | int main(int argc, char *argv[]) 11 | { 12 | if (argc == 1) 13 | return 1; 14 | 15 | cv::Mat m; 16 | 17 | tesseract::TessBaseAPI tess; 18 | 19 | if (tess.Init("./tessdata", "eng")) 20 | { 21 | std::cout << "OCRTesseract: Could not initialize tesseract." << std::endl; 22 | return 1; 23 | } 24 | 25 | // setup 26 | tess.SetPageSegMode(tesseract::PageSegMode::PSM_AUTO); 27 | tess.SetVariable("save_best_choices", "T"); 28 | 29 | // read image 30 | auto pixs = pixRead(argv[1]); 31 | if (!pixs) 32 | { 33 | std::cout << "Cannot open input file: " << argv[1] << std::endl; 34 | return 1; 35 | } 36 | 37 | // recognize 38 | tess.SetImage(pixs); 39 | tess.Recognize(0); 40 | 41 | // get result and delete[] returned char* string 42 | std::cout << std::unique_ptr(tess.GetUTF8Text()).get() << std::endl; 43 | 44 | // cleanup 45 | tess.Clear(); 46 | pixDestroy(&pixs); 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /test/integrations/png.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | png_access_version_number(); 7 | zlibVersion(); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /test/integrations/sqlite3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | sqlite3_libversion(); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /test/integrations/wscript: -------------------------------------------------------------------------------- 1 | # run me like: 2 | # python waf sw_configure sw_build configure build 3 | 4 | import os 5 | import subprocess 6 | 7 | top = '.' 8 | out = 'build_waf' 9 | 10 | swdir = out + '/.sw' 11 | swdeps = swdir + '/deps.txt' 12 | 13 | def sw_configure(ctx): 14 | deps = [ 15 | 'org.sw.demo.sqlite3', 16 | 'org.sw.demo.glennrp.png', 17 | ] 18 | 19 | os.makedirs(swdir, exist_ok=True) 20 | f = open(swdeps, 'w') 21 | for d in deps: 22 | f.write(d + '\n') 23 | f.close() 24 | p = subprocess.Popen(['sw', '-mt', '-d', swdir, 'integrate', '-waf-deps', 'deps.txt']) 25 | if p.wait(): 26 | ctx.fatal("Error during sw call") 27 | 28 | def sw_build(ctx): 29 | p = subprocess.Popen(['sw', '-mt', '-d', swdir, 'build', '@' + swdeps, 30 | '-ide-copy-to-dir', '..', '-ide-fast-path', 'fp.txt']) 31 | if p.wait(): 32 | ctx.fatal("Error during sw call") 33 | 34 | def options(opt): 35 | opt.load('compiler_cxx') 36 | 37 | def configure(ctx): 38 | ctx.load('compiler_cxx') 39 | ctx.recurse(swdir) 40 | 41 | def build(bld): 42 | bld.program(source='sqlite3.cpp', target='sqlite3', use='org.sw.demo.sqlite3') 43 | bld.program(source='png.cpp', target='png', use='org.sw.demo.glennrp.png') 44 | -------------------------------------------------------------------------------- /test/unit/path.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #define CATCH_CONFIG_RUNNER 9 | #include 10 | 11 | using namespace sw; 12 | 13 | TEST_CASE("Checking Paths", "[path]") 14 | { 15 | SECTION("Path") 16 | { 17 | REQUIRE_NOTHROW(Path{}); 18 | Path p1("com.ibm"); 19 | Path p2("CoM.IBM"); 20 | REQUIRE((p1 == p2)); 21 | REQUIRE_FALSE((p1 < p2)); 22 | REQUIRE_FALSE((p2 < p1)); 23 | REQUIRE_FALSE((p1 != p2)); 24 | REQUIRE(p1.toString() == "com.ibm"); 25 | REQUIRE(p2.toString() == "CoM.IBM"); 26 | REQUIRE(p1.toStringLower() == p2.toStringLower()); 27 | 28 | Path p3("org.IBM"); 29 | REQUIRE((p1 < p3)); 30 | REQUIRE((p2 < p3)); // icase! 31 | } 32 | 33 | SECTION("PackagePath") 34 | { 35 | REQUIRE_NOTHROW(PackagePath{}); 36 | PackagePath p1("com.ibm"); 37 | PackagePath p2("CoM.IBM"); 38 | REQUIRE((p1 == p2)); 39 | REQUIRE_FALSE((p1 < p2)); 40 | REQUIRE_FALSE((p2 < p1)); 41 | REQUIRE_FALSE((p1 != p2)); 42 | REQUIRE(p1.toString() == "com.ibm"); 43 | REQUIRE(p2.toString() == "CoM.IBM"); 44 | REQUIRE(p1.toStringLower() == "com.ibm"); 45 | REQUIRE(p2.toStringLower() == "com.ibm"); 46 | REQUIRE(p1.toStringLower() == p2.toStringLower()); 47 | 48 | PackagePath p3("org.IBM"); 49 | REQUIRE((p3 < p2)); 50 | REQUIRE_FALSE((p2 < p3)); // namespace! org < com 51 | } 52 | } 53 | 54 | int main(int argc, char **argv) 55 | { 56 | Catch::Session().run(argc, argv); 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /utils/build/linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -x 5 | 6 | git pull 7 | 8 | PROG=sw 9 | EXE=sw.client.sw-1.0.0 10 | COMPILER="-compiler gcc" 11 | 12 | function run { 13 | ARCH=$1 14 | shift 15 | PLATFORM=$1 16 | shift 17 | 18 | BUILD_TYPE=r # rwdi is too big for github 19 | CFG=${ARCH}_${BUILD_TYPE} 20 | OUT=.sw/out/$CFG 21 | 22 | $PROG build -sd -sfc -static -config ${BUILD_TYPE} $COMPILER -platform $ARCH -config-name $CFG $* 23 | chmod 755 $OUT/$EXE 24 | 25 | if [ "$ARCH" = "${BASE_PLATFORM}" ]; then 26 | #sudo rm /usr/local/bin/sw 27 | sudo cp $OUT/$EXE /usr/local/bin/sw 28 | sudo chmod 755 /usr/local/bin/sw 29 | sw setup 30 | fi 31 | } 32 | 33 | BASE_PLATFORM=x86_64 34 | run x86_64 linux $* 35 | -------------------------------------------------------------------------------- /utils/build/macos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -x 5 | 6 | git pull 7 | 8 | PROG=sw 9 | EXE=sw.client.sw-1.0.0 10 | COMPILER= 11 | 12 | function run { 13 | ARCH=$1 14 | shift 15 | PLATFORM=$1 16 | shift 17 | 18 | BUILD_TYPE=r # rwdi is too big for github 19 | CFG=${ARCH}_${BUILD_TYPE} 20 | OUT=.sw/out/$CFG 21 | 22 | $PROG build -sd -sfc -static -config ${BUILD_TYPE} $COMPILER -platform $ARCH -config-name $CFG $* 23 | chmod 755 $OUT/$EXE 24 | 25 | if [ "$ARCH" = "${BASE_PLATFORM}" ]; then 26 | sudo rm /usr/local/bin/sw 27 | sudo cp $OUT/$EXE /usr/local/bin/sw 28 | fi 29 | } 30 | 31 | BASE_PLATFORM=arm64 32 | run arm64 macos -os macos-13.0 $* 33 | --------------------------------------------------------------------------------