hbmk2 and vscode question

229 views
Skip to first unread message

Antonio Linares

unread,
Oct 1, 2022, 5:20:47 PM10/1/22
to Harbour Users
Dear Eric and others,

What hbmk2 macros may we use to get the equivalents of ${fileDirname}/${fileBasename} from vscode ?

many thanks!

José M. C. Quintas

unread,
Oct 1, 2022, 6:37:32 PM10/1/22
to harbou...@googlegroups.com
I think you need setup on vscode, not on hbmk2.

I setup on programmers notepad to use file folder, before call hbmk2.

José M. C. Quintas
> --
>

Antonio Linares

unread,
Oct 2, 2022, 2:21:43 AM10/2/22
to Harbour Users
DearJose,

We have been checking which is the fastest and simplest way to build a PRG using vscode.

Let say you are editing a PRG from vscode and you want to build it and get the job done easily with less possible keystrokes.

Pressing vscode Ctrl + Shift + B you invoke the default builld task that we define this way:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "build",
      "type": "shell",
      "command": "c:\\Users\\anto\\Documents\\go32.bat ${fileDirname}/${fileBasename} ${fileDirname}\\${fileBasenameNoExtension}.exe",
      "problemMatcher": [
        "$harbour"
      ]
    }
  ]
}

go32.bat simply sets the MS environment and call hbmk2:

call "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
c:\harbour\bin\hbmk2 %1 c:\users\anto\documents\fivewin.hbp -comp=msvc
%2

as you see the first parameter uses the ${fileDirname}/${fileBasename} and the second one is the name of the EXE itself to execute

fivewin.hbp is a generic hbmk2 project that just uses the macro -o${hb_self} and the rest of required params

Now, from vscode when you are editing a PRG, simply press Ctrl + Shift + B and yu get your PRG built and executed.

best regards

Antonio Linares

unread,
Oct 2, 2022, 3:33:51 AM10/2/22
to Harbour Users
Dear Jose,

After the rest from last night, this morning I found a simpler way using just a single parameter:

tasks.json 
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "build",
      "type": "shell",
      "command": "c:\\Users\\anto\\Documents\\go32.bat ${fileDirname}\\${fileBasenameNoExtension}",
      "problemMatcher": [
        "$harbour"
      ]
    }
  ]
}

go32.bat:
call "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
c:\harbour\bin\hbmk2 %1.prg c:\users\anto\documents\fivewin.hbp -o%1 -comp=msvc
%1

using this fivewin.hbp for FWH users:
-gui

-Ic:\fwteam\include

-Lc:\fwteam\lib
-lFiveH32
-lFiveHC32

-lgdiplus
-lole32
-lOleDlg
-lversion

xhb.hbc
hbct.hbc
hbwin.hbc
hbmzip.hbc
hbziparc.hbc
hbfoxpro.hbc

-ldflag=/NODEFAULTLIB:MSVCRT
-ldflag=/FORCE:multiple
 
The simpler, the better and nicer :-)

José M. C. Quintas

unread,
Oct 3, 2022, 8:04:59 AM10/3/22
to harbou...@googlegroups.com

compiler can be defined on HB_COMPILER=msvc

You can create harbour\bin\hbmk.hbc with default configuration, it will be used to all compilation.

hbmk2 %1

You can use fivewin.hbc to setup fivewin configuration, must be in lib path, or indicate path

hbmk2 %1 c:\users\anto\documents\fivewin.hbc


José M. C. Quintas
--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/775f1c39-3121-4734-80c3-0e047afa7ef0n%40googlegroups.com.

Antonio Linares

unread,
Oct 4, 2022, 2:50:08 AM10/4/22
to Harbour Users
Dear Jose,

>    compiler can be defined on HB_COMPILER=msvc

or using -comp=msvc as in the example

Eric Lendvai

unread,
Oct 5, 2022, 5:46:49 AM10/5/22
to Harbour Users

I just updated the following repo:  https://github.com/EricLendvai/Harbour_Samples

Check out the HelloHarbour example. The BuildTools folder has a bat and bash files that calls hbmk2. Those files are called via VSCode tasks.
I do use variables in the tasks.json as per your use case.
Please use the "Tasks" extension from "actboy168" along with "Harbour and xHarbour" extension from Antonino Perricone.

Also I added full support for Dev Containers. 
Per the README.md file:
Run and debug your code in Linux while editing your code in your host OS, like Windows/Mac. All your code remain in your local file system and is mounted in the docker container.  

Reply all
Reply to author
Forward
0 new messages