├── .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 | 
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 |  |  |  |  | | |  |
8 | | build system |  |  |  |  | | |  |
9 | | multilang |  | | | | | | |
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