KDevelop5/Manual/Building (compiling) projects with custom Makefiles/uk: Difference between revisions

    From KDE UserBase Wiki
    (Importing a new version from external source)
    (Importing a new version from external source)
    Line 17: Line 17:
    Щоб зібрати будь-яку з цілей у списку, наведіть на її пункт вказівник миші, клацніть правою кнопкою миші і виберіть у контекстному меню пункт <menuchoice>Зібрати</menuchoice>. Наприклад, виконання цих дій для цілі «clean» призведе до виконання команди «make clean». Повідомлення щодо виконання дій можна буде побачити у підвікні '''Збирання'''. Це вікно відповідає інструменту '''Зібрати''', отже його можна закрити і пізніше відкрити за допомогою пункту <menuchoice>Зібрати</menuchoice>, розташованої на панелі інструментів головного вікна. На нашому знімку цю кнопку розташовано праворуч внизу.
    Щоб зібрати будь-яку з цілей у списку, наведіть на її пункт вказівник миші, клацніть правою кнопкою миші і виберіть у контекстному меню пункт <menuchoice>Зібрати</menuchoice>. Наприклад, виконання цих дій для цілі «clean» призведе до виконання команди «make clean». Повідомлення щодо виконання дій можна буде побачити у підвікні '''Збирання'''. Це вікно відповідає інструменту '''Зібрати''', отже його можна закрити і пізніше відкрити за допомогою пункту <menuchoice>Зібрати</menuchoice>, розташованої на панелі інструментів головного вікна. На нашому знімку цю кнопку розташовано праворуч внизу.
    <span id="Selecting a collection of Makefile targets for repeated building"></span>
    <span id="Selecting a collection of Makefile targets for repeated building"></span>
    === Selecting a collection of Makefile targets for repeated building ===
    === Вибір збірки цілей з Makefile для регулярного збирання ===


    Right-clicking on individual Makefile targets every time you want to build something will quickly get old. Rather, we'd like to have individual targets for one or more of the projects in the session that we can repeatedly build without much mouse work. This is where the concept of "Build target selections" comes in: it is a collection of Makefile targets that are built one-after-the-other whenever you hit the <menuchoice>Build selection</menuchoice> button in the button list at the top, select the <menuchoice>Project -> Build selection</menuchoice> menu item, or
    Right-clicking on individual Makefile targets every time you want to build something will quickly get old. Rather, we'd like to have individual targets for one or more of the projects in the session that we can repeatedly build without much mouse work. This is where the concept of "Build target selections" comes in: it is a collection of Makefile targets that are built one-after-the-other whenever you hit the <menuchoice>Build selection</menuchoice> button in the button list at the top, select the <menuchoice>Project -> Build selection</menuchoice> menu item, or

    Revision as of 08:08, 1 October 2017

    Other languages:

    Збирання (компіляція) проектів з нетиповими Makefile

    У багатьох проектах спосіб збирання файлів коду та визначення тих файлів, які слід повторно зібрати у разі внесення змін до коду, виконується за допомогою файлів Makefile, обробку яких здійснює програма make (див., наприклад, GNU make). У простих проектах нескладно створити такий файл власноруч. У великих проектах створення таких файлів часто покладається на GNU autotools (autoconf, autoheader, automake). У цьому розділі ми припускатимемо, що файл Makefile вашого проекту вже створено, вам просто потрібно вказати KDevelop, у який спосіб слід взаємодіяти з цим файлом.

    Зауваження

    KDevelop 4.x не може працювати з GNU autotools безпосередньо на час написання цього підручника. Якщо відповідні інструменти використовуються у вашому проекті, вам доведеться запускати скрипт ./configure або подібний до нього скрипт з командного рядка вручну. Якщо ви бажаєте зробити це з самого вікна KDevelop, відкрийте панель інструмента Konsole (якщо потрібно, додайте цю панель у нижній частині головного вікна за допомогою пункту меню Вікна -> Додати панель інструмента), у якій можна буде віддати команду оболонці і вкажіть команду ./configure.


    Насамперед, слід повідомити KDevelop про цілі збирання у вашому файлі Makefile. Передбачено два способи: вибір окремих цілей Makefile і вибір набору цілей, які потрібно збирати доволі часто. Для реалізації обох цих способів слід відкрити вікно інструмента Проекти натисканням заголовка вкладки Проекти, розташованої у лівій частині головного вікна KDevelop (якщо цього заголовка немає у вікні вашої програми, вище наведено настанови щодо додавання кнопки відповідного інструмента). Панель Проекти складається з двох частин. У верхній частині з заголовком Проекти показано список всіх ваших проектів, у якому можна розгортати пункти каталогів. У нижній частині з заголовком Вибір проекту показано список набори проектів, які буде зібрано, якщо ви виберете пункт меню Проект -> Зібрати позначене або натиснете клавішу F8; нижче ми поговоримо про цю частину докладніше.

    Збирання окремих цілей з Makefile

    У верхній частині панелі проектів розгорніть список одного з проектів, наприклад, того, для якого слід виконати збирання однієї з цілей Makefile. У списку ви побачите піктограми каталогів, файлів у каталозі верхнього рівня проекту, цілі Makefile, які вдалося визначити KDevelop. На знімку вікна ці категорії показано праворуч. Зауважте, що KDevelop певною мірою розуміє синтаксис Makefile і тому сам визначає цілі, визначені у файлі Makefile (хоча це розуміння і має певні обмеження: не буде показано складені або неявні цілі).

    Щоб зібрати будь-яку з цілей у списку, наведіть на її пункт вказівник миші, клацніть правою кнопкою миші і виберіть у контекстному меню пункт Зібрати. Наприклад, виконання цих дій для цілі «clean» призведе до виконання команди «make clean». Повідомлення щодо виконання дій можна буде побачити у підвікні Збирання. Це вікно відповідає інструменту Зібрати, отже його можна закрити і пізніше відкрити за допомогою пункту Зібрати, розташованої на панелі інструментів головного вікна. На нашому знімку цю кнопку розташовано праворуч внизу.

    Вибір збірки цілей з Makefile для регулярного збирання

    Right-clicking on individual Makefile targets every time you want to build something will quickly get old. Rather, we'd like to have individual targets for one or more of the projects in the session that we can repeatedly build without much mouse work. This is where the concept of "Build target selections" comes in: it is a collection of Makefile targets that are built one-after-the-other whenever you hit the Build selection button in the button list at the top, select the Project -> Build selection menu item, or hit the F8 function key.

    The list of selected Makefile targets is shown in the bottom half of the Projects tool view. By default, the selection contains all projects, but you can change that. For example, if your list of projects contains three projects (a base library L and two applications A and B), but you're currently only working on project A, then you may want to remove project B from the selection by highlighting it in the selection and hitting the button. Furthermore, you probably want to make sure that the library L is built before project A by moving entries in the selection up and down using the buttons to the right of the list. You can also get a particular Makefile target into the selection by right-clicking onto it and selecting Add to buildset, or just highlighting it and hitting the button just above the list of selected targets.

    KDevelop allows you to configure what to do whenever you build the selection. To this end, use the menu item Project -> Open configuration. There, you can for example select the number of simultaneous jobs "make" should execute — if your computer has, say, 8 processor cores, then entering 8 in this field would be a useful choice. In this dialog, the Default make target is a Makefile target used for all targets in the selection.

    What to do with error messages

    If the compiler encounters an error message, simply click on the line with the error message or use Navigation - Jump to Next Outputmark item in the main menu and the editor will jump to the line (and if available column) where the error was reported. Depending on the error message, KDevelop may also offer you several possible actions to fix the error, for example by declaring a previously undeclared variable if an unknown symbol was found.